|||
熊荣川
六盘水师范学院
为了图文并貌,请下载pdf文件观看。
|
输入 |
注释 |
|
A <- read.table(file="onev.csv", header=TRUE, sep=",") |
读入工作目录中数据文件 |
|
A |
查看矩阵数据 |
|
plot (A$x, A$y) |
作x,y的散点图 |
|
|
|
|
作线性回归 | |
|
abline(lm.reg) |
画出回归曲线 |
|
|
|
|
查看统计结果 | |
|
Call: lm(formula = A$y ~ A$x)
Residuals: Min 1Q Median 3Q Max -0.67273 -0.33333 -0.07273 0.34545 0.68182
Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.12121 0.47708 19.12 5.8e-08 *** A$x 0.22303 0.01063 20.97 2.8e-08 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.483 on 8 degrees of freedom Multiple R-squared: 0.9821, Adjusted R-squared: 0.9799 F-statistic: 439.8 on 1 and 8 DF, p-value: 2.805e-08 |
|
|
point <- data.frame(A$x==42) |
|
|
lm.pred <- predict(lm.reg, point, interval ="prediction" , level = 0.95) |
预测理想回归曲线(fit),及其0.05误差上限(upr)、下限(lwr)上得代表点 |
|
显示预测点 | |
|
1 13.58182 12.28997 14.87367 2 14.69697 13.45254 15.94140 3 15.81212 14.60448 17.01976 4 16.92727 15.74480 18.10975 5 18.04242 16.87273 19.21212 6 19.15758 17.98788 20.32727 7 20.27273 19.09025 21.45520 8 21.38788 20.18024 22.59552 9 22.50303 21.25860 23.74746 10 23.61818 22.32633 24.91003 |
结果值为输入数据x对应的理想y值 |
|
|
|
|
|
原始的回归曲线图,斜率一致 |
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-26 05:56
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社