Description Usage Arguments Value See Also Examples
GAM plotting using ggplot2
| 1 2 | 
| gamFit | fitted gam model as produced by mgcv::gam() | 
| smooth.cov | (character) name of smooth term to be plotted | 
| groupCovs | (character) name of group variable to plot by, if NULL (default) then there are no groups in plot | 
| orderedAsFactor | if TRUE then the model is refitted with ordered variables as factors. | 
| rawOrFitted | If FALSE (default) then only smooth terms are plotted; if rawOrFitted = "raw" then raw values are plotted against smooth; if rawOrFitted = "fitted" then fitted values are plotted against smooth | 
| plotCI | if TRUE (default) upper and lower confidence intervals are added at 2 standard errors above and below the mean | 
Returns a ggplot object that can be visualized using the print() function
Other Plotting: plotGAMM
| 1 2 3 4 5 6 7 8 9 10 11 12 | data <- data.frame(x = rep(1:20, 2), group = rep(1:2, each = 20))
set.seed(1)
data$y <- (data$x^2)*data$group*3 + rnorm(40, sd = 200)
data$group <- ordered(data$group)
gam <- mgcv::gam(y ~ s(x) + group, data=data)
plot1 <- plotGAM(gamFit = gam, smooth.cov = "x", groupCovs = NULL,
                  rawOrFitted = "raw", plotCI=TRUE, orderedAsFactor = FALSE)
gam <- mgcv::gam(y ~ s(x) + group + s(x, by=group), data=data)
plot2 <- plotGAM(gamFit = gam, smooth.cov = "x", groupCovs = "group",
                             rawOrFitted = "raw", orderedAsFactor = FALSE)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.