如何通过两个条件对R中的数据帧进行子集化,然后将这些变量应用于回归?

时间:2018-04-24 19:40:31

标签: r regression logistic-regression

我在R中有一个不同变量的数据框,代表比赛,SAT分数,高中GPA,辍学率和性别等指标。我试图使用这些作为右侧输入来回退辍学率。但是,我只是试图为黑人和西班牙裔学生这样做,将黑色编码为" B"和西班牙裔一样" H"在比赛中。

 newdata <- subset(x.20, race %in% c("B", "H"), select=c(race, individual.ind, institutional.ind, male, twohousehold, foreignbornparent, parentdegree, welfare, householdincome, schoolquality, SAT, privateschool, apcourses, socialdistance, peerinfluence, selfefficacy, selfesteem, hsgpa, droppedout))

mylogit <- glm(droppedout ~ race + individual.ind + institutional.ind + male + twohousehold + foreignbornparent + parentdegree + welfare + householdincome + SAT + privateschool + apcourses + hsgpa + schoolquality + socialdistance + peerinfluence + selfefficacy + selfesteem, family = binomial, data=newdata)


stargazer(mylogit, title="Title: Logit Regression Results", type = "latex", single.row = TRUE, header=FALSE, column.sep.width = "1pt", 
         digits = 1, covariate.labels=c("Race"))

上面的代码给出了Stargazer中的回归表,但回归系数与我复制的数据中记录的回归系数大不相同。有谁知道出了什么问题?我是否有效地将所有数据分组为黑色和西班牙语?

0 个答案:

没有答案