statistics - Displaying factors and levels with logistic regression in R -
i have dataframe model.vars
containing discretized data on perform logistical regression, follows:
for(i in varnames) { modelformula = paste("dep_var~ ", as.factor(i)) modelfits[[i]] = glm(as.formula(modelformula), data=model.vars ,na.action="na.exclude", family=binomial(link = "logit")) }
this gets in turn converted dataframe using
fits = ldply(modelfits, function(x) { as.data.frame((coef(summary(x))), row.names=varnames)})
however, resulting output stored in modelfits
not contain column specifying relevant level labels each discretized variable. rather, like
.id estimate std. error zscore pr(>|z|) abs.zscore 1 twenty_80.age -0.6911487 0.2813814 -2.456270 1.403875e-02 2.4562 2 ten_80_10.age -1.0021909 0.2682952 -3.735403 1.874144e-04 3.735403 3 twenty_80.score -0.7023356 0.3315694 -2.118216 3.415679e-02 2.118216
unfortunately, need output dataframe (not list). best way add, say, column giving level labels? example, printing out raw modelfits
variable has statements like:
coefficients: (intercept) twenty_80.score[ 11, 19) twenty_80.score[ 19, 31) twenty_80.score[ 31,312]
i these listed in fits
dataframe above well.
Comments
Post a Comment