glmEff | R Documentation |
Efficient group comparison in a randomized experiment using baseline adjustment.
glmEff(
outcome,
treatment,
covariates,
data,
family.outcome,
method = "explicit"
)
outcome |
[character] the name of the outcome variable in the dataset |
treatment |
[character] the name of the treatment variable in the dataset |
covariates |
[character] the name of the baseline variables in the dataset |
data |
[data.frame] the dataset |
family.outcome |
[character] the type of outcome: can be continuous ( |
Zhang et al. 2010. Increasing the Efficiency of Prevention Trials by Incorporating Baseline Covariates. Statistical Communications in Infectious Diseases
library(lava)
## continuous case
m.cont <- lvm(Y~T+3*X1-3*X2)
distribution(m.cont,~T) <- binomial.lvm(size=1,p=0.5)
distribution(m.cont,~X1) <- binomial.lvm(size=1,p=0.25)
set.seed(10)
d <- lava::sim(m.cont, n = 100)
m.glmeff <- glmEff(outcome = "Y", treatment = "T", covariates = c("X1","X2"), data = d,
family.outcome = "gaussian")
m.glmeff ## efficient
tapply(d$Y,d$T,mean) ## naive
## binary case
m.bin <- lvm(Y~T+3*X1-3*X2)
distribution(m.bin,~Y) <- binomial.lvm(size=1,p=0.5)
distribution(m.bin,~T) <- binomial.lvm(size=1,p=0.5)
distribution(m.bin,~X1) <- binomial.lvm(size=1,p=0.25)
set.seed(10)
d <- lava::sim(m.bin, n = 1000)
m.glmeff <- glmEff(outcome = "Y", treatment = "T", covariates = c("X1","X2"), data = d,
family.outcome = "binomial")
m.glmeff ## efficient
tapply(d$Y,d$T,mean) ## naive
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.