Skip to content
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

Can we get ga() compatibility? ga() from gamlss.add package #623

Open
pntoiv opened this issue Dec 27, 2024 · 2 comments
Open

Can we get ga() compatibility? ga() from gamlss.add package #623

pntoiv opened this issue Dec 27, 2024 · 2 comments
Labels
reprex 💾 An example (and data) to reproduce the issue is needed to

Comments

@pntoiv
Copy link

pntoiv commented Dec 27, 2024

Hey!

I am using ggeffects 1.7.2.

I tried to create predictions with ggpredict but I ran to this error:

> P <- ggpredict(ModGAMLSS, terms=c("VAR1"), back_transform=T)

Error in names(x) <- value :
'names' attribute [10] must be the same length as the vector [4]

I am using gamlss-package and ga() function to build my model, and my model is something like this:
gamlss(Response~X+ga(s(VAR1)+s(VAR2)+te(VAR3, VAR4)), sigma.fo=~VAR4, data=data, family=LOGNO2)

I believe this is because I used ga() function from gamlss.add package to fit my smooth terms. https://www.rdocumentation.org/packages/gamlss.add/versions/5.1-13/topics/ga

When I use predict(model, type="terms") it is not able to separate the terms in ga() into their own columns. I can extract gam model object with getSmo(model) and when I do that, it is able to separate the smooth terms into their own columns, but ggpredict() doesn't work with the object returned by getSmo():

> P <- ggpredict(getSmo(ModGAMLSS), terms=c("VAR1"), back_transform=T)

Error in model_data[, rn, drop = FALSE]:
! Can't subset columns that don't exist.
✖ Column Y.var doesn't exist.

I really like using ga() when I want to bring my gam() model from mgcv-package to gamlss package.

I wonder if there is a possibility to get ga() compatibility with ggeffects?

@strengejacke strengejacke added the reprex 💾 An example (and data) to reproduce the issue is needed to label Dec 30, 2024
@strengejacke
Copy link
Owner

Do you have a reproducible example?

@pntoiv
Copy link
Author

pntoiv commented Dec 30, 2024

Do you have a reproducible example?

Well, confusingly I edited and subset my data to make a dataset for reproducible example and then it worked (though couldn't compute confidence intervals), so I have no idea why my original data doesn't work. So it must has something to do with the number of variables in the model, as I reduced the number of variables for the subset data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex 💾 An example (and data) to reproduce the issue is needed to
Projects
None yet
Development

No branches or pull requests

2 participants