't检验'
daily.intake = c(5260,5470,5640,6180,6390,6515,6805,7515,8230,8770)
t.test(daily.intake, mu = 7725)
intake.pre = c(5260,5470,5640,6180,6390,6515,6805,7515,7515,8230,8770)
intake.post = c(3910,4220,3885,5160,5645,4680,5265,5975,6790,6900,7335)
t.test(intake.pre,intake.post,paired = T)
'简单线性回归'
thuesen = read.table("thuesen.txt",header = TRUE)
attach(thuesen)
yfit = lm(velocity ~ glucose)
summary(yfit)
plot(glucose,velocity)
abline(lm(velocity~glucose),col='red')
pred = fitted(yfit)
confint(yfit,level = 0.95)
rs = rstandard(yfit)
plot(pred,rs)
abline(h=0,col='red')
qqnorm(rs)
qqline(rs,col='red')
hist(rs)
boxplot(rs)
cor(glucose,velocity)
cor.test(glucose,velocity)
'多元回归'
data(cystfibr,package='ISwR')
head(cystfibr)
attach(cystfibr)
pairs(cystfibr,gap=0,cex.labels=0.9)
yfit = lm(pemax~age+sex+height+weight+bmp+fev1+rv+frc+tlc)
summary(yfit)
'向前/向后回归'
library(Deducer)
step(yfit,dirrection='backward',trace=1)
step(lm(pemax~1),dirrection='forward',scope=list(lower=lm(pemax~1),upper=yfit,trace=1))
'ANOVA'
data(red.cell.folate,package='ISwR')
head(red.cell.folate)
attach(red.cell.folate)
summary(red.cell.folate)
yfit = anova(lm(folate~ventilation))
yfit