## examples for predict method
data(IBScovars)
fm <- fitDRModel(resp ~ dose, IBScovars, "emax", addCovars = ~ gender)
# predict only effect relative to placebo at 0, 1, 2, 3, 4
predict(fm, type = "EffectCurve", doseSeq = 0:4)
# add standard deviation for effect
predict(fm, type = "EffectCurve", doseSeq = 0:4, se.fit = TRUE)
# predict full model, specify where to predict via newdata
preddat <- data.frame(dose = 0:4, gender = as.factor(rep(1, 5)))
predict(fm, type = "fullModel", newdata = preddat)
# add standard deviation for predictions
predict(fm, type = "fullModel", newdata = preddat, se.fit = TRUE)
## examples for plot method
set.seed(123)
x <- rep(c(0,0.05,0.2,0.6,1), c(30,30,30,20,10))
y <- sigEmax(x, 0, 2, 0.2, 2)
age <- rnorm(120, 50, 10)
center <- as.factor(sample(c("C1","C2","C3"), 120, replace = TRUE))
y <- y + -0.03*age + 0.5*(center=="C1") + rnorm(120, 0, 1)
datfram <- data.frame(x, y, age, center)
fit <- fitDRModel(y ~ x, datfram, "sigEmax", addCovars = ~age+center)
# just plot effect curve
plot(fit, type = "EffectCurve")
# plot full dose-response curve, need values for covariates
op <- par()$mfrow
par(mfrow = c(1,2))
plot(fit, type = "DRCurve",
addCovarVals = data.frame(age = 20, center = as.factor("C1")))
plot(fit, type = "DRCurve",
addCovarVals = data.frame(age = 50, center = as.factor("C3")))
par(mfrow = op)
# plot full dose-response curve for covariates from datfram
plot(fit, type = "DRCurve",addCovarVals = datfram[1,3:4])
Run the code above in your browser using DataLab