0

I've got a simple question I hope.

I'm trying to assign predicted factor levels from an ordinal logistic regression to a variable in order to calculate the hit-rate of the model. I used the following code:

telecomdata$predfpm1 <- predict(fpm1,type = "class") 
FPM is an ordered logistic regression as presented below:
fpm1 <- clm(proposition ~ DMpropHigh + age + rel_length + education + gender + income + num_phones + arpu_index + calls_out_6_index + calls_in_6_index + calls_6_index + DM , data = telecomdata) 

enter image description here

The output can be found above. The numbers look okay, but the format is wrong. R now creates a list of factors for each observation, rather than assigning each individual predicted value to an observation. Can anyone help me with how to fix this?

  • 2
    What type of object is `fpm1`? When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick May 07 '18 at 20:08
  • fpm1 is an ordered logistic regression: fpm1 <- clm(proposition ~ DMpropHigh + age + rel_length + education + gender + income + num_phones + arpu_index + calls_out_6_index + calls_in_6_index + calls_6_index + DM , data = telecomdata) – Daniël Lutjens May 07 '18 at 20:10
  • 2
    you probably want `predict(fpm1, type="class")$fit` as the prediction object returns a list. See the help page `?predict.clm`, under the `value` section it details what the function returns *"A list containing the ... "* – user20650 May 07 '18 at 20:16

0 Answers0