我希望从有序logit模型中获得预测概率。
代码:
if [ "$(egrep -n 'end balance: [0-9.]' ./simulations/*.html)" -gt 1000 ]; then
echo ' end balance bigger than 1000 '
else
echo ' end balance less than 1000 '
fi
运行此操作后,会显示警告:
library(plyr)
library(forcats)
library(MASS)
library(tidyverse)
library(dplyr)
zz <- "DV IV1 IV2 year
1 51 0 1987
2 49 1 1988
3 47 0 1990
5 50 0 1991
5 54 1 1992
1 23 0 1993
3 15 0 1994"
Data <- read.table(text=zz, header = TRUE)
Data <- mutate(Data, DV=as.ordered(DV))
order <- polr(DV ~ IV1 + IV2 + IV1*IV2 + factor(year), data=Data,
method = "logistic", Hess = TRUE)
然后我跑:
Warning message:
In polr(DV ~ IV1 + IV2 + IV1 * IV2 + factor(year), data = Data, :
design appears to be rank-deficient, so dropping some coefs
R回应:
colMeans(predict(order, type="probs",
newdata=mutate(Data, IV2=1, IV1=50)), na.rm=TRUE)
我尝试了没有“因子(年)”的线性模型,然后错误消失了。但是“因素(年)”应该被包含在模型中以解决时间序列问题。如何在没有“不一致的参数”错误的情况下包含它?