Contents

With this R code I will generate sets of random numbers from the Normal distribution. I will do it for 4 sample sizes and 3 different variances. For each combination of sample size and variance I generated 15 groups of observations.

1 Data

## Set some sample sizes and variances
sizes <- c(5, 15, 25, 100)
variances <- c(1, 5, 10)
params <- expand.grid(size = sizes, variance = variances)

## Generate the data
set.seed(20161227)
normal <- mapply(function(size, variance) {
    values <- unlist(lapply(1:15, function(x) {
        rnorm(n = size, sd = sqrt(variance))
    }))
    data.frame(observation = values, size = size, variance = variance, group = rep(1:15, each = size))
}, params$size, params$variance, SIMPLIFY = FALSE)
normal <- do.call(rbind, normal)

## Explore the data
head(normal)
##   observation size variance group
## 1  0.64256603    5        1     1
## 2 -0.25579248    5        1     1
## 3  0.01562885    5        1     1
## 4  0.76796644    5        1     1
## 5 -0.43198031    5        1     1
## 6  1.00965719    5        1     2
## Attach variable labels
attr(normal, 'var.labels') <- c('Observed value',
    'Number of observations for the group',
    'Variance of the normal distribution for the group',
    'The sample group for a given size and variance')

## Export to Stata
library('foreign')
write.dta(normal, 'normal_2016.dta')

2 Reproducibility

Date this document was generated.

## [1] "2016-12-29 14:41:36 GST"

R session information.

## Session info -----------------------------------------------------------------------------------------------------------
##  setting  value                                             
##  version  R Under development (unstable) (2016-10-26 r71594)
##  system   x86_64, darwin13.4.0                              
##  ui       X11                                               
##  language (EN)                                              
##  collate  en_US.UTF-8                                       
##  tz       Asia/Dubai                                        
##  date     2016-12-29
## Packages ---------------------------------------------------------------------------------------------------------------
##  package   * version date       source                            
##  backports   1.0.4   2016-10-24 CRAN (R 3.4.0)                    
##  BiocStyle * 2.3.22  2016-12-04 Bioconductor                      
##  devtools  * 1.12.0  2016-12-05 CRAN (R 3.4.0)                    
##  digest      0.6.10  2016-08-02 CRAN (R 3.4.0)                    
##  evaluate    0.10    2016-10-11 CRAN (R 3.4.0)                    
##  foreign   * 0.8-67  2016-09-13 CRAN (R 3.4.0)                    
##  htmltools   0.3.5   2016-03-21 CRAN (R 3.4.0)                    
##  knitr       1.15.1  2016-11-22 CRAN (R 3.4.0)                    
##  magrittr    1.5     2014-11-22 CRAN (R 3.4.0)                    
##  memoise     1.0.0   2016-01-29 CRAN (R 3.4.0)                    
##  Rcpp        0.12.8  2016-11-17 CRAN (R 3.4.0)                    
##  rmarkdown * 1.3     2016-12-25 Github (rstudio/rmarkdown@3276760)
##  rprojroot   1.1     2016-10-29 CRAN (R 3.4.0)                    
##  stringi     1.1.2   2016-10-01 CRAN (R 3.4.0)                    
##  stringr     1.1.0   2016-08-19 CRAN (R 3.4.0)                    
##  withr       1.0.2   2016-06-20 CRAN (R 3.4.0)                    
##  yaml        2.1.14  2016-11-12 CRAN (R 3.4.0)

License: CC BY-NC-SA 4.0