R语言——第九课

'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

  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值