第七次作业-R002线性回归

真·科研狗 2017-09-19 23:39:14 阅读: 1012
X <- c(0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.20,0.23)
Y <- c(42.0,43.5,45.0,45.5,45.0,47.5,49.0,53.0,50.0,55.0,55.0)
plot(X,Y)
a=lm(Y~X)
b=summary(a)
abline(a)
#print(b$coefficients[2,1])
text=paste("Y=",round(b$coefficients[1,1],2),"+",round(b$coefficients[2,1],2),"*X")
print(text);
mtext(text)

Rplot02.png

data<- read.csv(file.choose())
y <-data$CON
x <-data$std_ave
a <-lm(y~x)
plot(x,y)
abline(a,col = 'green',lwd = 1,lty = 1)
sam <- data.frame(x = data$sam_ave)
sam_pred <- predict(a,sam,interval = "prediction",level = 0.95)
points(data$sam_ave,sam_pred[,1],col = "red",pch = c("A","B","C","D"),cex =3)

Rplot04.png

在上述代码下再加上如下代码:

par(mfrow=c(2,2))
plot(a)

Rplot01.png

 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号