Skip to content

Instantly share code, notes, and snippets.

@dmontecino
dmontecino / gist:b804853e4b36a57990a7108a35201cf5
Last active October 20, 2021 17:40
STAN Imputation of a categorical covariate when non-observed and modeling of a binary outcome
### Categorical missing data in Stan ###
library(rstan)
N <- 10000
N_missing <- 100
K <- 3 # number of categories
x <- sample( seq(from=1,to=K), size=N, replace=TRUE ) # unordered cateogrical covariate
# Simulating bivariate respose as function of a categorcial variable