R语言的lm()函数

lm()是R语言中线性建模的函数。lm()函数适合线性模型并用于执行回归分析。

fit <- lm(weight~height,data=women)
fit
    展开/折叠结果     
Call:
lm(formula = weight ~ height, data = women)
Coefficients:
(Intercept) height -87.52 3.45
summary(fit)
    展开/折叠结果     
Call:
lm(formula = weight ~ height, data = women)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.7333 -1.1333 -0.3833  0.7417  3.1167 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -87.51667    5.93694  -14.74 1.71e-09 ***
height        3.45000    0.09114   37.85 1.09e-14 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.525 on 13 degrees of freedom
Multiple R-squared:  0.991,     Adjusted R-squared:  0.9903 
F-statistic:  1433 on 1 and 13 DF,  p-value: 1.091e-14

$\hat{Weight}=-87.52+3.45\times Height$

该模型解释了99.1%的方差,残差标准误1.525可理解为身高预测体重的模型的平均误差是1.525。

评论

发表评论

了解 数据控|突破是我们的每一步 的更多信息

立即订阅以继续阅读并访问完整档案。

继续阅读