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

2019-07-29 08:24发布

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)

标签: r mlogit
0条回答
登录 后发表回答