Hi all. I am using Stata 17. I am not good at coding. You can say I am a novice.
This is just for an academic exercise. I am actually trying to prove the central limit theorem and calculate standard error. I use this code:
I can feel that this is an inefficient way to solve the problem. Here's what I intend to do.
1. Create a uniformly distributed variable with 1000 observations.
2. Take 1000 samples with replacement of size 50.
3. Calculate the mean of each sample in step 2.
4. Store the means in a dataset.
I am looking for an efficient code to accomplish this.
This is just for an academic exercise. I am actually trying to prove the central limit theorem and calculate standard error. I use this code:
Code:
clear set obs 1000 gen var = runiform() save data bsample 50 save sample_data clear forvalues i = 1/1000 { use data bsample 50 collapse var save sample_`i' } clear forvalues i = 1/1000 { append using sample_`i' } save SAMPLE
1. Create a uniformly distributed variable with 1000 observations.
2. Take 1000 samples with replacement of size 50.
3. Calculate the mean of each sample in step 2.
4. Store the means in a dataset.
I am looking for an efficient code to accomplish this.
Comment