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 [2026/06/09 23:10] – [rs.04] hkimscilusing_dummy_variables [2026/06/14 23:15] (current) – [Regression with two Catogorical IVs] hkimscil
Line 549: Line 549:
 3 = 81-100 3 = 81-100
 </code> </code>
 +
 +  * pct (%) of emer (emergency) credentials: Some states will grant an emergency certificate or permit at the request of a school district that has posted and failed to find a qualified candidate for a teacher vacancy. It typically allows the candidate to serve in a temporary capacity for the duration of a school year.
 +  * pct (%) of full credentials: To be fully certified, it generally means that a teacher must have graduated from an accredited college, completed an approved teacher credential program and passed a test of their academic skills.
  
 위의 변인들 중에서 "무방학학교"가 성적에 어떤 영향을 미칠 것인가를 알아 보기 위해서 regression 테스트를 시행하였다. 아래는 그 결과이다.  위의 변인들 중에서 "무방학학교"가 성적에 어떤 영향을 미칠 것인가를 알아 보기 위해서 regression 테스트를 시행하였다. 아래는 그 결과이다. 
Line 871: Line 874:
 {{pasted:20260609-224414.png?600}} {{pasted:20260609-224414.png?600}}
 {{pasted:20260609-224430.png?600}} {{pasted:20260609-224430.png?600}}
- 
 위의 아웃풋을 살펴 보면, 학생들의 성적이 가지는 총 변량의 (Sum of Square Total) 약 22.6% 를 방학이 있고 없고로 구분되는 yr_rnd 변인이 설명을 하고 있으며, 이는 통계적으로 유의미한 것이다 (F(1, 398) = 116.241, p < .001). 위의 regression output은 yr_rnd 변인 중에서 방학이 있는 특성이 baseline이 되어 있으며, 이를 염두에 두고 regression식을 적어 보면 아래와 같다. 위의 아웃풋을 살펴 보면, 학생들의 성적이 가지는 총 변량의 (Sum of Square Total) 약 22.6% 를 방학이 있고 없고로 구분되는 yr_rnd 변인이 설명을 하고 있으며, 이는 통계적으로 유의미한 것이다 (F(1, 398) = 116.241, p < .001). 위의 regression output은 yr_rnd 변인 중에서 방학이 있는 특성이 baseline이 되어 있으며, 이를 염두에 두고 regression식을 적어 보면 아래와 같다.
  
-$\hat{\text{api00}} = 684.54 - 160.51 * \text{yr_rndnobr} $ +''hat = 684.54 - 160.51 * (yr_rndno_break) '' 
-  +  * yr_rndno_break: yr_rndno_break = 1 
-이 때, $\text{yr_rndnobr} $ 은 no break인 경우를 1로 보고 대입된 dummy variable이다즉, +    * y hat = 684.54 - 160.51 * (1)  
 +    * y hat = 524.03 
 +  * yr_rndbreak: yr_rndnobreak = 0 
 +    * y hat = 684.54 - 160.51 * (0)  
 +    * y hat = 684.54 
  
-  * X: 0 = break +위 회귀식에서 r은  
-  * X: 1 no break +''y hat a + bX'' 의 형식에서 ''X'' 로 ''no_break''를 썼음을 (yr_rndno_break) 알 수 있다. 이 경우에는 yr_rndno_break를 1로 넣어서 석을 한다. 즉, no break일 경우는  ''y hat = 684.54 - 160.51(1) '' 는 이다. 반대로 break일 경우에는 뒤쪽 부분이 해당이 안되므로 ''0''으로 체한다. 따라서 이 경우의 회귀식은 ''y hat = 684.54''이다. 이 둘을 비교해보면 no break일 경우에는    
- +''y hat = 684.54 - 160.51(1) = 524.03'' 이고  
-이므로 x=0 일때를 대입해 보면, 즉, 방학이있는학교의 경우는 684.54 의 추정치를 엊을 수 있다. 이 점수는 방학이 있는 학교의 api점수 평균이 된다. 반면에 x = 1 때를 해 보면 즉, 방학이없는학교의 경우에는 684.54 - 160.51 = 524.03 의 추정치를 엊을 수 있다. b coefficient가 이 역할 (차이를 나타내는 역할을 하는데)에 대한 유의성에 대한 판단은 t-test로 하는데, 이 t값은 -10.782며 이는 F값인 116.241의 제곱근이다 (즉, $t^2 = F$ )사실, 이 상황은 정확히 t-test를 해야할 상황이므로 (두 그룹에 대한 성적평균의 차이), t-test를 해야 하지만 이와 같이 regression을 하여도 동일한 결과를 보게된다 (같은 미에서 F-test를 했어도 마찬가지). 뒷 부분의 t-test와 F-test는 이를 확인한 것.+break일 경우에는  
 +''y hat = 684.54 - 160.51(0) = 684.54'' 라는 것이다. 다시 이야기하면 break가 없는 학교의 평균 api점는 524.03점인 반면에 break가 는 학교의 평균은 684.54 이다. 이 점수의 차이는 두 집단의 평균을 비교하는 것과 같은 형태를 (형식) 갖는다. 즉, t-test를 하는 것과 마찬가지다. 위에서 얻은  
 +  * t.value 
 +  * F.value 
 +  * t.value.lm 
 +  * F.value.lm 은 모두 같은 원리로 두 그룹을 (집단의 api 평균을테스트 한 것이다
  
 {{regressionCategory.jpg}} {{regressionCategory.jpg}}
Line 888: Line 899:
  
 이와 같이 종류변인(category, nominal)을 가지고서도 regression 테스트를 할 수 있으며, 사실 이는 t-test나 F-test와 다르지 않다. 위에서 주의해야 할 점은 두 변인의 종류를 손으로 coding할 때, 1과 2가 아닌, 0과 1로 하였다는 점이다. 이렇게 하는 이유는 해석하기에 편하기 때문이며, 이것이 보통의 방법이다. 그러나, 1과 2로 coding 데이터를 이용해도 크게 다른지 않은 결과를 구하게 된다. 다른 점이라면, 절편에 해당되는 상수값이 다르게 되며, coefficient값은 위의 분석과 동일한 값을 갖게 된다. 그리고 일반적으로 r에서는 dummy variables을 얻기 위한 coding을 하지 않아도 r이 스스로 구하여 계산을 한다. 즉, dummy variable 을 구하지 않은 채로  ''lm(api00 ~ yr_rnd, data=df)'' 만으로도 계산이 된다.  이와 같이 종류변인(category, nominal)을 가지고서도 regression 테스트를 할 수 있으며, 사실 이는 t-test나 F-test와 다르지 않다. 위에서 주의해야 할 점은 두 변인의 종류를 손으로 coding할 때, 1과 2가 아닌, 0과 1로 하였다는 점이다. 이렇게 하는 이유는 해석하기에 편하기 때문이며, 이것이 보통의 방법이다. 그러나, 1과 2로 coding 데이터를 이용해도 크게 다른지 않은 결과를 구하게 된다. 다른 점이라면, 절편에 해당되는 상수값이 다르게 되며, coefficient값은 위의 분석과 동일한 값을 갖게 된다. 그리고 일반적으로 r에서는 dummy variables을 얻기 위한 coding을 하지 않아도 r이 스스로 구하여 계산을 한다. 즉, dummy variable 을 구하지 않은 채로  ''lm(api00 ~ yr_rnd, data=df)'' 만으로도 계산이 된다. 
 +
 +===== Regression with a categorical IV with 3 attributes =====
 +<tabbox rs.3att>
 +<code>
 +m.mealcat <- lm(api00 ~ mealcat, data=df) 
 +summary(m.mealcat)
 +</code>
 +<tabbox ro.3att>
 +<code>
 +> #######################################
 +> # categorical IV with 3 or more attributes
 +> #######################################
 +> m.mealcat <- lm(api00 ~ mealcat, data=df) 
 +> summary(m.mealcat)
 +
 +Call:
 +lm(formula = api00 ~ mealcat, data = df)
 +
 +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 ***
 +mealcatto80  -166.324      8.708  -19.10   <2e-16 ***
 +mealcatto100 -301.338      8.629  -34.92   <2e-16 ***
 +---
 +Signif. codes:  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>
 +</tabbox>
 +
 +<code>
 +y hat = 805.718 - 166.324 * to80 - 301.338 * to100 
 +mealcat0-46 (to46 으로 대체)
 +mealcat47-80 (to80 으로 대체)
 +maelcat81-100 (to100 으로 대체)
 +</code>
 +
 +이에 대한 해석도 앞에서의 것과 마찬가지이다. 
 +  * y hat = 805.718 - 166.324*mg2 - 301.338*mg3 
 +  * mg1 = 1, mg2 = 0, mg3 = 0 일 경우
 +    * y hat = 805.718 - 166.324*(0) - 301.338*(0)
 +    * y hat = 805.718 
 +  * mg1 = 0, mg2 = 1, mg3 = 0 일 경우 
 +    * y hat = 805.718 - 166.324*(1) - 301.338*(0)
 +    * y hat = 805.718 - 166.324
 +    * y hat = 639.394
 +  * mg1 = 0, mg2 = 0, mg3 = 1 일 경우
 +    * y hat = 805.718 - 166.324*(0) - 301.338*(1)
 +    * y hat = 805.718 - 301.338
 +    * y hat = 504.38
 +
 +  * 즉, 무료급식의 퍼센티지가 높을 수록 api점수가 낮음을 알 수 있다. 이렇게 무료급식 퍼센티지를 독립변인으로 종속변인인 api00점수를 (학력점수) 봤을 때, 그 설명력이 통계학적으로 유효한가는 regression output에서 (summary(mod2)) 
 +    * F-value 와 p-value를 가지고 판단한다. 
 +      * (F (2, 397) = 611.1; p-value < 2.2e-16)
 +      * 위에서 2, 397 은 각각 between degrees of freedom 과 within degrees of freedom 이다. 이를 보고도 우리는 
 +      * 총 400개의 학교가 데이터에 참여했음을 알 수 있고 (2 + 397 에 1을 더한 값), 
 +      * 독립변인의 종류가 3가지 (df = 2 이므로) 임을 알 수 있다.
 +    * R square value 는 설명력의 크기를 알려준다.
 +      * 0.7548 즉, 75.48% 를 독립변인이 종속변인을 설명한다 (상당한 크기임을 알 수 있다).
 +
  
 ===== Regression with a continuous and a categorical IV ===== ===== Regression with a continuous and a categorical IV =====
Line 1058: Line 1137:
  
  
 +</code>
 +{{pasted:20260609-230452.png?600}}
 +
 +<code>
 > # 1. 평균을 빼준 값을 새로운 변인으로 저장 > # 1. 평균을 빼준 값을 새로운 변인으로 저장
 > df$meals_centered <-  > df$meals_centered <- 
Line 1101: Line 1184:
  
  
 +</code>
 +{{pasted:20260609-230505.png?600}}
 +
 +<code>
 > # Install the package if you do not have it > # Install the package if you do not have it
 > # install.packages("interactions") > # install.packages("interactions")
Line 1110: Line 1197:
  
  
 +</code>
 +{{pasted:20260609-230516.png?600}}
 +
 +<code>
 > m.ellyr_rnd <- lm(api00~ell+yr_rnd, data=df) > m.ellyr_rnd <- lm(api00~ell+yr_rnd, data=df)
 > summary(m.ellyr_rnd) > summary(m.ellyr_rnd)
Line 1164: Line 1255:
 +        y = "api00") +        y = "api00")
 `geom_smooth()` using formula = 'y ~ x' `geom_smooth()` using formula = 'y ~ x'
 +>
 +>
 +> # ell mean centred 이번 경우는 큰 차이를 보이지 않는다
 +> df$ell_centered <- df$ell - mean(df$ell)
 +> m.ell.centered <- lm(api00 ~ ell_centered * yr_rnd, data = df)
 +> summary(m.ell.centered)
 +
 +Call:
 +lm(formula = api00 ~ ell_centered * yr_rnd, data = df)
 +
 +Residuals:
 +     Min       1Q   Median       3Q      Max 
 +-270.514  -57.800    5.994   65.845  206.275 
 +
 +Coefficients:
 +                        Estimate Std. Error t value Pr(>|t|)    
 +(Intercept)             654.5514     5.3323 122.752  < 2e-16 ***
 +ell_centered             -4.4418     0.2420 -18.354  < 2e-16 ***
 +yr_rndnobr              -63.7652    14.0117  -4.551 7.12e-06 ***
 +ell_centered:yr_rndnobr   1.4884     0.4673   3.185  0.00156 ** 
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 89.08 on 396 degrees of freedom
 +Multiple R-squared:  0.6108, Adjusted R-squared:  0.6078 
 +F-statistic: 207.1 on 3 and 396 DF,  p-value: < 2.2e-16
 +>
 +>
 > coefs <- summary(m.ellxyr_rnd)$coefficients > coefs <- summary(m.ellxyr_rnd)$coefficients
 > coefs  > coefs 
Line 1182: Line 1301:
  
 </code> </code>
-</tabbox> 
-{{pasted:20260609-230452.png?600}} 
-{{pasted:20260609-230505.png?600}} 
-{{pasted:20260609-230516.png?600}} 
 {{pasted:20260609-230601.png?600}} {{pasted:20260609-230601.png?600}}
  
-===== 3 or more groups ===== +</tabbox>
-만약에 ANOVA 테스트에서와 같이 종류가 3개 이상인 변인은 어떻게 처리해야 할까? 아래는 이를 regression으로 테스트 한 결과이다.+
  
 +===== Regression with a categorical and a continuous IV: e.g. 2 =====
 +<tabbox rs.06>
 <code> <code>
-> mod2 <- lm(api00 ~ factor(mealcat), data=datavar)  +############################### 
-> mod2+# 다른 예 
 +############################### 
 +m.ellmealcat <- lm(api00~ell+mealcat, data=df
 +summary(m.ellmealcat) 
 +# install.packages("emmeans"
 +# library(emmeans) 
 +# Calculate estimated marginal means for each group 
 +gmeans <- emmeans(m.ellmealcat, specs = ~ mealcat) 
 +# Perform pairwise comparisons using Tukey's adjustment (Default) 
 +pairs(gmeans, adjust = "tukey")
  
-Call: +m.ellxmealcat <- lm(api00~ell*mealcat, data=df) 
-lm(formula = api00 ~ factor(mealcat), data datavar)+summary(m.ellxmealcat) 
 +df %>% 
 +  ggplot(aes(x = ell, y = api00, color = factor(mealcat))) + 
 +  geom_point(size = 3) + 
 +  geom_smooth(method = "lm"se FALSE) + 
 +  scale_color_brewer(palette = "Set1", name = "mealcat") + 
 +  labs(title = "Multiple Regression: Interaction by meal cat", 
 +       x = " (ell, english language learner)", 
 +       y = "api00")
  
-Coefficients: +mealcat1 <- summary(m.ellxmealcat)$coefficients[[1]] 
-     (Intercept factor(mealcat) factor(mealcat)3   +mealcat2 <- summary(m.ellxmealcat)$coefficients[[1]] +  
-           805.7            -166.3            -301.3  +  summary(m.ellxmealcat)$coefficients[[3]] 
 +mealcat3 <summary(m.ellxmealcat)$coefficients[[1]] + 
 +  summary(m.ellxmealcat)$coefficients[[4]] 
 +data.frame(mealcat1, mealcat2, mealcat3)
  
-> summary(mod2)+ell.slope.mealcat1 <- summary(m.ellxmealcat)$coefficients[[2]] 
 +ell.slope.mealcat2 <- summary(m.ellxmealcat)$coefficients[[2]] + 
 +  summary(m.ellxmealcat)$coefficients[[5]] 
 +ell.slope.mealcat3 <- summary(m.ellxmealcat)$coefficients[[2]] + 
 +  summary(m.ellxmealcat)$coefficients[[6]] 
 +data.frame(ell.slope.mealcat1, 
 +           ell.slope.mealcat2, 
 +           ell.slope.mealcat3) 
 + 
 +</code> 
 +<tabbox ro.06> 
 +<code> 
 +> ############################### 
 +> # 다른 예 
 +> ############################### 
 +> m.ellmealcat <- lm(api00~ell+mealcat, data=df) 
 +> summary(m.ellmealcat)
  
 Call: Call:
-lm(formula = api00 ~ factor(mealcat), data = datavar)+lm(formula = api00 ~ ell + mealcat, data = df)
  
 Residuals: Residuals:
-     Min       1Q   Median       3Q      Max  +    Min      1Q  Median      3Q     Max  
--253.394  -47.883    0.282   52.282  185.620 +-224.96  -42.70   -0.32   48.93  179.92 
  
 Coefficients: Coefficients:
-                 Estimate Std. Error t value Pr(>|t|)     +             Estimate Std. Error t value Pr(>|t|)     
-(Intercept)       805.718      6.169  130.60   <2e-16 *** +(Intercept)   819.654      6.052 135.426  < 2e-16 *** 
-factor(mealcat)2 -166.324      8.708  -19.10   <2e-16 *** +ell            -1.546      0.203  -7.616 1.94e-13 *** 
-factor(mealcat)3 -301.338      8.629  -34.92   <2e-16 ***+mealcatto80  -134.493      9.153 -14.693  < 2e-16 *** 
 +mealcatto100 -230.737     12.290 -18.774  < 2e-16 ***
 --- ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
-Residual standard error: 70.61 on 397 degrees of freedom +Residual standard error: 66.03 on 396 degrees of freedom 
-Multiple R-squared:  0.7548, Adjusted R-squared:  0.7536  +Multiple R-squared:  0.7861, Adjusted R-squared:  0.7845  
-F-statistic: 611.1 on 2 and 397 DF,  p-value: < 2.2e-16+F-statistic: 485.2 on 3 and 396 DF,  p-value: < 2.2e-16
  
 +> # install.packages("emmeans")
 +> # library(emmeans)
 +> # Calculate estimated marginal means for each group
 +> gmeans <- emmeans(m.ellmealcat, specs = ~ mealcat)
 +> # Perform pairwise comparisons using Tukey's adjustment (Default)
 +> pairs(gmeans, adjust = "tukey")
 + contrast     estimate    SE  df t.ratio p.value
 + to46 - to80     134.5  9.15 396  14.693  <.0001
 + to46 - to100    230.7 12.30 396  18.774  <.0001
 + to80 - to100     96.2  9.53 396  10.102  <.0001
 +
 +P value adjustment: tukey method for comparing a family of 3 estimates 
  
-</code>+> m.ellxmealcat <- lm(api00~ell*mealcat, data=df) 
 +summary(m.ellxmealcat)
  
-아까와 같은 두 집단 간의 비교는 가능하였지만세 집단인 이 경우에 regression 테스트는 x를 연속변인으로 하는 선형관계를 구하게 된다. 즉, 두집단으로 이루어진 변인의 경우, 한 집단을 0으로 보았을 때 다른 집단은 자동으로 1이 되고, 이 둘을 비교하는 것이었는데, 3집단인 경우, 어느 한 집단을 0으로 놓고 본다고 비교할 집단이 두개나 되므로 비교가 어려워진다. 이는 현실에 맞지 않으므로 대개의 경우에는 집단 수에 해당하는 변인을 가외로 (가변인 혹은 dummy variable만든 후, 이를 가지고 regression을 하게 된다. +Call: 
 +lm(formula = api00 ~ ell * mealcatdata = df)
  
-SPSS의 경우에는 아래와 같이 recode작업을 할 수 있다+Residuals: 
 +     Min       1Q   Median       3Q      Max  
 +-221.854  -43.244    1.437   47.443  181.471 
  
-<code>compute mealcat1 = 0+Coefficients: 
-if mealcat = 1 mealcat1 = 1+                  Estimate StdError t value Pr(>|t|)     
-compute mealcat2 = 0. +(Intercept)       836.7724     8.8620  94.422  < 2e-16 *** 
-if mealcat = 2 mealcat2 = 1+ell                -3.4447     0.7508  -4.588 6.03e-06 *** 
-compute mealcat3 = 0+mealcatto80      -146.6127    13.9085 -10.541  < 2e-16 *** 
-if mealcat = 3 mealcat3 = 1. +mealcatto100     -270.8356    18.7941 -14.411  < 2e-16 *** 
-execute+ell:mealcatto80     1.7300     0.8111   2.133   0.0335 *   
-</code>+ell:mealcatto100    2.3190     0.8032   2.887   0.0041 **  
 +--- 
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
-위는 해당 카데고리를 1로 만들고, 나머지를 0으로 만들어서 2분화 하는 작업이다이렇게 하면 3개의 새로운 변인이 만들어지게 되는데 (mealcat1mealcat2, mealcat3)이 세개의 변인 중에서 2개만을 취해서 regression 테스트를 한다SPSS의 경우에는+Residual standard error: 65.47 on 394 degrees of freedom 
 +Multiple R-squared:  0.7909, Adjusted R-squared:  0.7882  
 +F-statistic:   298 on 5 and 394 DF p-value:2.2e-16
  
-<code>regression +df %>% 
- /dependent api00 ++   ggplot(aes(x = ell, y = api00, color = factor(mealcat))) + 
- /method = enter mealcat2 mealcat3. ++   geom_point(size = 3) + 
-주의세개의 변인을 모두 넣지 않는다.++   geom_smooth(method = "lm", se = FALSE) + 
 ++   scale_color_brewer(palette = "Set1", name = "mealcat") + 
 ++   labs(title = "Multiple Regression: Interaction by meal cat", 
 ++        x = " (ell, english language learner)", 
 ++        y = "api00"
 +`geom_smooth()` using formula = 'y ~ x' 
 +>  
 +> mealcat1 <- summary(m.ellxmealcat)$coefficients[[1]] 
 +mealcat2 <- summary(m.ellxmealcat)$coefficients[[1]] +  
 ++   summary(m.ellxmealcat)$coefficients[[3]] 
 +mealcat3 <- summary(m.ellxmealcat)$coefficients[[1]] + 
 ++   summary(m.ellxmealcat)$coefficients[[4]] 
 +> data.frame(mealcat1, mealcat2, mealcat3) 
 +  mealcat1 mealcat2 mealcat3 
 +1 836.7724 690.1597 565.9368 
 +>  
 +> ell.slope.mealcat1 <- summary(m.ellxmealcat)$coefficients[[2]] 
 +> ell.slope.mealcat2 <- summary(m.ellxmealcat)$coefficients[[2]] + 
 ++   summary(m.ellxmealcat)$coefficients[[5]] 
 +> ell.slope.mealcat3 <- summary(m.ellxmealcat)$coefficients[[2]] + 
 ++   summary(m.ellxmealcat)$coefficients[[6]] 
 +> data.frame(ell.slope.mealcat1, 
 ++            ell.slope.mealcat2, 
 ++            ell.slope.mealcat3) 
 +  ell.slope.mealcat1 ell.slope.mealcat2 ell.slope.mealcat3 
 +1          -3.444691          -1.714707          -1.125645 
 +
 </code> </code>
 +</tabbox>
 +{{pasted:20260609-231439.png?600}}
  
 +===== Regression with two Catogorical IVs =====
 +<tabbox rs.07>
 +<code>
 +##########################################
 +# 카테고리 iv 2개
 +##########################################
 +m.yrrndmealcat <- lm(api00~yr_rnd+mealcat, data=df)
 +summary(m.yrrndmealcat)
  
-<code> Model Summary +# 해석.  
-Model R R Square Adjusted R Square StdError of the Estimate +coefs <- summary(m.yrrndmealcat)$coefficients 
-1 .869a .755 .754 70.612 +coefs 
-aPredictors: (Constant), mealcat3mealcat2+br.to46 <- coefs[1] 
 +br.to80 <- coefs[1]+coefs[3]  
 +br.to100 <- coefs[1]+coefs[4] 
 +nobr.to46 <- coefs[1]+coefs[2] 
 +nobr.to80 <- coefs[1]+coefs[2]+coefs[3] 
 +nobr.to100 <- coefs[1]+coefs[2]+coefs[4] 
 +cat(br.to46, br.to80, br.to100) 
 +cat(nobr.to46nobr.to80nobr.to100)
  
- ANOVA(b) +# 해석interaction 
-Model Sum of Squares df Mean Square F Sig+m.yrrndxmealcat <- lm(api00~yr_rnd*mealcat, data=df
-1 Regression 6094197.670 2 3047098.835 611.121 .000a +summary(m.yrrndxmealcat)
- Residual 1979474.328 397 4986.081  +
- Total 8073671.997 399  +
-a. Predictors: (Constant), mealcat3, mealcat2 +
-b. Dependent Variable: api 2000 +
- +
- Coefficients(a) +
- Unstandardized Coefficients Standardized Coefficients +
-Model B StdError Beta t Sig. +
-1 (Constant) 805.718 6.169 130.599 .000 +
- mealcat2 -166.324 8.708 -.550 -19.099 .000 +
- mealcat3 -301.338 8.629 -1.007 -34.922 .000 +
-a. Dependent Variable: api 2000+
  
 +coefs <- summary(m.yrrndxmealcat)$coefficients
 +coefs
 +br.to46 <- coefs[1]
 +br.to80 <- coefs[1]+coefs[3] 
 +br.to100 <- coefs[1]+coefs[4]
 +nobr.to46 <- coefs[1]+coefs[2]
 +nobr.to80 <- coefs[1]+coefs[2]+coefs[3]+coefs[5]
 +nobr.to100 <- coefs[1]+coefs[2]+coefs[4]+coefs[6]
 +cat(br.to46, br.to80, br.to100)
 +cat(nobr.to46, nobr.to80, nobr.to100)
 </code> </code>
 +<tabbox ro.07>
 +<code>
 +> ##########################################
 +> # 카테고리 iv 2개
 +> ##########################################
 +> m.yrrndmealcat <- lm(api00~yr_rnd+mealcat, data=df)
 +> summary(m.yrrndmealcat)
  
-|  **Coefficients(a)**  ||||||| +Call: 
-|  |  | Unstandardized Coefficients      | Standardized Coefficients       | +lm(formula = api00 ~ yr_rnd + mealcat, data = df)
-| Model      | B   | Std. Error   | Beta   | t   | Sig.   | +
-| 1   (Constant  | 805.718   | 6.169      | 130.599   | .000   | +
-|    | mealcat2   | -166.324   | 8.708   | -.550   | -19.099   | .000   | +
-|    | mealcat3   | -301.338   | 8.629   | -1.007   | -34.922   | .000   | +
-| a. Dependent Variable: api 2000   |||||||+
  
-위에서 +Residuals: 
-$\hat{Y} = 805.718 166.324 \; \text{mealcat2} 301.338 \; \text{mealcat3} $+    Min      1Q  Median      3Q     Max  
 +-215.32  -49.50    1.65   49.17  183.63 
  
-이에 대한 해석은  +Coefficients: 
-  * mealcat2와 mealcat3이 0일 때 (즉 mealcat1 변인의 상태일 때), 805.718 +             Estimate Std. Error t value Pr(>|t|    
-  * mealcat3이 0일 때, 805.718-166.324 = 639.39 의 상황 +(Intercept)   808.013      6.040 133.777  < 2e-16 *** 
-  * mealcat2가 0일 때, 805.718-301.338 = 504.38 의 상황이다.  +yr_rndnobr    -42.960      9.362  -4.589 5.99e-06 *** 
-  * 그리고, 이 값들은 바로 각 그룹의 평균값이 된다+mealcatto80  -163.737      8.515 -19.229  < 2e-16 *** 
 +mealcatto100 -281.683      9.446 -29.821  < 2e-16 *** 
 +--- 
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
-<code> Report +Residual standard error: 68.89 on 396 degrees of freedom 
-api 2000 +Multiple R-squared:  0.7672, Adjusted R-squared:  0.7654  
-Percentage free meals in 3 categories Mean N StdDeviation +F-statistic:   435 on 3 and 396 DF,  p-value: < 2.2e-16
- 0-46% free meals 805.72 131 65.669 +
- 47-80% free meals 639.39 132 82.135 +
- 81-100% free meals 504.38 137 62.727 +
- Total 647.62 400 142.249 +
-</code>+
  
-위에서, mealcat1대신에 mealcat3 그룹을 빼고 사용했어도, 결과를 해석하는데는 지장이 없다.  +>  
- +> # 해석.  
-마지막으로, 위의 테스트는 이전에 언급되었던 FactorialAnova와 동일한 것이다.  +> coefs <- summary(m.yrrndmealcat)$coefficients 
- +> coefs 
-<code>glm +               Estimate StdError    t value      Pr(>|t|) 
- api00 by mealcat +(Intercept)   808.01313   6.039984 133.777362  0.000000e+00 
- /print=parameter.+yr_rndnobr    -42.96006   9.361761  -4.588886  5.990293e-06 
 +mealcatto80  -163.73737   8.515015 -19.229252  1.128686e-58 
 +mealcatto100 -281.68318   9.445676 -29.821388 2.767252e-103 
 +> br.to46 <- coefs[1] 
 +br.to80 <- coefs[1]+coefs[3]  
 +> br.to100 <- coefs[1]+coefs[4] 
 +> nobr.to46 <- coefs[1]+coefs[2] 
 +> nobr.to80 <- coefs[1]+coefs[2]+coefs[3] 
 +> nobr.to100 <- coefs[1]+coefs[2]+coefs[4] 
 +> cat(br.to46, br.to80, br.to100) 
 +808.0131 644.2758 526.33 
 +> cat(nobr.to46, nobr.to80, nobr.to100) 
 +765.0531 601.3157 483.3699> 
 </code> </code>
 +예측식은 아래와 같다. 
 +<code>
 +y hat = 808.013 + -42.960*(yr_rndno_break) + -163.737(mealcat47-80) + -281.683(mealcat81-100)
  
-|  **Between-Subjects Factors**  |||| +yr_rnd: 
-|    |    | Value Label   | N   | +break = 방학있음  
-| Percentage free meals in 3 categories   | 1   | 0-46% free meals   | 131   | +no_break = 방학없음
-|    | 2   | 47-80% free meals   | 132   | +
-|    | 3   | 81-100% free meals   | 137   |+
  
-|  **Tests of Between-Subjects Effects**  ||||||  +mealcat:  
-| Dependent Variable:api 2000    |  |  |  |  | +0-46free meals 
-| Source   | Type III Sum of Squares   | df   | Mean Square   | F   | Sig.   | +47-80% 
-| Corrected Model   | 6.094E6   | 2   | 3047098.835   | 611.121   | .000   | +81-100%
-| Intercept   | 1.688E8   | 1   | 1.688E8   | 33863.695   | .000   | +
-mealcat   | 6094197.670   | 2   | 3047098.835   | 611.121   | .000   | +
-| Error   | 1979474.328   | 397   | 4986.081      |    | +
-| Total   | 1.758E8   | 400      |    |    | +
-| Corrected Total   | 8073671.997   | 399      |    |    | +
-|a. R Squared = .755 (Adjusted R Squared = .754)   ||||||  +
- +
-|  **Parameter Estimates**   ||||||| +
-| Dependent Variable:api 2000   ||||||| +
-|    |    |    |    |    | 95Confidence Interval    | +
-| Parameter   | B   | Std. Error   | t   | Sig.   | Lower Bound   | Upper Bound   | +
-| Intercept   | 504.380   | 6.033   | 83.606   | .000   | 492.519   | 516.240   | +
-| [mealcat=1]   | 301.338   | 8.629   | 34.922   | .000   | 284.374   | 318.302   | +
-| [mealcat=2]   | 135.014   | 8.612   | 15.677   | .000   | 118.083   | 151.945   | +
-| [mealcat=3]   | 0a   | .   | .   | .   | .   | .   | +
-| a. This parameter is set to zero because it is redundant.   ||||||||  +
- +
-혹은 Oneway ANOVA  +
- +
-<code>ONEWAY api00 BY mealcat  +
-  /STATISTICS DESCRIPTIVES EFFECTS HOMOGENEITY  +
-  /PLOT MEANS  +
-  /MISSING ANALYSIS  +
-  /POSTHOC=TUKEY SCHEFFE ALPHA(0.05).+
 </code> </code>
 +이에 대한 해석은 각각의 독립변인의 종류 수인 2개와 3개를 곱한 6개의 경우로 나누어서 생각할 수 있다. 즉,
 +''y hat = 808.013 + -42.960*(yr_rndno_break) + -163.737(mealcat47-80) + -281.683(mealcat81-100)''
 +을 바탕으로 각각의 조건을 고려하여 y hat를 계산하면 아래와 같다. 
  
-| |  Sum of Squares  |  df  |  Mean Square  |  F  |  Sig.  | +<wrap #two_dummy_table /> 
- Between Groups   6094197.67  |  2  |  3047098.835  |  611.120953   .000  | +TABLETwo dummy variables 
- Within Groups   1979474.328   397  |  4986.08143        | +^                 ^ mealcat0-46  ^ mealcat47-80   ^ mealcat81-100    ^  
-|  Total  |  8073671.998  |  399  |    |    |    |+yr_rndbreak     <wrap> yr_rndbreak = 1 
 +yr_rndno_break = 0 
 +mealcat0-46 = 1 
 +mealcat47-80 = 0 
 +mealcat81-100 = 0 경우 
 +''y hat = 808.013''          
 +</wrap>  <wrap> yr_rndbreak = 1 
 +yr_rndno_break = 0 
 +mealcat0-46 = 0 
 +mealcat47-80 = 1 
 +mealcat81-100 = 0 경우   
 +''**y hat = 808.013 - 163.737 = 644.276**'' 
 +</wrap>  <wrap> yr_rndbreak = 1 
 +yr_rndno_break = 0 
 +mealcat0-46 = 0 
 +mealcat47-80 = 0 
 +mealcat81-100 = 1 경우 
 +''**y hat = 808.013 - 281.683 = 526.33**'' 
 +</wrap>  | 
 +yr_rndno_break  <wrap> yr_rndbreak = 0 
 +yr_rndno_break = 1 
 +mealcat0-46 = 1 
 +mealcat47-80 = 0 
 +mealcat81-100 = 0 경우 
 +''**y hat = 808.013 - 42.960 = 765.053**''          
 +</wrap>  <wrap> yr_rndbreak = 0 
 +yr_rndno_break = 1 
 +mealcat0-46 = 0 
 +mealcat47-80 = 1 
 +mealcat81-100 = 0 경우  
 +''**y hat = 808.013 - 42.960 - 163.737 = 601.316**'' 
 +</wrap>  <wrap> yr_rndbreak = 0 
 +yr_rndno_break = 1 
 +mealcat0-46 = 0 
 +mealcat47-80 = 0 
 +mealcat81-100 = 1 경우 
 +''**y hat = 808.013 - 42.960 - 281.683 = 483.37**'' 
 +</wrap>  |
  
 +<code>
 +> # 해석. interaction
 +> m.yrrndxmealcat <- lm(api00~yr_rnd*mealcat, data=df)
 +> summary(m.yrrndxmealcat)
  
-===== 2 variablescategorical ===== +Call: 
-위에서 사용된 __2 개의 독립변인을 모두__ 넣어서 regression을 할 수도 있다. 위에서 언급한 경로를 따른다면, 이는 FactorialAnova의 한 종류일 것이다.+lm(formula api00 ~ yr_rnd * mealcatdata df)
  
-<code>regression +Residuals: 
- /dep api00 +     Min       1Q   Median       3Q      Max  
- /method =  enter yr_rnd mealcat1 mealcat2. +-207.533  -50.764   -1.843   48.874  179.000 
-</code>+
  
-|  **Model Summary**  ||||| +Coefficients: 
-| Model   | R   | R Square   | Adjusted R Square   | StdError of the Estimate   | +                        Estimate Std. Error t value Pr(>|t|)     
-| 1   .876a   .767   .765   | 68.893   | +(Intercept)              809.685      6.185 130.911  < 2e-16 *** 
-| aPredictors(Constant), mealcat2, year round school, mealcat1   |||||+yr_rndnobr               -74.257     26.756  -2.775  0.00578 **  
 +mealcatto80             -164.412      8.877 -18.522  < 2e-16 *** 
 +mealcatto100            -288.193     10.443 -27.597  < 2e-16 *** 
 +yr_rndnobr:mealcatto80    22.517     32.752   0.687  0.49217     
 +yr_rndnobr:mealcatto100   40.764     29.231   1.395  0.16394     
 +--- 
 +Signifcodes 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
-|  **ANOVA(b)**  ||||||| +Residual standard error: 68.87 on 394 degrees of freedom 
-| Model                | Sum of Squares   | df    | Mean Square   | F   | Sig.   | +Multiple R-squared:  0.7685, Adjusted R-squared:  0.7656  
-| 1       | Regression   | 6194144.303      | 3     | 2064714.768   | 435.017  .000a   | +F-statistic: 261.6 on 5 and 394 DF,  p-value< 2.2e-16
-|         | Residual     | 1879527.694      | 396   | 4746.282      |    | +
-|         | Total        | 8073671.997      | 399      |    |    | +
-| a. Predictors(Constant), mealcat2, year round school, mealcat1   |||||| +
-| bDependent Variable: api 2000   |||||||+
  
-^  **Coefficients(a)**   ^^^^^^^  +>  
-|    |    | Unstandardized \\ Coefficients      | Standardized \\ Coefficients       | +> coefs <- summary(m.yrrndxmealcat)$coefficients 
-| Model      | B   Std. Error   | Beta   | t   | Sig.   +> coefs 
-| 1   (Constant  | 526.330   | 7.585      | 69.395   .000   | +                          Estimate Std. Error     t value     Pr(>|t|) 
-|    | year round school   -42.960   | 9.362   -.127   -4.589   .000   | +(Intercept             809.68548   6.184993 130.9113019 0.000000e+00 
-|    | mealcat1   | 281.683   | 9.446   .930   | 29.821   | .000   | +yr_rndnobr               -74.25691  26.756287  -2.7753071 5.777728e-03 
-   | mealcat2   | 117.946   | 9.189   .390   | 12.836   .000   | +mealcatto80             -164.41198   8.876767 -18.5216067 1.529685e-55 
-| aDependent Variable: api 2000   ||||||| +mealcatto100            -288.19295  10.442837 -27.5971894 4.297367e-94 
- +yr_rndnobr:mealcatto80    22.51674  32.751732   0.6874977 4.921736e-01 
- +yr_rndnobr:mealcatto100   40.76438  29.231183   1.3945510 1.639371e-01 
-똑같은 분석이지만 뒤의 두 변인의 효과를 따로 보기 위해서 뽑은 결과이다.  +> br.to46 <- coefs[1] 
- +> br.to80 <- coefs[1]+coefs[3]  
-<code>regression +> br.to100 <- coefs[1]+coefs[4] 
- /dep api00 +> nobr.to46 <- coefs[1]+coefs[2] 
- /method =  enter yr_rnd +> nobr.to80 <- coefs[1]+coefs[2]+coefs[3]+coefs[5] 
- /method = test(mealcat1 mealcat2).+> nobr.to100 <- coefs[1]+coefs[2]+coefs[4]+coefs[6] 
 +cat(br.to46, br.to80, br.to100) 
 +809.6855 645.2735 521.4925 
 +> cat(nobr.to46, nobr.to80, nobr.to100) 
 +735.4286 593.5333 488 
 +
 </code> </code>
 +위의 테스트는 두 개의 독립변인이 모두 종류이고 종속변인이 숫자일 때의 조건을 만족하니 factorial anova를 해도 된다. 아래는 그 결과이다. 
 +<code>
 +> mod4 <- lm(api00 ~ yr_rnd + mealcat + yr_rnd:mealcat, data=datavar) 
 +> summary(mod4)
  
-^ Model Summary   ^^^^^ +Call: 
-| Model   | R   | R Square   | Adjusted R Square   | Std. Error of the Estimate   | +lm(formula = api00 ~ yr_rnd + mealcat + yr_rnd:mealcatdata = datavar)
-| 1   | .475a   | .226   | .224   | 125.300   | +
-| 2   | .876b   | .767   | .765   | 68.893   | +
-| a. Predictors(Constant)year round school   \\ b. Predictors: (Constant), year round school, mealcat2, mealcat1   ||||| +
  
 +Residuals:
 +     Min       1Q   Median       3Q      Max 
 +-207.533  -50.764   -1.843   48.874  179.000 
  
-| ANOVA(d)   |  |  |  |  |  |  +Coefficients: 
-| Model      |    | Sum of Squares   | df   | Mean Square   | F   | Sig  | R Square Change   | +                             Estimate Std. Error t value Pr(>|t|)     
-| 1   | Regression      | 1825000.563   | 1   | 1825000.563   | 116.241   .000a      | +(Intercept)                   809.685      6.185 130.911  < 2e-16 *** 
-|    | Residual      | 6248671.435   | 398   | 15700.179      |    |    | +yr_rndno_break                -74.257     26.756  -2.775  0.00578 **  
-|    | Total      | 8073671.997   | 399      |    |    |    | +mealcat47-80                 -164.412      8.877 -18.522  < 2e-16 *** 
-| 2   | Subset Tests   | mealcat1, mealcat2   | 4369143.740   | 2   | 2184571.870   | 460.270   | .000b   | .541   | +mealcat81-100                -288.193     10.443 -27.597  < 2e-16 *** 
-   | Regression      | 6194144.303   | 3   | 2064714.768   | 435.017   .000c      | +yr_rndno_break:mealcat47-80    22.517     32.752   0.687  0.49217     
-|    | Residual   |    | 1879527.694   | 396   | 4746.282   |    |    |    | +yr_rndno_break:mealcat81-100   40.764     29.231   1.395  0.16394     
-|    | Total      | 8073671.997   | 399      |    |    |    | +--- 
-| aPredictors(Constant), year round school   \\ bTested against the full model  \\ cPredictors in the Full Model: (Constant), year round school, mealcat2, mealcat1 \\ dDependent Variable: api 2000  |||||||||+Signifcodes 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
- +Residual standard error: 68.87 on 394 degrees of freedom 
-^ Coefficients(a)    ^^^^^^^ +Multiple R-squared:  0.7685, Adjusted R-squared:  0.7656  
-|    |    | Unstandardized Coefficients      | Standardized Coefficients       | +F-statistic: 261.6 on 5 and 394 DF,  p-value: < 2.2e-16
-| Model      | B   | Std. Error   | Beta   | t   | Sig.   | +
-| 1   | (Constant)   | 684.539   | 7.140      | 95.878   .000   | +
-|    | year round school   -160.506   | 14.887   -.475   | -10.782   | .000   | +
-| 2   | (Constant)   | 526.330   | 7.585      | 69.395   | .000   | +
-|    | year round school   | -42.960   | 9.362   | -.127   | -4.589   | .000   | +
-|    | mealcat1   | 281.683   | 9.446   | .930   | 29.821   | .000   | +
-|    | mealcat2   | 117.946   | 9.189   | .390   | 12.836   | .000   | +
-| a. Dependent Variableapi 2000   ||||||| +
- +
- +
- **Excluded Variables(b)**   ^^^^^^^  +
-|    |    |    |    |    |    | Collinearity Statistics   | +
-| Model      | Beta In   | t   | Sig  | Partial Correlation   | Tolerance   | +
-| 1   | mealcat1   | .697a   | 23.132   | .000   | .758   | .914   | +
-|    | mealcat2   -.138a   | -3.106   | .002   | -.154   | .962   | +
-| a. Predictors in the Model: (Constant)year round school   \\ b. Dependent Variable: api 2000   ||||||| +
- +
- +
-해석에 대해서 . . . .  +
- **interpretation**  ^^^^ +
-|   | mealcat=1   | mealcat=2   | mealcat=0   | +
-|yr_rnd=0   | cell1   | cell2   | cell3   | +
-|yr_rnd=1   | cell4   | cell5   | cell6   | +
- +
- +
-^  **interpretation**  ^^^^ +
-|   | mealcat=1   | mealcat=2   | mealcat=0   | +
-|   | mealcat=1->1   | mealcat=2->   | mealcat=3->mealcat1,2=0   | +
-| yr_rnd=0   | cell1   | cell2   | cell3   | +
-:::  | intercept + \\ BMealCat1   | intercept + \\ BMealCat2   | intercept   | +
-| yr_rnd=1   | cell4   | cell5   | cell6   | +
-| :::  | intercept + \\ BMealCat1 + \\ Byr_rnd   | intercept + \\ BMealCat2 + \\ Byr_rnd   | intercept + \\ Byr_rnd   | +
- +
-<code>glm +
-  api00 BY yr_rnd mealcat +
-  /DESIGN = yr_rnd mealcat +
-  /print=parameter TEST(LMATRIX).+
 </code> </code>
  
-===== continuous + categorical variables ===== +<code> 
-<code>regress +Coefficients: 
- /dep = api00 +                             Estimate StdError t value Pr(>|t|    
- /method = enter yr_rnd some_col +(Intercept)                   809.685      6.185 130.911  < 2e-16 *** 
- /save pre. +yr_rndno_break                -74.257     26.756  -2.775  0.00578 **  
-* pre = predicted value (y hat).+mealcat47-80                 -164.412      8.877 -18.522  < 2e-16 *** 
 +mealcat81-100                -288.193     10.443 -27.597  < 2e-16 *** 
 +yr_rndno_break:mealcat47-80    22.517     32.752   0.687  0.49217     
 +yr_rndno_break:mealcat81-100   40.764     29.231   1.395  0.16394     
 +---
  
-output:+이전 식 
 +y hat = 808.013 + -42.960 * (nobr) + -163.737 * (to80) + -281.683 * (to100) 
 +위의 식 
 +y hat = 809.685 +  -74.257*(nobr) +  
 +                  -164.412*(to80) +   
 +                  -288.193*(to100) + 
 +                   22.517*(nobr:to80) +   --> aaaaa case 
 +                   40.764*(nobr:to100)    --> bbbbb case
  
- Model Summary(b) +yr_rnd
-Model R R Square Adjusted R Square Std. Error of the Estimate +break = 방학있음  
-1 .507a .257 .253 122.951 +no_break = 방학없음
-a. Predictors(Constant), parent some college, year round school +
-b. Dependent Variable: api 2000 +
- +
- ANOVA(b) +
-Model Sum of Squares df Mean Square F Sig. +
-1 Regression 2072201.839 2 1036100.919 68.539 .000a +
- Residual 6001470.159 397 15117.053  +
- Total 8073671.997 399  +
-a. Predictors: (Constant), parent some college, year round school +
-b. Dependent Variable: api 2000 +
- +
- Coefficients(a) +
- Unstandardized Coefficients Standardized Coefficients +
-Model B Std. Error Beta t Sig. +
-1 (Constant) 637.858 13.503 47.237 .000 +
- year round school -149.159 14.875 -.442 -10.027 .000 +
- parent some college 2.236 553 .178 4.044 .000 +
-a. Dependent Variable: api 2000+
  
 +mealcat: 
 +0-46% free meals
 +47-80%
 +81-100%
 </code> </code>
  
- +^                 ^ mealcat0-46  ^ mealcat47-80   ^ mealcat81-100    ^  
-<code>COMPUTE filt=(yr_rnd=0). +| yr_rndbreak     <wrap베이스라인 
-FILTER BY filt. +yr_rndno_break 
-regress +mealcat47-80 = 0 
- /dep api00 +mealcat81-100 0 경우 
- /method enter some_col+''y hat 809.685''          
-</code+</wrap | <wrap> yr_rndno_break = 0 
- +mealcat0-46 = 0 
-위의 명령어는 (spss) yr_rnd value -인것을 선택하여, 이를 필터링하면 (고르면) -> 1 이 되고 +mealcat81-100 = 경우   
-필터링되지 않은 케이스들은 버려지게 되어 필터링이 된 케이스들만 선택이 되어 분석에 사용됨을 뜻 한다. 즉, 위는 rn_rnd값이 인 케이스에 대해서만 simple regression을 하라는 것이다.  +''y hat = 809.685 -  
- +          163.737  
-<code> Model Summary +        = 645.9'' 
-Model R R Square Adjusted R Square StdError of the Estimate +</wrap>  | <wrap>  
-1 .126a .016 .013 131.278 +yr_rndno_break = 0     
-aPredictors: (Constant), parent some college +mealcat0-46 = 0 
- +mealcat47-80 = 0 경우 
- ANOVA(b) +''y hat = 809.685 -  
-Model Sum of Squares df Mean Square F Sig. +          281.683  
-1 Regression 84700.858 1 84700.858 4.915 .027a +        = 528'' 
- Residual 5273591.675 306 17233.960  +</wrap | 
- Total 5358292.532 307  +| yr_rndno_break <wrap 
-a. Predictors: (Constant), parent some college +yr_rndbreak 
-b. Dependent Variable: api 2000 +mealcat47-80 0 
- +mealcat81-100 0 경우 
- Coefficients(a) +''y hat 809.685 -  
- Unstandardized Coefficients Standardized Coefficients +          74.257  
-Model B Std. Error Beta t Sig. +        = 735.4''          
-1 (Constant) 655.110 15.237 42.995 .000 +</wrap>  | <wrapaaaaa 
- parent some college 1.409 .636 .126 2.217 .027 +yr_rndbreak = 0 
-a. Dependent Variable: api 2000 +mealcat0-46 0 
-</code+mealcat81-100 0 경우   
- +''y hat 809.685 -  
-{{regression-cat0.jpg}} +          74.257 -  
- +          164.412 +  
-<code>COMPUTE filt=(yr_rnd=1). +          <fc #ff0000>22.517</fc>  
-FILTER BY filt. +        593.5'' 
-regress +</wrap <wrapbbbbb 
- /dep api00 +yr_rndbreak = 0     
- /method enter some_col+mealcat0-46 = 0 
- +mealcat47-80 = 0 경우 
- +''y hat = 809.685 
- Model Summary +          74.257 
-Model R R Square Adjusted R Square StdError of the Estimate +          288.193 +  
-1 .648a .420 .413 75.773 +          <fc #ff0000>40.764</fc>  
-a. Predictors: (Constant), parent some college +        = 488'' 
- +</wrap> 
- ANOVA(b) +마지막 두 를 보면 no_break학교 중에서 밀카테고리 2와 3에서 떨어지는 정도가 어느 정도 완화되는 경향을 보이지만 통계학적으로 significant하지는 다. 
-Model Sum of Squares df Mean Square F Sig. +
-1 Regression 373644.064 1 373644.064 65.078 .000a +
- Residual 516734.838 90 5741.498  +
- Total 890378.902 91  +
-a. Predictors: (Constant), parent some college +
-b. Dependent Variable: api 2000 +
- +
- Coefficients(a) +
- Unstandardized Coefficients Standardized Coefficients +
-Model B Std. Error Beta t Sig. +
-1 (Constant) 407.039 16.515 24.647 .000 +
- parent some college 7.403 .918 .648 8.067 .000 +
-a. Dependent Variable: api 2000 +
-</code+
- +
-{{regression-cat1.jpg}} +
- +
-===== interaction effect ====+
- +
-위의 두 regression은 yr_rnd 변인이 갖는 두 가지 특성에 대해서 따로 regression (api_00 <some_col) 을 한 것이다. 이 결과, 두 집단의 regression 기울기 (coefficient)가 다르다는 것을 알았다. 즉, some_col의 api_00에 대한 영향력이 다르다는 것이다. 이는 각각의 상황(변인의 특성)에 따라서 동일한 독립변인이 역할을 달리하는 것으로 상호효과(interaction effect)라고 할 수 있다. 따라서, 두 기울기가 혹은 계수(coefficients)가 서로 다르다는 것을 검증한다면, 상호효과를 알아볼 수 있다. +
- +
-아래는 새로운 변인을 만들어서 변인의 값으로 yr_rnd와 some_col값을 곱한 값을 대체한 것이다. 즉,  +
- +
-DV: api00  +
- +
-IV1: some_col +
-IV2: yr_rnd +
-IV3: yr_rnd * some_col interaction effects +
- +
-<code>compute yrXsome yr_rnd*some_col+
-execute+
-</code> +
- +
-그리고, 이 변인을 regression 공식에 이용한다 +
- +
-<code>regress +
- /dep api00 +
- /method = enter some_col yr_rnd yrXsome +
- /save pre+
-</code> +
- +
-<code>output: +
- Model Summary(b) +
-Model R R Square Adjusted R Square Std. Error of the Estimate +
-1 .532a .283 .277 120.922 +
-a. Predictors: (Constant), yrXsome, parent some college, year round school +
-b. Dependent Variable: api 2000 +
- +
- ANOVA(b) +
-Model Sum of Squares df Mean Square F Sig. +
-1 Regression 2283345.485 3 761115.162 52.053 .000a +
- Residual 5790326.513 396 14622.037  +
- Total 8073671.997 399  +
-a. Predictors: (Constant), yrXsome, parent some college, year round school +
-b. Dependent Variable: api 2000 +
- +
- Coefficients(a) +
- Unstandardized Coefficients Standardized Coefficients +
-Model B Std. Error Beta t Sig. +
-1 (Constant) 655.110 14.035 46.677 .000 +
- parent some college 1.409 .586 .112 2.407 .017 +
- year round school -248.071 29.859 -.735 -8.308 .000 +
- __yrXsome__ 5.993 1.577 .330 3.800 .000 +
-a. Dependent Variable: api 2000 +
- +
- Residuals Statistics(a) +
- Minimum Maximum Mean Std. Deviation N +
-Predicted Value 407.04 749.54 647.62 75.648 400 +
-Residual -275.118 279.252 .000 120.466 400 +
-StdPredicted Value -3.180 1.347 .000 1.000 400 +
-StdResidual -2.275 2.309 .000 .996 400 +
-aDependent Variable: api 2000 +
-</code+
- +
-위에서 __yr_rnd__의 b 계수 값이 5.993으로 유의미하다고 판단된다 (t = 3.800, p .001). 따라서 두 변인 간의 상호효과가 존재한다고 할 수 있다. 이를 다시 도표화해서 보면, 두 집단의 기울기가 로 다르다는 것을 알 수 있다. +
- +
-{{regression-cat2-interctionx.jpg}} +
-{{regression-cat2-interaction-each.jpg}} +
- +
-위의 스트를 살펴보면, 두 개의 독립변인 중 하나는 종류변인이고 다른 하나는 숫자변인이다. 각 변인의 영력에 대해서 regression을 통해서 알아면서 두 변인의 상호작용까지 알아본 것이 된다. 이와 같은 절차는 FactorialAnova 에서 살펴본 것과 같다. 사실, 위의 연구문제(가설)를 ANOVA를 이용해서도 할 수 있다. +
- +
-<code>glm +
-  api00 BY yr_rnd WITH some_col +
-  /DESIGN = some_col yr_rnd yr_rnd*some_col. +
- +
-or +
-UNIANOVA api00 BY yr_rnd WITH some_col +
-  /DESIGN=yr_rnd some_col some_col*yr_rnd +
-  /print=parameter . +
- +
-</code>+
  
  
 +</tabbox>
  
using_dummy_variables.1781046655.txt.gz · Last modified: by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki