Closed ghost closed 2 years ago
Do you have a minimal reproducible example for this?
library(APCtools)
library(mgcv)
data(travel)
# Model formula with conversion:
travel$residence_region <- as.character(travel$residence_region)
model <- gam(mainTrip_distance ~ te(age, period) + as.factor(residence_region) +
household_size + s(household_income), data = travel)
plot_marginalAPCeffects(model, dat = travel, variable = "age")
plot_linearEffects(model)
# Model formula without conversion:
travel$residence_region <- as.factor(travel$residence_region)
model2 <- gam(mainTrip_distance ~ te(age, period) + residence_region +
household_size + s(household_income), data = travel)
plot_marginalAPCeffects(model2, dat = travel, variable = "age")
plot_linearEffects(model2)
Sorry for the delay. I haven't had this issue in mind anymore. The first call of plot_marginalAPCeffects
leads to an error. This is caused by extracting covariate names from the model formula. A column named as.factor(residence_region)
cannot be found. I'll try to find a simple fix.
@bauer-alex I fixed this issue by removing the text outside the brackets. If this ok for you, please close the issue.
plot_marginalAPCeffects cannot handle models where a variable is converted in the model formula (e.g. through as.factor), and throws out an error. plot_smoothEffects and plot_linearEffects do not have this kind of problem.