rt<-read.table("exam0203.txt", head=TRUE); rt lm.sol<-lm(Weight~Height, data=rt) summary(lm.sol)
rt<-read.table("exam0203.txt", head=TRUE); rt Name Sex Age Height Weight 1 Alice F 13 56.5 84.0 2 Becka F 13 65.3 98.0 3 Gail F 14 64.3 90.0 4 Karen F 12 56.3 77.0 5 Kathy F 12 59.8 84.5 6 Mary F 15 66.5 112.0 7 Sandy F 11 51.3 50.5 8 Sharon F 15 62.5 112.5 9 Tammy F 14 62.8 102.5 10 Alfred M 14 69.0 112.5 11 Duke M 14 63.5 102.5 12 Guido M 15 67.0 133.0 13 James M 12 57.3 83.0 14 Jeffrey M 13 62.5 84.0 15 John M 12 59.0 99.5 16 Philip M 16 72.0 150.0 17 Robert M 12 64.8 128.0 18 Thomas M 11 57.5 85.0 19 William M 15 66.5 112.0
summary(lm.sol) Call: lm(formula = Weight ~ Height, data = rt) Residuals: Min 1Q Median 3Q Max -17.6807 -6.0642 0.5115 9.2846 18.3698 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -143.0269 32.2746 -4.432 0.000366 *** Height 3.8990 0.5161 7.555 7.89e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 11.23 on 17 degrees of freedom Multiple R-squared: 0.7705, Adjusted R-squared: 0.757 F-statistic: 57.08 on 1 and 17 DF, p-value: 7.887e-07
#这是一个最基本的R语言回归模型的结果,其中,按照这些数据,可以得到身高和体重的模型:height=-143.02+3.899*weight,其中,相关系数R—squared,0.77,
p-Value:7.887e-7,可以认为是显著的。