I'm using R to construct an ordinal logistic regression model for response variable "Total.Spent".
First up, I'm aware that the lowest level for "Total.Spent" should be "$0 - $499" to avoid ambiguity but this isn't material to my problem.
Because the response variable is ordinal, and the model calculates cumulative probability, I need to get the levels for the response variable in the correct order. The default order is $0-$500, $1,000-$2,499, $2,500-$4,999, $5,000+, $500-$999. There are missing values in the data set.
I've reordered one of the predictor variables "Month", (and the code returns the expected result),but when I attempt to re-order the response variable, the values in my "Total.Spent" column in my data frame are removed, giving me an empty column.
Here's the code I've used:
# Re-order Month so that months appear in calendar order, beginning in April
months_in_survey_year_order <- c("April", "May", "June", "July", "August", "September",
"October", "November", "December", "January",
"February", "March")
KI_Data$Month <- factor(KI_Data$Month,
levels = months_in_survey_year_order)
# Re-order Total.Spent so that the levels appear in the correct order
spend_in_order <- c("$0 - $500", "$500 - $999", "$1,000 - $2,499",
"$2,500 - $4,999", "$5,000+")
KI_Data$Total.Spent <- factor(KI_Data$Total.Spent,
levels = spend_in_order) # This line is deleting all of the Total.Spent values
I have no idea what's going on to cause the values in KI_Data$Total.Spent to disappear. I'm wondering whether it's because this is the model's response variable? Maybe it's because there's missing values in the data set? Or is there something else going on?
I'd appreciate any guidance.
Thanks, Kirsten