# NOT RUN {
## subset to only include id, class name and distance variables
distdata <- homog_longitudinal_bef_data[,c("subj_ID","measure_ID","class","dist")]
timedata <- homog_longitudinal_bef_data[,c("subj_ID","measure_ID","class","time")]
## distance or time column must be numeric
timedata$time <- as.numeric(timedata$time)
fit <- stap_glmer(y_bern ~ centered_income + sex + centered_age + stap(Coffee_Shop) + (1|subj_ID),
family = binomial(link='logit'),
subject_data = homog_longitudinal_subject_data,
distance_data = distdata,
time_data = timedata,
subject_ID = 'subj_ID',
group_ID = 'measure_ID',
prior_intercept = normal(location = 25, scale = 4, autoscale = F),
prior = normal(location = 0, scale = 4, autoscale=F),
prior_stap = normal(location = 0, scale = 4),
prior_theta = list(Coffee_Shop = list(spatial = log_normal(location = 1,
scale = 1),
temporal = log_normal(location = 1,
scale = 1))),
max_distance = 3, max_time = 50,
chains = 4, refresh = -1, verbose = FALSE,
iter = 1E3, cores = 1)
# }
Run the code above in your browser using DataLab