Logistic regression, also known as logit regression, is what you use when your outcome variable (dependent variable) is dichotomous

Rather than estimate beta sizes, the logistic regression estimates the probability of getting one of your two outcomes (i.e., the probability of voting vs. not voting) given a predictor/independent variable(s). For our purposes

Poisson regression, also known as a log-linear model, is what you use when your outcome variable is a count (i.e., numeric, but not quite so wide in range as a continuous variable.)

``````mydata <- read.csv('C:/Users/hrd/Desktop/bootcamp/dataset/binary.csv')

``````mydata\$rank <- factor(mydata\$rank)
mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = "binomial")
summary(mylogit)``````

• 结果中首先会提示你跑的什么模型

• 然后我们会看到deviance residuals，这个和线性回归的残差一个意思，是表示模型好坏的一个指标

• 然后就是各个预测变量的系数和标准误，z统计量和p值，我们可以看到gpa,gre和rank都有显著意义，系数的解释就是预测变量每增加一个单位，LogOR的改变量，比如对于gre就有学生的gre每增加一个单位，那么它被录取为研究生的概率增加exp0.002倍。

``exp(cbind(OR = coef(mylogit), confint(mylogit)))``

``````newdata1 <- with(mydata, data.frame(gre = mean(gre), gpa = mean(gpa), rank = factor(1:4)))
newdata1\$rankP <- predict(mylogit, newdata = newdata1, type = "response")
newdata1``````

``````newdata2 <- with(mydata, data.frame(gre = rep(seq(from = 200, to = 800, length.out = 100),
4), gpa = mean(gpa), rank = factor(rep(1:4, each = 100))))``````

``````newdata3 <- cbind(newdata2, predict(mylogit, newdata = newdata2, type = "link",
se = TRUE))``````

``````newdata3 <- within(newdata3, {
PredictedProb <- plogis(fit)
LL <- plogis(fit - (1.96 * se.fit))
UL <- plogis(fit + (1.96 * se.fit))
})``````

``````ggplot(newdata3, aes(x = gre, y = PredictedProb)) + geom_ribbon(aes(ymin = LL,
ymax = UL, fill = rank), alpha = 0.2) + geom_line(aes(colour = rank),
size = 1)``````

If you are a student and you are worried about you statistical #Assignments, #Data #Analysis, #Thesis, #reports, #composing, #Quizzes, Exams.. And if you are facing problem in #SPSS, #R-Programming, #Excel, Mplus, then contact me. Because I could provide you the best services for your Data Analysis.

Are you confused with statistical Techniques like z-test, t-test, ANOVA, MANOVA, Regression, Logistic Regression, Chi-Square, Correlation, Association, SEM, multilevel model, mediation and moderation etc. for your Data Analysis...??

Then Contact Me. I will solve your Problem...