moran_ts | R Documentation |
moran_ts
moran_ts( df, time = "time", X = "X", Y = "Y", response = "pred", scaled = FALSE, alpha = 0.05 )
df |
Dataframe, containing locations, time, and predictions |
time |
Character string containing the name of time variable |
X |
Character string containing the name of X variable |
Y |
Character string containing the name of Y variable |
response |
The response to use for the Moran test. Name of variable in 'df', defaults to "pred" |
scaled |
Boolean, whether to use scaled (standardized) values in Moran statistic defaults to FALSE |
alpha |
Alpha level for significance test, defaults to 0.05 |
pred |
Character string containing the name of resonse variable to test |
A ggplot object 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$resid <- resid(m) d$pred <- predict(m) # the default names match, with the exception of year -- so change it moran_ts(d, time = "year", response = "pred") moran_ts(d, time = "year", response = "resid")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.