User Tools

Site Tools


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
Next revisionBoth sides next revision
regression [2019/05/13 08:57] hkimscilregression [2019/05/20 08:50] – [e.g. Simple Regression] hkimscil
Line 351: Line 351:
  
  
-====== E.g., 2. Simple regression ======+====== E.g., Simple regression ======
 data:  data: 
 {{:acidity.sav}} \\ {{:acidity.sav}} \\
Line 588: Line 588:
  SS<sub>total</sub> = 87.733  SS<sub>total</sub> = 87.733
  r<sup>2</sup> = SS<sub>reg</sub> / SS<sub>total</sub> = 42.462 / 87.733 = .484.  r<sup>2</sup> = SS<sub>reg</sub> / SS<sub>total</sub> = 42.462 / 87.733 = .484.
 +
 +====== e.g. Simple Regression ======
 +{{:AllenMursau.data.csv}}
 +
 +<code>datavar <- read.csv("http://commres.net/wiki/_media/allenmursau.data.csv")
 +</code>
 +
 +<code>> mod <- lm(Y ~ X, data=datavar)
 +> summary(mod)
 +
 +Call:
 +lm(formula = Y ~ X, data = datavar)
 +
 +Residuals:
 +    Min      1Q  Median      3Q     Max 
 +-250.22 -132.28   33.09  165.53  187.78 
 +
 +Coefficients:
 +            Estimate Std. Error t value Pr(>|t|)   
 +(Intercept)  300.976    229.754   1.310    0.219   
 +X             10.312      3.124   3.301    0.008 **
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 170.5 on 10 degrees of freedom
 +Multiple R-squared:  0.5214, Adjusted R-squared:  0.4736 
 +F-statistic:  10.9 on 1 and 10 DF,  p-value: 0.008002
 +
 +</code>
 +<code>> anova(mod)
 +Analysis of Variance Table
 +
 +Response: Y
 +          Df Sum Sq Mean Sq F value   Pr(>F)   
 +X          1 316874  316874  10.896 0.008002 **
 +Residuals 10 290824   29082                    
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +> </code>
 +
 +<code>
 +> ss_total <- var(datavar$Y)*11
 +> round(ss_total)
 +[1] 607698
 +> 316874 + 290824  # 위의 아웃풋에서 Sum Sq for X와 Residuals를 더한 값
 +[1] 607698
 +</code>
 +<WRAP box help>위의 anova 아웃풋 박스에서 R square value를 구할 수 있는가?
 +
 +
 +</WRAP>
 +
  
 ====== E.g., 3. Simple regression: Adjusted R squared & Slope test ====== ====== E.g., 3. Simple regression: Adjusted R squared & Slope test ======
regression.txt · Last modified: 2023/05/24 08:53 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki