logistic_regression
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
logistic_regression [2019/09/18 07:53] – hkimscil | logistic_regression [2019/09/18 07:56] – hkimscil | ||
---|---|---|---|
Line 16: | Line 16: | ||
{{youtube> | {{youtube> | ||
</ | </ | ||
+ | |||
+ | ====== e.g. 1 ====== | ||
+ | https:// | ||
+ | < | ||
+ | mydata <- read.csv(" | ||
+ | ## view the first few rows of the data | ||
+ | head(mydata) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | admit gre gpa rank | ||
+ | 1 0 380 3.61 3 | ||
+ | 2 1 660 3.67 3 | ||
+ | 3 1 800 4.00 1 | ||
+ | 4 1 640 3.19 4 | ||
+ | 5 0 520 2.93 4 | ||
+ | 6 1 760 3.00 2 | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | 1st Qu.: | ||
+ | | ||
+ | | ||
+ | 3rd Qu.: | ||
+ | | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | sapply(mydata, | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | | ||
+ | 0.3175 587.7000 | ||
+ | > sapply(mydata, | ||
+ | admit | ||
+ | 0.4660867 115.5165364 | ||
+ | > </ | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | rank | ||
+ | admit 1 2 3 4 | ||
+ | 0 28 97 93 55 | ||
+ | 1 33 54 28 12 | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = " | ||
+ | summary(mylogit) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Call: | ||
+ | glm(formula = admit ~ gre + gpa + rank, family = " | ||
+ | data = mydata) | ||
+ | |||
+ | Deviance Residuals: | ||
+ | Min | ||
+ | -1.6268 | ||
+ | |||
+ | Coefficients: | ||
+ | | ||
+ | (Intercept) -3.989979 | ||
+ | gre 0.002264 | ||
+ | gpa 0.804038 | ||
+ | rank2 | ||
+ | rank3 | ||
+ | rank4 | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | (Dispersion parameter for binomial family taken to be 1) | ||
+ | |||
+ | Null deviance: 499.98 | ||
+ | Residual deviance: 458.52 | ||
+ | AIC: 470.52 | ||
+ | |||
+ | Number of Fisher Scoring iterations: 4 | ||
+ | |||
+ | > </ | ||
+ | |||
+ | < | ||
+ | > confint(mylogit) | ||
+ | Waiting for profiling to be done... | ||
+ | 2.5 % 97.5 % | ||
+ | (Intercept) -6.2716202334 -1.792547080 | ||
+ | gre 0.0001375921 | ||
+ | gpa 0.1602959439 | ||
+ | rank2 | ||
+ | rank3 | ||
+ | rank4 | ||
+ | > | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > confint.default(mylogit) | ||
+ | 2.5 % 97.5 % | ||
+ | (Intercept) -6.2242418514 -1.755716295 | ||
+ | gre 0.0001202298 | ||
+ | gpa 0.1536836760 | ||
+ | rank2 | ||
+ | rank3 | ||
+ | rank4 | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | wald.test(b = coef(mylogit), | ||
+ | </ | ||
+ | |||
+ | {{tag> statistics r "logit statistics" | ||
+ |
logistic_regression.txt · Last modified: 2023/12/14 07:55 by hkimscil