试图从有序逻辑回归中计算预测概率。但是,我收到以下错误消息:
rep.int(rep.int(seq_len(nx),rep.int(rep.fac,nx)),orep)中的错误: 无效的“时间”值
这是我的代码:
new_data <- expand.grid(public=unique(brfss2013$incomeLev),
public=unique(brfss2013$X_bmi5),
public=unique(brfss2013$X_drnkmo4),
public=unique(brfss2013$X_frutsum),
public=unique(brfss2013$X_vegesum),
public=unique(brfss2013$fc60_))
predict(brfss2_model,new_data,type="probs")
new <- cbind(brfss2_easier, predict(brfss2013, type="probs"))
这是我的数据样本
brfss_2013 <- structure(list(mentalHealth = structure(c(5L, 1L, 1L, 1L, 1L,
1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 5L, 1L, 1L, 1L), .Label = c("Excellent",
"Good", "Ok", "Bad", "Very Bad"), class = "factor"), incomeLev = c("$50,000-$75,000",
"Over $75,000", "Over $75,000", "$50,000-$75,000", "$50,000-$75,000",
"Over $75,000", "missing", "$50,000-$75,000", "Over $75,000",
"$25,000-$35,000", "Over $75,000", "missing", "$50,000-$75,000",
"missing", "missing", "Over $75,000", "0-$20,000", "Over $75,000",
"Over $75,000", "$25,000-$35,000"), X_bmi5 = c(3916L, 1822L,
2746L, 2197L, 3594L, 3986L, 2070L, 2890L, 3017L, 2829L, 2968L,
2776L, 2067L, 2487L, 2976L, 3681L, 2114L, 2281L, 2835L, 2819L
), X_vegesum = c(53, 148, 191, 136, 243, 143, 216, 360, 172,
114, 44, 282, 214, 186, 143, 200, 643, 167, 183, 166), fc60_ = c(442,
506, 474, 417, 406, 512, 575, 442, 557, 392, 614, 491, 360, 423,
416, 379, 620, 404, 531, 416), X_drnkmo4 = c(2L, 0L, 80L, 16L,
20L, 0L, 1L, 2L, 4L, 0L, 5L, 0L, 8L, 2L, 0L, 0L, 0L, 0L, 2L,
10L), X_frutsum = c(413, 20, 46, 49, 7, 157, 150, 67, 100, 58,
13, 414, 100, 14, 43, 100, 0, 50, 40, 100)), row.names = c(NA,
20L), class = "data.frame")