1 / 31
文档名称:

R语言回归分析和方差分析上机.pptx

格式:pptx   大小:989KB   页数:31页
下载后只包含 1 个 PPTX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

R语言回归分析和方差分析上机.pptx

上传人:wz_198613 2018/8/14 文件大小:989 KB

下载得到文件列表

R语言回归分析和方差分析上机.pptx

文档介绍

文档介绍:建立 ,收缩压与年龄,收缩压与体重、年龄的回归方程,进行相关估计和预测。
具体处理过程:

rm(list=ls())
rd=("",head=T)
str(rd) ##structure of rd
attach(rd) ##链接rd
cor(sbp,weight);cor(sbp,age)
####sbp与weight;sbp与age的相关系数
Linear Regression
sbp &weight :
sbp &age :
M1=lm(sbp ~weight)
###做线性模型,其模型公式sbp ~ weight
即sbp = β0+β1 weight +ε,
summary(M1) ###模型的计算结果
plot(sbp ~weight,pch=19,main="sbp =+ ")
abline(M1) ##回归线
Call: ##列出相应的回归模型公式
lm(formula = sbp ~ weight)
Residuals:
Min 1Q Median 3Q Max
- - -
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) <2e-16 ***
weight <2e-16 ***
---
Signif. codes: 0 ‘***’ ‘**’ ‘*’ ‘.’ ‘’ 1
Residual standard error: on 3152 degrees of freedom
Multiple R-squared: , Adjusted R-squared:
F-statistic: 216 on 1 and 3152 DF, p-value: < -16
从检验结果可以看出回归方程通过了回归参数的检验和回归方程的检验。
M2=lm(sbp ~age)
summary(M2)
plot(sbp ~age);abline(M2)
boxplot(sbp ~age,ylab="sbp")
Call:
lm(formula = sbp ~ age)
Residuals:
Min 1Q Median 3Q Max
- - -
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) <2e-16 ***
age <2e-16 ***
---
Signif. codes: 0 ‘***’ ‘**’ ‘*’ ‘.’ ‘’ 1
Residual standard error: on 3152 degrees of freedom
Multiple R-squared: , Adjusted R-squared:
F-statistic: on 1 and 3152 DF, p-value: < -16
M3=lm(sbp ~weight+age)
summary(M3)
Call:
lm(formula = sbp ~ weight + age)
Residuals:
Min 1Q Median 3Q Max
- - -
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) <2e-16 ***
weight <2e-16 ***
age <2e-16 ***
---
Signif. codes: 0 ‘***’ ‘**’ ‘*’ ‘.’ ‘’ 1
Residual standard error: on 3151 deg