Effect of the ozone on the tree growth
> ggplot(spruces, aes(x=factor(days), y=size, fill=treat)) +
+ geom_boxplot(outlier.shape=16, outlier.size=1) +
+ labs(x="Days since the beginning of the experiment",
+ y="Size", fill="Atmosphere") +
+ scale_fill_manual(values=c("salmon2", "green2")) +
+ theme(legend.position="top", legend.direction="horizontal")
>
> res <- function(x,y)
+ data.frame(type=y,fitted(x),residuals(x,type="pearson"))
> m1 <- glmgee(size ~ poly(days,4)+treat, id=tree, data=spruces,
+ corstr="Independence", family=inverse.gaussian(log))
> r1 <- res(m1,"V(mu)==muˆ3")
> m2 <- update(m1,family=poisson(log));r2 <- res(m2,"V(mu)==mu")
> m3 <- update(m1,family=Gamma(log));r3 <- res(m3,"V(mu)==muˆ2")
> m4 <- update(m1,family=gaussian(log));r4 <- res(m4,"V(mu)==1")
> rs <- rbind(r1,r2,r3,r4);colnames(rs) <- c("type","mu","res")
>
> ggplot(rs, aes(x=mu, y=res)) +
+ geom_point(shape=16, col="black") +
+ labs(x="Fitted values", y="Pearson’s residuals") +
+ facet_wrap(vars(type), labeller=label_parsed)
433 / 460