User Tools

Site Tools


r:linear_regression

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
r:linear_regression [2018/12/07 08:16] – [Multiple Regression] hkimscilr:linear_regression [2019/06/13 10:15] (current) hkimscil
Line 162: Line 162:
  
 ====== Multiple Regression ====== ====== Multiple Regression ======
 +regression output table
 | anova(m)  | ANOVA table  | | anova(m)  | ANOVA table  |
 | coefficients(m) = coef(m)  | Model coefficients  | | coefficients(m) = coef(m)  | Model coefficients  |
Line 200: Line 201:
   * What is R<sup>2</sup>?   * What is R<sup>2</sup>?
   * How many cars are involved in this test? (cf. df = 90)   * How many cars are involved in this test? (cf. df = 90)
 +    * df + # of variables involved (3) = 93
 +    * check 'str(Cars93)'
   * If I eliminate the R<sup>2</sup> from the above output, can you still identify what it is?   * If I eliminate the R<sup>2</sup> from the above output, can you still identify what it is?
 +</WRAP>
 +<WRAP box info>The last question: 
 +  * If I eliminate the R<sup>2</sup> from the above output, can you still identify what it is?
 +  * to answer the question, use the regression output table:
 +
 +R<sup>2</sup> = SS<sub>reg</sub>/SS<sub>total</sub> = 1 - SS<sub>res</sub>/SS<sub>total</sub>
 +
 +
 +<code>> anova(lm.model)
 +Analysis of Variance Table
 +
 +Response: Cars93$MPG.city
 +                  Df Sum Sq Mean Sq F value  Pr(>F)    
 +Cars93$EngineSize  1   1465    1465  100.65 2.4e-16 ***
 +Cars93$Price          131     131    9.01  0.0035 ** 
 +Residuals         90   1310      15                    
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +> sstotal = 1465+131+1310
 +> ssreg <- 1465+131
 +> ssreg/sstotal
 +[1] 0.54921
 +
 +> # or
 +> 1-(deviance(lm.model)/sstotal)
 +[1] 0.54932
 +</code>
 +
 +
 </WRAP> </WRAP>
  
Line 207: Line 240:
   * $\hat{Y} = \widehat{\text{MPG.city}}$   * $\hat{Y} = \widehat{\text{MPG.city}}$
  
-<WRAP box help>in the meantime,+<WRAP box info>in the meantime,
 <code>> lm.beta(lm.model) <code>> lm.beta(lm.model)
 Cars93$EngineSize      Cars93$Price  Cars93$EngineSize      Cars93$Price 
Line 231: Line 264:
  
 </code> </code>
 +Beta coefficients are not equal to correlations among variables. 
 </WRAP> </WRAP>
  
r/linear_regression.1544138172.txt.gz · Last modified: 2018/12/07 08:16 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki