R Under development (unstable) (2025-07-15 r88411 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 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. > > ## > ## models with missing outcome data > ## > > #devtools::load_all("~/dev/geostan") > library(geostan) This is geostan version 0.8.2 > > iter = 25 > > # CAR Poisson model > data(georgia) > C <- shape2mat(georgia, "B", quiet = TRUE) > cars <- prep_car_data(C, quiet = TRUE) > N = nrow(georgia) > georgia$deaths.female[sample.int(N, size = 12)] <- NA > georgia$deaths.female[sample.int(N, size = 3)] <- 0 > > fit <- stan_car(deaths.female ~ offset(log(pop.at.risk.female)), + data = georgia, + car_parts = cars, + chains = 1, + family = poisson(), + iter = iter, + quiet = TRUE) |> + suppressWarnings() 15 NA values identified in the outcome variable Found in rows: 19, 26, 28, 32, 36, 45, 49, 55, 89, 108, 110, 126, 140, 157, 158 > > > # Binomial model with missing y > data(georgia) > A = shape2mat(georgia, "B") Contiguity condition: queen Number of neighbors per unit, summary: Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 4.000 5.000 5.409 6.000 10.000 Spatial weights, summary: Min. 1st Qu. Median Mean 3rd Qu. Max. 1 1 1 1 1 1 > N = nrow(A) > georgia$deaths.female[sample.int(N, size = 25)] <- NA > georgia$y <- round(georgia$deaths.female / 10) > georgia$y[sample.int(N, 5)] <- 0 > georgia$f <- round(4 * georgia$deaths.female / 10) > > > # glm > fit <- stan_glm(cbind(y, f) ~ 1, + data = georgia, + chains = 1, + family = binomial(), + iter = iter, + quiet = TRUE) |> + suppressWarnings() 28 NA values identified in the outcome variable Found in rows: 2, 10, 12, 16, 27, 30, 36, 37, 40, 46, 51, 55, 58, 67, 81, 83, 92, 93, 102, 109, 115, 126, 131, 140, 143, 150, 153, 157 > > # icar > fit <- stan_icar(cbind(deaths.female, pop.at.risk.female) ~ 1, + data = georgia, + type = 'bym', + C = A, + chains = 1, + family = binomial(), + iter = iter, + quiet = TRUE) |> + suppressWarnings() 28 NA values identified in the outcome variable Found in rows: 2, 10, 12, 16, 27, 30, 36, 37, 40, 46, 51, 55, 58, 67, 81, 83, 92, 93, 102, 109, 115, 126, 131, 140, 143, 150, 153, 157 > > # esf > data(georgia) > georgia$deaths.female[1:10] <- NA > georgia$y <- georgia$deaths.female > georgia$f <- round(4 * georgia$deaths.female) > > fit <- stan_esf(cbind(y, f) ~ log(income), + data = georgia, + C = shape2mat(georgia, "B"), + chains = 1, + family = binomial(), + iter = iter, + quiet = TRUE) |> + suppressWarnings() Contiguity condition: queen Number of neighbors per unit, summary: Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 4.000 5.000 5.409 6.000 10.000 Spatial weights, summary: Min. 1st Qu. Median Mean 3rd Qu. Max. 1 1 1 1 1 1 13 NA values identified in the outcome variable Found in rows: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 55, 126, 157 > > > proc.time() user system elapsed 13.53 0.93 15.31