r:logistic_regression_analysis
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| r:logistic_regression_analysis [2023/12/04 08:11] – hkimscil | r:logistic_regression_analysis [2023/12/06 23:00] (current) – [e.g. 1] hkimscil | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | \begin{align*} | ||
| - | \displaystyle ln \left( {\frac{p}{(1-p)}} \right) = a + bX | ||
| - | \end{align*} | ||
| - | * p = 변인 X가 A일 확률 | + | < |
| - | * 1-p = 변인 X가 A가 아닐 확률 | + | > Logit(Turnover ~ JS, data=td) |
| - | * ln 은 e를 밑으로 하는 log 를 말한다 | + | |
| - | * $ln \left( {\frac{p}{(1-p)}} \right) $ 을 $\text{logit(p)}$ 로 부른다 | + | |
| - | \begin{align*} | + | Data Frame: |
| - | \text{logit(p)} & = ln \left( {\frac{p}{(1-p)}} \right) = a + bX \\ | + | |
| - | \frac{p}{1-p} & = e^{a+bX} \\ | + | |
| - | p & = e^{a+bX} * (1-p) \\ | + | |
| - | p & = e^{a+bX} - p * \left(e^{a+bX} \right) \\ | + | |
| - | p + p * \left(e^{a+bX} \right) & = e^{a+bX} | + | |
| - | p * \left(1 + e^{a+bX} \right) & = e^{a+bX} | + | |
| - | p & = \frac {e^{a+bX}} { \left(1 + e^{a+bX} \right)} \\ | + | |
| - | \end{align*} | + | |
| - | | + | Response Variable: |
| - | | + | Predictor Variable 1: JS |
| - | 즉 p의 그래프는 아래와 같은 그래프의 곡선이다. | + | Number of cases (rows) of data: 99 |
| - | < | + | Number of cases retained for analysis: |
| - | install.packages(" | + | |
| - | library(sigmoid) | + | |
| - | library(ggplot2) | + | |
| - | input <- seq(-5, 5, 0.01) | + | |
| - | df = data.frame(input, | + | |
| - | ggplot( df, aes(input, logistic(input)) ) + | + | |
| - | geom_line(color=" | + | |
| - | </ | + | |
| - | {{:r: | + | |
| - | 여기서 | ||
| - | \begin{align*} | ||
| - | y & = ln(x) \\ | ||
| - | & = log_e {x} \\ | ||
| - | x & = e^{y} \\ | ||
| - | \text{if } \; x = 1, y = 0 \\ | ||
| - | ln(1) = 0 | ||
| - | \end{align*} | ||
| + | BASIC ANALYSIS | ||
| + | -- Estimated Model of Turnover for the Logit of Reference Group Membership | ||
| + | | ||
| + | (Intercept) | ||
| + | | ||
| + | |||
| + | |||
| + | -- Odds Ratios and Confidence Intervals | ||
| + | |||
| + | Odds Ratio Lower 95% Upper 95% | ||
| + | (Intercept) | ||
| + | | ||
| + | |||
| + | |||
| + | -- Model Fit | ||
| + | |||
| + | Null deviance: 131.746 on 97 degrees of freedom | ||
| + | Residual deviance: 126.341 on 96 degrees of freedom | ||
| + | |||
| + | AIC: 130.3413 | ||
| + | |||
| + | Number of iterations to convergence: | ||
| + | |||
| + | |||
| + | | ||
| + | Data, Fitted, Residual, Studentized Residual, Dffits, Cook's Distance | ||
| + | | ||
| + | | ||
| + | -------------------------------------------------------------------- | ||
| + | JS Turnover fitted residual rstudent | ||
| + | 69 6.00 quit 0.6838 | ||
| + | 7 1.38 stay 0.2225 | ||
| + | 73 5.48 quit 0.6327 | ||
| + | 58 5.43 quit 0.6276 | ||
| + | 12 1.72 stay 0.2493 | ||
| + | 31 1.77 stay 0.2534 | ||
| + | 13 1.96 stay 0.2695 | ||
| + | 1 4.96 quit 0.5783 | ||
| + | 33 4.88 quit 0.5698 | ||
| + | 84 4.66 quit 0.5460 | ||
| + | 63 4.65 quit 0.5449 | ||
| + | 61 2.52 stay 0.3203 | ||
| + | 97 5.59 stay 0.6438 | ||
| + | 70 5.48 stay 0.6327 | ||
| + | 74 2.56 stay 0.3242 | ||
| + | 75 2.57 stay 0.3251 | ||
| + | 67 2.65 stay 0.3329 | ||
| + | 80 5.04 stay 0.5869 | ||
| + | 77 4.46 quit 0.5243 | ||
| + | 39 4.43 quit 0.5210 | ||
| + | |||
| + | |||
| + | | ||
| + | |||
| + | Probability threshold for classification stay: 0.5 | ||
| + | |||
| + | 0: quit | ||
| + | 1: stay | ||
| + | |||
| + | Data, Fitted Values, Standard Errors | ||
| + | | ||
| + | | ||
| + | -------------------------------------------------------------------- | ||
| + | JS Turnover label fitted std.err | ||
| + | 24 0.23 | ||
| + | 88 0.67 | ||
| + | 48 1.05 | ||
| + | 66 1.19 | ||
| + | |||
| + | ... for the rows of data where fitted is close to 0.5 ... | ||
| + | |||
| + | JS Turnover label fitted std.err | ||
| + | 14 4.14 | ||
| + | 27 4.15 | ||
| + | 64 4.26 | ||
| + | 83 4.41 | ||
| + | 39 4.43 | ||
| + | |||
| + | ... for the last 4 rows of sorted data ... | ||
| + | |||
| + | JS Turnover label fitted std.err | ||
| + | 70 5.48 | ||
| + | 73 5.48 | ||
| + | 97 5.59 | ||
| + | 69 6.00 | ||
| + | -------------------------------------------------------------------- | ||
| + | |||
| + | |||
| + | ---------------------------- | ||
| + | Specified confusion matrices | ||
| + | ---------------------------- | ||
| + | |||
| + | Probability threshold for predicting stay: 0.5 | ||
| + | Corresponding cutoff threshold for JS: 4.238 | ||
| + | |||
| + | | ||
| + | --------------------------------------------------- | ||
| + | Total %Tot 0 1 %Correct | ||
| + | --------------------------------------------------- | ||
| + | | ||
| + | Turnover | ||
| + | --------------------------------------------------- | ||
| + | | ||
| + | |||
| + | Accuracy: 58.16 | ||
| + | Sensitivity: | ||
| + | Precision: 44.44 | ||
| + | |||
| + | > | ||
| + | </ | ||
| + | ====== e.g. 2 ====== | ||
| < | < | ||
| head(d) | head(d) | ||
r/logistic_regression_analysis.1701677461.txt.gz · Last modified: by hkimscil
