From 6eaa47405268f048ecdb0a49be149fc42804b87c Mon Sep 17 00:00:00 2001 From: ConnorDonegan Date: Wed, 4 Dec 2024 11:57:38 -0600 Subject: [PATCH] cleanup --- R/convenience-functions.R | 4 ++-- vignettes/raster-regression.Rmd | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/R/convenience-functions.R b/R/convenience-functions.R index 3fb3ddd5..24f8707f 100644 --- a/R/convenience-functions.R +++ b/R/convenience-functions.R @@ -171,7 +171,7 @@ sim_sar <- function(m = 1, w, type = c("SEM", "SLM"), approx = FALSE, - K = 15, + K = 20, ...) { check_sa_data(mu, w) type <- match.arg(type) @@ -625,7 +625,7 @@ me_diag <- function(fit, } } -#' Extract eigenfunctions of a connectivity matrix for spatial filtering +#' Prepare data for spatial filtering #' #' @export #' @param C A binary spatial weights matrix. See \code{\link[geostan]{shape2mat}}. diff --git a/vignettes/raster-regression.Rmd b/vignettes/raster-regression.Rmd index d869ab51..31f4afda 100644 --- a/vignettes/raster-regression.Rmd +++ b/vignettes/raster-regression.Rmd @@ -122,8 +122,10 @@ sar_list <- prep_sar_data2(row = row, col = col) W <- sar_list$W z <- sim_sar(rho = .8, w = W, quick = TRUE) -y <- sim_sar(mu = -.5 * z, rho = .9, w = W, quick = TRUE) +y <- sim_sar(mu = -.5 * z, rho = .7, w = W, quick = TRUE) dat <- cbind(y, z) ``` +The approximate method uses matrix powers, and for high values of SA (especially values of rho greater than 0.9) the approximation is sensitive to the number of powers taken. In `sim_sar` this is controlled by the argument `K`. For `rho = 0.9`, you may need to raise the default value of K for the approximation to hold. Notice that $0.9^{45} = 0.009$, which is near zero and should provide sound results, whereas $0.9^25 = 0.07$ which is not quite there, and $0.9^{15} = 0.2$ will be completely inadequate. In geostan 0.8.0, the default is $K = 20$. + ## References