data(studentratings)
fml <- MathDis + ReadDis + SchClimate ~ (1|ID)
imp <- panImpute(studentratings, formula = fml, n.burn = 1000, n.iter = 100, m = 5)
implist <- mitmlComplete(imp)
# fit simple regression model
fit.lm <- with(implist, lm(SchClimate ~ ReadDis + MathDis))
# apply Rubin's rules
testEstimates(fit.lm)
# * Example 1: test 'identity' function of two parameters (automatic)
# test equivalent to model comparison with a restricted model (without 'ReadDis'
# and 'MathDis')
cons <- c("ReadDis", "MathDis")
testConstraints(fit.lm, constraints = cons)
# ... adjusting for finite samples
testConstraints(fit.lm, constraints = cons, df.com = 749)
# ... using D2
testConstraints(fit.lm, constraints = cons, method = "D2")
# * Example 2: test for equality of two parameters
# tests the hypothesis that the coefficients pertaining to 'ReadDis' and 'MathDis'
# are equal (ReadDis = MathDis)
cons <- c("ReadDis-MathDis")
testConstraints(fit.lm, constraints = cons)
# * Example 3: test against a fixed value
# tests the hypothesis that the coefficient of "ReadDis" is equal to one
# (i.e., 'ReadDis' - 1 == 0)
cons <- c("ReadDis-1")
testConstraints(fit.lm, constraints = cons)
# * Example 4: test 'identity' function of two parameters (qhat, uhat)
fit.lm <- with(implist, lm(SchClimate ~ ReadDis + MathDis))
qhat <- sapply(fit.lm, coef)
uhat <- sapply(fit.lm, function(x) vcov(x), simplify = "array")
cons <- c("ReadDis", "MathDis")
testConstraints(qhat = qhat, uhat = uhat, constraints = cons)
Run the code above in your browser using DataLab