library(faraway)
data(sexab)
sexab
by(sexab,sexab$csa,summary)
plot(ptsd ~ csa, sexab)
plot(ptsd ~ cpa, pch=as.character(csa), sexab)
t.test(sexab$ptsd[1:45],sexab$ptsd[46:76])
g <- lm(ptsd ~ cpa+csa+cpa:csa,sexab)
summary(g)
model.matrix(g)
g <- lm(ptsd ~ cpa+csa,sexab)
summary(g)
plot(ptsd ~ cpa, pch=as.character(csa), sexab)
abline(10.248,0.551)
abline(10.248-6.273,0.551,lty=2)
confint(g)[3,]
plot(fitted(g),residuals(g),pch=as.character(sexab$csa),xlab="Fitted",ylab="Residuals")
sexab$csa <- relevel(sexab$csa,ref="NotAbused")
g <- lm(ptsd ~ cpa+csa,sexab)
summary(g)
contr.treatment(4)
contr.helmert(4)
data(fruitfly)
plot(longevity ~ thorax, fruitfly, pch=unclass(activity))
legend(0.63,100,levels(fruitfly$activity),pch=1:5)
g <- lm(longevity ~ thorax*activity, fruitfly)
summary(g)
model.matrix(g)
plot(g)
anova(g)
1-pf(0.05,4,114)
gb <- lm(longevity ~ thorax+activity, fruitfly)
drop1(gb,test="F")
summary(gb)
plot(residuals(gb) ~ fitted(gb),pch=unclass(fruitfly$activity))
gt <- lm(log(longevity) ~ thorax+activity, fruitfly)
plot(residuals(gt) ~ fitted(gt), pch=unclass(fruitfly$activity))
summary(gt)
exp(coef(gt)[3:6])
gh <- lm(thorax ~ activity, fruitfly)
anova(gh)
gu <- lm(log(longevity) ~ activity, fruitfly)
summary(gu)
