View source: R/plot_partialAPCeffects.R
plot_marginalAPCeffects | R Documentation |
Plot the marginal effect of age, period or cohort, based on an APC model
estimated as a semiparametric additive regression model with gam
or bam
.
This function is a simple wrapper to plot_partialAPCeffects
,
called with argument hide_partialEffects = TRUE
.
plot_marginalAPCeffects( model, dat, variable = "age", vlines_vec = NULL, return_plotData = FALSE )
model |
Optional regression model estimated with |
dat |
Dataset with columns |
variable |
One of |
vlines_vec |
Optional numeric vector of values on the x-axis where vertical lines should be drawn. Can be used to highlight the borders of specific age groups, time intervals or cohorts. |
return_plotData |
If TRUE, a list of the datasets prepared for plotting
is returned instead of the ggplot object. The list contains one dataset each
for the overall effect (= evaluations of the APC surface to plot the partial
effects) and for each marginal APC effect (no matter the specified value of
the argument |
ggplot object
Alexander Bauer alexander.bauer@stat.uni-muenchen.de, Maximilian Weigert maximilian.weigert@stat.uni-muenchen.de
Weigert, M., Bauer, A., Gernert, J., Karl, M., Nalmpatian, A., Küchenhoff, H., and Schmude, J. (2021). Semiparametric APC analysis of destination choice patterns: Using generalized additive models to quantify the impact of age, period, and cohort on travel distances. Tourism Economics. doi:10.1177/1354816620987198.
library(APCtools) library(mgcv) data(travel) model <- gam(mainTrip_distance ~ te(age, period), data = travel) plot_marginalAPCeffects(model, dat = travel, variable = "age") # mark specific cohorts plot_marginalAPCeffects(model, dat = travel, variable = "cohort", vlines_vec = c(1966.5,1982.5,1994.5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.