r:dummy_variables_with_significant_interaction
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| r:dummy_variables_with_significant_interaction [2023/06/02 01:26] – hkimscil | r:dummy_variables_with_significant_interaction [2023/06/05 22:01] (current) – [Regression with a continous + a categorical variables: ANCOVA] hkimscil | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Regression with two categorical variables (IVs): Two way anova ====== | ||
| + | https:// | ||
| < | < | ||
| college <- read.csv(" | college <- read.csv(" | ||
| Line 18: | Line 20: | ||
| a.m2 <- aov(salary~public*location) | a.m2 <- aov(salary~public*location) | ||
| summary(a.m2) | summary(a.m2) | ||
| + | |||
| + | interaction.plot(x.factor = location, | ||
| + | | ||
| + | | ||
| + | fun = median, | ||
| + | ylab = " | ||
| + | xlab = " | ||
| + | | ||
| + | lty = 1, | ||
| + | | ||
| + | | ||
| </ | </ | ||
| + | ====== output ====== | ||
| < | < | ||
| #################### | #################### | ||
| Line 111: | Line 125: | ||
| --- | --- | ||
| Signif. codes: | Signif. codes: | ||
| + | > | ||
| + | > | ||
| + | > interaction.plot(x.factor = location, | ||
| + | + trace.factor = public, | ||
| + | + response = salary, | ||
| + | + fun = median, | ||
| + | + ylab = " | ||
| + | + xlab = " | ||
| + | + col=c(" | ||
| + | + lty = 1, | ||
| + | + lwd=2, | ||
| + | + trace.label=" | ||
| > | > | ||
| </ | </ | ||
| + | {{: | ||
| + | |||
| + | ====== Regression with a continous + a categorical variables: ANCOVA ====== | ||
| + | < | ||
| + | summary(mod< | ||
| + | anova(mod) | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | > summary(mod< | ||
| + | |||
| + | Call: | ||
| + | lm(formula = salary ~ cost + location) | ||
| + | |||
| + | Residuals: | ||
| + | Min 1Q Median | ||
| + | -20.244 | ||
| + | |||
| + | Coefficients: | ||
| + | | ||
| + | (Intercept) | ||
| + | cost | ||
| + | locationMW | ||
| + | locationNE | ||
| + | locationW | ||
| + | --- | ||
| + | Signif. codes: | ||
| + | |||
| + | Residual standard error: 8.02 on 80 degrees of freedom | ||
| + | Multiple R-squared: | ||
| + | F-statistic: | ||
| + | |||
| + | > anova(mod) | ||
| + | Analysis of Variance Table | ||
| + | |||
| + | Response: salary | ||
| + | Df Sum Sq Mean Sq F value Pr(> | ||
| + | cost | ||
| + | location | ||
| + | Residuals 80 | ||
| + | --- | ||
| + | Signif. codes: | ||
| + | > | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | (Intercept) | ||
| + | cost | ||
| + | locationMW | ||
| + | locationNE | ||
| + | locationW | ||
| + | |||
| + | </ | ||
| + | |||
| + | '' | ||
| + | |||
| + | * S, MW, NE, W 중에서 S가 default | ||
| + | * y hat ~ 87.8 + .00006*cost | ||
| + | * MW: | ||
| + | * y hat ~ 87.8 - 2.8 + .00006*cost | ||
| + | * y hat ~ 85 + .00006*cost | ||
| + | * NE: | ||
| + | * y hat ~ 87.8 - 9.23 + .00006*cost | ||
| + | * y hat ~ 78.57 + .00006*cost | ||
| + | * E: | ||
| + | * y hat ~ 87.8 - 10.5 + .00006*cost | ||
| + | * y hat ~ 77.3 + .00006*cost | ||
| + | |||
| + | < | ||
| + | > summary(mod2< | ||
| + | |||
| + | Call: | ||
| + | lm(formula = salary ~ cost * location) | ||
| + | |||
| + | Residuals: | ||
| + | | ||
| + | -17.1126 | ||
| + | |||
| + | Coefficients: | ||
| + | Estimate Std. Error t value Pr(> | ||
| + | (Intercept) | ||
| + | cost | ||
| + | locationMW | ||
| + | locationNE | ||
| + | locationW | ||
| + | cost: | ||
| + | cost: | ||
| + | cost: | ||
| + | --- | ||
| + | Signif. codes: | ||
| + | |||
| + | Residual standard error: 7.644 on 77 degrees of freedom | ||
| + | Multiple R-squared: | ||
| + | F-statistic: | ||
| + | |||
| + | > anova(mod2) | ||
| + | Analysis of Variance Table | ||
| + | |||
| + | Response: salary | ||
| + | Df Sum Sq Mean Sq F value Pr(> | ||
| + | cost 1 2757.0 2756.97 | ||
| + | location | ||
| + | cost: | ||
| + | Residuals | ||
| + | --- | ||
| + | Signif. codes: | ||
| + | > | ||
| + | </ | ||
| + | |||
| + | |||
r/dummy_variables_with_significant_interaction.1685636777.txt.gz · Last modified: by hkimscil
