R Under development (unstable) (2024-11-15 r87338 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.0 > > 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.08, 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: The largest R-hat is 1.14, 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 > > print(rbind(dic(sdlm), dic(sdem))) DIC penalty [1,] 903.5 4.3 [2,] 903.0 4.1 > print(rbind(waic(sdlm), waic(sdem))) WAIC Eff_pars Lpd [1,] 902.06 2.15 -448.88 [2,] 901.49 2.07 -448.67 > > > # 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.57 0.45 8.01