# Linear regression (simple)

I'm iniciating in the R "experience" and trying to do a simple linear regression, but I am doing something wrong, since it allways apeears an error.

The file is in excel, and on variable is in the column A, the other in "B".

I'm trying to obtain the equacion, the variance of β, as well as the SD of B0 and B1.

Regards...

Life will become easiwe when you get to the point of importing your Excel files into data frames or tables and are able to provide reproducible examples, called reprex.

Let's take an example from the help(lm) page:

require(graphics)

## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
## Page 9: Plant Weight Data.
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)
summary(lm.D9)

Call:
lm(formula = weight ~ group)

Residuals:
Min      1Q  Median      3Q     Max
-1.0710 -0.4938  0.0685  0.2462  1.3690

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)    5.032      0.220   22.85  9.5e-15 ***
groupTrt      -0.371      0.311   -1.19     0.25
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.696 on 18 degrees of freedom
Multiple R-squared:  0.0731,	Adjusted R-squared:  0.0216
F-statistic: 1.42 on 1 and 18 DF,  p-value: 0.249


The "equation" is given in Call. The meaning of other parts of the output are explained in one of my posts.

However, you should review the concept of linear regression with aids such as this to understand that \mu and \sigma don't map over from the normal distribution in any way that will be useful to your understanding of linear regression.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.