{
data(heart)
#descriptive plots:
if(0){
library(mgee2)
library(ggplot2)
# covariates
heart$chol = as.factor(heart$chol)
heart$CURSMOKE = as.factor(heart$CURSMOKE)
heart$exam3 = as.factor(heart$exam3)
levels(heart$exam3) = c("exam2","exam3")
ggplot(heart, aes(x=AGE, y=SYSBP)) +
geom_line(aes(group=RANDID), alpha=0.5) +
geom_smooth(se=FALSE, size=2) +
ylab("SBP")+
facet_grid(chol~CURSMOKE, labeller = label_both)
# trend
ggplot(heart, aes(x=AGE, y=SYSBP,
colour = chol,linetype = CURSMOKE)) +
geom_smooth(method="lm", se=FALSE) +
ylab("SBP")+facet_wrap(~exam3)+
scale_color_brewer(palette = "Dark2")
}
#Example 1:
heart$chol = as.factor(heart$chol)
heart$exam3 = as.factor(heart$exam3)
## set misclassification parameters to be known.
varphiMat <- gamMat <- log( cbind(0.04/0.95, 0.01/0.95,
0.95/0.03, 0.02/0.03,
0.04/0.01, 0.95/0.01) )
mgee2k.fit = mgee2k(formula = HBP~chol+AGE+CURSMOKE+exam3, id = "RANDID",
data = heart,
corstr = "exchangeable", misvariable = "chol",
gamMat = gamMat,
varphiMat = varphiMat)
summary(mgee2k.fit)
#Example 2:
naigee.fit = ordGEE2(formula = HBP~chol+AGE+CURSMOKE+exam3, id = "RANDID",
data = heart, corstr = "exchangeable")
summary(naigee.fit)
}
Run the code above in your browser using DataLab