c:ma:2019:multiple_regression_exercise
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| c:ma:2019:multiple_regression_exercise [2021/11/09 03:57] – [Ex. 1] hkimscil | c:ma:2019:multiple_regression_exercise [2021/11/11 01:14] (current) – [Ex. 2] hkimscil | ||
|---|---|---|---|
| Line 32: | Line 32: | ||
| * load the tidyverse | * load the tidyverse | ||
| * '' | * '' | ||
| - | * '' | + | |
| - | * Use a dataset | + | * load the car and the carData |
| - | * describe the data set | + | |
| + | * '' | ||
| + | * explain what it is | ||
| + | | ||
| ---- | ---- | ||
| * Regress sex variable on salary variable | * Regress sex variable on salary variable | ||
| * Write the regression model | * Write the regression model | ||
| - | * Discuss the difference | + | * Discuss the difference |
| * Use rank variable for the same purpose | * Use rank variable for the same purpose | ||
| - | * -- | + | * Write the regression model |
| - | * Use yrs.service + rank + discipline | + | * Regress |
| - | * on salary | + | |
| * How do you interpret the result? | * How do you interpret the result? | ||
| + | * And regress rank + sex + rank:sex on salary | ||
| + | * How do you interpret this result? | ||
| + | * Do factorial ANOVA test with rank and sex on salary | ||
| + | * How do you interpret the result? | ||
| + | |||
| + | * Test regression model of your own choice | ||
| + | * Interpret the result | ||
| + | |||
| ----- | ----- | ||
| 위의 Salaries 데이터사용이 안 될 때 | 위의 Salaries 데이터사용이 안 될 때 | ||
| Line 55: | Line 65: | ||
| Please copy and paste the proper r command and output to a txt file (use notepad or some other text editing program). You could use MS Word, but, please make it sure that you use type-setting fonts such as " | Please copy and paste the proper r command and output to a txt file (use notepad or some other text editing program). You could use MS Word, but, please make it sure that you use type-setting fonts such as " | ||
| < | < | ||
| - | > head(Salaries) | ||
| - | rank discipline yrs.since.phd yrs.service | ||
| - | 1 Prof B 19 18 Male 139750 | ||
| - | 2 Prof B 20 16 Male 173200 | ||
| - | 3 AsstProf | ||
| - | 4 Prof B 45 39 Male 115000 | ||
| - | 5 Prof B 40 41 Male 141500 | ||
| - | 6 AssocProf | ||
| - | </ | ||
| - | |||
| - | |||
| - | < | ||
| - | > summary(lm.sal.sex) | ||
| - | |||
| - | Call: | ||
| - | lm(formula = salary ~ sex, data = Salaries) | ||
| - | |||
| - | Residuals: | ||
| - | | ||
| - | -57290 -23502 | ||
| - | |||
| - | Coefficients: | ||
| - | Estimate Std. Error | ||
| - | (Intercept) | ||
| - | sexMale | ||
| - | t value Pr(> | ||
| - | (Intercept) | ||
| - | sexMale | ||
| - | --- | ||
| - | Signif. codes: | ||
| - | 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ | ||
| - | 0.05 ‘.’ 0.1 ‘ ’ 1 | ||
| - | |||
| - | Residual standard error: 30030 on 395 degrees of freedom | ||
| - | Multiple R-squared: | ||
| - | F-statistic: | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | > summary(lm.sal.rank) | ||
| - | |||
| - | Call: | ||
| - | lm(formula = salary ~ rank, data = Salaries) | ||
| - | |||
| - | Residuals: | ||
| - | | ||
| - | -68972 -16376 | ||
| - | |||
| - | Coefficients: | ||
| - | Estimate Std. Error | ||
| - | (Intercept) | ||
| - | rankAssocProf | ||
| - | rankProf | ||
| - | t value Pr(> | ||
| - | (Intercept) | ||
| - | rankAssocProf | ||
| - | rankProf | ||
| - | --- | ||
| - | Signif. codes: | ||
| - | 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ | ||
| - | 0.05 ‘.’ 0.1 ‘ ’ 1 | ||
| - | |||
| - | Residual standard error: 23630 on 394 degrees of freedom | ||
| - | Multiple R-squared: | ||
| - | F-statistic: | ||
| - | |||
| - | > </ | ||
| - | |||
| - | < | ||
| - | |||
| - | Call: | ||
| - | lm(formula = salary ~ yrs.service + rank + discipline + sex, | ||
| - | data = Salaries) | ||
| - | |||
| - | Residuals: | ||
| - | | ||
| - | -64202 -14255 | ||
| - | |||
| - | Coefficients: | ||
| - | Estimate Std. Error t value Pr(> | ||
| - | (Intercept) | ||
| - | yrs.service | ||
| - | rankAssocProf 14560.40 | ||
| - | rankProf | ||
| - | disciplineB | ||
| - | sexMale | ||
| - | --- | ||
| - | Signif. codes: | ||
| - | |||
| - | Residual standard error: 22650 on 391 degrees of freedom | ||
| - | Multiple R-squared: | ||
| - | F-statistic: | ||
| - | > </ | ||
| ====== Discussion ====== | ====== Discussion ====== | ||
| Common topics | Common topics | ||
c/ma/2019/multiple_regression_exercise.1636430276.txt.gz · Last modified: by hkimscil
