multicolinearity
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| multicolinearity [2018/12/26 02:41] – hkimscil | multicolinearity [2018/12/26 02:49] (current) – [regression test with factors] hkimscil | ||
|---|---|---|---|
| Line 24: | Line 24: | ||
| $ sector | $ sector | ||
| $ marr : int 1 1 0 0 1 0 0 0 1 0 ... | $ marr : int 1 1 0 0 1 0 0 0 1 0 ... | ||
| + | > head(cps) | ||
| > head(cps) | > head(cps) | ||
| education south sex experience union wage age race occupation sector marr | education south sex experience union wage age race occupation sector marr | ||
| Line 34: | Line 34: | ||
| 6 13 | 6 13 | ||
| </ | </ | ||
| - | |||
| - | < | ||
| - | > cps$sex <- factor(cps$sex) | ||
| - | > cps$union <- factor(cps$union) | ||
| - | > cps$race <- factor(cps$race) | ||
| - | > cps$sector <- factor(cps$sector) | ||
| - | > cps$occupation <- factor(cps$occupation) | ||
| - | > cps$marr <- factor(cps$marr) | ||
| - | > str(cps) | ||
| - | ' | ||
| - | $ education : int 8 9 12 12 12 13 10 12 16 12 ... | ||
| - | $ south : int 0 0 0 0 0 0 1 0 0 0 ... | ||
| - | $ sex : Factor w/ 2 levels " | ||
| - | $ experience: int 21 42 1 4 17 9 27 9 11 9 ... | ||
| - | $ union : Factor w/ 2 levels " | ||
| - | $ wage : num 5.1 4.95 6.67 4 7.5 ... | ||
| - | $ age : int 35 57 19 22 35 28 43 27 33 27 ... | ||
| - | $ race : Factor w/ 3 levels " | ||
| - | $ occupation: Factor w/ 6 levels " | ||
| - | $ sector | ||
| - | $ marr : Factor w/ 2 levels " | ||
| - | > </ | ||
| - | |||
| < | < | ||
| Line 67: | Line 44: | ||
| Residuals: | Residuals: | ||
| | | ||
| - | -2.36167 -0.27926 | + | -2.16246 -0.29163 -0.00469 0.29981 1.98248 |
| Coefficients: | Coefficients: | ||
| - | | + | Estimate Std. Error t value Pr(> |
| - | (Intercept) | + | (Intercept) |
| - | education | + | education |
| - | south -0.09290 | + | south -0.102360 |
| - | sex1 | + | sex -0.221997 |
| - | experience | + | experience |
| - | union1 | + | union |
| - | age -0.05858 | + | age -0.085444 |
| - | race2 -0.03345 | + | race 0.050406 |
| - | race3 0.07973 | + | occupation |
| - | occupation2 -0.36440 | + | sector |
| - | occupation3 -0.20964 | + | marr 0.076611 |
| - | occupation4 -0.38345 0.08105 | + | |
| - | occupation5 | + | |
| - | occupation6 -0.26555 0.08002 | + | |
| - | sector1 | + | |
| - | sector2 | + | |
| - | marr1 0.06335 | + | |
| --- | --- | ||
| Signif. codes: | Signif. codes: | ||
| - | Residual standard error: 0.4281 on 517 degrees of freedom | + | Residual standard error: 0.4398 on 523 degrees of freedom |
| - | Multiple R-squared: | + | Multiple R-squared: |
| - | F-statistic: | + | F-statistic: |
| - | + | ||
| - | > | + | |
| </ | </ | ||
| Line 248: | Line 217: | ||
| > </ | > </ | ||
| + | ====== regression test with factors ====== | ||
| < | < | ||
| + | > cps$sex <- factor(cps$sex) | ||
| + | > cps$union <- factor(cps$union) | ||
| + | > cps$race <- factor(cps$race) | ||
| + | > cps$sector <- factor(cps$sector) | ||
| + | > cps$occupation <- factor(cps$occupation) | ||
| + | > cps$marr <- factor(cps$marr) | ||
| + | > str(cps) | ||
| + | ' | ||
| + | $ education : int 8 9 12 12 12 13 10 12 16 12 ... | ||
| + | $ south : int 0 0 0 0 0 0 1 0 0 0 ... | ||
| + | $ sex : Factor w/ 2 levels " | ||
| + | $ experience: int 21 42 1 4 17 9 27 9 11 9 ... | ||
| + | $ union : Factor w/ 2 levels " | ||
| + | $ wage : num 5.1 4.95 6.67 4 7.5 ... | ||
| + | $ age : int 35 57 19 22 35 28 43 27 33 27 ... | ||
| + | $ race : Factor w/ 3 levels " | ||
| + | $ occupation: Factor w/ 6 levels " | ||
| + | $ sector | ||
| + | $ marr : Factor w/ 2 levels " | ||
| </ | </ | ||
| < | < | ||
| + | > lm4 = lm(log(cps$wage) ~ . -age, data = cps) | ||
| + | > summary(lm4) | ||
| + | |||
| + | Call: | ||
| + | lm(formula = log(cps$wage) ~ . - age, data = cps) | ||
| + | |||
| + | Residuals: | ||
| + | | ||
| + | -2.36103 -0.28080 | ||
| + | |||
| + | Coefficients: | ||
| + | | ||
| + | (Intercept) | ||
| + | education | ||
| + | south | ||
| + | sex1 -0.216934 | ||
| + | experience | ||
| + | union1 | ||
| + | race2 | ||
| + | race3 0.079851 | ||
| + | occupation2 -0.364444 | ||
| + | occupation3 -0.210295 | ||
| + | occupation4 -0.383882 | ||
| + | occupation5 -0.050664 | ||
| + | occupation6 -0.265348 | ||
| + | sector1 | ||
| + | sector2 | ||
| + | marr1 0.062211 | ||
| + | --- | ||
| + | Signif. codes: | ||
| + | |||
| + | Residual standard error: 0.4278 on 518 degrees of freedom | ||
| + | Multiple R-squared: | ||
| + | F-statistic: | ||
| + | |||
| + | > | ||
| + | |||
| </ | </ | ||
| - | < | + | <code>> lm5 = lm(log(cps$wage) ~ . -age -race, data = cps) |
| + | > summary(lm5) | ||
| + | |||
| + | Call: | ||
| + | lm(formula = log(cps$wage) ~ . - age - race, data = cps) | ||
| + | |||
| + | Residuals: | ||
| + | | ||
| + | -2.34366 -0.28169 -0.00017 | ||
| + | |||
| + | Coefficients: | ||
| + | | ||
| + | (Intercept) | ||
| + | education | ||
| + | south | ||
| + | sex1 -0.213602 | ||
| + | experience | ||
| + | union1 | ||
| + | occupation2 -0.355381 | ||
| + | occupation3 -0.209820 | ||
| + | occupation4 -0.385680 | ||
| + | occupation5 -0.047694 | ||
| + | occupation6 -0.254277 | ||
| + | sector1 | ||
| + | sector2 | ||
| + | marr1 0.065464 | ||
| + | --- | ||
| + | Signif. codes: | ||
| + | |||
| + | Residual standard error: 0.4283 on 520 degrees of freedom | ||
| + | Multiple R-squared: | ||
| + | F-statistic: | ||
| + | |||
| + | > | ||
| </ | </ | ||
| + | < | ||
| + | > summary(lm6) | ||
| + | Call: | ||
| + | lm(formula = log(cps$wage) ~ . - age - race - occupation - marr - | ||
| + | sector, data = cps) | ||
| + | |||
| + | Residuals: | ||
| + | | ||
| + | -2.13809 -0.28681 -0.00078 | ||
| + | |||
| + | Coefficients: | ||
| + | | ||
| + | (Intercept) | ||
| + | education | ||
| + | south | ||
| + | sex1 -0.231978 | ||
| + | experience | ||
| + | union1 | ||
| + | --- | ||
| + | Signif. codes: | ||
| + | |||
| + | Residual standard error: 0.4433 on 528 degrees of freedom | ||
| + | Multiple R-squared: | ||
| + | F-statistic: | ||
| + | |||
| + | > </ | ||
multicolinearity.1545759664.txt.gz · Last modified: by hkimscil
