Consider this example:
set.seed(5) # this line will allow you to run these commands on your
# own computer & get *exactly* the same output
x = rnorm(50)
y = rnorm(50)
fit = lm(y~x)
summary(fit)
# Call:
# lm(formula = y ~ x)
#
# Residuals:
# Min 1Q Median 3Q Max
# -2.04003 -0.43414 -0.04609 0.50807 2.48728
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) -0.00761 0.11554 -0.066 0.948
# x 0.09156 0.10901 0.840 0.405
#
# Residual standard error: 0.8155 on 48 degrees of freedom
# Multiple R-squared: 0.01449, Adjusted R-squared: -0.006046
# F-statistic: 0.7055 on 1 and 48 DF, p-value: 0.4051
The question, I'm guessing, is how to figure out the regression equation from R's summary output. Algebraically, the equation for a simple regression model is:
y^i=β^0+β^1xi+ε^iwhere ε∼N(0, σ^2)
We just need to map the
summary.lm()
output to these terms. To wit:
- β^0 is the
Estimate
value in the (Intercept)
row (specifically, -0.00761
)
- β^1 is the
Estimate
value in the x
row (specifically, 0.09156
)
- σ^ is the
Residual standard error
(specifically, 0.8155
)
Plugging these in above yields:
y^i=−0.00761 + 0.09156xi + ε^iwhere ε∼N(0, 0.81552)
For a more thorough overview, you may want to read this thread:
Interpretation of R's lm() output.
lm
ve lineer modellere oldukça aşinayım , fakat tam olarak ne istediğinizi tam olarak bilmiyorsunuz. Açıklamak için bir örnek veya bir şey verebilir misiniz? Bu bir konu için mi?