R Under development (unstable) (2024-12-03 r87418 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## > ## spatial econometric models and model comparison with DIC, WAIC, and model probabilities. N = 520 > ## > > #devtools::load_all("~/dev/geostan") > > library(geostan) This is geostan version 0.8.1 > > row = 12 > col = 26 > N <- row * col > sdl <- prep_sar_data2(row = row, col = col, quiet = TRUE) > w <- sdl$W > x <- sim_sar(w = w, rho = .5) > mu = (.5 * x - .25 * w %*% w)[,1] > y <- sim_sar(w = w, rho = .5, mu = mu) > df <- data.frame(y=y, x=x) > > iter = 175 > > sdlm <- stan_sar(y ~ x, + data = df, + type = "SDLM", + sar_parts = sdl, + chains = 1, + iter = iter, + quiet = TRUE, + keep_all = TRUE, + slim = F) Warning messages: 1: The largest R-hat is 1.05, indicating chains have not mixed. Running the chains for more iterations may help. See https://mc-stan.org/misc/warnings.html#r-hat 2: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. Running the chains for more iterations may help. See https://mc-stan.org/misc/warnings.html#bulk-ess 3: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. Running the chains for more iterations may help. See https://mc-stan.org/misc/warnings.html#tail-ess > > sdem <- stan_sar(y ~ x, + data = df, + type = "SDEM", + sar_parts = sdl, + chains = 1, + iter = iter, + quiet = TRUE, + keep_all = TRUE, + slim = F) Warning messages: 1: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. Running the chains for more iterations may help. See https://mc-stan.org/misc/warnings.html#bulk-ess 2: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. Running the chains for more iterations may help. See https://mc-stan.org/misc/warnings.html#tail-ess > > print(rbind(dic(sdlm), dic(sdem))) DIC penalty [1,] 899.7 4.3 [2,] 900.2 4.8 > print(rbind(waic(sdlm), waic(sdem))) WAIC Eff_pars Lpd [1,] 898.21 2.17 -446.94 [2,] 898.63 2.39 -446.93 > > > # library(bridgesampling) > # sdlm <- bridge_sampler(sdlm$stanfit) > # sdem <- bridge_sampler(sdem$stanfit) > # cat("post_prob (SDLM, SDEM):\n", post_prob(sdlm, sdem), "\n") > > > proc.time() user system elapsed 7.78 0.43 8.17