glmEff: Efficient Group Comparison Using Baseline Adjustment

View source: R/glmEff.R

glmEffR Documentation

Efficient Group Comparison Using Baseline Adjustment

Description

Efficient group comparison in a randomized experiment using baseline adjustment.

Usage

glmEff(
  outcome,
  treatment,
  covariates,
  data,
  family.outcome,
  method = "explicit"
)

Arguments

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 ("gaussian") or binary ("binomial").

References

Zhang et al. 2010. Increasing the Efficiency of Prevention Trials by Incorporating Baseline Covariates. Statistical Communications in Infectious Diseases

Examples

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

bozenne/butils documentation built on Oct. 14, 2023, 6:19 a.m.