multiple_regression
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
multiple_regression [2019/05/21 22:33] – [무엇부터? 라는 문제] hkimscil | multiple_regression [2019/11/01 09:32] – [exercise] hkimscil | ||
---|---|---|---|
Line 331: | Line 331: | ||
see https:// | see https:// | ||
- | This problem | + | < |
+ | RSS = 3:10 #Right shoe size | ||
+ | LSS = rnorm(RSS, RSS, 0.1) #Left shoe size - similar to RSS | ||
+ | cor(LSS, RSS) # | ||
+ | |||
+ | weights = 120 + rnorm(RSS, 10*RSS, 10) | ||
+ | |||
+ | ##Fit a joint model | ||
+ | m = lm(weights ~ LSS + RSS) | ||
+ | |||
+ | ##F-value is very small, but neither LSS or RSS are significant | ||
+ | summary(m) | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | > LSS = rnorm(RSS, RSS, 0.1) #Left shoe size - similar to RSS | ||
+ | > cor(LSS, RSS) # | ||
+ | [1] 0.9994836 | ||
+ | > | ||
+ | > weights = 120 + rnorm(RSS, 10*RSS, 10) | ||
+ | > | ||
+ | > ##Fit a joint model | ||
+ | > m = lm(weights ~ LSS + RSS) | ||
+ | > | ||
+ | > ##F-value is very small, but neither LSS or RSS are significant | ||
+ | > summary(m) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = weights ~ LSS + RSS) | ||
+ | |||
+ | Residuals: | ||
+ | 1 | ||
+ | | ||
+ | |||
+ | Coefficients: | ||
+ | Estimate Std. Error t value Pr(> | ||
+ | (Intercept) | ||
+ | LSS -14.162 | ||
+ | RSS | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 7.296 on 5 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | |||
+ | > | ||
+ | > ##Fitting RSS or LSS separately gives a significant result. | ||
+ | > summary(lm(weights ~ LSS)) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = weights ~ LSS) | ||
+ | |||
+ | Residuals: | ||
+ | | ||
+ | -6.055 -4.930 -2.925 | ||
+ | |||
+ | Coefficients: | ||
+ | Estimate Std. Error t value Pr(> | ||
+ | (Intercept) | ||
+ | LSS | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 7.026 on 6 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | |||
+ | > | ||
+ | </ | ||
Line 410: | Line 480: | ||
* LifeSat Score on Life Satisfaction Inventory seven years after College | * LifeSat Score on Life Satisfaction Inventory seven years after College | ||
* Income Income seven years after College (in thousands) | * Income Income seven years after College (in thousands) | ||
+ | |||
+ | ====== exercise ====== | ||
+ | < | ||
+ | library(ggplot2) | ||
+ | library(dplyr) | ||
+ | library(statsr) | ||
+ | library(varhandle) | ||
+ | |||
+ | library(gridExtra) | ||
+ | library(janitor) | ||
+ | library(car) | ||
+ | library(SignifReg) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | ## download data file at | ||
+ | ## https:// | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | load(" | ||
+ | </ | ||
+ | |||
Line 432: | Line 525: | ||
* https:// | * https:// | ||
* http:// | * http:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | |||
{{tag> " | {{tag> " | ||
+ |
multiple_regression.txt · Last modified: 2024/06/12 08:36 by hkimscil