User Tools

Site Tools


logit_analysis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
logit_analysis [2019/09/15 02:41] – created hkimscillogit_analysis [2019/09/15 02:54] hkimscil
Line 1: Line 1:
-====== logit analysis ======+====== Logit Analysis ====== 
 +https://stats.idre.ucla.edu/r/dae/logit-regression/
 <code> <code>
 mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv") mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
Line 43: Line 44:
 <code>xtabs(~admit + rank, data = mydata)</code> <code>xtabs(~admit + rank, data = mydata)</code>
  
-<code> xtabs(~admit + rank, data = mydata)+<code>> xtabs(~admit + rank, data = mydata)
      rank      rank
 admit  1  2  3  4 admit  1  2  3  4
Line 49: Line 50:
     1 33 54 28 12     1 33 54 28 12
 </code> </code>
 +
 +<code>mydata$rank <- factor(mydata$rank)
 +mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = "binomial")
 +summary(mylogit)
 +</code>
 +
 +<code>
 +Call:
 +glm(formula = admit ~ gre + gpa + rank, family = "binomial", 
 +    data = mydata)
 +
 +Deviance Residuals: 
 +    Min       1Q   Median       3Q      Max  
 +-1.6268  -0.8662  -0.6388   1.1490   2.0790  
 +
 +Coefficients:
 +             Estimate Std. Error z value Pr(>|z|)    
 +(Intercept) -3.989979   1.139951  -3.500 0.000465 ***
 +gre          0.002264   0.001094   2.070 0.038465 *  
 +gpa          0.804038   0.331819   2.423 0.015388 *  
 +rank2       -0.675443   0.316490  -2.134 0.032829 *  
 +rank3       -1.340204   0.345306  -3.881 0.000104 ***
 +rank4       -1.551464   0.417832  -3.713 0.000205 ***
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +(Dispersion parameter for binomial family taken to be 1)
 +
 +    Null deviance: 499.98  on 399  degrees of freedom
 +Residual deviance: 458.52  on 394  degrees of freedom
 +AIC: 470.52
 +
 +Number of Fisher Scoring iterations: 4
 +
 +> </code>
 +
 +<code>
 +> confint(mylogit)
 +Waiting for profiling to be done...
 +                    2.5 %       97.5 %
 +(Intercept) -6.2716202334 -1.792547080
 +gre          0.0001375921  0.004435874
 +gpa          0.1602959439  1.464142727
 +rank2       -1.3008888002 -0.056745722
 +rank3       -2.0276713127 -0.670372346
 +rank4       -2.4000265384 -0.753542605
 +
 +</code>
 +
 +<code>> ## CIs using standard errors
 +> confint.default(mylogit)
 +                    2.5 %       97.5 %
 +(Intercept) -6.2242418514 -1.755716295
 +gre          0.0001202298  0.004408622
 +gpa          0.1536836760  1.454391423
 +rank2       -1.2957512650 -0.055134591
 +rank3       -2.0169920597 -0.663415773
 +rank4       -2.3703986294 -0.732528724
 +</code>
 +
 +<code>wald.test(b = coef(mylogit), Sigma = vcov(mylogit), Terms = 4:6)</code>
 +
 +<code>l <- cbind(0, 0, 0, 1, -1, 0)
 +wald.test(b = coef(mylogit), Sigma = vcov(mylogit), L = l)
 +</code>
 +
 +{{tag> statistics r "logit statistics" "multiple regression"}}
 +

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki