Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to understand simple Linear regression in R language

Shulou Source: shulou.com Published: 2022-06-01 22:21:29 10月02日 Update

This article introduces how to understand the simple linear regression in R language. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Basic knowledge of R language:

Simple linear regression

> fit 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'.

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

> women$weight

[1] 115 117 120 123 126 129 132 135 139 142 146 150 154 159 164

> fitted (fit)

1 2 3 4 5 6 7 8 9 10

112.5833 116.0333 119.4833 122.9333 126.3833 129.8333 133.2833 136.7333 140.1833 143.6333

11 12 13 14 15

147.0833 150.5333 153.9833 157.4333 160.8833

> residuals (fit)

1 2 3 4 5 6 7

2.41666667 0.96666667 0.51666667 0.06666667-0.38333333-0.83333333-1.28333333

8 9 10 11 12 13 14

-1.73333333-1.18333333-1.63333333-1.08333333-0.53333333 0.01666667 1.56666667

fifteen

3.11666667

> plot (women$height,women$weight,xlab= "Height (in inpches", ylab = "Weight (in pounds"))

> abline (fit)

Formula:

Because the height cannot be zero, it is just a constant adjustment. In Pr (> | t |), you can see that the regression coefficient (3.45) is significantly less than 0 (p

Tags: Height linearity language coefficient test weight content more model knowledge help good significant between formula interest only basics basic knowledge reality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Huawei Microsoft Docker macOS