-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for multinomial family in mgcv::gam #418
Comments
Hi, thanks for reporting this - I can't run it because I don't have the df object, but I can reproduce your problem with an example from the help, see below. It is not surprising that you get an error because I haven't implemented any support in DHARMa for multinomial logic or clogit GLMM, as I wasn't really sure how to define quantile residuals for these distributions. The reason why you didn't get a better error straight away is that I overlooked that mgcv also provides a multinomial. On the positive side of things:
I will take a look at this paper and see if that could be implemented in DHARMa. If so, I will report it here. Of course, feel free to add further thoughts on this if you have any. Best
|
Hi Florian, Maybe this way?
Best, |
Hi Wilbert, yes, you can formally do that, and I don't think it will hurt, in the sense that if the model is correctly specified, you should see nothing, but the question is if the standard plots make sense to diagnose problems in the multinomial. I don't think the standard plots are very informative. For example, if standard plots show a dispersion problem, it would likely not be dispersion, but rather a sign that some classes are over predicted. I think in the end I will have to do special tests / plots for multi-class responses. What I could imagine is to transform the res ~ observed plot such that you see a res ~ predicted as done in the last example below for all classes in one plot. What one could also check already would be using the testGeneric if the number of predicted 1,2,3 corresponds to the observed, see also example below. I think it will take some trying around to find out which diagnostics are informative for this type of models!
|
Thanks Florian, A res ~ predicted for all classes in one plot sounds like a good idea. Best, |
Hi,
Thanks for developing and making available the DHARMa package.
I am trying to use this for diagnosing a multinomial gam model:
library(mgcv)
library(DHARMa)
all <- list()
all$formula <- formula(Type ~ s(Frisian_proficiency) +
s(IQ) +
te(IQ , by = Measurement) +
s(Subject, bs="re") +
s(Measurement, bs="re"), data = df)
all$data <- df
f <- replicate(2, update(all$formula, NULL~.))
f[[1]] <- update(f[[1]], Type~.)
model.gam <- gam(f, data=df, family=multinom(2), method="fREML")
summary(model.gam) # works!
simRes <- simulateResiduals(fittedModel = model.gam, plot = F)
Here I get an error:
Error in match.arg(type) : 'arg' should be “deviance”
What solution woud you recommend?
The text was updated successfully, but these errors were encountered: