This vignette goes over typical ‘constuction’ projects for each of the analysis designs. First, let’s load up mason!
library(mason)
swiss %>%
design('t.test') %>%
add_settings() %>%
add_variables('yvars', c('Fertility', 'Agriculture')) %>%
add_variables('xvars', c('Examination', 'Education')) %>%
construct() %>%
scrub()
#> # A tibble: 4 x 12
#> Yterms Xterms estimate estimate1 estimate2 statistic
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 Agriculture Education 39.68085 50.65957 10.97872 11.030289
#> 2 Agriculture Examination 34.17021 50.65957 16.48936 9.731731
#> 3 Fertility Education 59.16383 70.14255 10.97872 25.730207
#> 4 Fertility Examination 53.65319 70.14255 16.48936 24.816482
#> # ... with 6 more variables: p.value <dbl>, parameter <dbl>,
#> # conf.low <dbl>, conf.high <dbl>, method <fctr>, alternative <fctr>
swiss %>%
design('cor') %>%
add_settings() %>%
add_variables('yvars', c('Fertility', 'Agriculture')) %>%
add_variables('xvars', c('Examination', 'Education')) %>%
construct() %>%
scrub()
#> # A tibble: 4 x 3
#> Vars1 Vars2 Correlations
#> <chr> <chr> <dbl>
#> 1 Examination Fertility -0.6458827
#> 2 Education Fertility -0.6637889
#> 3 Examination Agriculture -0.6865422
#> 4 Education Agriculture -0.6395225
swiss %>%
design('glm') %>%
add_settings() %>%
add_variables('yvars', c('Fertility', 'Agriculture')) %>%
add_variables('xvars', c('Examination', 'Education')) %>%
add_variables('covariates', 'Catholic') %>%
construct() %>%
scrub()
#> # A tibble: 12 x 10
#> Yterms Xterms term estimate std.error statistic
#> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 Agriculture Education (Intercept) 59.05963234 4.62225617 12.77723048
#> 2 Agriculture Education <-Xterm -1.39785668 0.25409607 -5.50129212
#> 3 Agriculture Education Catholic 0.16883756 0.05858401 2.88197372
#> 4 Agriculture Examination (Intercept) 82.30857657 8.71604359 9.44334155
#> 5 Agriculture Examination <-Xterm -1.93530048 0.38062966 -5.08447097
#> 6 Agriculture Examination Catholic 0.00638899 0.07281213 0.08774622
#> 7 Fertility Education (Intercept) 74.23368920 2.35197061 31.56233713
#> 8 Fertility Education <-Xterm -0.78832926 0.12929324 -6.09721944
#> 9 Fertility Education Catholic 0.11092095 0.02980965 3.72097417
#> 10 Fertility Examination (Intercept) 83.03565524 4.97729702 16.68288128
#> 11 Fertility Examination <-Xterm -0.88618608 0.21735858 -4.07706962
#> 12 Fertility Examination Catholic 0.04179341 0.04157937 1.00514762
#> # ... with 4 more variables: p.value <dbl>, conf.low <dbl>,
#> # conf.high <dbl>, sample.size <int>
data.frame(state.x77, state.region) %>%
design('gee') %>%
add_settings(cluster.id = 'state.region') %>%
add_variables('yvars', c('Income', 'Frost')) %>%
add_variables('xvars', c('Population', 'Murder')) %>%
add_variables('covariates', c('Life.Exp', 'Area')) %>%
add_variables('interaction', 'Area') %>%
construct() %>%
add_variables('xvars', c('Illiteracy')) %>%
construct() %>%
scrub()
#> Loading required namespace: geepack
#> xvars already exists in the specs, but will be replaced.
#> # A tibble: 30 x 12
#> Yterms Xterms term estimate std.error statistic
#> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 Frost Murder (Intercept) 1.425879e+03 4.664546e+02 9.34429563
#> 2 Frost Murder <-Xterm -1.301990e+01 1.900418e+00 46.93720171
#> 3 Frost Murder Life.Exp -1.743501e+01 6.506417e+00 7.18059704
#> 4 Frost Murder Area 1.836322e-04 3.072173e-04 0.35727813
#> 5 Frost Murder <-Xterm:Area -4.352580e-06 2.748875e-05 0.02507169
#> 6 Frost Population (Intercept) -7.260855e+02 3.995192e+02 3.30293661
#> 7 Frost Population <-Xterm 2.136489e-04 1.705346e-03 0.01569553
#> 8 Frost Population Life.Exp 1.171606e+01 5.661719e+00 4.28219507
#> 9 Frost Population Area 1.493809e-04 4.707465e-05 10.06969109
#> 10 Frost Population <-Xterm:Area -3.674397e-08 7.575809e-09 23.52415329
#> # ... with 20 more rows, and 6 more variables: p.value <dbl>,
#> # conf.low <dbl>, conf.high <dbl>, sample.total <int>, sample.max <int>,
#> # sample.min <int>