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

predict with pvc not working #15

Open
alvinwmtan opened this issue Jul 29, 2024 · 1 comment
Open

predict with pvc not working #15

alvinwmtan opened this issue Jul 29, 2024 · 1 comment

Comments

@alvinwmtan
Copy link

alvinwmtan commented Jul 29, 2024

When fitting a gamlss model with pvc(), the predict method doesn't work.

Minimal reprex:

age <- c(17,17,18,18,19,19,17,17,18,18,19,19)
language <- c("eng","eng","eng","eng","eng","eng","spa","spa","spa","spa","spa","spa")
prop <- c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.2, 0.3, 0.4, 0.3, 0.6, 0.6)
df <- data.frame(age = age, language = as.factor(language), prop = prop)

mod <- gamlss(prop ~ pvc(age, by = language, lambda=10000), sigma.fo = prop ~ pvc(age, by = language), data = df)

nd <- expand_grid(age = c(17,18,19), language = c("eng", "spa"))
pred <- predict(mod, newdata = nd, type = "response", data = df)
# Error in l$beta : $ operator is invalid for atomic vectors
# In addition: Warning messages:
# 1: In model.matrix.default(~fac - 1, contrast = "") :
#   non-list contrasts argument ignored
# 2: In model.matrix.default(~fac - 1, contrast = "") :
#   non-list contrasts argument ignored
# 3: In model.matrix.default(~fac - 1, contrast = "") :
#   non-list contrasts argument ignored
@TenanATC
Copy link

TenanATC commented Sep 24, 2024

I've also noticed that pvc() appears to throw those warnings when building the model and would be interested to know if they represent an issue that needs resolution.

Though, it is worth noting that the predict() method works fine when the following model is specified:

mod <- gamlss(prop ~ pvc(age, by = language), data = df)

So, it is not entirely clear to me if the issue resides with pvc() exactly or because there is some sparsity or another issue with overall model specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants