diagnostic_plots | R Documentation |
diagnostic_plots
diagnostic_plots( df, X = "X", Y = "Y", time = "time", pred = "pred", resid = "resid", demean_time = TRUE )
df |
Dataframe, containing locations, time, and predictions |
X |
Character string containing the name of X variable |
Y |
Character string containing the name of Y variable |
time |
Character string containing the name of time variable |
pred |
Character string containing the name of prediction variable |
resid |
Character string containing the name of residual |
demean_time |
Boolean, whether or not to remove temporal means (similar to fixed time effects). Defaults to TRUE |
A list of ggplot objects that can be manipulated further
set.seed(2021) d <- data.frame( X = runif(1000), Y = runif(1000), year = sample(1:10, size = 1000, replace = TRUE) ) d$density <- rnorm(0.01 * d$X - 0.001 * d$X * d$X + d$Y * 0.02 - 0.005 * d$Y * d$Y, 0, 0.1) m <- mgcv::gam(density ~ 0 + as.factor(year) + s(X, Y), data = d) d$pred <- predict(m) # d$resid = residuals(m) # # the default names match, with the exception of year -- so change it # plots <- diagnostic_plots(d, time="year")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.