1
$\begingroup$

I want to get the direction of association from a linear model (beta value) using the "lm" function in R. How do I get that? I've used the following:

m <- lm( X ~  Y )
s <- summary(m)

When I print the output of summary(m) I get this:

Call:
lm(formula = X ~ Y)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.077047 -0.009917  0.001262  0.010990  0.031181 

Coefficients:
                      Estimate Std. Error  t value Pr(>|t|)    
(Intercept)          0.9449522  0.0009249 1021.715   <2e-16 ***
Y                   -0.0004059  0.0015299   -0.265    0.791    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.01494 on 351 degrees of freedom
  (6 observations deleted due to missingness)
Multiple R-squared:  0.0002005, Adjusted R-squared:  -0.002648 
F-statistic: 0.07039 on 1 and 351 DF,  p-value: 0.7909

Which of these parameters corresponds to beta (direction of association between X and Y? Thanks,

$\endgroup$
  • 2
    $\begingroup$ (Intercept) is "beta_0" and Y is "beta_1". $\endgroup$ – Roman Luštrik Feb 24 '16 at 8:14
  • 2
    $\begingroup$ Is your question more on the interpretation of output, or on how to get these estimates (of beta :)) out of the model? If the first, your q might be better suited for cross validated. If the second, look at ?coefficients $\endgroup$ – Heroka Feb 24 '16 at 8:31
  • $\begingroup$ You need to edit your question incorporating type of data and the hypothesis/objective of your project. $\endgroup$ – Subhash C. Davar Jul 10 '17 at 8:29
1
$\begingroup$

You can extract the beta values using coef. In the summary output the Estimate column corresponds to the coefficients.

set.seed(1)
X <- matrix(rnorm(200), nrow = 100)
Y <- rnorm(100)

m <- lm(Y ~  X)
summary(m)
coef(m)    
# (Intercept)          X1          X2
#  0.02535343  0.02111017 -0.05346682

The coefficient on X1 for example is saying that holding all else equal a 1 unit change in X1 would lead to a 0.0211 unit change in Y

| cite | improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.