R: na.action=na.exclude not working with mlogit

痞子三分冷 提交于 2020-01-23 17:18:28

问题


I am trying to add the fitted values of my multinomial logistic regression to the original data frame (called "ORDERS"). Unfortunately this is not possible, as apparently the predicted probabilities and the data frame don't have the same length - even though I use na.exclude in the regression. Maybe this has something to do with the necessary mlogit.data transformation, so that na.exclude does not work?

mlModel_refPRE_STD <- mlogit(PAYMENT_METHOD ~ 1 | GROSS_RETAIL_TOTAL_STD + SOLVENCY_SCORE_STD + GENDER + EXISTING_CUSTOMER, data=mlORDERS, reflevel="PRE", na.action=na.exclude)

> ORDERS$predicted.probabilities <- fitted(mlModel_refPRE_STD) #
Error in `$<-.data.frame`(`*tmp*`, "predicted.probabilities", value = c(0.0168546281869084,  : 
  replacement has 129159 rows, data has 129372

> length(mlModel_refPRE_STD$fitted.values)
[1] 129159
> length(ORDERS$SOLVENCY_SCORE_STD)
[1] 129372

(All other variables in the regression also have length 129372)

来源:https://stackoverflow.com/questions/43609803/r-na-action-na-exclude-not-working-with-mlogit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!