77# ' @param ... Additional argument to pass to Stan model
88# '
99# ' @return A list containing:
10- # ' * `means`: A list containing vectors of posterior means (one per synthesis `M `):
10+ # ' * `means`: A list containing vectors of posterior means (one per synthesis `n_imp `):
1111# ' * `A`: Comparator means.
1212# ' * `C`: Reference means.
1313# ' * `model`: A list containing:
1414# ' * `fit`: The first-stage [rstanarm::stan_glm()] object.
1515# ' * `hats.v`: Vector of variance point estimates for each synthesis.
16- # ' * `M `: Number of posterior prediction draws (syntheses).
16+ # ' * `n_imp `: Number of posterior prediction draws (syntheses).
1717# ' * `rho`, `N`, `stan_args`: Strategy and model parameters.
1818# '
1919# ' @importFrom rstanarm posterior_predict stan_glm
@@ -72,10 +72,10 @@ calc_mim <- function(strategy,
7272
7373 # ANALYSIS STAGE ---
7474
75- M <- nrow(y_star )
75+ n_imp <- nrow(y_star )
7676
7777 # fit second-stage regression to each synthesis using maximum-likelihood estimation
78- reg2.fits <- lapply(1 : M , function (m ) {
78+ reg2.fits <- lapply(1 : n_imp , function (m ) {
7979 data_m <- aug.target
8080 data_m $ y <- y_star [m , ]
8181 glm(as.formula(paste(" y ~" , trt_var )), data = data_m , family = family )
@@ -103,7 +103,7 @@ calc_mim <- function(strategy,
103103 model = list (
104104 fit = outcome_model ,
105105 hats.v = hats.v ,
106- M = M ,
106+ n_imp = n_imp ,
107107 rho = rho ,
108108 N = N ,
109109 stan_args = stan_args )
@@ -114,27 +114,27 @@ calc_mim <- function(strategy,
114114# '
115115# ' Constructed using t-distribution with nu degrees of freedom.
116116# '
117- # ' @param M Number of syntheses used in analysis stage (high for low Monte Carlo error)
117+ # ' @param n_imp Number of syntheses used in analysis stage (high for low Monte Carlo error)
118118# ' @param bar.v "within" variance (average of variance point estimates)
119119# ' @param b "between" variance (sample variance of point estimates)
120120# ' @return Numeric value of Wald-type interval estimates.
121121# ' @keywords internal
122122# '
123- wald_type_interval <- function (M , bar.v , b ) {
124- (M - 1 ) * (1 + bar.v / ((1 + 1 / M ) * b )) ^ 2
123+ wald_type_interval <- function (n_imp , bar.v , b ) {
124+ (n_imp - 1 ) * (1 + bar.v / ((1 + 1 / n_imp ) * b )) ^ 2
125125}
126126
127127# ' Variance estimate by pooling
128128# '
129129# ' Use combining rules to estimate.
130130# '
131- # ' @param M Number of syntheses used in analysis stage (high for low Monte Carlo error)
131+ # ' @param n_imp Number of syntheses used in analysis stage (high for low Monte Carlo error)
132132# ' @param bar.v "within" variance (average of variance point estimates)
133133# ' @param b "between" variance (sample variance of point estimates)
134134# ' @return Numeric value of variance estimate using pooling.
135135# ' @keywords internal
136136# '
137- var_by_pooling <- function (M , bar.v , b ) {
138- (1 + (1 / M )) * b - bar.v
137+ var_by_pooling <- function (n_imp , bar.v , b ) {
138+ (1 + (1 / n_imp )) * b - bar.v
139139}
140140
0 commit comments