User Tools

Site Tools


using_dummy_variables

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
using_dummy_variables [2015/11/04 09:45] hkimscilusing_dummy_variables [2019/10/18 10:18] (current) hkimscil
Line 2: Line 2:
 ===== 2 groups ===== ===== 2 groups =====
 data: data:
-{{:elemapi2.sav}} \\ +{{:elemapi2.sav}}  
-{{elemapi2_categories.sps}} \\+{{:elemapi2_categories.sps}}  
 + 
 +{{:elemapi2.csv}}  
 +in r <code>datavar <- read.csv("http://commres.net/wiki/_media/r/elemapi2.csv")</code>
  
 <code> Variable Labels <code> Variable Labels
Line 14: Line 17:
 meals 6 pct free meals meals 6 pct free meals
 ell 7 english language learners ell 7 english language learners
-yr_rnd 8 year round school 무방학학교+yr_rnd 8 year round school 무방학학교 0 = 방학있음 1 = 방학없음
 mobility 9 pct 1st year in school mobility 9 pct 1st year in school
 acs_k3 10 avg class size k-3 acs_k3 10 avg class size k-3
Line 45: Line 48:
 </code> </code>
  
-'''Model Summary''' +|  **Model Summary**  |||||
 | Model   | R   | R Square   | Adjusted R Square   | Std. Error of the Estimate    | Model   | R   | R Square   | Adjusted R Square   | Std. Error of the Estimate   
 | 1   | .475a   | 0.226   | 0.224   | 125.3    | 1   | .475a   | 0.226   | 0.224   | 125.3   
 | a. Predictors: (Constant), year round school   ||||| | a. Predictors: (Constant), year round school   |||||
  
-ANOVA(b)+|  **ANOVA(b)**  |||||||
 | Model      | Sum of Squares   | df   | Mean Square   | F   | Sig.    | Model      | Sum of Squares   | df   | Mean Square   | F   | Sig.   
 | 1   | Regression   | 1825000.563   | 1   | 1825000.563   | 116.241   | .000a    | 1   | Regression   | 1825000.563   | 1   | 1825000.563   | 116.241   | .000a   
Line 58: Line 61:
  
  
-Coefficients(a)+|  **Coefficients(a)**  |||||||
 |    |    | Unstandardized Coefficients      | Standardized Coefficients      |    |  |    |    | Unstandardized Coefficients      | Standardized Coefficients      |    | 
 | Model      | B   | Std. Error   | Beta   | t   | Sig.    | Model      | B   | Std. Error   | Beta   | t   | Sig.   
Line 95: Line 98:
 </code> </code>
  
-'''Report''' +|  **Report**  |||| 
-|api 2000 ||||+| api 2000 ||||
 | year round school  | Mean  | N  | Std. Deviation  | | year round school  | Mean  | N  | Std. Deviation  |
 | No     | 684.54  | 308  | 132.113  | | No     | 684.54  | 308  | 132.113  |
Line 104: Line 107:
 이와 같이 종류변인(category, nominal)을 가지고서도 regression 테스트를 할 수 있으며, 사실 이는 t-test나 F-test와 다르지 않다. 위에서 주의해야 할 점은 두 변인의 종류를 coding할 때, 1과 2가 아닌, 0과 1로 하였다는 점이다. 이렇게 하는 이유는 해석하기에 편하기 때문이며, 이것이 보통의 방법이다. 그러나, 1과 2로 coding 데이터를 이용해도 크게 다른지 않은 결과를 구하게 된다. 다른 점이라면, 절편에 해당되는 상수값이 다르게 되며, coefficient값은 위의 분석과 동일한 값을 갖게 된다.  이와 같이 종류변인(category, nominal)을 가지고서도 regression 테스트를 할 수 있으며, 사실 이는 t-test나 F-test와 다르지 않다. 위에서 주의해야 할 점은 두 변인의 종류를 coding할 때, 1과 2가 아닌, 0과 1로 하였다는 점이다. 이렇게 하는 이유는 해석하기에 편하기 때문이며, 이것이 보통의 방법이다. 그러나, 1과 2로 coding 데이터를 이용해도 크게 다른지 않은 결과를 구하게 된다. 다른 점이라면, 절편에 해당되는 상수값이 다르게 되며, coefficient값은 위의 분석과 동일한 값을 갖게 된다. 
  
-====== 3 or more groups ======+===== 3 or more groups =====
 만약에 ANOVA 테스트에서와 같이 종류가 3개 이상인 변인은 어떻게 처리해야 할까? 아래는 이를 regression으로 테스트 한 결과이다. 만약에 ANOVA 테스트에서와 같이 종류가 3개 이상인 변인은 어떻게 처리해야 할까? 아래는 이를 regression으로 테스트 한 결과이다.
  
-<code> Model Summary +<code> 
-Model R R Square Adjusted R Square Std. Error of the Estimate +> mod2 <- lm(api00 ~ factor(mealcat), data=datavar)  
-1 .867a .752 .752 70.908 +> mod2
-a. Predictors: (Constant), Percentage free meals in 3 categories+
  
- ANOVA(b) +Call: 
-Model Sum of Squares df Mean Square F Sig. +lm(formula = api00 ~ factor(mealcat), data = datavar)
-1 Regression 6072527.519 1 6072527.519 1207.742 .000a +
- Residual 2001144.479 398 5028.001  +
- Total 8073671.997 399  +
-a. Predictors: (Constant), Percentage free meals in 3 categories +
-b. Dependent Variable: api 2000+
  
- Coefficients(a+Coefficients
- Unstandardized Coefficients Standardized Coefficients +     (Intercept factor(mealcat)2  factor(mealcat)3   
-Model B Std. Error Beta t Sig. +           805.7            -166.3            -301.3   
-1 (Constant) 950.987 9.422 100.935 .000 + 
- Percentage free meals in categories -150.553 4.332 -.867 -34.753 .000 +> summary(mod2) 
-aDependent Variableapi 2000+ 
 +Call: 
 +lm(formula = api00 ~ factor(mealcat), data = datavar) 
 + 
 +Residuals: 
 +     Min       1Q   Median       3Q      Max  
 +-253.394  -47.883    0.282   52.282  185.620  
 + 
 +Coefficients: 
 +                 Estimate Std. Error t value Pr(>|t|)     
 +(Intercept      805.718      6.169  130.60   <2e-16 *** 
 +factor(mealcat)2 -166.324      8.708  -19.10   <2e-16 *** 
 +factor(mealcat)3 -301.338      8.629  -34.92   <2e-16 *** 
 +--- 
 +Signifcodes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
 + 
 +Residual standard error: 70.61 on 397 degrees of freedom 
 +Multiple R-squared 0.7548, Adjusted R-squared:  0.7536  
 +F-statistic: 611.1 on 2 and 397 DF,  p-value: < 2.2e-16 
 + 
 +
 </code> </code>
  
Line 173: Line 190:
 </code> </code>
  
-Coefficients(a) +|  **Coefficients(a)**  |||||||
 |  |  | Unstandardized Coefficients      | Standardized Coefficients       | |  |  | Unstandardized Coefficients      | Standardized Coefficients       |
 | Model      | B   | Std. Error   | Beta   | t   | Sig.   | | Model      | B   | Std. Error   | Beta   | t   | Sig.   |
Line 193: Line 210:
 api 2000 api 2000
 Percentage free meals in 3 categories Mean N Std. Deviation Percentage free meals in 3 categories Mean N Std. Deviation
-0-46% free meals 805.72 131 65.669 + 0-46% free meals 805.72 131 65.669 
-47-80% free meals 639.39 132 82.135 + 47-80% free meals 639.39 132 82.135 
-81-100% free meals 504.38 137 62.727 + 81-100% free meals 504.38 137 62.727 
-Total 647.62 400 142.249+ Total 647.62 400 142.249
 </code> </code>
  
Line 208: Line 225:
 </code> </code>
  
-'''Between-Subjects Factors'''+|  **Between-Subjects Factors**  ||||
 |    |    | Value Label   | N   | |    |    | Value Label   | N   |
 | Percentage free meals in 3 categories   | 1   | 0-46% free meals   | 131   | | Percentage free meals in 3 categories   | 1   | 0-46% free meals   | 131   |
Line 214: Line 231:
 |    | 3   | 81-100% free meals   | 137   | |    | 3   | 81-100% free meals   | 137   |
  
-'''Tests of Between-Subjects Effects'''+|  **Tests of Between-Subjects Effects**  |||||| 
 | Dependent Variable:api 2000    |  |  |  |  | | Dependent Variable:api 2000    |  |  |  |  |
 | Source   | Type III Sum of Squares   | df   | Mean Square   | F   | Sig.   | | Source   | Type III Sum of Squares   | df   | Mean Square   | F   | Sig.   |
Line 225: Line 242:
 |a. R Squared = .755 (Adjusted R Squared = .754)   ||||||  |a. R Squared = .755 (Adjusted R Squared = .754)   |||||| 
  
-'''Parameter Estimates''' +|  **Parameter Estimates**   ||||||| 
-| Dependent Variable:api 2000         |+| Dependent Variable:api 2000   |||||||
 |    |    |    |    |    | 95% Confidence Interval    | |    |    |    |    |    | 95% Confidence Interval    |
 | Parameter   | B   | Std. Error   | t   | Sig.   | Lower Bound   | Upper Bound   | | Parameter   | B   | Std. Error   | t   | Sig.   | Lower Bound   | Upper Bound   |
Line 258: Line 275:
 </code> </code>
  
-'''Model Summary'''+|  **Model Summary**  |||||
 | Model   | R   | R Square   | Adjusted R Square   | Std. Error of the Estimate   | | Model   | R   | R Square   | Adjusted R Square   | Std. Error of the Estimate   |
 | 1   | .876a   | .767   | .765   | 68.893   | | 1   | .876a   | .767   | .765   | 68.893   |
 | a. Predictors: (Constant), mealcat2, year round school, mealcat1   ||||| | a. Predictors: (Constant), mealcat2, year round school, mealcat1   |||||
  
-'''ANOVA(b)''' +|  **ANOVA(b)**  ||||||| 
-| Model      | Sum of Squares   | df   | Mean Square   | F   | Sig.   | +| Model                | Sum of Squares   | df    | Mean Square   | F   | Sig.   | 
-| 1   | Regression   | 6194144.303   | 3   | 2064714.768   | 435.017   | .000a   | +| 1       | Regression   | 6194144.303      | 3     | 2064714.768   | 435.017  | .000a   | 
-   | Residual   | 1879527.694   | 396   | 4746.282      |    | +        | Residual     | 1879527.694      | 396   | 4746.282      |    | 
-   | Total   | 8073671.997   | 399      |    |    | +        | Total        | 8073671.997      | 399      |    |    | 
-| a. Predictors: (Constant), mealcat2, year round school, mealcat1   ||||||| +| a. Predictors: (Constant), mealcat2, year round school, mealcat1   |||||| 
-| b. Dependent Variable: api 2000   ||||||||+| b. Dependent Variable: api 2000   |||||||
  
- |  |  |  |  |  |  | Coefficients(a)   | + **Coefficients(a)**   ^^^^^^^  
-|    |    | Unstandardized Coefficients      | Standardized Coefficients       |+|    |    | Unstandardized \\ Coefficients      | Standardized \\ Coefficients       |
 | Model      | B   | Std. Error   | Beta   | t   | Sig.   | | Model      | B   | Std. Error   | Beta   | t   | Sig.   |
 | 1   | (Constant)   | 526.330   | 7.585      | 69.395   | .000   | | 1   | (Constant)   | 526.330   | 7.585      | 69.395   | .000   |
Line 320: Line 337:
  
  
-^ Excluded Variables(b)   ^^^^^^^ + **Excluded Variables(b)**   ^^^^^^^ 
 |    |    |    |    |    |    | Collinearity Statistics   | |    |    |    |    |    |    | Collinearity Statistics   |
 | Model      | Beta In   | t   | Sig.   | Partial Correlation   | Tolerance   | | Model      | Beta In   | t   | Sig.   | Partial Correlation   | Tolerance   |
Line 329: Line 346:
  
 해석에 대해서 . . . .  해석에 대해서 . . . . 
-''interpretation''' ^^^^ + **interpretation**  ^^^^ 
-|   | mealcat=1   | mealcat=2   | mealcat=  |+|   | mealcat=1   | mealcat=2   | mealcat=  |
 |yr_rnd=0   | cell1   | cell2   | cell3   | |yr_rnd=0   | cell1   | cell2   | cell3   |
 |yr_rnd=1   | cell4   | cell5   | cell6   | |yr_rnd=1   | cell4   | cell5   | cell6   |
  
  
-''interpretation''' ^^^^ + **interpretation**  ^^^^ 
-|   | mealcat=1   | mealcat=2   | mealcat=3   |+|   | mealcat=1   | mealcat=2   | mealcat=0   | 
 +|   | mealcat=1->  | mealcat=2->   | mealcat=3->mealcat1,2=0   |
 | yr_rnd=0   | cell1   | cell2   | cell3   | | yr_rnd=0   | cell1   | cell2   | cell3   |
 | :::  | intercept + \\ BMealCat1   | intercept + \\ BMealCat2   | intercept   | | :::  | intercept + \\ BMealCat1   | intercept + \\ BMealCat2   | intercept   |
Line 348: Line 366:
 </code> </code>
  
-====== continuous + categorical variables ======+===== continuous + categorical variables =====
 <code>regress <code>regress
  /dep = api00  /dep = api00
using_dummy_variables.1446599704.txt.gz · Last modified: 2015/11/04 09:45 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki