0
$\begingroup$

I am trying to fit a GAM model to predict CSAT (customer satisfaction scores on a scale of 0 to 10) which I believe are ordinal in nature. I used a categorical predictor (type) and two numeric predictors (duration, difference) which I believe have non-linear relationship to csat scores.

  gam_model = gam(
  csat_score ~ type + s(duration) + s(difference),
  family = ocat(R = 11), # since we have 11 possible values i.e. 0 to 10
  data = train_data)

However the above code throws error, which I couldn't figure out. I checked my data and it does have responses from 0 to 10 (all 11 of them are present) . No variables have missing values or outliers.

Error in eval(family$initialize) : values out of range

Structure of the dataset is as below:

csat_score : num [1:200] 8 9 9 9 10 ...
type : Factor w/ 4 levels "A","B".. 
duration : num [1:200] 3.75 3.75 4.52 ...
difference : num [1:200] -3.75 -3.75 -2.98 -5.25 ...

Can you please help me with :

  1. Is this the right approach to predict CSAT scores using GAM ?
  2. Why am I getting this error & how can I fix it?
  3. Should I convert the response variable (csat_score) to categorical type?

Thank you.

$\endgroup$

1 Answer 1

1
$\begingroup$

From ?mgcv::ocat:

The observed categories are coded 1, 2, 3, ... up to the number of categories.

I presume you used the CSAT scores as is (i.e. including a 0), which is not what is required for this model/family.

You shouldn't convert this response to be a factor; it needs to be an integer.

$\endgroup$
1
  • $\begingroup$ Thank you @Gavin. That worked once I changed the categories to 1 to 11. $\endgroup$
    – Math Lover
    Commented Oct 19, 2023 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.