pred_space
pred_space(
df,
X = "X",
Y = "Y",
time = "time",
pred = "pred",
demean_time = TRUE,
by_time = TRUE
)
Dataframe, containing locations, time, and predictions
Character string containing the name of X variable
Character string containing the name of Y variable
Character string containing the name of time variable
Character string containing the name of prediction variable
Boolean, whether or not to remove temporal means (similar to fixed time effects). Defaults to TRUE
Whether to facet by time (default = TRUE) or not
A ggplot object that can be manipulated further
# \donttest{
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)
pred_space(df = d, time = "year")
# }