1 Preamble

This document contains all code associated with the “Does subjective stress cause criminal intent” paper (Brauer, Day, & Kotlaja), including data wrangling, modeling, and visualizations. Warning: the document is long - excessively so - because it is intended to serve as a digital lab notebook of sorts that transparently documents decisions made as we navigated through the garden of forking paths on the way to publication. Some readers may appreciate this format, while others will not; c’est la vie.

In order to successfully knit into a single document, the full code was separated into several “child” RMD files that were compiled and sequentially knitted within this “mother” document. Further, within those separate child files, many additional files (e.g., modified datasets; model fits; posterior contrasts) were cached in various subfolders to reduce memory and computational demands and drastically speed up processing. All cached files may be deleted then, upon deletion, may be subsequently cached again by, e.g., running each individual “child” file. However, the full document will take a substantial amount of computational resources and time to run with the cached files, so delete these at your own risk. Also, you will need a computer with sufficient memory and processing power to render the final merged document (for comparison, I used a Dell XPS with Intel i9 2.4GHz processor & 32GB of RAM).

Also, final manuscript writing and pre-publication review inevitably result in changes. I plan to include any major additions to code and results; however, such changes could result in labeling misalignment between this document and the text. For example, initially I had generated DAGs outside this lab notebook, but ultimately decided to include them in the supplement and add them as a formal “Figure 1” in the manuscript. As a result, this “bumped” each figure label by one in the manuscript: Figure 1 in this supplement is now labeled as Figure 2 in the current manuscript; Figure 2 in the supplement is Figure 3 in the manuscript, and so on. After pre-publication review and (hopefully) acceptance, I hope to find time to relabel everything to match.

With all that said, buckle up for a bumpy ride.

2 Figure 1: Stress distributions (RQ1A)

(RMD FILE: BDK_2023_Stress_1_Fig1)

2.1 Reading Data, Packages, & Options

Load libraries & settings

#Load necessary libraries and set options. 

# Start by installing "here" and "groundhog" packages if not installed
# initial_packages <- c("here", "groundhog")
# # Install packages not yet installed
# installed_packages <- initial_packages %in% rownames(installed.packages())
# if (any(installed_packages == FALSE)) {
#   install.packages(initial_packages[!installed_packages])
# }

#If using groundhog, then load necessary libraries with "here" & "groundhog": 

library(here)
  #start by loading here package for self-referential file directory structure
# library(groundhog)  
  # load groundhog package for reproducible date-specified library loading  
# here()
  # check here() working directory 
# get.groundhog.folder()    
  # check default groundhog working directory - may be diff than here() 
# set.groundhog.folder(here())
  # set groundhog working directory to same as here()
# groundhog.day="2024-07-15"
  # assign date as object (at least two days b4 today)
  # NOTE: must set date at least two *months* b4 today w/github install 

# groundhog inconsistent after v3 update; removed from workflow Feb 2024
  # commented out but kept script to help future reproductions

# groundhog.library("
library('tidyverse')
library('haven')
library('rstanarm')
library('brms')
library('bayesplot')
library('tidybayes')
library('modelr')
library('scico')
library('ggdist')
library('ggridges')
library('ggpubr')
library('ggnewscale')
library('viridis')
library('rstan')
library('StanHeaders')
library('parallel')
library('parallelly')
library('future')
library('emmeans')
library('patchwork')
library('mirt')
library('bmlm')
library('mediation')
library('bayestestR')
library('qgraph')
library('summarytools')
library('ggstance')
library('gridGraphics')
library('grid')
library('gridExtra')
library('xfun')
library('ggh4x')
library('cmdstanr')
library('polycor')
library('latticeExtra')
library('gt')
library(modelsummary)
library(naniar)
# ", groundhog.day)

#library(MASS) #conflicts w/select(), if attached, call dplyr::select()
#library(psych) #conflicts with alpha (figure transparency)

#NOTE: brm() models specified with "cmdstanr" backend instead of "rstan" for compiling
  # Need to install RTools(4.3) outside R first to get cmdstanr to work. See:
  # https://mc-stan.org/cmdstanr/articles/cmdstanr.html
  # Once loaded, additional steps may be necessary to install cmdstan. 
  # E.g., run following to install cmdstanr, load library, & check cmdstan: 
# install.packages("cmdstanr",repos = c("https://mc-stan.org/r-packages/",
#                                       getOption("repos")))
# library(cmdstanr) 
# cmdstanr::check_cmdstan_toolchain(fix = TRUE)
# check_cmdstan_toolchain()

#set default knit & scientific notation options
knitr::opts_chunk$set(echo=TRUE, warning=FALSE, message=FALSE, fig.align="center")
options(scipen = 999, digits = 2) #set global option to two decimals 

# identify & set # of available cores
  # replaced parallel::detectCores()
  # https://www.jottr.org/2022/12/05/avoid-detectcores/
nCoresphys <- parallelly::availableCores(logical = FALSE) 

theme_set(bayesplot::theme_default())
options(mc.cores = parallelly::availableCores(logical=FALSE))
#options(mc.cores = 4, logical=FALSE)
  #alt: can specify exact number of cores desired here &/or in models/ppchecks   

# graphics.off() # This closes all of R's graphics windows.
# rm(list=ls())  # Careful! This clears all of R's memory!

print("T/F: Root 'here()' folder contains subfolder 'Output'")
## [1] "T/F: Root 'here()' folder contains subfolder 'Output'"
#check for Output folder to save figures, create if one does not exist
ifelse(dir.exists(here("Output")), TRUE, dir.create(here("Output")))
## [1] TRUE

Read data & create mean/median-split indicators for community SES

#NOTE: COMMENTED OUT SCRIPT BELOW SAVES ANALYSIS SUBSET FROM ORIGINAL FULL DATASET FOR PUBLIC SHARING
  # ANALYSIS DATASET SAVED AND SHARED (/1_Data_Files/stress_dat.Rdata)
  # (FULL ORIGINAL SPSS DATAFILE IS INCLUDED HERE)

# stress_dat <- read_spss(here("1_Data_Files/Datasets",'Merged_Bangladesh_Data_W12.sav'))
# names(stress_dat) <- tolower(names(stress_dat))
# stress_dat <- stress_dat %>%
#   dplyr::select(
#     slno, centerw1, centerw2, w_now1, n_villw1, #id vars
#     q10_1w1, q10_2w1, q10_3w1, q10_4w1,
#     q10_5w1, q10_6w1, q10_7w1,               #stress w1
#     q10_1w2, q10_2w2, q10_3w2, q10_4w2,
#     q10_5w2, q10_6w2, q10_7w2,               #stress w2
#     q25_1w1, q25_2w1, q25_4w1,
#     q25_5w1, q25_6w1, q25_8w1,               #past crime w1
#     q25_1w2, q25_2w2, q25_4w2,
#     q25_5w2, q25_6w2, q25_7w2,               #past crime w2
#     q26_1w1, q26_2w1, q26_4w1,
#     q26_5w1, q26_6w1, q26_8w1,               #criminal intent w1
#     q26_1w2, q26_2w2, q26_4w2,
#     q26_5w2, q26_6w2, q26_7w2,               #criminal intent w2
#     q12_1w1, q12_2w1, q12_3w1, q12_4w1,
#     q12_5w1, q12_6w1, q12_7w1,               #negative emotions w1
#     q12_1w2, q12_2w2, q12_3w2, q12_4w2,
#     q12_5w2, q12_6w2, q12_7w2,               #negative emotions w2
#     q11_1w1, q11_2w1, q11_3w1,
#     q11_6w1, q11_7w1, q11_8w1,               #financial hardship/SES w1
#     q11_1w2, q11_2w2, q11_3w2,
#     q11_6w2, q11_7w2, q11_8w2,               #financial hardship/SES w2
#     q1w1, areaw1, areaw2, q2w1, q7w1, q8khaw1, q5w1  #basic demographics
#   ) %>%
#   mutate(                   #Community-level area ID (urban ward/rural village)
#     wardvill = w_now1 + n_villw1
#     ) %>%
#   group_by(wardvill) %>%                      #generate anonymous area ID
#   mutate(area_id = cur_group_id()) %>%
#   ungroup() %>%
#   rename(
#     id = slno,
#     agew1 = q2w1,                             #rename demographics
#     educw1 = q7w1, 
#     kidsw1 = q8khaw1, 
#     stmonyw1 = q10_4w1,                       #rename stress items
#     stmonyw2 = q10_4w2, 
#     sttranw1 = q10_5w1, 
#     sttranw2 = q10_5w2, 
#     strespw1 = q10_2w1, 
#     strespw2 = q10_2w2, 
#     stfairw1 = q10_3w1, 
#     stfairw2 = q10_3w2, 
#     stjobw1 = q10_1w1, 
#     stjobw2 = q10_1w2, 
#     stthftw1 = q10_6w1, 
#     stthftw2 = q10_6w2, 
#     stmugw1 = q10_7w1, 
#     stmugw2 = q10_7w2, 
#     pstthflt5w1 = q25_1w1,               #rename past crime w1 items
#     pstthfgt5w1 = q25_2w1, 
#     pstthreatw1 = q25_4w1, 
#     pstharmw1 = q25_5w1, 
#     pstusedrgw1 = q25_6w1, 
#     psthackw1 = q25_8w1, 
#     pstthflt5w2 = q25_1w2,               #rename past crime w2 items
#     pstthfgt5w2 = q25_2w2,
#     pstthreatw2 = q25_4w2,
#     pstharmw2 = q25_5w2,
#     pstusedrgw2 = q25_6w2,
#     psthackw2 = q25_7w2, 
#     prjthflt5w1 = q26_1w1,               #rename criminal intent w1 items 
#     prjthfgt5w1 = q26_2w1,
#     prjthreatw1 = q26_4w1,
#     prjharmw1 = q26_5w1,
#     prjusedrgw1 = q26_6w1,
#     prjhackw1 = q26_8w1,
#     prjthflt5w2 = q26_1w2,               #rename criminal intent w2 items 
#     prjthfgt5w2 = q26_2w2,
#     prjthreatw2 = q26_4w2,
#     prjharmw2 = q26_5w2, 
#     prjusedrgw2 = q26_6w2, 
#     prjhackw2 = q26_7w2, 
#     depcantgow1 = q12_1w1,               #rename negative emotions w1 items
#     depeffortw1 = q12_2w1,
#     deplonelyw1 = q12_3w1,
#     depbluesw1 = q12_4w1,
#     depunfairw1 = q12_5w1,
#     depmistrtw1 = q12_6w1,
#     depbetrayw1 = q12_7w1, 
#     depcantgow2 = q12_1w2,               #rename negative emotions w2 items
#     depeffortw2 = q12_2w2,
#     deplonelyw2 = q12_3w2,
#     depbluesw2 = q12_4w2,
#     depunfairw2 = q12_5w2,
#     depmistrtw2 = q12_6w2,
#     depbetrayw2 = q12_7w2
#     ) %>%
#   mutate(
#     female = if_else(q1w1 == 1, 0, 1), 
#     rural = if_else(areaw1 == 2, 1, 0),       #(no rural/urban chg from areaw1-areaw2)
#     marriedw1 = if_else(q5w1 == 2, 1, 0), 
#     sesaw1 = q11_1w1 + q11_2w1 + q11_3w1 +    #used create area (L2) SES 
#       q11_6w1 + q11_7w1 + q11_8w1,                #(reverse of indiv hardship below)
#     depunfairw1 = na_if(depunfairw1, 9)       #recode missing obs from 9 to NA
#   ) %>% 
#   group_by(area_id) %>%                       #create area (L2) SES
#   mutate(
#     L2sesw1 = mean(sesaw1)
#     ) %>% 
#   ungroup() %>%
#   mutate_at(vars(c(q11_1w1, q11_2w1, q11_3w1, q11_6w1, q11_7w1, q11_8w1,
#                    q11_1w2, q11_2w2, q11_3w2, q11_6w2, q11_7w2, q11_8w2)),
#             function(x) 6-x) %>% #reverse-code SES items for indiv financial hardship
#   mutate(                                     #create financial hardship sum scale
#     osfinaw1 = q11_1w1 + q11_2w1 + q11_3w1 + q11_6w1 + q11_7w1 + q11_8w1, 
#     osfinaw2 = q11_1w2 + q11_2w2 + q11_3w2 + q11_6w2 + q11_7w2 + q11_8w2
#     ) %>%
#   dplyr::select(                 #drop ward/village identifiers & redundant cols
#     -c(w_now1, n_villw1, wardvill, q1w1, areaw1, areaw2, q5w1, sesaw1,
#        q11_1w1, q11_2w1, q11_3w1, q11_6w1, q11_7w1, q11_8w1, 
#        q11_1w2, q11_2w2, q11_3w2, q11_6w2, q11_7w2, q11_8w2)
#     ) 
# 
# # freq(stress_dat$depunfairw1)
# 
# save(stress_dat, file = here("1_Data_Files/Datasets/stress_dat.Rdata"))

2.1.1 Read data subset into R

#load Rdata file containing Dhaka W1/W2 stress analysis subset
load(here("1_Data_Files/Datasets/stress_dat.Rdata"))

options(scipen = 999, digits = 3) #change global option to three decimals 

Now that the data subset are read into R, let’s skim the data. A Pearson’s R correlation matrix is also included for future meta-analytic purposes. However, note that a key focus here will be on moving beyond metric normality assumptions underlying traditional linear model summaries (e.g., Pearson’s r; linear regression) and, instead, providing more valid and precise summaries of “bivariate” correlations (at T1 and change corrs that decompose within-person & between-person variance) using ordinal modeling approaches.

2.1.2 Skim data & correlations

2.1.2.1 Preview data

stress_dat %>% zap_label() %>% head() %>% gt()
id centerw1 centerw2 stjobw1 strespw1 stfairw1 stmonyw1 sttranw1 stthftw1 stmugw1 stjobw2 strespw2 stfairw2 stmonyw2 sttranw2 stthftw2 stmugw2 pstthflt5w1 pstthfgt5w1 pstthreatw1 pstharmw1 pstusedrgw1 psthackw1 pstthflt5w2 pstthfgt5w2 pstthreatw2 pstharmw2 pstusedrgw2 psthackw2 prjthflt5w1 prjthfgt5w1 prjthreatw1 prjharmw1 prjusedrgw1 prjhackw1 prjthflt5w2 prjthfgt5w2 prjthreatw2 prjharmw2 prjusedrgw2 prjhackw2 depcantgow1 depeffortw1 deplonelyw1 depbluesw1 depunfairw1 depmistrtw1 depbetrayw1 depcantgow2 depeffortw2 deplonelyw2 depbluesw2 depunfairw2 depmistrtw2 depbetrayw2 agew1 educw1 kidsw1 area_id female rural marriedw1 L2sesw1 osfinaw1 osfinaw2
1 1 1 5 2 1 4 5 1 1 5 2 1 4 5 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 3 4 1 2 1 1 1 1 2 4 2 3 2 2 26 14 0 2 0 0 0 16.9 24 24
2 1 1 5 5 4 5 2 1 1 5 5 5 5 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 1 3 4 1 1 4 4 1 3 3 3 3 24 7 0 2 0 0 0 16.9 21 20
3 1 1 3 1 1 5 5 1 3 3 1 1 5 4 1 3 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 5 2 5 4 2 4 4 5 5 5 2 1 60 8 3 2 0 0 0 16.9 27 27
4 1 1 4 5 5 1 2 5 1 5 5 5 1 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 3 1 1 3 1 1 1 2 1 1 2 3 1 1 1 2 3 3 3 3 3 23 14 0 2 0 0 0 16.9 13 13
5 1 NA 4 5 5 5 5 5 4 NA NA NA NA NA NA NA 1 1 1 1 1 1 NA NA NA NA NA NA 1 1 1 1 1 1 NA NA NA NA NA NA 3 1 1 2 1 2 1 NA NA NA NA NA NA NA 46 12 2 2 0 0 1 16.9 17 NA
6 1 1 1 2 3 1 3 1 1 1 2 3 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 1 1 3 1 1 5 4 1 2 3 3 1 37 15 4 2 1 0 1 16.9 18 18

2.1.2.2 Column names & labels

setNames(stack(lapply(stress_dat, label))[2:1], c("Varcode", "Variables")) %>% gt()
Varcode Variables
id Serial Number
centerw1 Center
centerw2 Center
stjobw1 Getting a job that you really enjoy?
strespw1 Earning respect from others around you?
stfairw1 Being treated fairly by others around you?
stmonyw1 Having enough money to buy the things you need?
sttranw1 Having reliable daily transportation?
stthftw1 Other people stealing from you?
stmugw1 Other people mugging or assaulting you?
stjobw2 Getting a job that you really enjoy?
strespw2 Earning respect from others around you?
stfairw2 Being treated fairly by others around you?
stmonyw2 Having enough money to buy the things you need?
sttranw2 Having reliable daily transportation?
stthftw2 Having your money or property stolen by other people?
stmugw2 Being physically attacked or assaulted by other people
pstthflt5w1 Took money or property that didn't belong to you worth less than Tk 150.
pstthfgt5w1 Took money or property that didn't belong to you worth Tk 150 or more.
pstthreatw1 Threatened to use violence on someone else.
pstharmw1 Physically harmed someone else on purpose.
pstusedrgw1 Used ganja or other illegal drug.
psthackw1 Attempt to access another person's private information, such as a bank account or computer files, without his or her knowledge or permission
pstthflt5w2 Took money or property that didn't belong to you worth less than Tk 150.
pstthfgt5w2 Took money or property that didn't belong to you worth Tk 150 or more.
pstthreatw2 Threatened to use violence on someone else.
pstharmw2 Physically harmed someone else on purpose.
pstusedrgw2 Used ganja or other illegal drug.
psthackw2 Attempt to access another person’s private information, such as a bank account or computer files, without his or her knowledge or permission.
prjthflt5w1 Take money or property that didn't belong to you worth less than Tk 150.
prjthfgt5w1 Take money or property that didn't belong to you worth Tk 150 or more.
prjthreatw1 Threaten to use violence on someone else.
prjharmw1 Physically harm someone else on purpose.
prjusedrgw1 Use ganja or other illegal drug.
prjhackw1 Attempt to access another person's private information, such as a bank account or computer files, without his or her knowledge or permission
prjthflt5w2 Take money or property that didn't belong to you worth less than Tk 150.
prjthfgt5w2 Take money or property that didn't belong to you worth Tk 150 or more.
prjthreatw2 Threaten to use violence on someone else.
prjharmw2 Physically harm someone else on purpose.
prjusedrgw2 Use ganja or other illegal drug.
prjhackw2 Attempt to access another person’s private information, such as a bank account or computer files, without his or her knowledge or permission.
depcantgow1 Felt you just could not get going
depeffortw1 Felt everything was an effort
deplonelyw1 Felt lonely
depbluesw1 Felt you could not shake the blues
depunfairw1 Felt like your life circumstances are unfair
depmistrtw1 Felt mistreated by others
depbetrayw1 Felt betrayed by people you care about
depcantgow2 Felt you just could not get going
depeffortw2 Felt everything was an effort
deplonelyw2 Felt lonely
depbluesw2 Felt you could not shake the blues
depunfairw2 Felt like your life circumstances are unfair
depmistrtw2 Felt mistreated by others
depbetrayw2 Felt betrayed by people you care about
agew1 What is the respondent's age?
educw1 How many years of formal education do you have?
kidsw1 IF YES TO 8a. How many children do you have?
area_id NA
female NA
rural NA
marriedw1 NA
L2sesw1 NA
osfinaw1 NA
osfinaw2 NA

2.1.2.3 Skim data

datasummary_skim(stress_dat)
tinytable_9btg4o6asvd044gphvop
Unique Missing Pct. Mean SD Min Median Max Histogram
Serial Number 600 0 300.5 173.3 1.0 300.5 600.0
Center 1 0 1.0 0.0 1.0 1.0 1.0
2 18 1.0 0.0 1.0 1.0 1.0
Getting a job that you really enjoy? 5 0 3.3 1.4 1.0 3.0 5.0
Earning respect from others around you? 5 0 3.3 1.5 1.0 4.0 5.0
Being treated fairly by others around you? 5 0 3.4 1.5 1.0 4.0 5.0
Having enough money to buy the things you need? 5 0 3.2 1.1 1.0 3.0 5.0
Having reliable daily transportation? 5 0 3.2 1.1 1.0 3.0 5.0
Other people stealing from you? 5 0 2.3 1.2 1.0 2.0 5.0
Other people mugging or assaulting you? 5 0 2.0 1.1 1.0 2.0 5.0
Getting a job that you really enjoy? 6 18 3.3 1.4 1.0 4.0 5.0
Earning respect from others around you? 6 18 3.5 1.3 1.0 4.0 5.0
Being treated fairly by others around you? 6 18 3.5 1.3 1.0 4.0 5.0
Having enough money to buy the things you need? 6 18 3.3 1.1 1.0 3.0 5.0
Having reliable daily transportation? 6 18 3.3 1.0 1.0 3.0 5.0
Having your money or property stolen by other people? 6 18 2.3 1.2 1.0 2.0 5.0
Being physically attacked or assaulted by other people 6 18 2.0 1.1 1.0 2.0 5.0
Took money or property that didn't belong to you worth less than Tk 150. 5 0 1.2 0.6 1.0 1.0 5.0
Took money or property that didn't belong to you worth Tk 150 or more. 4 0 1.2 0.5 1.0 1.0 4.0
Threatened to use violence on someone else. 4 0 1.1 0.3 1.0 1.0 4.0
Physically harmed someone else on purpose. 3 0 1.1 0.4 1.0 1.0 3.0
Used ganja or other illegal drug. 4 0 1.1 0.4 1.0 1.0 4.0
Attempt to access another person's private information, such as a bank account or computer files, without his or her knowledge or permission 4 0 1.1 0.3 1.0 1.0 4.0
Took money or property that didn't belong to you worth less than Tk 150. 5 18 1.2 0.5 1.0 1.0 4.0
Took money or property that didn't belong to you worth Tk 150 or more. 4 18 1.2 0.5 1.0 1.0 3.0
Threatened to use violence on someone else. 4 18 1.0 0.3 1.0 1.0 3.0
Physically harmed someone else on purpose. 4 18 1.1 0.3 1.0 1.0 3.0
Used ganja or other illegal drug. 5 18 1.1 0.4 1.0 1.0 4.0
Attempt to access another person’s private information, such as a bank account or computer files, without his or her knowledge or permission. 4 18 1.0 0.2 1.0 1.0 3.0
Take money or property that didn't belong to you worth less than Tk 150. 5 0 1.1 0.5 1.0 1.0 5.0
Take money or property that didn't belong to you worth Tk 150 or more. 3 0 1.1 0.4 1.0 1.0 3.0
Threaten to use violence on someone else. 3 0 1.1 0.3 1.0 1.0 3.0
Physically harm someone else on purpose. 4 0 1.1 0.3 1.0 1.0 4.0
Use ganja or other illegal drug. 3 0 1.1 0.3 1.0 1.0 3.0
Attempt to access another person's private information, such as a bank account or computer files, without his or her knowledge or permission 4 0 1.0 0.3 1.0 1.0 4.0
Take money or property that didn't belong to you worth less than Tk 150. 5 18 1.2 0.5 1.0 1.0 4.0
Take money or property that didn't belong to you worth Tk 150 or more. 5 18 1.1 0.4 1.0 1.0 4.0
Threaten to use violence on someone else. 4 18 1.1 0.3 1.0 1.0 3.0
Physically harm someone else on purpose. 4 18 1.0 0.3 1.0 1.0 3.0
Use ganja or other illegal drug. 5 18 1.1 0.3 1.0 1.0 5.0
Attempt to access another person’s private information, such as a bank account or computer files, without his or her knowledge or permission. 3 18 1.0 0.1 1.0 1.0 2.0
Felt you just could not get going 5 0 3.0 1.2 1.0 3.0 5.0
Felt everything was an effort 5 0 2.5 1.0 1.0 2.0 5.0
Felt lonely 5 0 2.5 1.2 1.0 2.0 5.0
Felt you could not shake the blues 5 0 2.5 1.1 1.0 2.0 5.0
Felt like your life circumstances are unfair 6 0 2.4 1.2 1.0 2.0 5.0
Felt mistreated by others 5 0 2.1 1.2 1.0 2.0 5.0
Felt betrayed by people you care about 5 0 2.1 1.1 1.0 2.0 5.0
Felt you just could not get going 6 18 3.0 1.3 1.0 3.0 5.0
Felt everything was an effort 6 18 2.6 1.0 1.0 3.0 5.0
Felt lonely 6 18 2.7 1.3 1.0 3.0 5.0
Felt you could not shake the blues 6 18 2.2 1.0 1.0 2.0 5.0
Felt like your life circumstances are unfair 6 18 2.9 1.2 1.0 3.0 5.0
Felt mistreated by others 6 18 2.4 1.1 1.0 2.0 5.0
Felt betrayed by people you care about 6 18 2.3 1.1 1.0 2.0 5.0
What is the respondent's age? 47 0 32.8 11.7 19.0 30.0 75.0
How many years of formal education do you have? 19 0 10.4 3.9 1.0 10.0 20.0
IF YES TO 8a. How many children do you have? 8 0 1.4 1.3 0.0 1.0 7.0
area_id 31 0 15.7 8.9 1.0 15.5 31.0
female 2 0 0.5 0.5 0.0 0.5 1.0
rural 2 0 0.4 0.5 0.0 0.0 1.0
marriedw1 2 0 0.8 0.4 0.0 1.0 1.0
L2sesw1 27 0 19.5 1.5 16.4 19.1 22.6
osfinaw1 23 0 16.5 5.0 6.0 17.0 28.0
osfinaw2 23 18 16.4 4.4 6.0 16.0 27.0

2.1.2.4 Pearson’s r matrix

stress_dat %>% 
  zap_label() %>% 
  dplyr::select(stmonyw1, sttranw1, strespw1, stfairw1, stjobw1, stthftw1, stmugw1, 
                stmonyw2, sttranw2, strespw2, stfairw2, stjobw2, stthftw2, stmugw2, 
                prjthflt5w1, prjthfgt5w1, prjthreatw1, prjharmw1, prjusedrgw1, prjhackw1, 
                prjthflt5w2, prjthfgt5w2, prjthreatw2, prjharmw2, prjusedrgw2, prjhackw2, 
                depcantgow1, depeffortw1, deplonelyw1, depbluesw1, depunfairw1, depmistrtw1, depbetrayw1,   
                depcantgow2, depeffortw2, deplonelyw2, depbluesw2, depunfairw2, depmistrtw2, depbetrayw2)  %>% 
  datasummary_correlation(method="pearson")
tinytable_lqghklzw4tqa8nzhir53
stmonyw1 sttranw1 strespw1 stfairw1 stjobw1 stthftw1 stmugw1 stmonyw2 sttranw2 strespw2 stfairw2 stjobw2 stthftw2 stmugw2 prjthflt5w1 prjthfgt5w1 prjthreatw1 prjharmw1 prjusedrgw1 prjhackw1 prjthflt5w2 prjthfgt5w2 prjthreatw2 prjharmw2 prjusedrgw2 prjhackw2 depcantgow1 depeffortw1 deplonelyw1 depbluesw1 depunfairw1 depmistrtw1 depbetrayw1 depcantgow2 depeffortw2 deplonelyw2 depbluesw2 depunfairw2 depmistrtw2 depbetrayw2
stmonyw1 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sttranw1 .64 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
strespw1 .09 .06 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stfairw1 .13 .09 .87 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stjobw1 .34 .23 .39 .36 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stthftw1 .10 .14 .24 .29 .17 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stmugw1 .01 .01 .30 .34 .19 .57 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stmonyw2 .82 .55 .10 .13 .32 .06 .03 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sttranw2 .51 .77 .03 .04 .19 .08 .03 .51 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
strespw2 .11 .04 .86 .79 .38 .18 .28 .13 .05 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stfairw2 .13 .07 .80 .89 .37 .22 .30 .15 .07 .82 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stjobw2 .30 .20 .40 .35 .88 .10 .16 .29 .20 .40 .38 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stthftw2 .08 .07 .18 .21 .14 .84 .46 .04 .09 .15 .18 .13 1 . . . . . . . . . . . . . . . . . . . . . . . . . . .
stmugw2 .05 .03 .24 .30 .16 .48 .83 .04 .03 .22 .25 .16 .45 1 . . . . . . . . . . . . . . . . . . . . . . . . . .
prjthflt5w1 -.03 -.05 .09 .12 .10 .04 .03 .00 .04 .14 .14 .16 .08 .02 1 . . . . . . . . . . . . . . . . . . . . . . . . .
prjthfgt5w1 -.03 .00 .05 .07 .13 .12 .06 -.03 .04 .11 .09 .15 .17 .03 .61 1 . . . . . . . . . . . . . . . . . . . . . . . .
prjthreatw1 -.03 .00 .09 .11 .13 .05 .01 -.05 -.01 .16 .13 .15 .11 .00 .35 .43 1 . . . . . . . . . . . . . . . . . . . . . . .
prjharmw1 -.03 -.02 .03 .04 .06 .00 .04 -.04 -.03 .08 .04 .08 .05 .04 .21 .31 .51 1 . . . . . . . . . . . . . . . . . . . . . .
prjusedrgw1 -.03 .00 .10 .07 .11 -.01 .06 .00 -.02 .13 .11 .12 -.02 .03 .14 .27 .37 .26 1 . . . . . . . . . . . . . . . . . . . . .
prjhackw1 .05 .02 -.03 -.01 .09 .00 -.04 .00 .03 .09 .11 .18 .02 -.01 .14 .23 .30 .12 .14 1 . . . . . . . . . . . . . . . . . . . .
prjthflt5w2 -.01 -.06 .11 .13 .11 .08 .01 .03 -.02 .11 .15 .10 .07 .00 .71 .52 .28 .23 .16 .16 1 . . . . . . . . . . . . . . . . . . .
prjthfgt5w2 .01 .01 .11 .10 .13 .09 .00 .05 .01 .10 .11 .13 .11 .01 .57 .64 .33 .26 .15 .14 .82 1 . . . . . . . . . . . . . . . . . .
prjthreatw2 .02 .04 .13 .12 .12 .13 -.01 .02 .00 .16 .10 .13 .15 -.01 .25 .33 .67 .36 .20 .25 .27 .33 1 . . . . . . . . . . . . . . . . .
prjharmw2 -.02 .04 .09 .09 .08 .09 .03 .00 -.03 .10 .06 .11 .07 .05 .19 .29 .38 .61 .18 .07 .27 .32 .51 1 . . . . . . . . . . . . . . . .
prjusedrgw2 .02 .07 .14 .09 .14 .02 .03 .04 -.02 .13 .12 .14 .00 .05 .15 .19 .14 .10 .56 .08 .27 .29 .37 .36 1 . . . . . . . . . . . . . . .
prjhackw2 .00 .01 .06 .04 .08 .06 -.01 .04 -.02 .07 .04 .12 .02 .04 .03 .05 .01 .03 -.02 .04 .13 .15 .20 .42 .34 1 . . . . . . . . . . . . . .
depcantgow1 .10 .03 .08 .08 .05 .18 .15 .11 .08 .07 .08 -.01 .11 .13 .00 .01 -.03 -.03 .00 -.04 -.01 -.01 -.05 .00 -.08 -.01 1 . . . . . . . . . . . . .
depeffortw1 .11 .07 .19 .16 .15 .17 .22 .05 .05 .14 .13 .15 .12 .21 .00 .03 .00 -.03 -.01 -.03 -.01 .00 -.01 .02 .00 .05 .35 1 . . . . . . . . . . . .
deplonelyw1 .07 .03 .17 .17 .03 .14 .17 .05 .04 .19 .20 .04 .12 .16 .04 .08 .02 -.03 .10 -.02 .07 .04 .04 .01 .11 .05 .19 .22 1 . . . . . . . . . . .
depbluesw1 .10 .07 .11 .13 .08 .15 .12 .09 .07 .02 .05 .08 .07 .10 -.01 -.02 -.02 .03 .04 -.03 -.06 -.10 -.05 .00 -.03 .05 .13 .16 .26 1 . . . . . . . . . .
depunfairw1 .24 .17 .06 .07 .12 .11 .12 .14 .17 .04 .07 .11 .06 .11 .05 -.01 .09 .02 .04 -.01 .05 .00 .06 .09 .03 .01 .15 .28 .22 .26 1 . . . . . . . . .
depmistrtw1 .07 .00 .26 .29 .07 .26 .37 .05 .00 .25 .27 .07 .23 .39 .01 -.01 .00 -.02 .03 -.07 -.02 -.01 -.01 -.02 .02 .01 .13 .17 .28 .25 .25 1 . . . . . . . .
depbetrayw1 .09 .04 .30 .33 .15 .31 .43 .11 .04 .30 .33 .17 .28 .41 .07 .08 .12 .07 .15 .03 .12 .12 .09 .08 .14 .05 .18 .20 .26 .12 .16 .64 1 . . . . . . .
depcantgow2 -.05 -.06 -.13 -.10 -.11 .06 .06 .00 .00 -.11 -.08 -.08 .08 .08 .00 .01 -.09 -.03 -.09 -.11 -.01 .01 -.05 .02 -.05 .02 .15 .07 .07 .02 -.02 -.01 -.03 1 . . . . . .
depeffortw2 .00 -.03 -.01 -.02 .01 .02 .02 .00 .01 -.01 -.01 .05 .05 .04 .02 .00 -.09 -.04 -.04 -.09 .01 .02 -.06 .01 -.01 .05 .03 .12 .08 .06 .08 .09 .01 .45 1 . . . . .
deplonelyw2 -.08 -.04 -.04 -.07 .03 -.06 .01 -.08 -.05 -.04 -.07 .03 -.04 .05 -.03 .05 .03 .00 .10 .07 -.04 .00 .03 .01 .12 .06 -.04 .05 .15 -.03 .01 .01 .00 .26 .29 1 . . . .
depbluesw2 .00 -.05 .01 .01 .00 -.04 .02 -.03 -.06 -.05 -.07 .00 -.01 .05 .00 -.01 .05 .09 .01 .00 .03 .04 .01 .01 .00 .05 -.02 .08 .08 .06 .07 .06 .06 .13 .24 .36 1 . . .
depunfairw2 .04 .01 .05 .02 .13 .04 .07 .04 .08 .11 .10 .19 .10 .05 .12 .12 .10 .04 .13 .05 .13 .14 .03 .03 .09 .05 .01 .13 .07 .01 .11 .10 .15 .06 .30 .22 .27 1 . .
depmistrtw2 .05 .02 .06 .09 .05 .04 -.04 .06 .08 .04 .07 .08 .09 .02 .09 .08 .05 .03 -.04 -.02 .07 .07 .09 .11 .05 .14 .04 .09 -.03 .02 .01 .02 .10 .10 .22 .13 .23 .38 1 .
depbetrayw2 .10 .07 .11 .13 .13 .10 .04 .12 .08 .12 .11 .16 .14 .07 .12 .12 .15 .10 .06 .13 .14 .16 .17 .15 .11 .14 -.01 .11 .07 .09 .07 .08 .17 .05 .20 .13 .28 .34 .54 1

Let’s also take a look at some missingness patterns due to attrition from T1 to T2.

2.1.3 Examine Missingness due to Attrition (T1 to T2)

missdf <- stress_dat %>% 
  dplyr::select(centerw2, stmonyw1, sttranw1, strespw1, stfairw1, stjobw1, stthftw1,
                stmugw1, prjthflt5w1, prjthfgt5w1, prjthreatw1,
                prjharmw1, prjusedrgw1, prjhackw1, depcantgow1, depeffortw1,
                deplonelyw1, depbluesw1, depunfairw1, depmistrtw1, depbetrayw1)

shadowdat <- bind_shadow(missdf)

#missing plot function 
missplot <- function(df, x_var, y_var) {
  
  ggplot(df, aes(x = .data[[x_var]], colour = .data[[y_var]])) + 
    geom_density()  
}

# list approach did not work
# plot_list <- colnames(shadowdat)[-1] %>% 
#   map( ~ missplot(shadowdat, colnames(shadowdat)[1], .x))

mp1 <- missplot(shadowdat, "stmonyw1", "centerw2_NA")
mp2 <- missplot(shadowdat, "sttranw1", "centerw2_NA")
mp3 <- missplot(shadowdat, "strespw1", "centerw2_NA")
mp4 <- missplot(shadowdat, "stfairw1", "centerw2_NA")
mp5 <- missplot(shadowdat, "stjobw1", "centerw2_NA")
mp6 <- missplot(shadowdat, "stthftw1", "centerw2_NA")
mp7 <- missplot(shadowdat, "stmugw1", "centerw2_NA")

mp8 <- missplot(shadowdat, "prjthflt5w1", "centerw2_NA")
mp9 <- missplot(shadowdat, "prjthfgt5w1", "centerw2_NA")
mp10 <- missplot(shadowdat, "prjthreatw1", "centerw2_NA")
mp11 <- missplot(shadowdat, "prjharmw1", "centerw2_NA")
mp12 <- missplot(shadowdat, "prjusedrgw1", "centerw2_NA")
mp13 <- missplot(shadowdat, "prjhackw1", "centerw2_NA")

mp14 <- missplot(shadowdat, "depcantgow1", "centerw2_NA")
mp15 <- missplot(shadowdat, "depeffortw1", "centerw2_NA")
mp16 <- missplot(shadowdat, "deplonelyw1", "centerw2_NA")
mp17 <- missplot(shadowdat, "depbluesw1", "centerw2_NA")
mp18 <- missplot(shadowdat, "depunfairw1", "centerw2_NA")
mp19 <- missplot(shadowdat, "depmistrtw1", "centerw2_NA")
mp20 <- missplot(shadowdat, "depbetrayw1", "centerw2_NA")

2.1.3.1 Stress x attrition

mpstress <- (mp1 + mp2) / (mp3 + mp4) / (mp5 + guide_area()) / (mp6 + mp7) + 
  plot_layout(guides = 'collect', widths = c(4,.6)) + 
    plot_annotation(
      title = 'Stress by Attrition')  
mpstress

2.1.3.2 Crim intent x attrition

mpprj <- (mp8 + mp9) / (mp10 + mp11) / (mp12 + mp13) / guide_area() + 
  plot_layout(guides = 'collect', widths = c(4,.6)) + 
    plot_annotation(
      title = 'Crim intent by Attrition')  
mpprj

2.1.3.3 Neg emotions x attrition

mpdep <- (mp14 + mp15) / (mp16 + mp17) / (mp18 + mp19) / (mp20 + guide_area()) + 
  plot_layout(guides = 'collect', widths = c(4,.6)) + 
    plot_annotation(
      title = 'Crim intent by Attrition')  
mpdep

2.1.3.4 Item means x attrition

varsw1 <- c("stmonyw1", "sttranw1", "strespw1", "stfairw1", "stjobw1", "stthftw1",
            "stmugw1", "pstthflt5w1", "pstthfgt5w1", "pstthreatw1", "pstharmw1",
            "pstusedrgw1", "psthackw1", "prjthflt5w1", "prjthfgt5w1", "prjthreatw1",
            "prjharmw1", "prjusedrgw1", "prjhackw1", "depcantgow1", "depeffortw1",
            "deplonelyw1", "depbluesw1", "depunfairw1", "depmistrtw1", "depbetrayw1")

stress_dat %>%
  bind_shadow() %>%
  group_by(centerw2_NA) %>%
  summarise_at(.vars = varsw1,
               .funs = c("mean"),
               na.rm = TRUE) %>%
  gt()
centerw2_NA stmonyw1 sttranw1 strespw1 stfairw1 stjobw1 stthftw1 stmugw1 pstthflt5w1 pstthfgt5w1 pstthreatw1 pstharmw1 pstusedrgw1 psthackw1 prjthflt5w1 prjthfgt5w1 prjthreatw1 prjharmw1 prjusedrgw1 prjhackw1 depcantgow1 depeffortw1 deplonelyw1 depbluesw1 depunfairw1 depmistrtw1 depbetrayw1
!NA 3.15 3.16 3.31 3.4 3.27 2.22 1.96 1.20 1.16 1.07 1.10 1.11 1.06 1.14 1.11 1.08 1.06 1.06 1.04 3.0 2.48 2.52 2.50 2.41 2.15 2.17
NA 3.24 3.36 3.41 3.5 3.23 2.50 1.92 1.24 1.14 1.01 1.05 1.05 1.06 1.14 1.09 1.02 1.04 1.04 1.06 2.9 2.49 2.49 2.41 2.24 1.91 1.77

With those basic data exploration tasks out of the way, we can begin answering our research questions. First, we need to do a bit of data wrangling.

2.1.4 Data wrangling

stress.wide <- stress_dat %>%
  dplyr::filter(centerw2==1) %>%                    #retain n=489/600 Rs in both waves
  dplyr::select(-c(centerw1, centerw2)) %>%
  mutate(                                    #standardize community (L2) SES 
    L2sesw1z = (L2sesw1 - mean(L2sesw1))/sd(L2sesw1) 
  )
# freq(stress.wide)

#summarize median community (L2) SES value (-.268), 
  #save as vector (value) to create community groups    
L2SESw1zmed <- as_vector(stress.wide %>%
  summarise_at(c("L2sesw1z"), median))
# L2SESw1zmed

#create community-level rural/urban + median-split L2 SES factor variable, 
  #dichotomize crime outcomes
stress.wide <- stress.wide %>% 
  mutate(
    #Create rural/ses catetories:
    #split communities based on mean ses
    rural.ses.avg = 0,
    rural.ses.avg = ifelse(rural == 1 & L2sesw1z <= 0, 1, 
                           rural.ses.avg), #Rural/Low SES
    rural.ses.avg = ifelse(rural == 1 & L2sesw1z > 0, 2, 
                           rural.ses.avg), #Rural/High SES
    rural.ses.avg = ifelse(rural == 0 & L2sesw1z <= 0, 3, 
                           rural.ses.avg), #Urban/Low SES
    rural.ses.avg = ifelse(rural == 0 & L2sesw1z > 0, 4, 
                           rural.ses.avg), #Urban/High SES
    rural.ses.avg = factor(rural.ses.avg, levels = c(1, 2, 3, 4)),
    #split communities based on median ses
    rural.ses.med = 0, 
    rural.ses.med = ifelse(rural == 1 & L2sesw1z <= L2SESw1zmed, 1, 
                           rural.ses.med), #Rural/Low SES
    rural.ses.med = ifelse(rural == 1 & L2sesw1z > L2SESw1zmed, 2, 
                           rural.ses.med), #Rural/High SES
    rural.ses.med = ifelse(rural == 0 & L2sesw1z <= L2SESw1zmed, 3, 
                           rural.ses.med), #Urban/Low SES
    rural.ses.med = ifelse(rural == 0 & L2sesw1z > L2SESw1zmed, 4, 
                           rural.ses.med), #Urban/High SES
    rural.ses.med = factor(rural.ses.med, levels = c(1, 2, 3, 4)), 
    stmonych12 = stmonyw2 - stmonyw1, #stress change vars (for plotting descriptives)
    sttranch12 = sttranw2 - sttranw1,
    strespch12 = strespw2 - strespw1,
    stfairch12 = stfairw2 - stfairw1, 
    stjobch12 = stjobw2 - stjobw1, 
    stthftch12 = stthftw2 - stthftw1, 
    stmugch12 = stmugw2 - stmugw1
    ) %>% 
  rename(
    pstthflt5w1di = pstthflt5w1,          #rename past crime w1 items (binary)
    pstthfgt5w1di = pstthfgt5w1, 
    pstthreatw1di = pstthreatw1, 
    pstharmw1di = pstharmw1, 
    pstusedrgw1di = pstusedrgw1, 
    psthackw1di = psthackw1, 
    pstthflt5w2di = pstthflt5w2,          #rename past crime w2 items (binary)
    pstthfgt5w2di = pstthfgt5w2,
    pstthreatw2di = pstthreatw2,
    pstharmw2di = pstharmw2,
    pstusedrgw2di = pstusedrgw2,
    psthackw2di = psthackw2, 
    prjthflt5w1di = prjthflt5w1,          #rename criminal intent w1 items (binary)
    prjthfgt5w1di = prjthfgt5w1,
    prjthreatw1di = prjthreatw1,
    prjharmw1di = prjharmw1,
    prjusedrgw1di = prjusedrgw1,
    prjhackw1di = prjhackw1,
    prjthflt5w2di = prjthflt5w2,          #rename criminal intent w2 items (binary)
    prjthfgt5w2di = prjthfgt5w2,
    prjthreatw2di = prjthreatw2,
    prjharmw2di = prjharmw2, 
    prjusedrgw2di = prjusedrgw2, 
    prjhackw2di = prjhackw2
  ) %>% 
  mutate_at(vars(c(                       #dichotomize crime outcomes
    pstthflt5w1di, pstthfgt5w1di, pstthreatw1di, 
    pstharmw1di, pstusedrgw1di, psthackw1di,       
    pstthflt5w2di, pstthfgt5w2di, pstthreatw2di, 
    pstharmw2di, pstusedrgw2di, psthackw2di, 
    prjthflt5w1di, prjthfgt5w1di, prjthreatw1di, 
    prjharmw1di, prjusedrgw1di, prjhackw1di, 
    prjthflt5w2di, prjthfgt5w2di, prjthreatw2di, 
    prjharmw2di, prjusedrgw2di, prjhackw2di)),
    list(~ if_else(. > 1, 1, 0)) 
    )

# freq(stress.wide)

options(scipen = 999, digits = 2) #change global option back to two decimals 

#head(stress.wide)
#view(stress.wide)
# table(stress.wide$rural.ses.med, stress.wide$rural)

Now that we have read in, explored, and begun wrangling the data, we can start answering our research questions.

2.2 RQ1a: Stress Prevalance by Wave (Full Sample)

How often did participants report stressing or worrying in T1 and T2 - overall and specifically about financial, relational, occupational, or victimization issues?

As in our “Stress in Bangladesh” paper, we start by displaying the distributions of all seven subjective stress items at T1 and T2, as well as within-person change distributions, in Figure 1 below.

#Begin by transforming all 14 stress items (7 per wave, two waves) into new factor variables

#Create vector for variables I'm turning into factors:
stress_vars <- c("stmonyw1", "stmonyw2", "sttranw1", "sttranw2", "strespw1", "strespw2", "stfairw1","stfairw2", 
                 "stjobw1", "stjobw2", "stthftw1", "stthftw2", "stmugw1", "stmugw2")

stress_vars_fct <- c("stmonyw1_fct", "stmonyw2_fct", "sttranw1_fct", "sttranw2_fct", "strespw1_fct", "strespw2_fct", "stfairw1_fct","stfairw2_fct", 
                 "stjobw1_fct", "stjobw2_fct", "stthftw1_fct", "stthftw2_fct", "stmugw1_fct", "stmugw2_fct")


stress_vars_levels = c( "Never (1)" = "1",
                           "Rarely (2)" = "2",
                           "Sometimes (3)" = "3",
                           "Often (4)" = "4",
                           "Very often (5)" = "5")

stress.wide <- stress.wide %>%
  mutate(stmonyw1_fct = fct_recode(as.factor(stmonyw1), !!!stress_vars_levels),
         stmonyw2_fct = fct_recode(as.factor(stmonyw2), !!!stress_vars_levels),
         sttranw1_fct = fct_recode(as.factor(sttranw1), !!!stress_vars_levels),
         sttranw2_fct = fct_recode(as.factor(sttranw2), !!!stress_vars_levels),
         strespw1_fct = fct_recode(as.factor(strespw1), !!!stress_vars_levels),
         strespw2_fct = fct_recode(as.factor(strespw2), !!!stress_vars_levels),
         stfairw1_fct = fct_recode(as.factor(stfairw1), !!!stress_vars_levels),
         stfairw2_fct = fct_recode(as.factor(stfairw2), !!!stress_vars_levels),
         stjobw1_fct = fct_recode(as.factor(stjobw1), !!!stress_vars_levels),
         stjobw2_fct = fct_recode(as.factor(stjobw2), !!!stress_vars_levels),
         stthftw1_fct = fct_recode(as.factor(stthftw1), !!!stress_vars_levels),
         stthftw2_fct = fct_recode(as.factor(stthftw2), !!!stress_vars_levels),
         stmugw1_fct = fct_recode(as.factor(stmugw1), !!!stress_vars_levels),
         stmugw2_fct = fct_recode(as.factor(stmugw2), !!!stress_vars_levels))

#Wrangle data to get both T1 & T2 onto same figure

tab1dataw1 <- stress.wide %>%
  dplyr::select(id, stmonyw1, sttranw1, strespw1, stfairw1, stjobw1, stthftw1, stmugw1) %>%
  dplyr::mutate(wave = "Time 1") 
# tab1dataw1

tab1dataw2 <- stress.wide %>%
  dplyr::select(id, stmonyw2, sttranw2, strespw2, stfairw2, stjobw2, stthftw2, stmugw2) %>%
  dplyr::mutate(wave = "Time 2") 
# tab1dataw2

items_vars_levels = c("stmonyw1", "sttranw1", "strespw1", "stfairw1", "stjobw1", "stthftw1", "stmugw1")
items_vars_labels = c("Money for\nnecessities" = "stmonyw1",
                      "Reliable\ntransportation" = "sttranw1",
                      "Being treated\nwith respect" = "strespw1",
                      "Being treated\nfairly" = "stfairw1",
                      "Finding job\nyou enjoy" = "stjobw1", 
                      "Others stealing\nfrom you" = "stthftw1", 
                      "Others\nassaulting you" = "stmugw1")
items_vars_wave1 = c("Money for necessities, T1" = "stmonyw1",
                      "Reliable transportation, T1" = "sttranw1",
                      "Being treated w/respect, T1" = "strespw1",
                      "Being treated fairly, T1" = "stfairw1",
                      "Finding job you enjoy, T1" = "stjobw1", 
                      "Others stealing from you, T1" = "stthftw1", 
                      "Others assaulting you, T1" = "stmugw1")

items_vars_levelsw2 = c("stmonyw2", "sttranw2", "strespw2", "stfairw2", "stjobw2", "stthftw2", "stmugw2")
items_vars_labelsw2 = c("Money for\nnecessities" = "stmonyw2",
                      "Reliable\ntransportation" = "sttranw2",
                      "Being treated\nwith respect" = "strespw2",
                      "Being treated\nfairly" = "stfairw2",
                      "Finding job\nyou enjoy" = "stjobw2", 
                      "Others stealing\nfrom you" = "stthftw2", 
                      "Others\nassaulting you" = "stmugw2")

items_vars_wave2 = c("Money for necessities, T2" = "stmonyw2",
                      "Reliable transportation, T2" = "sttranw2",
                      "Being treated w/respect, T2" = "strespw2",
                      "Being treated fairly, T2" = "stfairw2",
                      "Finding job you enjoy, T2" = "stjobw2", 
                      "Others stealing from you, T2" = "stthftw2", 
                      "Others assaulting you, T2" = "stmugw2")

#pivot data and combine
#Wave 1
tab1datalgw1 <- tab1dataw1 %>%
  pivot_longer(cols = c("stmonyw1", "sttranw1", "strespw1", "stfairw1", "stjobw1", "stthftw1", "stmugw1"), 
               names_to = "items", values_to = "response") %>%
  mutate(items = factor(items, levels = items_vars_levels),
         items_fct = fct_recode(items, !!!items_vars_labels),
         items_fct_wave = fct_recode(items, !!!items_vars_wave1),
         response_fct = fct_recode(as.factor(response), !!!stress_vars_levels)) 
           
# levels(tab1datalgw1$items)
# levels(tab1datalgw1$items_fct)
# levels(tab1datalgw1$items_fct_wave)
# levels(tab1datalgw1$response_fct)

#calculate mean and standard error and sd for each variable
tab1datalgw1_sum <- tab1datalgw1 %>%
  dplyr::group_by(items) %>%
  dplyr::summarize(mean_se(response), sd = sd(response)) %>%
  rename(mean = y,
         min95 = ymin,
         max95 = ymax) 

#merge summary data with individual data
tab1datalgw1 <- full_join(tab1datalgw1, tab1datalgw1_sum)


#Wave 2
tab1datalgw2 <- tab1dataw2 %>%
  pivot_longer(cols = c("stmonyw2", "sttranw2", "strespw2", "stfairw2", "stjobw2", "stthftw2", "stmugw2"), 
               names_to = "items", values_to = "response") %>%
  mutate(items = factor(items, levels = items_vars_levelsw2),
         items_fct = fct_recode(items, !!!items_vars_labelsw2),
         items_fct_wave = fct_recode(items, !!!items_vars_wave2),
         response_fct = fct_recode(as.factor(response), !!!stress_vars_levels)) 
           
# levels(tab1datalgw2$items)
# levels(tab1datalgw2$items_fct)
# levels(tab1datalgw2$items_fct_wave)
# levels(tab1datalgw2$response_fct)

#calculate mean and standard error and sd for each variable
tab1datalgw2_sum <- tab1datalgw2 %>%
  dplyr::group_by(items) %>%
  dplyr::summarize(mean_se(response), sd = sd(response)) %>%
  rename(mean = y,
         min95 = ymin,
         max95 = ymax) 

#merge summary data with individual data
tab1datalgw2 <- full_join(tab1datalgw2, tab1datalgw2_sum)

tab1datalg <- bind_rows(tab1datalgw1, tab1datalgw2) %>%
  mutate(wave = as.factor(wave)) %>%
  arrange(id, wave)

# head(tab1datalg)

# levels(tab1datalg$items)
# levels(tab1datalg$items_fct)
# levels(tab1datalg$items_fct_wave)
# levels(tab1datalg$response_fct)

2.2.1 FIGURE 1: Subj Stress by Wave

#NOTE: Cannot properly align italicized expression as below - consider ggtext package w/html tags instead 
# expression(italic("Note: N") ~ "=489 respondents participating at both survey waves. \nInterval plots display item mean (horizontal dash), 50% (thick vertical bar) and 95% (thin vertical bar) intervals. \nBar charts display proportion of full sample reporting each item response category.")


# E99D53 "#883E3A"

Fig1 <- tab1datalg %>%
  ggplot() + 
  geom_bar(aes(y = response_fct, fill = wave), width = .7, stat="count") +
  scale_fill_manual(values = c("#E99D53", "#E0754F")) +
  facet_grid(rows = vars(items_fct), cols = vars(wave), switch = "both") + #switch y-axis strip titles to left side of plot
  scale_color_manual(values = c("#E99D53", "#E0754F")) +
  stat_pointinterval(data = tab1datalg, aes(y = response, color = wave), .width = c(0.5, 0.95),
                     point_interval = mean_qi, show_point = TRUE, shape=3, 
                     position = position_nudge(x = -15)) +
  # labs(title = "FIGURE 1: Subjective Stress Item Distributions\n ",
  #      subtitle = "How often do you stress or worry about...",
  #      caption =  "Note: N=489 respondents participating at both survey waves. Interval plots show item mean (horizontal \ntick) and 50% (thick vertical bar) and 95% (thin vertical bar) intervals. Bars display proportion \nof full sample reporting each response category, from 'never' (bottom bar) to 'very often' (top bar)."
  #      ) +
  theme(axis.title = element_blank(), #removes axis titles
        panel.grid=element_blank(), #removes grid lines
        # plot.title.position = "plot",  #changes default title location from graph to whole plot 
        # plot.title = element_text(face = "bold", size = 12),
        # plot.subtitle = element_text(face = "italic", size = 11),
        # plot.caption.position = "plot",
        # plot.caption = element_text(face = "plain", size = 10, hjust=0, vjust=0),
        legend.position = "none",
        legend.title = element_blank(),
        axis.line = element_blank(),
        axis.ticks.x = element_line(), 
        axis.text.x = element_text(size = 7, angle = 0),
        #strip.text.x = element_blank(), #remove x-axis strip titles (Time 1 and Time 2)
        axis.text.y = element_text(size = 7, angle = 0, hjust = 1),
        strip.text.y.left = element_text(angle = 0, hjust=0),
        strip.placement = "outside",
        strip.background = element_blank(),
        # strip.background = element_rect(fill="white"),
        axis.title.x = element_blank(), 
        axis.title.y = element_blank()) +  
    scale_x_continuous(limit=c(-16,220), breaks=c("0"=0,".1"=0.1*489,".2"=0.2*489,".3"=0.3*489,".4"=0.4*489))  

# Fig1 


# Add change distributions to Fig1 

stchgitems <- c("stmonych12", "sttranch12", "strespch12", "stfairch12",
                "stjobch12", "stthftch12", "stmugch12")

stress_chg_levels = c("Decrease (-2+)"= "-2",
                           "Decrease (-1)" = "-1",
                           "No change (0)" = "0",
                           "Increase (+1)" = "1",
                           "Increase (+2+)" = "2")


tab1chgdata <- stress.wide %>%
  dplyr::select(id, stmonych12, sttranch12, strespch12, stfairch12, stjobch12, stthftch12, stmugch12) %>%
  mutate(wave = "T2-T1") %>%
  pivot_longer(cols = c("stmonych12", "sttranch12", "strespch12", "stfairch12", "stjobch12", "stthftch12", "stmugch12"), 
               names_to = "items", values_to = "response") %>%
  mutate(items = factor(items, levels = stchgitems),
         items_fct = factor(items),
response = if_else(response >2, 2, response), 
         response = if_else(response < -2, -2, response),
         response_fct = fct_recode(as.factor(response), !!!stress_chg_levels)) 

#calculate mean and standard error and sd for each variable
tab1chgdata_sum <- tab1chgdata %>%
  dplyr::group_by(items) %>%
  dplyr::summarize(mean_se(response), sd = sd(response)) %>%
  rename(mean = y,
         min95 = ymin,
         max95 = ymax) 

#merge summary data with individual data
tab1chgdatalg <- full_join(tab1chgdata, tab1chgdata_sum)

Fig1chg <- tab1chgdatalg %>%
  ggplot() + 
  # facet_wrap(~items_fct, nrow = 7, strip.position = "left") +   
  geom_bar(aes(y = response, fill = wave), width = .7, stat="count") +  
  facet_grid(rows = vars(items_fct), cols = vars(wave), switch = "both") +
  scale_fill_manual(values = "#883E3A") +
  scale_color_manual(values = "#883E3A") +
  scale_y_continuous(breaks=c(-2,-1,0,1,2), 
                     labels=c("Decrease (-2+)", "Decrease (-1)", "No Change (0)", 
                              "Increase (+1)", "Increase (+2+)")) + 
  stat_pointinterval(data = tab1chgdatalg, aes(y = response, color = wave), .width = c(0.5, 0.95),
                     point_interval = mean_qi, show_point = TRUE, shape=3, 
                     position = position_nudge(x = -15)) + 
  theme(axis.title.y = element_blank(), #removes axis titles
        strip.text.y = element_blank(),
        axis.title.x = element_blank(),
        panel.grid=element_blank(), #removes grid lines
        legend.position = "none",
        legend.title = element_blank(),
        axis.line = element_blank(),
        axis.text.y = element_text(size = 7, angle = 0),
        axis.ticks.x = element_line(), 
        axis.text.x = element_text(size = 7, angle = 0)) + 
    scale_x_continuous(limit=c(-16,350), breaks=c("0"=0,".1"=0.1*489,".2"=0.2*489,
                                                  ".3"=0.3*489,".4"=0.4*489,
                                                  ".5"=0.5*489, ".6"=0.6*489, 
                                                  ".7"=0.7*489)) 

# Fig1chg 



design <- "
112
112
"    

  # labs(title = "FIGURE 1: Subjective Stress Item Distributions\n ",
  #      subtitle = "How often do you stress or worry about...",
  #      caption =  "Note: N=489 respondents participating at both survey waves. Interval plots show item mean (horizontal \ntick) and 50% (thick vertical bar) and 95% (thin vertical bar) intervals. Bars display proportion \nof full sample reporting each response category, from 'never' (bottom bar) to 'very often' (top bar)."
  #      ) +


Figure1 <- Fig1 + Fig1chg +
  plot_layout(design=design) +
    plot_annotation(
    title = 'FIGURE 1 Subjective Stress Item Distributions',
    subtitle = 'How often do you stress or worry about...',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Interval plots show item mean (horizontal tick), 50% (thick vertical bar), and 95% (thin vertical bar) intervals. Bars display proportion of full sample reporting each item response category (Time 1; Time 2) or degrees of change in item response categories (T2-T1).', width=140)) &
  theme(plot.title = element_text(size=12, face="bold"),
        plot.subtitle = element_text(face="italic"),
        plot.caption = element_text(size=8, hjust = 0)) #move caption to left of plot

#Export to image
 ggsave("Figure1.jpeg", Figure1, width=6.5, height=9, path=here("Output"))

Figure1

#Grab Figure 1 plot data for specific counts/props/percents to use in text
plt_b <- ggplot_build(Fig1)
fig1data <- as.data.frame(plt_b$data[[1]]) %>%
  mutate(ynew=as.integer(y)) 
# fig1data
# glimpse(fig1data)

#Write function to calculate specific response category percentages 
panel_catpct <- function(figpanel, ycatvalue) {
  paneldata <- as_tibble(fig1data %>% filter(PANEL==figpanel))
  catcounts <- as.numeric(paneldata %>% filter(y %in% ycatvalue) %>% .$x) 
  catpct <- ((sum(catcounts))/489)*100
  return(catpct)
}

#First value input is Fig 1 panel of desired stress item (top left = 1, top right = 2, second left = 3, etc.)
#Second value/vector is desired response category(ies) (1 = never, 2 = rarely, 3 = sometimes, etc.) 

#Example: Percent reporting *sometimes* (cat=3) or *often* (cat=4) stress abt money
  #panel_catpct(1,c(3,4))

As Figure 1 shows, the observed response patterns for the first two financial stress items are approximately normally distributed in both waves, with the majority of respondents reporting somewhat or often stressing about money (T1: 61.55%; T2: 62.78%) or transportation (T1: 58.9%; T2: 65.64%) and relatively few reportedly never stressing about these things (range: 3.07% to 7.77%). In contrast, the observed item distributions for relational and job-related stress items do not exhibit symmetric decay about the midpoint characteristic of normal distributions; rather, approximately half of our Bangladeshi respondents reportedly often or very often stress about being treated with respect (T1: 52.15%; T2: 52.76%), being treated fairly (T1: 55.83%; T2: 55.42%), and finding a job they enjoy (T1: 49.28%; T2: 51.12%), whereas a sizeable proportion of respondents report never experiencing these types of stress (range: 8.79% to 16.36%). Finally, response distributions for subjective stress about criminal victimization exhibit high positive skew, with the majority of respondents reporting never or rarely stressing about others stealing from them (T1: 63.39%; T2: 62.17%) or assaulting them (T1: 71.78%; T2: 69.94%). In contrast, very few respondents report very often stressing about such victimization (range: 2.04% to 5.11%), which might be expected given the relative rarity of crime and criminal victimization. Of course, frequency and potency of stress are distinct characteristics, and general strain theory suggests that victimization-related stress may be especially potent and criminogenic despite being comparatively rare.

save(stress.wide, file = here("1_Data_Files/Datasets/stress_wide.Rdata"))

3 Figure 2: Stress by community (RQ1B)

(RMD FILE: BDK_2023_Stress_2_Fig2)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

3.1 RQ1B: Social Distributions of Stress by Community (T1)

RQ1B (Social distributions): Do these levels of subjective stress vary systematically across rural/urban communities with high/low aggregate SES? Specifically, do residents of low-SES urban communities report more frequently stressing or worrying about these various potential sources of stress?

3.1.1 From observations to models of subjective stress ordinal responses

Instead of plotting observed response variable distributions to visualize differences in stress prevalence across communities, we will recover these response distributions from posterior estimates (medians) generated by Bayesian sequential ordinal probit models for each stress item. While we could simply plot the observed frequencies for each community group as we did above by wave for the full sample, recovering these estimates from Bayesian posterior prediction distributions will serve a couple useful purposes. First, recall this is a probability sample of residents in the Dhaka metropolitan region of Bangladesh. A (Bayesian, in this case) statistical model permits us to visualize and communicate uncertainty surrounding these observed proportions as estimates of population parameters, such as by plotting 50% and 95% uncertainty (e.g., posterior HDI or credible) intervals around the estimated proportions for every response category for a given item.

Second, ultimately we wish to estimate the association between stress and its posited outcomes (criminal intent; depressive symptoms) by including the stress items as predictors in outcome models. Typically, researchers simply include ordinal items or ordered composite scales as predictor variables in regression models and treat them as metric or continuous normal variables without much thought given to their distributional properties. Yet, such practices can have disastrous and often under-appreciated consequences for model inferences (see Liddell & Kruschke 2017). Instead, by building ordinal models predicting response category probabilities for each stress item, we can generate ordinal probit threshold estimates that can subsequently be used in outcome regression models to more accurately estimate, for instance, the average change in an outcome like criminal behavior or depressive symptoms that is associated with a one-unit increase in a stress item’s ordered response categories (e.g., from never to rarely; see … brms paper). Hence, building ordinal descriptive models of our stress item distributions that accurately recover observed data is an essential first step towards building outcome models that accurately estimate associations between those outcomes and their ordinal predictors.

We estimate both cumulative and category-specific threshold models for all seven stress items, then use the threshold estimates (and uncertainty from posterior distributions) from each of the seven category-specific models to plot the stress response distributions (and uncertainty bounds) by community in Figure 2. Most of this section is devoted to exploring the appropriateness of these modeling decisions, including comparisons to standard linear models, posterior predictive checks, and conditional effects plots. If you wish, you can skip this and jump directly to the stress distribtions in Figure 2.

3.1.2 Comparing Metric & Ordinal Models of Subjective Stress

Now, we turn to visualizations of stress patterns across rural/urban and low/high SES communities. To do this, we estimate both cumulative and category-specific models for all seven stress items, then used the threshold estimates (and uncertainty from posterior distributions) from each of the seven category-specific models to plot the stress response distributions (and uncertainty bounds) by community group in Figure 2. In our “Stress in Bangladesh” paper, we noted that the supplemenary materials contain more information about the appropriateness of these modeling decisions, including comparisons to standard linear models, posterior predictive checks, and conditional effects plots. This section contains that supplementary information for the models used to analyze RQ1 (descriptive distributions for stress items).

Before generating models that recovered stress item response distributions for each community group, we want to briefly illustrate how simple descriptive models that impose metric normality assumptions on ordinal stress items - as is the case in a typical regression model with ordinal items entered as continuous predictors - is a poor fit for the observed data.

We then show that the quite parsimonious cumulative probit model (which is used in regression models for RQ2 and beyond) does a much better job of recovering the observed stress item response distributions in the entire sample and in each community group. From there, we generate plots of stress item response distributions across community groups from estimates generated in more complex sequential ordinal models that specify category-specific effects of each rural/SES community subgroup on stress item response thresholds. These more complex models generate threshold estimates that accurately recover observed data distributions in the entire sample as well as in each community group, thereby ensuring that our model-based summaries of the stress item distributions across groups is consistent with observed item distributions, which is essential to accurately answer RQ1.

After answering questions about community variations in levels and sources of stress, we will later return to simpler cumulative probit models of stress items in assessing stress-outcome associations. Cumulative probit models are reasonably accurate and quite parsimonious, whereas the large number of threshold parameters estimated in more complex sequential category-specific models can pose problems when using relatively small samples to predict rare event outcomes like crime.

3.1.3 (Not-so-)Normal models: Stress abt money & assault

We begin with the Bayesian equivalent of simple means or intercept-only model. As implied by the name, the intercept-only model for an individual stress in the full sample estimates only one parameter - the intercept or mean value of overall stress. In a classical (frequentist) model, this estimate of the mean stress level would be computed directly from the data or likelihood. In a Bayesian model, this estimate represents the center of a posterior sample of estimates that each are generated by combining the likelihood (e.g., observed mean in the data) with a prior distribution of plausible values for the parameter in question. In constructing a Bayesian model, one might specify a highly diffuse or “flat” prior distribution(s), which would result in posterior estimates that are generated primarily by the likelihood; with diffuse priors, Bayesian model estimates generally will converge with estimates generated from comparable classical statistical models. Alternatively, one might specify stronger or “more informative” prior distributions that, for instance, specify a certain range of values as highly implausible or even as impossible; doing so will result in posterior estimates that deviate from likelihood-only estimates in predictable, prior-specified ways. For a simple example, a classical model of crime counts might sometimes generate negative predicted counts for some subgroups and improbably extreme positive counts for other subgroups; in a Bayesian model, one could specify an a priori distribution of plausible values for which negative counts are impossible and extreme positive counts are improbable. In this study, we specify “weakly informative” or “regularizing” priors (McElreath) that are sufficiently diffuse as to allow for a wide range of likelihood-driven estimates yet are informative or “tight” enough to down-weight and pull in extreme or highly implausible likelihood-based estimates; such priors are designed to generate better out-of-sample predictive properties than likelihood-based estimates, particularly in small (sub)samples.

We start by illustrating the poor fit between Gaussian normal distributional assumptions and these ordinal stress items by focusing on two individual stress items at wave one: stress about having enough money to buy necessities (stmonyw1) and stress about being assaulted (stmugw1). As we noted above, the financial stress item item exhibits an approximately normal distribution with nearly symmetric decay about the midpoint, whereas the victimization stress item has a positively skewed distribution. These full-sample item distributions can be seen in Figure 1 above; they are also replicated for convenience in the frequency bar graphs below.

#load stress.wide (from Fig1 Rmd) 
load(here("1_Data_Files/Datasets/stress_wide.Rdata"))

stress.wide <- zap_labels(stress.wide)
stress.wide <- zap_label(stress.wide)

3.1.3.1 Example stress item response distributions

3.1.3.1.1 stmonyw1 (stress about money, time 1)
ggplot(stress.wide, aes(stmonyw1)) +
  geom_bar()

3.1.3.1.2 stmugw1 (stress about assault, time 1)
ggplot(stress.wide, aes(stmugw1)) +
  geom_bar()

To estimate means in an intercept-only Bayesian model, one might specify a normally distributed prior distribution centered at the measurement scale midpoint (mu=3), and perhaps specify sd=2 for a relatively flat prior that allows for a wide range of plausible values - as well as implausible values given measured range is from 1 to 5. In fact, this is the default scaled prior distribution for the intercept estimate that will be used in the rstanarm model below. This prior distribution would be very weakly informative for this distribution (i.e., a one standard deviation unit decrease or increase is specified equivalent to the variable’s min and max values, respectively), meaning that it should result in the likelihood (data) driving the posterior estimates. Moreover, the posterior estimates generated by this model will converge with results generated using classical frequentist approaches (many of which also assume distributional normality). The figure below helps with visualizing this prior. The black normal curve displays prior probability values for a range of a priori theoretically plausible response categories. The bulk of this prior distribution falls within the red lines indicating the limits of the measured response values of 1 and 5 for our stress items. However, a substantial amount of the probability distribution also covers values for “implausible” category responses laying outside these bounds. Hence, non-zero probabilities for stress categories such as “0” or “6” are technically permitted by the prior distribution though, when combined with the likelihood, estimated response probabilities for these categories should converge to zero since there are no observed data beyond these bounds and ample data within them.

#simulate intercept prior for linear models predicting specific stress items
#Center at midpoint x=3 and rescale to sd=2
  a <- rnorm(1e4,3,2)
  # mean(a)
  minx <- 1
  maxx <- 5
  
  curve(dnorm(x,3,2),from=-5,to=10,n=200)
  curve((x-1), add = TRUE, col = "red", lwd = 2)
  curve((x-5), add = TRUE, col = "red", lwd = 2)

Now let’s estimate overall and group-specific means with rstanarm models, which automatically scale the variable priors, using the same procedures as before. We can generate a prior summary after estimating the model to see that the scaled prior specified automatically by the model is same as the one graphically depicted in the example above.

3.1.3.2 stmonyw1: Normal model, full sample

We begin with the stmonyw1 intercept-only model in the full sample, …

#Bayesian models estimating *full sample mean* and specific rural/ses subgroup means for specific stress at T1.
  #Items: *stmonyw1* sttranw1 strespw1 stfairw1 stjobw1 stthftw1 stmugw1 

#Stress about money at T1: Intercept only, Normal prior
  #Midpoint of plausible range [1,5] = 3

  #Manual caching for stan_glm - file & file_refit built into brms 
if (file.exists(here("Models","stmony.rds"))) {
  stmony <- readRDS("Models/stmony.rds")
} else {
stmony <- stan_glm(stmonyw1 ~ 1,
            family = gaussian(),
            data = stress.wide,
            prior_intercept = normal(3, 2),
            chains = 4, 
            cores = nCoresphys, 
            seed = 8675309
            )
saveRDS(stmony, "Models/stmony.rds")
}
out.stmony <- ppchecks(stmony) #runs user-written "ppchecks" function that request common checks
3.1.3.2.1 PPcheck(density)
out.stmony[[3]]

3.1.3.2.2 PPcheck(histogram)
out.stmony[[5]]

3.1.3.2.3 PPcheck(mean)
out.stmony[[6]]

3.1.3.2.4 PPcheck(median)
out.stmony[[7]]

3.1.3.2.5 PPcheck(boxplots)
out.stmony[[4]]

3.1.3.2.6 Fit summary
out.stmony[[1]]
## 
## Model Info:
##  function:     stan_glm
##  family:       gaussian [identity]
##  formula:      stmonyw1 ~ 1
##  algorithm:    sampling
##  sample:       4000 (posterior sample size)
##  priors:       see help('prior_summary')
##  observations: 489
##  predictors:   1
## 
## Estimates:
##               mean   sd   2.5%   97.5%
## (Intercept) 3.15   0.05 3.05   3.24   
## sigma       1.10   0.03 1.04   1.17   
## 
## Fit Diagnostics:
##            mean   sd   2.5%   97.5%
## mean_PPD 3.15   0.07 3.01   3.29   
## 
## The mean_ppd is the sample average posterior predictive distribution of the outcome variable (for details see help('summary.stanreg')).
## 
## MCMC diagnostics
##               mcse Rhat n_eff
## (Intercept)   0.00 1.00 2794 
## sigma         0.00 1.00 2455 
## mean_PPD      0.00 1.00 3355 
## log-posterior 0.02 1.00 1610 
## 
## For each parameter, mcse is Monte Carlo standard error, n_eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor on split chains (at convergence Rhat=1).
3.1.3.2.7 Prior summary
out.stmony[[2]]
## Priors for model 'modelfit' 
## ------
## Intercept (after predictors centered)
##  ~ normal(location = 3, scale = 2)
## 
## Auxiliary (sigma)
##   Specified prior:
##     ~ exponential(rate = 1)
##   Adjusted prior:
##     ~ exponential(rate = 0.91)
## ------
## See help('prior_summary.stanreg') for more details

… followed by the stmonyw1 group-specific means model.

3.1.3.3 stmonyw1: Normal model, grouped

#Bayesian models estimating full sample mean and *specific rural/ses subgroup means* for specific stress at T1.
  #Items: *stmonyw1* sttranw1 strespw1 stfairw1 stjobw1 stthftw1 stmugw1 

#Stress about money at T1: Group intercepts, Normal prior 
if (file.exists(here("Models","stmony.rurses"))) {
  stmony.rurses <- readRDS("Models/stmony.rurses")
} else {
stmony.rurses <- update(stmony, formula. = ~ 0 + rural.ses.med)
saveRDS(stmony.rurses, "Models/stmony_rurses.rds")
}
out.stmony.rurses  <- ppchecks(stmony.rurses)
3.1.3.3.1 PPcheck(density)
out.stmony.rurses[[3]]

3.1.3.3.2 PPcheck(histogram)
out.stmony.rurses[[5]]

3.1.3.3.3 PPcheck(mean)
out.stmony.rurses[[6]]

3.1.3.3.4 PPcheck(median)
out.stmony.rurses[[7]]

3.1.3.3.5 PPcheck(boxplots)
out.stmony.rurses[[4]]

3.1.3.3.6 PPcheck(grouped-mean)
pp_check(stmony.rurses, plotfun = "stat_grouped", stat = "mean", group = "rural.ses.med")

3.1.3.3.7 PPcheck(grouped-median)
pp_check(stmony.rurses, plotfun = "stat_grouped", stat = "median", group = "rural.ses.med")

3.1.3.3.8 Fit summary
out.stmony.rurses[[1]]
## 
## Model Info:
##  function:     stan_glm
##  family:       gaussian [identity]
##  formula:      stmonyw1 ~ rural.ses.med - 1
##  algorithm:    sampling
##  sample:       4000 (posterior sample size)
##  priors:       see help('prior_summary')
##  observations: 489
##  predictors:   4
## 
## Estimates:
##                  mean   sd   2.5%   97.5%
## rural.ses.med1 2.93   0.10 2.73   3.13   
## rural.ses.med2 3.10   0.10 2.90   3.29   
## rural.ses.med3 3.41   0.09 3.23   3.59   
## rural.ses.med4 3.10   0.11 2.90   3.31   
## sigma          1.09   0.04 1.02   1.16   
## 
## Fit Diagnostics:
##            mean   sd   2.5%   97.5%
## mean_PPD 3.15   0.07 3.01   3.29   
## 
## The mean_ppd is the sample average posterior predictive distribution of the outcome variable (for details see help('summary.stanreg')).
## 
## MCMC diagnostics
##                mcse Rhat n_eff
## rural.ses.med1 0.00 1.00 7020 
## rural.ses.med2 0.00 1.00 6261 
## rural.ses.med3 0.00 1.00 6531 
## rural.ses.med4 0.00 1.00 5985 
## sigma          0.00 1.00 5326 
## mean_PPD       0.00 1.00 5051 
## log-posterior  0.04 1.00 1962 
## 
## For each parameter, mcse is Monte Carlo standard error, n_eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor on split chains (at convergence Rhat=1).
3.1.3.3.9 Prior summary
out.stmony.rurses[[2]]
## Priors for model 'modelfit' 
## ------
## 
## Coefficients
##   Specified prior:
##     ~ normal(location = [0,0,0,...], scale = [2.5,2.5,2.5,...])
##   Adjusted prior:
##     ~ normal(location = [0,0,0,...], scale = [6.52,6.32,6.03,...])
## 
## Auxiliary (sigma)
##   Specified prior:
##     ~ exponential(rate = 1)
##   Adjusted prior:
##     ~ exponential(rate = 0.91)
## ------
## See help('prior_summary.stanreg') for more details

3.1.3.4 stmugw1: Normal model, full sample

Next, the stmugw1 full sample model…

#Bayesian models estimating *full sample mean* and specific rural/ses subgroup means for specific stress at T1.
  #Items: stmonyw1 sttranw1 strespw1 stfairw1 stjobw1 stthftw1 *stmugw1* 

#Stress about assault at T1: Intercept only, Normal prior
  #Midpoint of plausible range [1,5] = 3
if (file.exists(here("Models","stmug"))) {
  stmug <- readRDS("Models/stmug")
} else {
stmug <- stan_glm(stmugw1 ~ 1,
            family = gaussian(),
            data = stress.wide,
            prior_intercept = normal(3, 2),
            #chains = 4, cores = 8,
            seed = 8675309)
saveRDS(stmug, "Models/stmug.rds")
}
out.stmug <- ppchecks(stmug)
3.1.3.4.1 PPcheck(density)
out.stmug[[3]]

3.1.3.4.2 PPcheck(histogram)
out.stmug[[5]]

3.1.3.4.3 PPcheck(mean)
out.stmug[[6]]

3.1.3.4.4 PPcheck(median)
out.stmug[[7]]

3.1.3.4.5 PPcheck(boxplots)
out.stmug[[4]]

3.1.3.4.6 Fit summary
out.stmug[[1]]
## 
## Model Info:
##  function:     stan_glm
##  family:       gaussian [identity]
##  formula:      stmugw1 ~ 1
##  algorithm:    sampling
##  sample:       4000 (posterior sample size)
##  priors:       see help('prior_summary')
##  observations: 489
##  predictors:   1
## 
## Estimates:
##               mean   sd   2.5%   97.5%
## (Intercept) 1.96   0.05 1.86   2.05   
## sigma       1.06   0.03 0.99   1.12   
## 
## Fit Diagnostics:
##            mean   sd   2.5%   97.5%
## mean_PPD 1.96   0.07 1.82   2.09   
## 
## The mean_ppd is the sample average posterior predictive distribution of the outcome variable (for details see help('summary.stanreg')).
## 
## MCMC diagnostics
##               mcse Rhat n_eff
## (Intercept)   0.00 1.00 2905 
## sigma         0.00 1.00 2677 
## mean_PPD      0.00 1.00 3325 
## log-posterior 0.03 1.00 1228 
## 
## For each parameter, mcse is Monte Carlo standard error, n_eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor on split chains (at convergence Rhat=1).
3.1.3.4.7 Prior summary
out.stmug[[2]]
## Priors for model 'modelfit' 
## ------
## Intercept (after predictors centered)
##  ~ normal(location = 3, scale = 2)
## 
## Auxiliary (sigma)
##   Specified prior:
##     ~ exponential(rate = 1)
##   Adjusted prior:
##     ~ exponential(rate = 0.95)
## ------
## See help('prior_summary.stanreg') for more details

…and the stmugw1 group-specific means model.

3.1.3.5 stmugw1: Normal model, grouped

#Bayesian models estimating full sample mean and *specific rural/ses subgroup means* for specific stress at T1.
  #Items: stmonyw1 sttranw1 strespw1 stfairw1 stjobw1 stthftw1 *stmugw1* 

#Stress about assault at T1: Group intercepts, Normal prior 
if (file.exists(here("Models","stmug.rurses"))) {
  stmug.rurses <- readRDS("Models/stmug.rurses")
} else {
stmug.rurses <- update(stmug, formula. = ~ 0 + rural.ses.med)
saveRDS(stmug.rurses, "Models/stmug_rurses.rds")
}
out.stmug.rurses <- ppchecks(stmug.rurses)
3.1.3.5.1 PPcheck(density)
out.stmug.rurses[[3]]

3.1.3.5.2 PPcheck(histogram)
out.stmug.rurses[[5]]

3.1.3.5.3 PPcheck(mean)
out.stmug.rurses[[6]]

3.1.3.5.4 PPcheck(median)
out.stmug.rurses[[7]]

3.1.3.5.5 PPcheck(boxplots)
out.stmug.rurses[[4]]

3.1.3.5.6 PPcheck(grouped-mean)
pp_check(stmug.rurses, plotfun = "stat_grouped", stat = "mean", group = "rural.ses.med")

3.1.3.5.7 PPcheck(grouped-median)
pp_check(stmug.rurses, plotfun = "stat_grouped", stat = "median", group = "rural.ses.med")

3.1.3.5.8 Fit summary
out.stmug.rurses[[1]]
## 
## Model Info:
##  function:     stan_glm
##  family:       gaussian [identity]
##  formula:      stmugw1 ~ rural.ses.med - 1
##  algorithm:    sampling
##  sample:       4000 (posterior sample size)
##  priors:       see help('prior_summary')
##  observations: 489
##  predictors:   4
## 
## Estimates:
##                  mean   sd   2.5%   97.5%
## rural.ses.med1 1.65   0.10 1.46   1.83   
## rural.ses.med2 1.90   0.09 1.72   2.10   
## rural.ses.med3 2.19   0.09 2.02   2.36   
## rural.ses.med4 2.04   0.10 1.84   2.23   
## sigma          1.04   0.03 0.98   1.11   
## 
## Fit Diagnostics:
##            mean   sd   2.5%   97.5%
## mean_PPD 1.96   0.07 1.83   2.09   
## 
## The mean_ppd is the sample average posterior predictive distribution of the outcome variable (for details see help('summary.stanreg')).
## 
## MCMC diagnostics
##                mcse Rhat n_eff
## rural.ses.med1 0.00 1.00 5720 
## rural.ses.med2 0.00 1.00 4876 
## rural.ses.med3 0.00 1.00 4560 
## rural.ses.med4 0.00 1.00 5039 
## sigma          0.00 1.00 5324 
## mean_PPD       0.00 1.00 4868 
## log-posterior  0.04 1.00 1936 
## 
## For each parameter, mcse is Monte Carlo standard error, n_eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor on split chains (at convergence Rhat=1).
3.1.3.5.9 Prior summary
out.stmug.rurses[[2]]
## Priors for model 'modelfit' 
## ------
## 
## Coefficients
##   Specified prior:
##     ~ normal(location = [0,0,0,...], scale = [2.5,2.5,2.5,...])
##   Adjusted prior:
##     ~ normal(location = [0,0,0,...], scale = [6.25,6.06,5.78,...])
## 
## Auxiliary (sigma)
##   Specified prior:
##     ~ exponential(rate = 1)
##   Adjusted prior:
##     ~ exponential(rate = 0.95)
## ------
## See help('prior_summary.stanreg') for more details

A couple things are noteworthy here. First, the overall and group-specific means were recovered from the predicted distributions generated by these “normal” models. This is unsurprising, since this is essentially what these models are designed to do. However, the medians were not recovered by predicted distributions. Other posterior predicted checks, such as observed versus predicted (Y vs. Yrep) density overlays or histograms, also show poor fit between ordinal variable distributions and metric normality assumptions.

Descriptive and inferential problems stemming from poor fit in metric linear models will be minimized when analyzing ordinal items or multi-item ordinal scales with a substantial number of categories and with distributions characterized by symmetric decay about a centrally located mean (e.g., “stmony” above). Problems will be exacerbated in metric linear models for ordinal items (or multi-item ordinal scales) with few categories and/or with distributions that do not resembles a Gaussian normal distribution (e.g., “stmug” above).

Yet, alternative ordinal models can better handle each of these situations. So, while treating a general stress scale comprised of multiple ordinal items as metric might be defensible, particularly if the scale exhibits symmetric decay about the mean, analyzing individual stress-specific ordinal items as metric is potentially more problematic. Since a key goal is to accurately describe the item-level relationships between stress and theorized outcomes, traditional linear (i.e., metric normal) models are not a wise choice.

3.1.4 Ordinal, not normal, models should be ordinary

Alternatively, let’s consider an ordinal model for the specific stress items. First, we need to recode specific stress variables as factors. We will also create a new community group factor that is more descriptive (i.e., “Rural/Low SES” instead of “1”), since we will want to start paying attention to specific group distributions soon.

#First, need to recode specific stress variables as factors. 
  #Items: stmonyw1 sttranw1 strespw1 stfairw1 stjobw1 stthftw1 stmugw1 
#Also create new community "group" variable.

stress.wide2 <- stress.wide %>% 
  mutate(
    stmonyw1f = factor(stmonyw1, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    sttranw1f = factor(sttranw1, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    strespw1f = factor(strespw1, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stfairw1f = factor(stfairw1, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stjobw1f = factor(stjobw1, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stthftw1f = factor(stthftw1, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stmugw1f = factor(stmugw1, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    rural.ses.med2 = 0, 
    rural.ses.med2 = ifelse(rural.ses.med == 1, "Rural/Low SES", rural.ses.med2), #Rural/Low SES
    rural.ses.med2 = ifelse(rural.ses.med == 2, "Rural/High SES", rural.ses.med2), #Rural/High SES
    rural.ses.med2 = ifelse(rural.ses.med == 3, "Urban/Low SES", rural.ses.med2), #Urban/Low SES
    rural.ses.med2 = ifelse(rural.ses.med == 4, "Urban/High SES", rural.ses.med2), #Urban/High SES
    rural.ses.med2 = factor(rural.ses.med2)
    )
  # head(stress.wide2)

Next, let’s consider a cumulative probit brms model to see if we can recover overall and group-specific means and medians for the ordinal stress items as well as their specific ordinal category values or “thresholds.” Recall, the metric normal models above recovered means well, which is what they are designed to do, but the posterior predictive check plots (e.g., density and histogram) show that the underlying normal distribution assumption results in model predictions that fail to recover the observed ordinal item values. We will start with the stmonyw1 item again.

3.1.4.1 stmonyw1: Cumul. probit, full sample

#Revise function to call basic summaries & ppchecks 
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit, probs = c(0.025, 0.975), digits = 2) #summarize results
  priorsum <- prior_summary(modelfit) #check priors  
  ppcheck <- pp_check(modelfit, cores=1) #posterior predictive checks
   allchecks <- list(fitsummary, priorsum, ppcheck)
    return(allchecks)
}
#Ordinal cumulative probit model predicting stress about money at T1 

#Stress about money at T1 - Thresholds only, Cumulative probit model:
stmony.ord <-
  brm(data = stress.wide2,
      family = cumulative("probit"),
      stmonyw1f ~ 1,
      prior(normal(0, 4), class = Intercept), #see kruschke/kurtz re: priors for this model
      iter = 2000, warmup = 1000, 
      chains = 4,               
      cores = nCoresphys, 
        backend = "cmdstanr", 
        #threads = threading(2), #consider within-chain threading if machine has at least 8 physical cores
      seed = 8675309,
      file = "Models/stmony.ord",
      file_refit = "on_change"
      )

out.stmony.ord <-  ppchecks(stmony.ord) #posterior predictive checks

# Plot fit
# plot(stmony.ord, ask=FALSE) 
3.1.4.1.1 PPcheck(bars, full sample)
  pp_check(stmony.ord, type="bars", ndraws=1000, cores=1) +
      scale_x_continuous("Stress abt money, T1", breaks = 1:5) + 
      scale_y_continuous(NULL, breaks = NULL, expand = expansion(mult = c(0, 0.05))) +
      ggtitle("Data with posterior predictions (cumul-ord, fullsamp)",
          subtitle = "N = 489") +
      theme(legend.background = element_blank(),
          legend.position = c(.9, .8))

3.1.4.1.2 PPcheck(density, full sample)
out.stmony.ord[[3]]

3.1.4.1.3 Fit summary (full sample)
out.stmony.ord[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stmonyw1f ~ 1 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept[1]    -1.43      0.08    -1.60    -1.27 1.00     2391     2566
## Intercept[2]    -0.60      0.06    -0.72    -0.49 1.00     3634     3273
## Intercept[3]     0.27      0.06     0.16     0.38 1.00     3904     3417
## Intercept[4]     1.23      0.07     1.09     1.37 1.00     3636     3339
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.1.4 Prior summary (full sample)
out.stmony.ord[[2]]
##         prior     class coef group resp dpar nlpar lb ub       source
##  normal(0, 4) Intercept                                          user
##  normal(0, 4) Intercept    1                             (vectorized)
##  normal(0, 4) Intercept    2                             (vectorized)
##  normal(0, 4) Intercept    3                             (vectorized)
##  normal(0, 4) Intercept    4                             (vectorized)

3.1.4.2 stmonyw1: Cumul. probit, grouped

#Ordinal cumulative probit model predicting stress about money at T1 

#Stress about money at T1: Thresholds + group differences, Cumul probit 

stmony.ord.rurses <- update(stmony.ord,
                            formula. = ~ 1 + rural.ses.med2,
                            newdata = stress.wide2, 
                            file = "Models/stmony.ord.rurses",
                            file_refit = "on_change"
                            )

out.stmony.ord.rurses  <- ppchecks(stmony.ord.rurses) #posterior predictive checks

# Plot fit
# plot(stmony.ord.rurses, ask=FALSE) 
3.1.4.2.1 PPcheck(bars, grouped)
  pp_check(stmony.ord.rurses, type="bars_grouped", 
             group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt money, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cumul-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.2.2 PPcheck(density, grouped)
out.stmony.ord.rurses[[3]]

3.1.4.2.3 Fit summary (grouped)
out.stmony.ord.rurses[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stmonyw1f ~ rural.ses.med2 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept[1]                   -1.39      0.12    -1.62    -1.17 1.00     2460
## Intercept[2]                   -0.56      0.10    -0.74    -0.37 1.00     2649
## Intercept[3]                    0.33      0.10     0.13     0.52 1.00     2534
## Intercept[4]                    1.30      0.11     1.09     1.52 1.00     3007
## rural.ses.med2RuralDLowSES     -0.16      0.13    -0.43     0.11 1.00     3223
## rural.ses.med2UrbanDHighSES     0.01      0.13    -0.26     0.27 1.00     3014
## rural.ses.med2UrbanDLowSES      0.31      0.13     0.06     0.56 1.00     3003
##                             Tail_ESS
## Intercept[1]                    2606
## Intercept[2]                    2934
## Intercept[3]                    3015
## Intercept[4]                    3465
## rural.ses.med2RuralDLowSES      2705
## rural.ses.med2UrbanDHighSES     2803
## rural.ses.med2UrbanDLowSES      2966
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.2.4 Prior summary (grouped)
out.stmony.ord.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##        (flat)         b                                                        
##        (flat)         b  rural.ses.med2RuralDLowSES                            
##        (flat)         b rural.ses.med2UrbanDHighSES                            
##        (flat)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 4) Intercept                                                        
##  normal(0, 4) Intercept                           1                            
##  normal(0, 4) Intercept                           2                            
##  normal(0, 4) Intercept                           3                            
##  normal(0, 4) Intercept                           4                            
##        source
##       default
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

As expected, this model is a much better fit to the data than the metric normal model. The overall unconditional model recovers the observed data very well; however, the group means model does not quite recover the observed data for all five categories within each of the four groups.

Rather than specifying a cumulative ordinal model, a sequential ordinal model with category-specific effects of community group on stress might do a better job of recovering the observed data in the group means models. The cumulative model is more parsimonious, but it is over- and under-predicting values for some categories of stmonyw1, and it cannot be modified to specify category-specific effects.

The sequential ordinal model has an intuitive theoretical derivation - it relies on the logic, built into truly ordinal variables, that in order to achieve a category k, one must first achieve all lower categories 1 through k – 1. The sequential model, as well as the mathematically similar adjacent category model, allows for specification of category-specific effects of a predictor (for details, see Burkner & Vuorre, Appendix A).

3.1.4.3 stmonyw1: Seq. probit, cat-specific, grouped

#See if sequential model also improves recovery of observed data compared to cumulative model

prior_seq <- prior(normal(0, 5), class = b) +
            prior(normal(0, 5), class = Intercept)
  #see burkner & vuorre re: priors for this model
  # https://journals.sagepub.com/doi/full/10.1177/2515245918823199

stmony.seq.rurses <- update(stmony.ord, 
                            formula. = ~ 1 + cs(rural.ses.med2), 
                            prior = prior_seq, 
                            newdata = stress.wide2,
                            family = sratio("cloglog"), 
                            file = "Models/stmony.seq.rurses",
                            file_refit = "on_change"
                            )

out.stmony.seq.rurses <-  ppchecks(stmony.seq.rurses) #posterior predictive checks

# Plot fit
# plot(stmony.seq.rurses, ask=FALSE)
3.1.4.3.1 PPcheck(bars, cat-spec)
  pp_check(stmony.seq.rurses, type="bars_grouped", 
           group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt money, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cat-spec-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.3.2 PPcheck(density, cat-spec)
out.stmony.seq.rurses[[3]]

3.1.4.3.3 Fit summary (cat-spec)
out.stmony.seq.rurses[[1]]
##  Family: sratio 
##   Links: mu = cloglog; disc = identity 
## Formula: stmonyw1f ~ cs(rural.ses.med2) 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                                Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept[1]                      -2.89      0.39    -3.70    -2.20 1.00
## Intercept[2]                      -1.49      0.20    -1.91    -1.12 1.00
## Intercept[3]                      -0.18      0.14    -0.47     0.10 1.00
## Intercept[4]                       0.31      0.20    -0.10     0.69 1.00
## rural.ses.med2RuralDLowSES[1]     -0.82      0.47    -1.78     0.08 1.00
## rural.ses.med2RuralDLowSES[2]     -0.03      0.29    -0.60     0.55 1.00
## rural.ses.med2RuralDLowSES[3]     -0.02      0.21    -0.42     0.38 1.00
## rural.ses.med2RuralDLowSES[4]     -0.02      0.30    -0.59     0.57 1.00
## rural.ses.med2UrbanDHighSES[1]    -0.61      0.50    -1.58     0.37 1.00
## rural.ses.med2UrbanDHighSES[2]    -0.26      0.28    -0.82     0.28 1.00
## rural.ses.med2UrbanDHighSES[3]     0.59      0.25     0.12     1.07 1.00
## rural.ses.med2UrbanDHighSES[4]     0.11      0.28    -0.43     0.65 1.00
## rural.ses.med2UrbanDLowSES[1]      0.35      0.58    -0.78     1.54 1.00
## rural.ses.med2UrbanDLowSES[2]      0.10      0.28    -0.46     0.63 1.00
## rural.ses.med2UrbanDLowSES[3]      0.71      0.22     0.29     1.14 1.00
## rural.ses.med2UrbanDLowSES[4]      0.16      0.25    -0.33     0.66 1.00
##                                Bulk_ESS Tail_ESS
## Intercept[1]                       2666     2149
## Intercept[2]                       2197     2246
## Intercept[3]                       2319     2740
## Intercept[4]                       2394     2192
## rural.ses.med2RuralDLowSES[1]      2770     2547
## rural.ses.med2RuralDLowSES[2]      2629     2921
## rural.ses.med2RuralDLowSES[3]      2768     3130
## rural.ses.med2RuralDLowSES[4]      2998     2954
## rural.ses.med2UrbanDHighSES[1]     2793     2918
## rural.ses.med2UrbanDHighSES[2]     2584     2591
## rural.ses.med2UrbanDHighSES[3]     3311     2975
## rural.ses.med2UrbanDHighSES[4]     2728     2793
## rural.ses.med2UrbanDLowSES[1]      2965     2869
## rural.ses.med2UrbanDLowSES[2]      2504     2675
## rural.ses.med2UrbanDLowSES[3]      3168     2859
## rural.ses.med2UrbanDLowSES[4]      2726     2627
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.3.4 Prior summary (cat-spec)
out.stmony.seq.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##  normal(0, 5)         b                                                        
##  normal(0, 5)         b  rural.ses.med2RuralDLowSES                            
##  normal(0, 5)         b rural.ses.med2UrbanDHighSES                            
##  normal(0, 5)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 5) Intercept                                                        
##  normal(0, 5) Intercept                           1                            
##  normal(0, 5) Intercept                           2                            
##  normal(0, 5) Intercept                           3                            
##  normal(0, 5) Intercept                           4                            
##        source
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

As suspected, this model does a much better job of recovering the observed data. Also, it is the specification of category-specific effects (not the specification of a sequential model) that improves recovery of the observed data distribution (not shown). Of course, the improved (over)fit to the data was purchased at the steep cost of estimating nine additional parameters, which is not too unwieldy for this simple descriptive model but would become problematic in more complex multivariate regression models with our sample.

For this type of model, it can be helpful to plot the estimated relationship between community group and stmonyw1 for each threshold or response category of the stress outcome variable.

conditional_effects(stmony.seq.rurses, "rural.ses.med2", categorical = TRUE)

The figure shows that respondents in rural communities are much more likely to report “sometimes” (=3) stressing about money compared to urban respondents - this is the modal response category for rural residents. In contrast, the modal category is “often” (=4) for urban residents - and this pattern is especially pronounced among respondents in low SES urban areas. Overall, then, it appears that urban residents are more likely than rural residents to stress about having money to pay for necessities.

We will continue examining the fit of both the more parsimonious cumulative model and the more flexible sequential model from here. The sequential category-specific model will ensure that we accurately recover the observed data when plotting descriptive response distributions for stress items by community (Figure 2). Later, when building models to predict our key outcomes (criminal behavior; criminal intent; negative emotions), we will switch back to cumulative probit models of stress and use the built-in cumulative ordinal predictor specification with mo(). As these `stmonyw1’ results show, a cumulative ordinal model specification might not result in a perfect fit relative to the observed data, but it is a substantial improvement on assuming a normal distribution, and this relatively small loss of fit (at least compared to metric normal models) is a worthwhile trade-off for the cumulative model’s parsimony as our models get more complex. If we had a much larger sample and/or our key outcome variables were not so rare, we might also be able to include the stress item predictors as sequential category-specific ordinal thresholds, such as by recoding categorical versions of our stress items with “sequential difference coding” (see p.23: https://bpspsychub.onlinelibrary.wiley.com/doi/10.1111/bmsp.12195). With our data, though, we will need to accept the loss of precision for the sake of parsimony in our ordinal modeling.

# CHECK LOO POSTERIOR PREDICTIVE COMPARISON? 

3.1.4.4 stmugw1: Cumul. probit, full sample

Let’s continue the example by following the same procedure with our stmugw1 variable.

#Ordinal cumulative probit model predicting stress about assault at T1 

#Stress about assault at T1 - Thresholds only, Cumulative probit model:
stmug.ord <-
  brm(data = stress.wide2,
      family = cumulative("probit"),
      stmugw1f ~ 1,
      prior(normal(0, 4), class = Intercept), #see kruschke/kurz re: priors for this model
      #file = here("2_Models", "stmug.ord"), 
          #Save fit - CAUTION: despite model changes, will *NOT* rerun the model if `file` exists,    
      iter = 2000, warmup = 1000, 
      chains = 4, 
       cores = nCoresphys, 
        backend = "cmdstanr", 
        #threads = threading(2), #consider within-chain threading if machine has at least 8 physical cores
      seed = 8675309,         
      file = "Models/stmug.ord",
      file_refit = "on_change"
      )

out.stmug.ord <-  ppchecks(stmug.ord) #posterior predictive checks
3.1.4.4.1 PPcheck(bars, full sample)
  pp_check(stmug.ord, type="bars", ndraws=1000, cores=1) +
      scale_x_continuous("Stress abt assault, T1", breaks = 1:5) + 
      scale_y_continuous(NULL, breaks = NULL, expand = expansion(mult = c(0, 0.05))) +
      ggtitle("Data with posterior predictions (cumul-ord, fullsamp)",
          subtitle = "N = 489") +
      theme(legend.background = element_blank(),
          legend.position = c(.9, .8))

3.1.4.4.2 PPcheck(density, full sample)
out.stmug.ord[[3]]

3.1.4.4.3 Fit summary (full sample)
out.stmug.ord[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stmugw1f ~ 1 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept[1]    -0.16      0.06    -0.27    -0.05 1.00     3599     2936
## Intercept[2]     0.58      0.06     0.46     0.70 1.00     4875     3399
## Intercept[3]     1.31      0.08     1.16     1.46 1.00     4858     3219
## Intercept[4]     2.06      0.13     1.82     2.33 1.00     4276     3150
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.4.4 Prior summary (full sample)
out.stmug.ord[[2]]
##         prior     class coef group resp dpar nlpar lb ub       source
##  normal(0, 4) Intercept                                          user
##  normal(0, 4) Intercept    1                             (vectorized)
##  normal(0, 4) Intercept    2                             (vectorized)
##  normal(0, 4) Intercept    3                             (vectorized)
##  normal(0, 4) Intercept    4                             (vectorized)

3.1.4.5 stmugw1: Cumul. probit, grouped

#Ordinal cumulative probit model predicting stress about assault at T1 

#Stress about assault at T1: Thresholds + group differences, Cumul probit 
stmug.ord.rurses <- update(stmug.ord,
                            formula. = ~ 1 + rural.ses.med2,
                            newdata = stress.wide2, 
                           file = "Models/stmug.ord.rurses",
                           file_refit = "on_change"
                           )
out.stmug.ord.rurses <-  ppchecks(stmug.ord.rurses) #posterior predictive checks
3.1.4.5.1 PPcheck(bars, grouped)
  pp_check(stmug.ord.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt assault, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cumul-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.5.2 PPcheck(density, grouped)
stmug.ord.rurses[[3]]
##         prior     class                        coef group resp dpar nlpar lb ub
##        (flat)         b                                                        
##        (flat)         b  rural.ses.med2RuralDLowSES                            
##        (flat)         b rural.ses.med2UrbanDHighSES                            
##        (flat)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 4) Intercept                                                        
##  normal(0, 4) Intercept                           1                            
##  normal(0, 4) Intercept                           2                            
##  normal(0, 4) Intercept                           3                            
##  normal(0, 4) Intercept                           4                            
##        source
##       default
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)
3.1.4.5.3 Conditional effects (grouped)
conditional_effects(stmug.ord.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.5.4 Fit summary (grouped)
out.stmug.ord[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stmugw1f ~ 1 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept[1]    -0.16      0.06    -0.27    -0.05 1.00     3599     2936
## Intercept[2]     0.58      0.06     0.46     0.70 1.00     4875     3399
## Intercept[3]     1.31      0.08     1.16     1.46 1.00     4858     3219
## Intercept[4]     2.06      0.13     1.82     2.33 1.00     4276     3150
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.5.5 Prior summary (grouped)
out.stmug.ord[[2]]
##         prior     class coef group resp dpar nlpar lb ub       source
##  normal(0, 4) Intercept                                          user
##  normal(0, 4) Intercept    1                             (vectorized)
##  normal(0, 4) Intercept    2                             (vectorized)
##  normal(0, 4) Intercept    3                             (vectorized)
##  normal(0, 4) Intercept    4                             (vectorized)

The cumulative model does a much better job recovering the observed data for the stmugw1 item, relative to the earlier stmonyw1 model. Also, as expected, it is a much better fit than the metric normal model. Let’s compare the sequential model with category-specific effects for the group means model.

3.1.4.6 stmugw1: Seq. probit, cat-specific, grouped

#See if sequential model w/category specific effects improves recovery of observed data
stmug.seq.rurses <- update(stmug.ord, 
                           formula. = ~ 1 + cs(rural.ses.med2), 
                           prior = prior_seq, 
                           newdata = stress.wide2,
                           family = sratio("cloglog"), 
                           file = "Models/stmug.seq.rurses",
                           file_refit = "on_change"
                           )

out.stmug.seq.rurses <-  ppchecks(stmug.seq.rurses) #posterior predictive checks
3.1.4.6.1 PPcheck(bars, cat-spec)
  pp_check(stmug.seq.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt assault, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cat-spec-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.6.2 PPcheck(density, cat-spec)
out.stmug.seq.rurses[[3]]

3.1.4.6.3 Conditional effects (cat-spec)
conditional_effects(stmug.seq.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.6.4 Fit summary (cat-spec)
out.stmug.seq.rurses[[1]]
##  Family: sratio 
##   Links: mu = cloglog; disc = identity 
## Formula: stmugw1f ~ cs(rural.ses.med2) 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                                Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept[1]                      -0.47      0.14    -0.75    -0.21 1.00
## Intercept[2]                      -0.61      0.19    -0.98    -0.25 1.00
## Intercept[3]                       0.42      0.20     0.01     0.80 1.00
## Intercept[4]                       3.13      1.72     0.73     7.26 1.00
## rural.ses.med2RuralDLowSES[1]     -0.06      0.19    -0.43     0.31 1.00
## rural.ses.med2RuralDLowSES[2]     -0.95      0.25    -1.43    -0.47 1.00
## rural.ses.med2RuralDLowSES[3]     -0.55      0.42    -1.41     0.28 1.00
## rural.ses.med2RuralDLowSES[4]     -1.90      3.84   -10.34     4.64 1.00
## rural.ses.med2UrbanDHighSES[1]     0.10      0.20    -0.30     0.50 1.00
## rural.ses.med2UrbanDHighSES[2]    -0.15      0.26    -0.65     0.36 1.00
## rural.ses.med2UrbanDHighSES[3]     0.63      0.32     0.02     1.30 1.00
## rural.ses.med2UrbanDHighSES[4]     3.15      1.74     0.61     7.20 1.00
## rural.ses.med2UrbanDLowSES[1]      0.27      0.19    -0.11     0.64 1.00
## rural.ses.med2UrbanDLowSES[2]      0.10      0.25    -0.40     0.58 1.00
## rural.ses.med2UrbanDLowSES[3]      0.64      0.28     0.10     1.19 1.00
## rural.ses.med2UrbanDLowSES[4]      2.71      1.74     0.23     6.90 1.00
##                                Bulk_ESS Tail_ESS
## Intercept[1]                       2009     1822
## Intercept[2]                       1837     2546
## Intercept[3]                       1782     2204
## Intercept[4]                       1330     1292
## rural.ses.med2RuralDLowSES[1]      2458     2802
## rural.ses.med2RuralDLowSES[2]      2148     2583
## rural.ses.med2RuralDLowSES[3]      2958     3058
## rural.ses.med2RuralDLowSES[4]      3096     2281
## rural.ses.med2UrbanDHighSES[1]     2381     2436
## rural.ses.med2UrbanDHighSES[2]     2262     3066
## rural.ses.med2UrbanDHighSES[3]     2276     2843
## rural.ses.med2UrbanDHighSES[4]     1357     1418
## rural.ses.med2UrbanDLowSES[1]      2441     2122
## rural.ses.med2UrbanDLowSES[2]      2146     2712
## rural.ses.med2UrbanDLowSES[3]      2249     2298
## rural.ses.med2UrbanDLowSES[4]      1339     1479
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.6.5 Prior summary (cat-spec)
out.stmug.seq.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##  normal(0, 5)         b                                                        
##  normal(0, 5)         b  rural.ses.med2RuralDLowSES                            
##  normal(0, 5)         b rural.ses.med2UrbanDHighSES                            
##  normal(0, 5)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 5) Intercept                                                        
##  normal(0, 5) Intercept                           1                            
##  normal(0, 5) Intercept                           2                            
##  normal(0, 5) Intercept                           3                            
##  normal(0, 5) Intercept                           4                            
##        source
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

Again, the parsimonious cumulative ordinal model recovers the observed group means data well and, as expected, the sequential category-specific model recovers the observed data even better - but at the cost of estimating substantially more threshold parameters.

As far as descriptive patterns, urban residents are less likely to report “never” stressing about being victims of assault and more likely to “often” or “very often” report stressing about assault.

Below are the ordinal models for the remaining stress items that we used to generate Figure 2.
#### sttranw1: Cumul. probit, full & grouped {.tabset}

#Ordinal cumulative probit models predicting stress about transport at T1 
  #Items: stmonyw1 *sttranw1* strespw1 stfairw1 stjobw1 stthftw1 stmugw1 

#Stress about transportation at T1 - Thresholds only, Cumulative probit model:
sttran.ord <-
  brm(data = stress.wide2,
      family = cumulative("probit"),
      sttranw1f ~ 1,
      prior(normal(0, 4), class = Intercept), #see kruschke/kurz re: priors for this model
      iter = 2000, warmup = 1000, 
      chains = 4, 
       cores = nCoresphys, 
        backend = "cmdstanr", 
        #threads = threading(2), #consider within-chain threading if machine has at least 8 physical cores
      seed = 8675309,
      file = "Models/sttran.ord",
      file_refit = "on_change"
      )

out.sttran.ord <-  ppchecks(sttran.ord) #posterior predictive checks

#Stress about transportation at T1: Thresholds + group differences, Cumul probit 
sttran.ord.rurses <- update(sttran.ord,
                            formula. = ~ 1 + rural.ses.med2,
                            newdata = stress.wide2, 
                            file = "Models/sttran.ord.rurses",
                            file_refit = "on_change"
                            )

out.sttran.ord.rurses <- ppchecks(sttran.ord.rurses) #posterior predictive checks
3.1.4.6.6 PPcheck(bars, full sample)
  pp_check(sttran.ord, type="bars", ndraws=1000, cores=1) +
      scale_x_continuous("Stress abt transport, T1", breaks = 1:5) + 
      scale_y_continuous(NULL, breaks = NULL, expand = expansion(mult = c(0, 0.05))) +
      ggtitle("Data with posterior predictions (cumul-ord, fullsamp)",
          subtitle = "N = 489") +
      theme(legend.background = element_blank(),
          legend.position = c(.9, .8))

3.1.4.6.7 PPcheck(bars, grouped)
  pp_check(sttran.ord.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt transport, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cumul-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.6.8 PPcheck(density, full sample)
out.sttran.ord[[3]]

3.1.4.6.9 PPcheck(density, grouped)
out.sttran.ord.rurses[[3]]

3.1.4.6.10 Conditional effects (grouped)
 conditional_effects(sttran.ord.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.6.11 Fit summary (full sample)
out.sttran.ord[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: sttranw1f ~ 1 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept[1]    -1.70      0.10    -1.90    -1.51 1.00     2179     1863
## Intercept[2]    -0.55      0.06    -0.66    -0.43 1.00     3989     3382
## Intercept[3]     0.31      0.06     0.20     0.42 1.00     4192     2732
## Intercept[4]     1.18      0.07     1.05     1.33 1.00     3687     3378
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.6.12 Prior summary (full sample)
out.sttran.ord[[2]]
##         prior     class coef group resp dpar nlpar lb ub       source
##  normal(0, 4) Intercept                                          user
##  normal(0, 4) Intercept    1                             (vectorized)
##  normal(0, 4) Intercept    2                             (vectorized)
##  normal(0, 4) Intercept    3                             (vectorized)
##  normal(0, 4) Intercept    4                             (vectorized)
3.1.4.6.13 Fit summary (grouped)
out.sttran.ord.rurses[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: sttranw1f ~ rural.ses.med2 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept[1]                   -1.67      0.13    -1.92    -1.41 1.00     2570
## Intercept[2]                   -0.49      0.10    -0.69    -0.30 1.00     2955
## Intercept[3]                    0.38      0.10     0.19     0.57 1.00     3161
## Intercept[4]                    1.28      0.11     1.07     1.50 1.00     3144
## rural.ses.med2RuralDLowSES     -0.24      0.13    -0.50     0.01 1.00     3458
## rural.ses.med2UrbanDHighSES     0.17      0.13    -0.10     0.43 1.00     3390
## rural.ses.med2UrbanDLowSES      0.30      0.13     0.05     0.55 1.00     3269
##                             Tail_ESS
## Intercept[1]                    2764
## Intercept[2]                    2969
## Intercept[3]                    2958
## Intercept[4]                    2962
## rural.ses.med2RuralDLowSES      2915
## rural.ses.med2UrbanDHighSES     2888
## rural.ses.med2UrbanDLowSES      3077
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.6.14 Prior summary (grouped)
out.sttran.ord.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##        (flat)         b                                                        
##        (flat)         b  rural.ses.med2RuralDLowSES                            
##        (flat)         b rural.ses.med2UrbanDHighSES                            
##        (flat)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 4) Intercept                                                        
##  normal(0, 4) Intercept                           1                            
##  normal(0, 4) Intercept                           2                            
##  normal(0, 4) Intercept                           3                            
##  normal(0, 4) Intercept                           4                            
##        source
##       default
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.7 sttranw1: Seq. probit, cat-specific, grouped

#See if sequential model w/category specific effects improves recovery of observed data
sttran.seq.rurses <- update(sttran.ord, 
                            formula. = ~ 1 + cs(rural.ses.med2), 
                            prior = prior_seq, 
                            newdata = stress.wide2,
                            family = sratio("cloglog"), 
                            file = "Models/sttran.seq.rurses",
                            file_refit = "on_change"
                            )

out.sttran.seq.rurses <-  ppchecks(sttran.seq.rurses) #posterior predictive checks
3.1.4.7.1 PPcheck(bars, cat-spec)
  pp_check(sttran.seq.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt transport, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cat-spec-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.7.2 PPcheck(density, cat-spec)
out.sttran.seq.rurses[[3]]

3.1.4.7.3 Conditional effects (cat-spec)
  conditional_effects(sttran.seq.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.7.4 Fit summary (cat-spec)
out.sttran.seq.rurses[[1]]
##  Family: sratio 
##   Links: mu = cloglog; disc = identity 
## Formula: sttranw1f ~ cs(rural.ses.med2) 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                                Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept[1]                      -3.50      0.50    -4.58    -2.63 1.00
## Intercept[2]                      -1.26      0.18    -1.66    -0.92 1.00
## Intercept[3]                      -0.22      0.14    -0.52     0.05 1.00
## Intercept[4]                       0.39      0.20    -0.01     0.76 1.00
## rural.ses.med2RuralDLowSES[1]     -0.83      0.61    -2.06     0.33 1.00
## rural.ses.med2RuralDLowSES[2]     -0.55      0.24    -1.00    -0.07 1.00
## rural.ses.med2RuralDLowSES[3]      0.30      0.24    -0.16     0.78 1.00
## rural.ses.med2RuralDLowSES[4]     -0.27      0.29    -0.81     0.29 1.00
## rural.ses.med2UrbanDHighSES[1]    -0.87      0.61    -2.11     0.27 1.00
## rural.ses.med2UrbanDHighSES[2]     0.51      0.32    -0.08     1.17 1.00
## rural.ses.med2UrbanDHighSES[3]     0.06      0.21    -0.36     0.47 1.00
## rural.ses.med2UrbanDHighSES[4]     0.89      0.31     0.31     1.52 1.00
## rural.ses.med2UrbanDLowSES[1]      1.01      0.93    -0.69     2.98 1.00
## rural.ses.med2UrbanDLowSES[2]      0.04      0.26    -0.47     0.53 1.00
## rural.ses.med2UrbanDLowSES[3]      0.66      0.22     0.25     1.09 1.00
## rural.ses.med2UrbanDLowSES[4]      0.27      0.25    -0.22     0.76 1.00
##                                Bulk_ESS Tail_ESS
## Intercept[1]                       2398     2296
## Intercept[2]                       2437     2207
## Intercept[3]                       2899     2995
## Intercept[4]                       2545     2981
## rural.ses.med2RuralDLowSES[1]      2595     2439
## rural.ses.med2RuralDLowSES[2]      2703     2655
## rural.ses.med2RuralDLowSES[3]      3604     3082
## rural.ses.med2RuralDLowSES[4]      2835     2806
## rural.ses.med2UrbanDHighSES[1]     2564     2617
## rural.ses.med2UrbanDHighSES[2]     3027     2573
## rural.ses.med2UrbanDHighSES[3]     3326     3129
## rural.ses.med2UrbanDHighSES[4]     2904     2892
## rural.ses.med2UrbanDLowSES[1]      2845     2497
## rural.ses.med2UrbanDLowSES[2]      2914     2939
## rural.ses.med2UrbanDLowSES[3]      3320     3502
## rural.ses.med2UrbanDLowSES[4]      2812     2896
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.7.5 Prior summary (cat-spec)
out.sttran.seq.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##  normal(0, 5)         b                                                        
##  normal(0, 5)         b  rural.ses.med2RuralDLowSES                            
##  normal(0, 5)         b rural.ses.med2UrbanDHighSES                            
##  normal(0, 5)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 5) Intercept                                                        
##  normal(0, 5) Intercept                           1                            
##  normal(0, 5) Intercept                           2                            
##  normal(0, 5) Intercept                           3                            
##  normal(0, 5) Intercept                           4                            
##        source
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.8 strespw1: Cumul. probit, full & grouped

#Ordinal cumulative probit models predicting stress about respect at T1 
  #Items: stmonyw1 sttranw1 *strespw1* stfairw1 stjobw1 stthftw1 stmugw1 

#Stress about respect at T1 - Thresholds only, Cumulative probit model:
stresp.ord <-
  brm(data = stress.wide2,
      family = cumulative("probit"),
      strespw1f ~ 1,
      prior(normal(0, 4), class = Intercept), #see kruschke/kurz re: priors for this model
      iter = 2000, warmup = 1000, 
      chains = 4, 
      cores = nCoresphys, 
        backend = "cmdstanr", 
        #threads = threading(2), #consider within-chain threading if machine has at least 8 physical cores
      seed = 8675309,
      file = "Models/stresp.ord",
      file_refit = "on_change"
      )

out.stresp.ord <- ppchecks(stresp.ord) #posterior predictive checks

#Stress about respect at T1: Thresholds + group differences, Cumul probit 
stresp.ord.rurses <- update(stresp.ord,
                            formula. = ~ 1 + rural.ses.med2,
                            newdata = stress.wide2, 
                            file = "Models/stresp.ord.rurses",
                            file_refit = "on_change"
                            )

out.stresp.ord.rurses  <-  ppchecks(stresp.ord.rurses) #posterior predictive checks
3.1.4.8.1 PPcheck(bars, full sample)
  pp_check(stresp.ord, type="bars", ndraws=1000, cores=1) +
      scale_x_continuous("Stress abt respect, T1", breaks = 1:5) + 
      scale_y_continuous(NULL, breaks = NULL, expand = expansion(mult = c(0, 0.05))) +
      ggtitle("Data with posterior predictions (cumul-ord, fullsamp)",
          subtitle = "N = 489") +
      theme(legend.background = element_blank(),
          legend.position = c(.9, .8))

3.1.4.8.2 PPcheck(bars, grouped)
  pp_check(stresp.ord.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt respect, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cumul-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.8.3 PPcheck(density, full sample)
out.stresp.ord[[3]]

3.1.4.8.4 PPcheck(density, grouped)
out.stresp.ord.rurses[[3]]

3.1.4.8.5 Conditional effects (grouped)
conditional_effects(stresp.ord.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.8.6 Fit summary (full sample)
out.stresp.ord[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: strespw1f ~ 1 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept[1]    -1.02      0.07    -1.15    -0.89 1.00     2767     2619
## Intercept[2]    -0.43      0.06    -0.55    -0.32 1.00     4400     3214
## Intercept[3]    -0.05      0.06    -0.16     0.06 1.00     3625     3152
## Intercept[4]     0.59      0.06     0.47     0.71 1.00     4459     3396
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.8.7 Prior summary (full sample)
out.stresp.ord[[2]]
##         prior     class coef group resp dpar nlpar lb ub       source
##  normal(0, 4) Intercept                                          user
##  normal(0, 4) Intercept    1                             (vectorized)
##  normal(0, 4) Intercept    2                             (vectorized)
##  normal(0, 4) Intercept    3                             (vectorized)
##  normal(0, 4) Intercept    4                             (vectorized)
3.1.4.8.8 Fit summary (grouped)
out.stresp.ord.rurses[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: strespw1f ~ rural.ses.med2 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept[1]                   -0.82      0.11    -1.03    -0.62 1.00     3033
## Intercept[2]                   -0.23      0.10    -0.43    -0.03 1.00     3506
## Intercept[3]                    0.15      0.10    -0.04     0.34 1.00     3436
## Intercept[4]                    0.80      0.10     0.60     0.99 1.00     3215
## rural.ses.med2RuralDLowSES      0.20      0.14    -0.07     0.47 1.00     3656
## rural.ses.med2UrbanDHighSES     0.50      0.14     0.23     0.78 1.00     3436
## rural.ses.med2UrbanDLowSES      0.17      0.13    -0.08     0.43 1.00     3582
##                             Tail_ESS
## Intercept[1]                    2916
## Intercept[2]                    2974
## Intercept[3]                    3178
## Intercept[4]                    3061
## rural.ses.med2RuralDLowSES      2788
## rural.ses.med2UrbanDHighSES     3039
## rural.ses.med2UrbanDLowSES      3074
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.8.9 Prior summary (grouped)
out.stresp.ord.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##        (flat)         b                                                        
##        (flat)         b  rural.ses.med2RuralDLowSES                            
##        (flat)         b rural.ses.med2UrbanDHighSES                            
##        (flat)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 4) Intercept                                                        
##  normal(0, 4) Intercept                           1                            
##  normal(0, 4) Intercept                           2                            
##  normal(0, 4) Intercept                           3                            
##  normal(0, 4) Intercept                           4                            
##        source
##       default
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.9 strespw1: Seq. probit, cat-specific, grouped

#See if sequential model w/category specific effects improves recovery of observed data
stresp.seq.rurses <- update(stresp.ord, 
                            formula. = ~ 1 + cs(rural.ses.med2), 
                            prior = prior_seq, 
                            newdata = stress.wide2,
                            family = sratio("cloglog"), 
                            file = "Models/stresp.seq.rurses",
                            file_refit = "on_change"
                            )

out.stresp.seq.rurses <- ppchecks(stresp.seq.rurses) #posterior predictive checks
3.1.4.9.1 PPcheck(bars, cat-spec)
  pp_check(stresp.seq.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt respect, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cat-spec-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.9.2 PPcheck(density, cat-spec)
out.stresp.seq.rurses[[3]]

3.1.4.9.3 Conditional effects (cat-spec)
conditional_effects(stresp.seq.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.9.4 Fit summary (cat-spec)
out.stresp.seq.rurses[[1]]
##  Family: sratio 
##   Links: mu = cloglog; disc = identity 
## Formula: strespw1f ~ cs(rural.ses.med2) 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                                Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept[1]                      -1.47      0.19    -1.86    -1.11 1.00
## Intercept[2]                      -1.62      0.24    -2.12    -1.17 1.00
## Intercept[3]                      -1.33      0.23    -1.81    -0.91 1.00
## Intercept[4]                       0.09      0.17    -0.24     0.41 1.00
## rural.ses.med2RuralDLowSES[1]      1.08      0.39     0.35     1.87 1.00
## rural.ses.med2RuralDLowSES[2]     -0.49      0.31    -1.09     0.11 1.00
## rural.ses.med2RuralDLowSES[3]     -0.25      0.32    -0.88     0.38 1.00
## rural.ses.med2RuralDLowSES[4]      0.50      0.26    -0.01     1.00 1.00
## rural.ses.med2UrbanDHighSES[1]     1.03      0.39     0.31     1.85 1.00
## rural.ses.med2UrbanDHighSES[2]    -0.17      0.33    -0.81     0.49 1.00
## rural.ses.med2UrbanDHighSES[3]     0.59      0.39    -0.14     1.38 1.00
## rural.ses.med2UrbanDHighSES[4]     0.98      0.26     0.48     1.50 1.00
## rural.ses.med2UrbanDLowSES[1]     -0.07      0.26    -0.59     0.44 1.00
## rural.ses.med2UrbanDLowSES[2]      0.08      0.34    -0.58     0.76 1.00
## rural.ses.med2UrbanDLowSES[3]      0.17      0.33    -0.48     0.80 1.00
## rural.ses.med2UrbanDLowSES[4]      0.85      0.26     0.34     1.35 1.00
##                                Bulk_ESS Tail_ESS
## Intercept[1]                       3119     3054
## Intercept[2]                       2224     2330
## Intercept[3]                       2371     2269
## Intercept[4]                       2509     2964
## rural.ses.med2RuralDLowSES[1]      3933     3305
## rural.ses.med2RuralDLowSES[2]      2501     2798
## rural.ses.med2RuralDLowSES[3]      2810     2709
## rural.ses.med2RuralDLowSES[4]      2997     3130
## rural.ses.med2UrbanDHighSES[1]     3577     2599
## rural.ses.med2UrbanDHighSES[2]     2597     2633
## rural.ses.med2UrbanDHighSES[3]     3094     3152
## rural.ses.med2UrbanDHighSES[4]     3176     2197
## rural.ses.med2UrbanDLowSES[1]      3272     2796
## rural.ses.med2UrbanDLowSES[2]      2501     2693
## rural.ses.med2UrbanDLowSES[3]      2877     2261
## rural.ses.med2UrbanDLowSES[4]      2765     3140
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.9.5 Prior summary (cat-spec)
out.stresp.seq.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##  normal(0, 5)         b                                                        
##  normal(0, 5)         b  rural.ses.med2RuralDLowSES                            
##  normal(0, 5)         b rural.ses.med2UrbanDHighSES                            
##  normal(0, 5)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 5) Intercept                                                        
##  normal(0, 5) Intercept                           1                            
##  normal(0, 5) Intercept                           2                            
##  normal(0, 5) Intercept                           3                            
##  normal(0, 5) Intercept                           4                            
##        source
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.10 stfairw1: Cumul. probit, full & grouped

#Ordinal cumulative probit models predicting stress about fair treatment at T1 
  #Items: stmonyw1 sttranw1 strespw1 *stfairw1* stjobw1 stthftw1 stmugw1 

#Stress about fair treatment at T1 - Thresholds only, Cumulative probit model:
stfair.ord <-
  brm(data = stress.wide2,
      family = cumulative("probit"),
      stfairw1f ~ 1,
      prior(normal(0, 4), class = Intercept), #see kruschke/kurz re: priors for this model
      iter = 2000, warmup = 1000, 
      chains = 4, 
      cores = nCoresphys, 
        backend = "cmdstanr", 
        #threads = threading(2), #consider within-chain threading if machine has at least 8 physical cores
      seed = 8675309, 
      file = "Models/stfair.ord",
      file_refit = "on_change"
      )

out.stfair.ord <- ppchecks(stfair.ord) #posterior predictive checks

#Stress about fair treatment at T1: Thresholds + group differences, Cumul probit 
stfair.ord.rurses <- update(stfair.ord,
                            formula. = ~ 1 + rural.ses.med2,
                            newdata = stress.wide2, 
                            file = "Models/stfair.ord.rurses",
                            file_refit = "on_change"
                            )

out.stfair.ord.rurses <- ppchecks(stfair.ord.rurses) #posterior predictive checks
3.1.4.10.1 PPcheck(bars, full sample)
  pp_check(stfair.ord, type="bars", ndraws=1000, cores=1) +
      scale_x_continuous("Stress abt fair trtmt, T1", breaks = 1:5) + 
      scale_y_continuous(NULL, breaks = NULL, expand = expansion(mult = c(0, 0.05))) +
      ggtitle("Data with posterior predictions (cumul-ord, fullsamp)",
          subtitle = "N = 489") +
      theme(legend.background = element_blank(),
          legend.position = c(.9, .8))

3.1.4.10.2 PPcheck(bars, grouped)
  pp_check(stfair.ord.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt fair trtmt, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cumul-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.10.3 PPcheck(density, full sample)
out.stfair.ord[[3]]

3.1.4.10.4 PPcheck(density, grouped)
out.stfair.ord.rurses[[3]]

3.1.4.10.5 Conditional effects (grouped)
conditional_effects(stfair.ord.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.10.6 Fit summary (full sample)
out.stfair.ord[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stfairw1f ~ 1 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept[1]    -1.03      0.07    -1.16    -0.90 1.00     2990     2819
## Intercept[2]    -0.43      0.06    -0.54    -0.31 1.00     4615     3790
## Intercept[3]    -0.14      0.06    -0.25    -0.03 1.00     4787     3504
## Intercept[4]     0.43      0.06     0.32     0.55 1.00     5003     3324
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.10.7 Prior summary (full sample)
out.stfair.ord[[2]]
##         prior     class coef group resp dpar nlpar lb ub       source
##  normal(0, 4) Intercept                                          user
##  normal(0, 4) Intercept    1                             (vectorized)
##  normal(0, 4) Intercept    2                             (vectorized)
##  normal(0, 4) Intercept    3                             (vectorized)
##  normal(0, 4) Intercept    4                             (vectorized)
3.1.4.10.8 Fit summary (grouped)
out.stfair.ord.rurses[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stfairw1f ~ rural.ses.med2 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept[1]                   -0.94      0.11    -1.15    -0.72 1.00     2522
## Intercept[2]                   -0.33      0.10    -0.54    -0.13 1.00     2847
## Intercept[3]                   -0.04      0.10    -0.24     0.16 1.00     2877
## Intercept[4]                    0.54      0.10     0.35     0.75 1.00     2968
## rural.ses.med2RuralDLowSES     -0.06      0.14    -0.32     0.21 1.00     2869
## rural.ses.med2UrbanDHighSES     0.38      0.15     0.10     0.67 1.00     3420
## rural.ses.med2UrbanDLowSES      0.12      0.13    -0.16     0.38 1.00     3122
##                             Tail_ESS
## Intercept[1]                    2887
## Intercept[2]                    3003
## Intercept[3]                    3092
## Intercept[4]                    3030
## rural.ses.med2RuralDLowSES      2878
## rural.ses.med2UrbanDHighSES     3055
## rural.ses.med2UrbanDLowSES      2780
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.10.9 Prior summary (grouped)
out.stfair.ord.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##        (flat)         b                                                        
##        (flat)         b  rural.ses.med2RuralDLowSES                            
##        (flat)         b rural.ses.med2UrbanDHighSES                            
##        (flat)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 4) Intercept                                                        
##  normal(0, 4) Intercept                           1                            
##  normal(0, 4) Intercept                           2                            
##  normal(0, 4) Intercept                           3                            
##  normal(0, 4) Intercept                           4                            
##        source
##       default
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.11 stfairw1: Seq. probit, cat-specific, grouped

#See if sequential model w/category specific effects improves recovery of observed data
stfair.seq.rurses <- update(stfair.ord, 
                            formula. = ~ 1 + cs(rural.ses.med2), 
                            prior = prior_seq, 
                            newdata = stress.wide2,
                            family = sratio("cloglog"), 
                            file = "Models/stfair.seq.rurses",
                            file_refit = "on_change"
                            )

out.stfair.seq.rurses <- ppchecks(stfair.seq.rurses) #posterior predictive checks
3.1.4.11.1 PPcheck(bars, cat-spec)
  pp_check(stfair.seq.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt fair trtmt, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cat-spec-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.11.2 PPcheck(density, cat-spec)
out.stfair.seq.rurses[[3]]

3.1.4.11.3 Conditional effects (cat-spec)
conditional_effects(stfair.seq.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.11.4 Fit summary (cat-spec)
out.stfair.seq.rurses[[1]]
##  Family: sratio 
##   Links: mu = cloglog; disc = identity 
## Formula: stfairw1f ~ cs(rural.ses.med2) 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                                Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept[1]                      -1.65      0.22    -2.10    -1.25 1.00
## Intercept[2]                      -1.29      0.20    -1.69    -0.92 1.00
## Intercept[3]                      -2.25      0.36    -3.01    -1.60 1.00
## Intercept[4]                      -0.40      0.17    -0.75    -0.07 1.00
## rural.ses.med2RuralDLowSES[1]      0.33      0.34    -0.31     1.02 1.00
## rural.ses.med2RuralDLowSES[2]     -0.18      0.28    -0.73     0.37 1.00
## rural.ses.med2RuralDLowSES[3]     -1.14      0.42    -1.98    -0.34 1.00
## rural.ses.med2RuralDLowSES[4]      0.11      0.27    -0.41     0.65 1.00
## rural.ses.med2UrbanDHighSES[1]     0.85      0.40     0.11     1.66 1.00
## rural.ses.med2UrbanDHighSES[2]     0.40      0.31    -0.21     1.02 1.00
## rural.ses.med2UrbanDHighSES[3]     0.08      0.52    -0.94     1.11 1.00
## rural.ses.med2UrbanDHighSES[4]     0.32      0.25    -0.18     0.83 1.00
## rural.ses.med2UrbanDLowSES[1]     -0.14      0.29    -0.71     0.41 1.00
## rural.ses.med2UrbanDLowSES[2]      0.45      0.31    -0.15     1.07 1.00
## rural.ses.med2UrbanDLowSES[3]     -0.51      0.44    -1.39     0.33 1.00
## rural.ses.med2UrbanDLowSES[4]      0.65      0.27     0.14     1.19 1.00
##                                Bulk_ESS Tail_ESS
## Intercept[1]                       2678     2655
## Intercept[2]                       2599     2473
## Intercept[3]                       2172     2272
## Intercept[4]                       2595     2873
## rural.ses.med2RuralDLowSES[1]      3114     3057
## rural.ses.med2RuralDLowSES[2]      3010     2971
## rural.ses.med2RuralDLowSES[3]      2479     2407
## rural.ses.med2RuralDLowSES[4]      3335     3305
## rural.ses.med2UrbanDHighSES[1]     3459     2701
## rural.ses.med2UrbanDHighSES[2]     3324     3294
## rural.ses.med2UrbanDHighSES[3]     2687     2556
## rural.ses.med2UrbanDHighSES[4]     3186     3034
## rural.ses.med2UrbanDLowSES[1]      3067     3034
## rural.ses.med2UrbanDLowSES[2]      3158     2744
## rural.ses.med2UrbanDLowSES[3]      2428     2479
## rural.ses.med2UrbanDLowSES[4]      3330     3203
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.11.5 Prior summary (cat-spec)
out.stfair.seq.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##  normal(0, 5)         b                                                        
##  normal(0, 5)         b  rural.ses.med2RuralDLowSES                            
##  normal(0, 5)         b rural.ses.med2UrbanDHighSES                            
##  normal(0, 5)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 5) Intercept                                                        
##  normal(0, 5) Intercept                           1                            
##  normal(0, 5) Intercept                           2                            
##  normal(0, 5) Intercept                           3                            
##  normal(0, 5) Intercept                           4                            
##        source
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.12 stjobw1: Cumul. probit, full & grouped

#Ordinal cumulative probit models predicting stress about job at T1 
  #Items: stmonyw1 sttranw1 strespw1 stfairw1 *stjobw1* stthftw1 stmugw1 

#Stress about job at T1 - Thresholds only, Cumulative probit model:
stjob.ord <-
  brm(data = stress.wide2,
      family = cumulative("probit"),
      stjobw1f ~ 1,
      prior(normal(0, 4), class = Intercept), #see kruschke/kurz re: priors for this model
      iter = 2000, warmup = 1000, 
      chains = 4, 
      cores = nCoresphys, 
        backend = "cmdstanr", 
        #threads = threading(2), #consider within-chain threading if machine has at least 8 physical cores
      seed = 8675309, 
      file = "Models/stjob.ord",
      file_refit = "on_change"
      )

out.stjob.ord <- ppchecks(stjob.ord) #posterior predictive checks

#Stress about job at T1: Thresholds + group differences, Cumul probit 
stjob.ord.rurses <- update(stjob.ord,
                            formula. = ~ 1 + rural.ses.med2,
                            newdata = stress.wide2, 
                            file = "Models/stjob.ord.rurses",
                            file_refit = "on_change"
                           )

out.stjob.ord.rurses <- ppchecks(stjob.ord.rurses) #posterior predictive checks
3.1.4.12.1 PPcheck(bars, full sample)
  pp_check(stjob.ord, type="bars", ndraws=1000, cores=1) +
      scale_x_continuous("Stress abt job, T1", breaks = 1:5) + 
      scale_y_continuous(NULL, breaks = NULL, expand = expansion(mult = c(0, 0.05))) +
      ggtitle("Data with posterior predictions (cumul-ord, fullsamp)",
          subtitle = "N = 489") +
      theme(legend.background = element_blank(),
          legend.position = c(.9, .8))

3.1.4.12.2 PPcheck(bars, grouped)
  pp_check(stjob.ord.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt job, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cumul-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.12.3 PPcheck(density, full sample)
out.stjob.ord[[3]]

3.1.4.12.4 PPcheck(density, grouped)
out.stjob.ord.rurses[[3]]

3.1.4.12.5 Conditional effects (grouped)
conditional_effects(stjob.ord.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.12.6 Fit summary (full sample)
out.stjob.ord[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stjobw1f ~ 1 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept[1]    -0.98      0.07    -1.12    -0.85 1.00     3114     2588
## Intercept[2]    -0.48      0.06    -0.60    -0.37 1.00     4493     3359
## Intercept[3]     0.02      0.06    -0.09     0.13 1.00     4673     3418
## Intercept[4]     0.65      0.06     0.53     0.77 1.00     5329     3236
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.12.7 Prior summary (full sample)
out.stjob.ord[[2]]
##         prior     class coef group resp dpar nlpar lb ub       source
##  normal(0, 4) Intercept                                          user
##  normal(0, 4) Intercept    1                             (vectorized)
##  normal(0, 4) Intercept    2                             (vectorized)
##  normal(0, 4) Intercept    3                             (vectorized)
##  normal(0, 4) Intercept    4                             (vectorized)
3.1.4.12.8 Fit summary (grouped)
out.stjob.ord.rurses[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stjobw1f ~ rural.ses.med2 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept[1]                   -0.81      0.11    -1.02    -0.61 1.00     2957
## Intercept[2]                   -0.32      0.10    -0.51    -0.12 1.00     3321
## Intercept[3]                    0.19      0.10    -0.00     0.39 1.00     3172
## Intercept[4]                    0.84      0.10     0.64     1.05 1.00     3080
## rural.ses.med2RuralDLowSES      0.03      0.13    -0.24     0.28 1.00     3443
## rural.ses.med2UrbanDHighSES     0.39      0.14     0.12     0.66 1.00     3224
## rural.ses.med2UrbanDLowSES      0.31      0.13     0.06     0.56 1.00     3170
##                             Tail_ESS
## Intercept[1]                    2806
## Intercept[2]                    3421
## Intercept[3]                    3497
## Intercept[4]                    3037
## rural.ses.med2RuralDLowSES      3078
## rural.ses.med2UrbanDHighSES     2918
## rural.ses.med2UrbanDLowSES      2995
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.12.9 Prior summary (grouped)
out.stjob.ord.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##        (flat)         b                                                        
##        (flat)         b  rural.ses.med2RuralDLowSES                            
##        (flat)         b rural.ses.med2UrbanDHighSES                            
##        (flat)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 4) Intercept                                                        
##  normal(0, 4) Intercept                           1                            
##  normal(0, 4) Intercept                           2                            
##  normal(0, 4) Intercept                           3                            
##  normal(0, 4) Intercept                           4                            
##        source
##       default
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.13 stjobw1: Seq. probit, cat-specific, grouped

#See if sequential model w/category specific effects improves recovery of observed data
stjob.seq.rurses <- update(stjob.ord, 
                            formula. = ~ 1 + cs(rural.ses.med2), 
                            prior = prior_seq, 
                            newdata = stress.wide2,
                            family = sratio("cloglog"), 
                            file = "Models/stjob.seq.rurses",
                            file_refit = "on_change"
                           )
out.stjob.seq.rurses <- ppchecks(stjob.seq.rurses) #posterior predictive checks
3.1.4.13.1 PPcheck(bars, cat-spec)
  pp_check(stjob.seq.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt job, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cat-spec-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.13.2 PPcheck(density, cat-spec)
out.stjob.seq.rurses[[3]]

3.1.4.13.3 Conditional effects (cat-spec)
conditional_effects(stjob.seq.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.13.4 Fit summary (cat-spec)
out.stjob.seq.rurses[[1]]
##  Family: sratio 
##   Links: mu = cloglog; disc = identity 
## Formula: stjobw1f ~ cs(rural.ses.med2) 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                                Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept[1]                      -1.94      0.24    -2.45    -1.50 1.00
## Intercept[2]                      -1.30      0.20    -1.72    -0.93 1.00
## Intercept[3]                      -0.58      0.17    -0.92    -0.26 1.00
## Intercept[4]                      -0.14      0.20    -0.55     0.23 1.00
## rural.ses.med2RuralDLowSES[1]     -0.34      0.33    -0.98     0.29 1.00
## rural.ses.med2RuralDLowSES[2]      0.71      0.35     0.04     1.40 1.00
## rural.ses.med2RuralDLowSES[3]      0.10      0.24    -0.35     0.59 1.00
## rural.ses.med2RuralDLowSES[4]     -0.11      0.28    -0.64     0.45 1.00
## rural.ses.med2UrbanDHighSES[1]    -0.44      0.32    -1.08     0.18 1.00
## rural.ses.med2UrbanDHighSES[2]     0.95      0.40     0.18     1.74 1.00
## rural.ses.med2UrbanDHighSES[3]     1.33      0.36     0.66     2.06 1.00
## rural.ses.med2UrbanDHighSES[4]     0.72      0.29     0.15     1.29 1.00
## rural.ses.med2UrbanDLowSES[1]     -0.01      0.33    -0.66     0.61 1.00
## rural.ses.med2UrbanDLowSES[2]      0.12      0.28    -0.42     0.67 1.00
## rural.ses.med2UrbanDLowSES[3]      1.16      0.31     0.57     1.76 1.00
## rural.ses.med2UrbanDLowSES[4]      0.48      0.26    -0.03     1.00 1.00
##                                Bulk_ESS Tail_ESS
## Intercept[1]                       2548     2579
## Intercept[2]                       2967     2276
## Intercept[3]                       3201     3164
## Intercept[4]                       2229     2560
## rural.ses.med2RuralDLowSES[1]      2857     2796
## rural.ses.med2RuralDLowSES[2]      3268     3323
## rural.ses.med2RuralDLowSES[3]      3472     3233
## rural.ses.med2RuralDLowSES[4]      2505     3126
## rural.ses.med2UrbanDHighSES[1]     2813     2645
## rural.ses.med2UrbanDHighSES[2]     3635     2756
## rural.ses.med2UrbanDHighSES[3]     3615     2948
## rural.ses.med2UrbanDHighSES[4]     2672     2590
## rural.ses.med2UrbanDLowSES[1]      2988     2736
## rural.ses.med2UrbanDLowSES[2]      3454     2420
## rural.ses.med2UrbanDLowSES[3]      3649     3009
## rural.ses.med2UrbanDLowSES[4]      2657     2754
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.13.5 Prior summary (cat-spec)
out.stjob.seq.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##  normal(0, 5)         b                                                        
##  normal(0, 5)         b  rural.ses.med2RuralDLowSES                            
##  normal(0, 5)         b rural.ses.med2UrbanDHighSES                            
##  normal(0, 5)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 5) Intercept                                                        
##  normal(0, 5) Intercept                           1                            
##  normal(0, 5) Intercept                           2                            
##  normal(0, 5) Intercept                           3                            
##  normal(0, 5) Intercept                           4                            
##        source
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.14 stthftw1: Cumul. probit, full & grouped

#Ordinal cumulative probit models predicting stress about job at T1 
  #Items: stmonyw1 sttranw1 strespw1 stfairw1 stjobw1 *stthftw1* stmugw1 

#Stress about theft at T1 - Thresholds only, Cumulative probit model:
stthft.ord <-
  brm(data = stress.wide2,
      family = cumulative("probit"),
      stthftw1 ~ 1,
      prior(normal(0, 4), class = Intercept), #see kruschke/kurz re: priors for this model
      iter = 2000, warmup = 1000, 
      chains = 4, 
      cores = nCoresphys, 
        backend = "cmdstanr", 
        #threads = threading(2), #consider within-chain threading if machine has at least 8 physical cores
      seed = 8675309, 
      file = "Models/stthft.ord",
      file_refit = "on_change"
      )

out.stthft.ord <- ppchecks(stthft.ord) #posterior predictive checks

#Stress about theft at T1: Thresholds + group differences, Cumul probit 
stthft.ord.rurses <- update(stthft.ord,
                            formula. = ~ 1 + rural.ses.med2,
                            newdata = stress.wide2, 
                            file = "Models/stthft.ord.rurses",
                            file_refit = "on_change"
                            )

out.stthft.ord.rurses <- ppchecks(stthft.ord.rurses) #posterior predictive checks
3.1.4.14.1 PPcheck(bars, full sample)
  pp_check(stthft.ord, type="bars", ndraws=1000, cores=1) +
      scale_x_continuous("Stress abt theft, T1", breaks = 1:5) + 
      scale_y_continuous(NULL, breaks = NULL, expand = expansion(mult = c(0, 0.05))) +
      ggtitle("Data with posterior predictions (cumul-ord, fullsamp)",
          subtitle = "N = 489") +
      theme(legend.background = element_blank(),
          legend.position = c(.9, .8))

3.1.4.14.2 PPcheck(bars, grouped)
  pp_check(stthft.ord.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt theft, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cumul-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.14.3 PPcheck(density, full sample)
out.stthft.ord[[3]]

3.1.4.14.4 PPcheck(density, grouped)
out.stthft.ord.rurses[[3]]

3.1.4.14.5 Conditional effects (grouped)
conditional_effects(stthft.ord.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.14.6 Fit summary (full sample)
out.stthft.ord[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stthftw1 ~ 1 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept[1]    -0.42      0.06    -0.53    -0.30 1.00     3576     3138
## Intercept[2]     0.34      0.06     0.23     0.45 1.00     4996     3305
## Intercept[3]     1.02      0.07     0.89     1.16 1.00     4174     2856
## Intercept[4]     1.71      0.10     1.52     1.91 1.00     4521     3148
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.14.7 Prior summary (full sample)
out.stthft.ord[[2]]
##         prior     class coef group resp dpar nlpar lb ub       source
##  normal(0, 4) Intercept                                          user
##  normal(0, 4) Intercept    1                             (vectorized)
##  normal(0, 4) Intercept    2                             (vectorized)
##  normal(0, 4) Intercept    3                             (vectorized)
##  normal(0, 4) Intercept    4                             (vectorized)
3.1.4.14.8 Fit summary (grouped)
out.stthft.ord.rurses[[1]]
##  Family: cumulative 
##   Links: mu = probit; disc = identity 
## Formula: stthftw1 ~ rural.ses.med2 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept[1]                   -0.35      0.10    -0.55    -0.16 1.00     3479
## Intercept[2]                    0.42      0.10     0.23     0.61 1.00     3840
## Intercept[3]                    1.14      0.11     0.93     1.35 1.00     3739
## Intercept[4]                    1.86      0.14     1.60     2.14 1.00     4251
## rural.ses.med2RuralDLowSES     -0.31      0.14    -0.59    -0.04 1.00     3674
## rural.ses.med2UrbanDHighSES     0.27      0.14    -0.01     0.55 1.00     3799
## rural.ses.med2UrbanDLowSES      0.32      0.13     0.06     0.57 1.00     3539
##                             Tail_ESS
## Intercept[1]                    2963
## Intercept[2]                    3244
## Intercept[3]                    3772
## Intercept[4]                    3419
## rural.ses.med2RuralDLowSES      2865
## rural.ses.med2UrbanDHighSES     3179
## rural.ses.med2UrbanDLowSES      3114
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.14.9 Prior summary (grouped)
out.stthft.ord.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##        (flat)         b                                                        
##        (flat)         b  rural.ses.med2RuralDLowSES                            
##        (flat)         b rural.ses.med2UrbanDHighSES                            
##        (flat)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 4) Intercept                                                        
##  normal(0, 4) Intercept                           1                            
##  normal(0, 4) Intercept                           2                            
##  normal(0, 4) Intercept                           3                            
##  normal(0, 4) Intercept                           4                            
##        source
##       default
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

3.1.4.15 stthftw1: Seq. probit, cat-specific, grouped

#See if sequential model w/category specific effects improves recovery of observed data
stthft.seq.rurses <- update(stthft.ord, 
                            formula. = ~ 1 + cs(rural.ses.med2), 
                            prior = prior_seq, 
                            newdata = stress.wide2,
                            family = sratio("cloglog"), 
                            file = "Models/stthft.seq.rurses",
                            file_refit = "on_change"
                            )

out.stthft.seq.rurses <- ppchecks(stthft.seq.rurses) #posterior predictive checks
3.1.4.15.1 PPcheck(bars, cat-spec)
  pp_check(stthft.seq.rurses, type="bars_grouped", group = "rural.ses.med2", ndraws=1000, cores = 1) +
      scale_x_continuous("Stress abt theft, T1", breaks = 1:5) + 
      ggtitle("Data with posterior predictions (cat-spec-ord)",
          subtitle = "N = 489") + 
       theme(legend.background = element_blank(),
          legend.position = c(.5, 1))

3.1.4.15.2 PPcheck(density, cat-spec)
out.stjob.seq.rurses[[3]]

3.1.4.15.3 Conditional effects (cat-spec)
conditional_effects(stthft.seq.rurses, "rural.ses.med2", categorical = TRUE)

3.1.4.15.4 Fit summary (cat-spec)
out.stthft.seq.rurses[[1]]
##  Family: sratio 
##   Links: mu = cloglog; disc = identity 
## Formula: stthftw1 ~ cs(rural.ses.med2) 
##    Data: stress.wide2 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                                Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept[1]                      -1.04      0.16    -1.38    -0.73 1.00
## Intercept[2]                      -0.29      0.15    -0.61    -0.00 1.00
## Intercept[3]                       0.47      0.20     0.06     0.85 1.00
## Intercept[4]                       0.71      0.44    -0.19     1.54 1.00
## rural.ses.med2RuralDLowSES[1]     -0.41      0.21    -0.82     0.01 1.00
## rural.ses.med2RuralDLowSES[2]     -0.38      0.22    -0.79     0.07 1.00
## rural.ses.med2RuralDLowSES[3]     -0.39      0.35    -1.08     0.29 1.00
## rural.ses.med2RuralDLowSES[4]     -3.58      3.21   -11.15     1.02 1.00
## rural.ses.med2UrbanDHighSES[1]    -0.09      0.24    -0.55     0.38 1.00
## rural.ses.med2UrbanDHighSES[2]     0.70      0.26     0.20     1.23 1.00
## rural.ses.med2UrbanDHighSES[3]     0.98      0.29     0.39     1.55 1.00
## rural.ses.med2UrbanDHighSES[4]     0.32      0.50    -0.68     1.28 1.00
## rural.ses.med2UrbanDLowSES[1]     -0.11      0.22    -0.55     0.32 1.00
## rural.ses.med2UrbanDLowSES[2]      0.68      0.24     0.21     1.16 1.00
## rural.ses.med2UrbanDLowSES[3]      1.08      0.28     0.52     1.64 1.00
## rural.ses.med2UrbanDLowSES[4]      0.81      0.49    -0.16     1.74 1.00
##                                Bulk_ESS Tail_ESS
## Intercept[1]                       2479     2199
## Intercept[2]                       2684     2474
## Intercept[3]                       2517     2517
## Intercept[4]                       2265     2550
## rural.ses.med2RuralDLowSES[1]      2958     2814
## rural.ses.med2RuralDLowSES[2]      3150     2871
## rural.ses.med2RuralDLowSES[3]      3402     3030
## rural.ses.med2RuralDLowSES[4]      2945     2037
## rural.ses.med2UrbanDHighSES[1]     2881     2888
## rural.ses.med2UrbanDHighSES[2]     3195     2876
## rural.ses.med2UrbanDHighSES[3]     3037     3000
## rural.ses.med2UrbanDHighSES[4]     2544     2542
## rural.ses.med2UrbanDLowSES[1]      2777     2902
## rural.ses.med2UrbanDLowSES[2]      3173     3140
## rural.ses.med2UrbanDLowSES[3]      2917     2879
## rural.ses.med2UrbanDLowSES[4]      2396     2712
## 
## Further Distributional Parameters:
##      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## disc     1.00      0.00     1.00     1.00   NA       NA       NA
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
3.1.4.15.5 Prior summary (cat-spec)
out.stthft.seq.rurses[[2]]
##         prior     class                        coef group resp dpar nlpar lb ub
##  normal(0, 5)         b                                                        
##  normal(0, 5)         b  rural.ses.med2RuralDLowSES                            
##  normal(0, 5)         b rural.ses.med2UrbanDHighSES                            
##  normal(0, 5)         b  rural.ses.med2UrbanDLowSES                            
##  normal(0, 5) Intercept                                                        
##  normal(0, 5) Intercept                           1                            
##  normal(0, 5) Intercept                           2                            
##  normal(0, 5) Intercept                           3                            
##  normal(0, 5) Intercept                           4                            
##        source
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##          user
##  (vectorized)
##  (vectorized)
##  (vectorized)
##  (vectorized)

As with the money and assault stress variables, the cumulative probit model recovered stress item response distributions in the full sample and generally did an adequate but not perfect job of recovering grouped item distributions. In contrast, the sequential probit category-specific model recovered observed response in all four groups and for all five categories across all seven stress response items as expected. Thus, the threshold estimates and uncertainty from posterior distributions from each of the category-specific models above were used to plot Figure 2.

3.1.5 Visualizing ordinal thresholds

Before we created Figure 2 to help visualizing posterior predicted distributions for the stress response scales generated by the thresholds from our category-specific ordinal models, we also generated some plots to help readers try visualizing the thresholds themselves. Below, we plot the posterior distributions that generated the threshold estimates in the cumulative model applied to the full sample for each of the stress items.

Before doing so, we set a colorblind-friendly color palette.

#Change color palette 
sl <- scico(palette = "lajolla", n = 9)
scales::show_col(sl)

We begin by plotting thresholds from the first stress item (stress about money, or stmonyw1f). First, though, it is well past time that I gave a huge shout-out to John Kruschke’s Doing Bayesian Data Analysis and Solomon Kurz’s bookdown translation to brms for explaining why/how to do all this and generously sharing all their code publicly so I could copy and apply it in my own work. None of this would be possible without the tireless efforts and steadfast commitment to open science practices of these scholars and of several others (e.g., Richard McElreath; Paul Buerkner; Matthew Kay; Andrew Heiss).

#wrangle posterior 
  # posterior_samples(stmony.ord) # posterior_samples function is deprecated
postmony <- 
  as_draws_df(stmony.ord) %>%
  dplyr::select(`b_Intercept[1]`:`b_Intercept[4]`, .iteration) 
glimpse(postmony) 
## Rows: 4,000
## Columns: 5
## $ `b_Intercept[1]` <dbl> -1.3, -1.3, -1.4, -1.3, -1.5, -1.5, -1.5, -1.4, -1.4,…
## $ `b_Intercept[2]` <dbl> -0.57, -0.57, -0.61, -0.53, -0.48, -0.66, -0.62, -0.5…
## $ `b_Intercept[3]` <dbl> 0.237, 0.235, 0.199, 0.280, 0.352, 0.296, 0.202, 0.25…
## $ `b_Intercept[4]` <dbl> 1.2, 1.3, 1.2, 1.3, 1.3, 1.2, 1.4, 1.2, 1.4, 1.3, 1.3…
## $ .iteration       <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16…
#Plot thresholds ala Kruschke/Kurz: https://bookdown.org/content/3686/ordinal-predicted-variable.html#the-case-of-metric-predictors

#Stress about money
means <-
  postmony %>% 
  summarise_at(vars(`b_Intercept[1]`:`b_Intercept[4]`), mean) %>% 
  pivot_longer(everything(),
               values_to = "mean")
postmony %>% 
  gather(name, threshold, -.iteration) %>% 
  group_by(.iteration) %>% 
  mutate(theta_bar = mean(threshold)) %>% 
  
  ggplot(aes(x = threshold, y = theta_bar, color = name)) +
  geom_vline(data = means,
             aes(xintercept = mean, color = name),
             linetype = 2) +
  geom_point(alpha = 1/10) +
  scale_color_scico_d(palette = "lajolla", begin = .25) +
  ylab("mean threshold") +
  theme(legend.position = "none")

For comparison, the plot below displays the ordinal thresholds for all seven stress items; recall, all seven are measured on the same response scale (1=Never to 5=Very often).

#Plot thresholds ala Kruschke/Kurz: https://bookdown.org/content/3686/ordinal-predicted-variable.html#the-case-of-metric-predictors

#Wrangle posteriors 
    #Items: stmonyw1 sttranw1 strespw1 stfairw1 stjobw1 *stthftw1* stmugw1 

#Stress abt money posterior wrangled above (postmony) 
#Stress abt transport 
posttran <- 
  as_draws_df(sttran.ord)  %>%
  dplyr::select(`b_Intercept[1]`:`b_Intercept[4]`, .iteration) 
#Stress abt respect 
postresp <- 
  as_draws_df(stresp.ord)  %>%
  dplyr::select(`b_Intercept[1]`:`b_Intercept[4]`, .iteration) 
#Stress abt fair trtmt
postfair <- 
  as_draws_df(stfair.ord)  %>%
  dplyr::select(`b_Intercept[1]`:`b_Intercept[4]`, .iteration) 
#Stress abt job
postjob <- 
  as_draws_df(stjob.ord)  %>%
  dplyr::select(`b_Intercept[1]`:`b_Intercept[4]`, .iteration) 
#Stress abt theft victimization
postthft <- 
  as_draws_df(stthft.ord)  %>%
  dplyr::select(`b_Intercept[1]`:`b_Intercept[4]`, .iteration) 
#Stress abt assault victimization
postmug <- 
  as_draws_df(stmug.ord)  %>%
  dplyr::select(`b_Intercept[1]`:`b_Intercept[4]`, .iteration) 

p <-
  bind_rows(
    # money
    postmony %>% 
      gather(name, threshold, -.iteration) %>% 
      group_by(.iteration) %>% 
      mutate(theta_bar = mean(threshold)),
    # transport
    posttran %>% 
      gather(name, threshold, -.iteration) %>% 
      group_by(.iteration) %>% 
      mutate(theta_bar = mean(threshold)),
    # respect
    postresp %>% 
      gather(name, threshold, -.iteration) %>% 
      group_by(.iteration) %>% 
      mutate(theta_bar = mean(threshold)),
    # fair trtmt
    postfair %>% 
      gather(name, threshold, -.iteration) %>% 
      group_by(.iteration) %>% 
      mutate(theta_bar = mean(threshold)),
    # job
    postjob %>% 
      gather(name, threshold, -.iteration) %>% 
      group_by(.iteration) %>% 
      mutate(theta_bar = mean(threshold)),
    # theft victimization 
    postthft %>% 
      gather(name, threshold, -.iteration) %>% 
      group_by(.iteration) %>% 
      mutate(theta_bar = mean(threshold)),
    # assault victimization 
    postmug %>% 
      gather(name, threshold, -.iteration) %>% 
      group_by(.iteration) %>% 
      mutate(theta_bar = mean(threshold))
  ) %>% 
  # add an index
  mutate(model = rep(c("Stress: money", "Stress: transport", "Stress: Respect", "Stress: Fairness", "Stress: Job", "Stress: Theft", "Stress: Assault"), each = n() / 7))

# compute the means by model and threshold for the vertical lines
means <-
  p %>% 
  ungroup() %>% 
  group_by(model, name) %>% 
  summarise(mean = mean(threshold))

# plot!
p %>% 
  ggplot(aes(x = threshold, y = theta_bar)) +
  geom_vline(data = means,
             aes(xintercept = mean, color = name),
             linetype = 2) +
  geom_point(aes(color = name),
             alpha = 1/10, size = 1/2) +
  scale_color_scico_d(palette = "lajolla", begin = .25) +
  ylab("mean threshold") +
  theme(legend.position = "none") +
  facet_wrap(~model, ncol = 3, scales = "free")

As these plots show, the thresholds capture the approximate normality of the stress about money item, with the midpoint of the threshold values - where x-axis equals 0 - being located near the midpoint of the plots and relative balance around zero. Meanwhile, these thresholds also capture the high positive skew in the victimization items (theft; assault), with the midpoint (x-axis = 0) loaded on the far left end of the plot and the remaining values spread out to the right of zero. For more information, see (Kruschke; Kurz).

Now let’s turn to summarizing and visualizing group differences in stress using the posterior distributions and threshold estimates from the category specific models. We can begin by generating posterior predicted response probabilities for each group.

3.1.6 Generating predicted response probabilities for stress by community

#Posterior predicted category probabilities for all 489 observations
#pp <- predict(stmony.rurses.ord)
#head(pp)


#Fitted values - posterior predicted response probabilities by group
#"Rural/Low SES"
pred.rurlow <- fitted(stmony.seq.rurses, 
                newdata = tibble(rural.ses.med2 = "Rural/Low SES"))
head(pred.rurlow)
## , , P(Y = 1)
## 
##      Estimate Est.Error  Q2.5 Q97.5
## [1,]     0.12     0.031 0.069  0.19
## 
## , , P(Y = 2)
## 
##      Estimate Est.Error Q2.5 Q97.5
## [1,]     0.18     0.035 0.12  0.26
## 
## , , P(Y = 3)
## 
##      Estimate Est.Error Q2.5 Q97.5
## [1,]      0.4     0.045 0.31  0.49
## 
## , , P(Y = 4)
## 
##      Estimate Est.Error Q2.5 Q97.5
## [1,]     0.22     0.038 0.15   0.3
## 
## , , P(Y = 5)
## 
##      Estimate Est.Error  Q2.5 Q97.5
## [1,]    0.074     0.025 0.034  0.13
#"Rural/High SES"
pred.rurhi <- fitted(stmony.seq.rurses, 
                newdata = tibble(rural.ses.med2 = "Rural/High SES"))
#head(pred.rurhi)

#"Urban/Low SES"
pred.urblow <- fitted(stmony.seq.rurses, 
                newdata = tibble(rural.ses.med2 = "Urban/Low SES"))
#head(pred.urblow)

#"Urban/High SES"
pred.urbhi <- fitted(stmony.seq.rurses, 
                newdata = tibble(rural.ses.med2 = "Urban/High SES"))
#head(pred.urbhi)

#plot help
#https://solomonkurz.netlify.app/post/would-you-like-all-your-posteriors-in-one-plot/

We could wrangle and plot these posterior predicted values, Instead, we plotted predicted stress response distributions directly from the posterior samples in Figure 2. This is the same as the Figure 2 found in the “Stress in Bangladesh” paper.

3.1.7 FIGURE 2: Stress by Community

# Set a color scale to colorblind-safe lajolla palette
  # uses library(scico)

#Change color palette 
sl <- scico::scico(palette = "lajolla", n = 9)
# scales::show_col(sl)
#Instead of manually calculating conditional means & plotting, use "add_fitted_draws":
  #http://mjskay.github.io/tidybayes/articles/tidy-brms.html
    #See "esoph_plot" example...

#function to grab & save fig2 plot data as object for each stress item
get_pp_data <- function(fitdraw, varname, varlabel) {
stress.wide2 %>%
  data_grid(rural.ses.med2) %>%
  # add_fitted_draws(fitdraw) %>% #depricated - use add_epred_draws()
  add_epred_draws(fitdraw) %>%
  mutate(stress_fct = .category,
         stress_var = varname,
         stress_label = varlabel
         )
}

#Get posterior prediction draws for Figure 2 plots for each stress item
  #Can add directly to ggplot, though separate files may be useful for advanced faceting
stmony_pp_data <- get_pp_data(stmony.seq.rurses, "stmonyw1f","Money")
sttran_pp_data <- get_pp_data(sttran.seq.rurses, "sttranw1f","Transportation")
stresp_pp_data <- get_pp_data(stresp.seq.rurses, "strespw1f","Respect")
stfair_pp_data <- get_pp_data(stfair.seq.rurses, "stfairw1f","Fair treatment")
stjob_pp_data <- get_pp_data(stjob.seq.rurses, "stjobw1f","Job")
stthft_pp_data <- get_pp_data(stthft.seq.rurses, "stthftw1f","Theft")
stmug_pp_data <- get_pp_data(stmug.seq.rurses, "stmugw1f","Assault")

#Create label for community types
commlabs <- c("Rural/Low SES"="Rural/\nLowSES", 
              "Rural/High SES"="Rural/\nHighSES", 
              "Urban/Low SES"="Urban/\nLowSES", 
              "Urban/High SES"="Urban/\nHighSES")

#function to find & drop leading zeroes (used for x-axis label)
dropLeadingZero <- function(l){
  str_replace(l, '0(?=.)', '')
}

#function to create same/similar plots for each stress item (to combine into Fig2)
  #NOTE: To generalize to new/data & cols, see: 
    #https://www.infoworld.com/article/3410295/how-to-write-your-own-ggplot2-functions-in-r.html
    #when treating colname as input, need to wrap in {{colname}}
    #e.g., aes(x = {{myxcol}},y = {{myycol}}, fill = {{myycol}}) 
    #then change to function(pp_data, myxcol, myycol, y_label)
    #and function call like this: plot_item(stmony_pp_data, .value, stress_fct, "Money")
    #NOTE: change .value (add_fitted_draws) to .epred (add_epred draws) 

plot_item <- function(pp_data, y_label) {
ggplot(data = pp_data, aes(x = .epred, y = stress_fct, fill = stress_fct)) +
  coord_cartesian(expand = FALSE, xlim=c(0,.58)) +
  stat_summary(fun = median, geom = "bar", width = 1, color = "white") +
  stat_pointinterval(color="dark grey", .width=.95, alpha=.7, size=.01, show.legend = FALSE) +
#  facet_wrap(~rural.ses.med2, nrow = 1, strip.position = "bottom") +
  scale_x_continuous(limits=c(0, .64), breaks=c(0,.2,.4),  
                     labels = dropLeadingZero) +
  scale_fill_scico_d(palette = "lajolla", begin=.2, end=.8,
                     guide = guide_legend(reverse = TRUE),
                     labels = c("Never", "Rarely", "Sometimes", "Often", "Very often")) + 
  ylab(y_label)
}

#Set theme for figure 2 plots 
  #NOTE: for global theme setting (e.g., blog), see `thematic` package
  #after update, changed axis.title.x to axis.title.x.bottom to remove .epred title
fig2theme.base <- theme_set(
  theme_classic() +
  theme(strip.background = element_blank(), 
        strip.placement = "outside",
        # axis.title.x.bottom = element_blank(),
        axis.title.x = element_blank(),
        axis.line.x = element_line(size=.25),
        axis.ticks.x = element_line(size=.25),
        axis.text.y = element_blank(),
        axis.line.y = element_blank(),
        axis.ticks.y = element_blank(),
        legend.title = element_blank(),
        legend.position = "right", 
        strip.text.x = element_text(size = 8)) 
 ) 

fig2theme.top <- theme(
          strip.text = element_blank(),
          strip.text.x = element_blank(),
          axis.text.x = element_blank(), 
          axis.line.x = element_line(color="grey90", size=.25),
          axis.ticks.x = element_line(color="grey90", size=.25)
)

stmony_plot <- plot_item(stmony_pp_data, "Money") +
  facet_wrap(~rural.ses.med2, nrow = 1, strip.position = "bottom") +
  fig2theme.base +
        fig2theme.top

sttran_plot <- plot_item(sttran_pp_data, "Transportation") +
  facet_wrap(~rural.ses.med2, nrow = 1, strip.position = "bottom") +
  fig2theme.base +
        fig2theme.top

stresp_plot <- plot_item(stresp_pp_data, "Respect") +
  facet_wrap(~rural.ses.med2, nrow = 1, strip.position = "bottom") +
  fig2theme.base +
        fig2theme.top

stfair_plot <- plot_item(stfair_pp_data, "Fair treatment") +
  facet_wrap(~rural.ses.med2, nrow = 1, strip.position = "bottom") +
  fig2theme.base +
        fig2theme.top

stjob_plot <- plot_item(stjob_pp_data, "Job") +
  facet_wrap(~rural.ses.med2, nrow = 1, strip.position = "bottom",
              labeller = labeller(rural.ses.med2= as_labeller(commlabs))) +
  fig2theme.base +
        fig2theme.top

stthft_plot <- plot_item(stthft_pp_data, "Theft") +
  facet_wrap(~rural.ses.med2, nrow = 1, strip.position = "bottom",
              labeller = labeller(rural.ses.med2= as_labeller(commlabs))) +
  fig2theme.base 

stmug_plot <- plot_item(stmug_pp_data, "Assault") +
  facet_wrap(~rural.ses.med2, nrow = 1, strip.position = "bottom",
              labeller = labeller(rural.ses.med2= as_labeller(commlabs))) +
  fig2theme.base 

Fig2 <- stmony_plot + sttran_plot + 
        stresp_plot + stfair_plot + 
        stjob_plot + guide_area() + 
        stthft_plot + stmug_plot + 
        plot_layout(ncol = 2, guides = 'collect') +
  plot_annotation(
    title = 'FIGURE 2 Subjective Stress Distributions (T1), by Community',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves. Bar charts display T1 stress item response distributions by \ncommunity (rural/urban; high/low SES), calculated as the median of the posterior predictive distribution (PPD) for each \nresponse category within a community from sequential ordinal models specifying response category-specific effects of \ncommunity. Grey interval plots display PPD median (dot) and 95% uncertainty interval (line). Median estimates accurately \nrecover observed proportions for each response category within each group.') &
  theme(legend.justification = "center", #align legend in center of guide_area()
        legend.text = element_text(size=8, face="italic"),
        plot.title = element_text(size=12, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.title = element_blank(),
        legend.key.width = unit(1.5, "cm"), #adjust width of key (color box) in legend
        legend.key.height = unit(.85, "cm"), #adjust width of key (color box) in legend
        #legend.key.size = unit(2, "cm"), #adjusts overall size of square of key (color box) in legend 
        axis.title.x.bottom = element_blank() #removes axis titles
        # strip.background = element_rect(color="white", fill="white") 
        )
Fig2

#Export to image
 ggsave("Figure2.jpeg", Fig2, width=6.5, height=9, path=here("Output"))

#Grab Figure 2 plot data to view & set limits for coord_cartesian xlim
# plt_b <- ggplot_build(fig2)
# fig2data1 <- as.data.frame(plt_b$data[[1]]) 
# fig2data2 <- as.data.frame(plt_b$data[[2]]) 
  #stmug, rural/low ses, "never" cat: 95%ci(xmax) < 0.58 (=.576)
  #set xlim in data to .64 (captures all posterior values & sets equal scale for all plots)
    #max value for 100% posterior = .637 
  #zoom plot to view coord_cartesian to xlim=.58 (will not cut off data)

Our primary aim with this figure was to visualize stress response distributions and community differences in these distributions to answer RQ1b, which asked whether levels and sources of stress vary at T1 across rural/urban communities with high/low aggregate SES. In general, respondents residing in urban areas report more frequently experiencing stress from all sources - financial, interpersonal, job, and victimization.

Now we move from describing stress distributions to examining stress as a theoretically posited predictor of criminal intent and depressive symptoms. Recall, when we include the stress items as predictors, we will want to properly account for their ordinal nature in our models. We will do so by relying on thresholds from monotonic cumulative ordinal probit models rather than treating the stress items as continuous metric variables in regression models (the standard approach).

save(stress.wide2, file = here("1_Data_Files/Datasets/stress_wide2.Rdata"))

4 Modeling T1 correlations (RQ2A)

(RMD FILE: BDK_2023_Stress_3_T1corr_mods)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

4.1 RQ2: Stress Deficit

RQ2 (Stress deficit): Is subjective stress positively correlated with self-reported criminal intent and negative emotions?

We will use two different estimation methods to answer this question - a cross-sectional “between-person” and a longitudinal “within-person” change approach, respectively. To do so, we will rephrase the question twice to better correspond to each estimation strategy:

RQ2A: (Stress deficit; Between-person): Do individuals who report higher levels of subjective stress at Time 1 (T1) also have a higher probability of reporting criminal intentions or negative emotions compared to those reporting less stress at T1?

RQ2B: (Stress deficit; Within-person): Are within-person increases in subjective stress from T1 to T2 (i.e., T2-T1) correlated with within-person increases (T2-T1) in the probability of reporting criminal intent or negative emotions?

4.1.1 Visualizing prevalence of past crime, criminal intent, & negative emotions

Before begin to answer these questions with models of crime and negative emotions, let’s examine prevalence for these outcomes.

Answering this question requires a switch from modeling stress (which, as noted, will become useful soon in getting the predictor side of our model correct) to modeling three constructs measuring theorized causal outcomes of stress: criminal behavior, criminal intent, and depressive symptoms. We will start with the crime outcomes.

These data contain items indicating how often participants reportedly engaged in past criminal behavior in the past two years (originally from 1=Never to 5=Very often) and comparable items that ask the participants estimate the future likelihood that they will engage in these same criminal acts (originally from 1=No chance to 5=High probability), referred to hereafter for brevity as criminal intent. We focus on items measuring six different acts: theft less than 5BAM (approximately equivalent purchasing power in 2013 as $5USD); theft greater than 5BAM; threats to use violence on someone; physically harming someone else on purpose; using marijuana or other illegal drugs; and attempting to access another person’s private information (e.g., bank account; computer files) without permission. Despite having five measured response categories, as is typical with crime items, the vast majority of responses are “1” (Never) and responses exceeding “2” (Rarely or Little chance) are extremely uncommon for these items. Due to the lack of variability and in an attempt to minimize problems caused by empty cell frequencies, each of these items is dichotomized as “0” (=Never or No chance) or “1” (=At least rarely or Little chance or greater). As such, these items are modeled using distributions that are appropriate for binary responses (e.g., Bernoulli or binomial with logit or probit link).

In analyses of stress-outcome, we limit our focus to criminal intent. Examining associations between current reports of stress in the past week and criminal behavior in the past two years would fail to establish proper causal ordering among variables implied by strain or stress process theories, whereas current reports of stress in the past week and future behavioral intentions in theory provides more appropriate causal ordering. Yet, there is high stability in past crime and criminal intent responses, with an average polychoric correlation of rho=0.84 and range from rho=0.8 to rho=0.9 between the original T1 ordinal item pairs. Additionally, supplementary figures will illustrate similar item response distributions and highly comparable stress-crime associations at T1.

load(here("1_Data_Files/Datasets/stress_dat.Rdata"))

#calculate individual & avg tetrachoric corrs 
  # original ordinal past crime & criminal intent items at T1

rho1 <- polychor(stress_dat$pstthflt5w1, stress_dat$prjthflt5w1)
# rho1 #.82
rho2 <- polychor(stress_dat$pstthfgt5w1, stress_dat$prjthfgt5w1)
# rho2 #.8
rho3 <- polychor(stress_dat$pstthreatw1, stress_dat$prjthreatw1) 
# rho3 #.84
rho4 <- polychor(stress_dat$pstharmw1, stress_dat$prjharmw1) 
# rho4 #.84
rho5 <- polychor(stress_dat$pstusedrgw1, stress_dat$prjusedrgw1) 
# rho5 #.9
rho6 <- polychor(stress_dat$psthackw1, stress_dat$prjhackw1) 
# rho6 #.83

rhoavg <- (rho1 + rho2 + rho3 + rho4 + rho5 + rho6)/6
# rhoavg #.84

In addition, we will assess seven binary items related to experiences with negative emotions in which respondents were asked how often in the past week they: felt you could not get going; felt everything was an effort; felt lonely; felt you could not shake the blues; felt like your life circumstances were unfair; felt mistreated by others; and felt betrayed by people you care about. The first four are classic items from the popular CESD scale’s “depressive affect” factor (CITE). The remaining three items were modified (see also 2008 survey & JQ Coercion piece) to capture an affective sense of unfairness or mistreatment, which are theorized to be subjective consequences of coercion or criminogenic stress. For all items, the five original response categories were recoded so that “0” indicates infrequently (Never; Rarely; Sometimes) and “1” indicates frequently (Often; Very often) experiencing theses depressive symptoms or feelings in the past week.

Supplemental Figure 1 below visualizes the prevalence rates for each of the crime and negative emotion items.

First, we need to create a factor version of each crime and affect item for use in binary models. We also need to transform our stress items into integers to model their monotonic ordinal effects using cumulative probit thresholds.

#load stress.wide (from Fig1 Rmd) 
load(here("1_Data_Files/Datasets/stress_wide.Rdata"))

stress.wide <- zap_labels(stress.wide)
stress.wide <- zap_label(stress.wide)

load(here("1_Data_Files/Datasets/stress_wide2.Rdata"))
#   cesdw1: q12_1w1 q12_2w1 q12_3w1 q12_4w1 q12_5mw1 q12_6w1 q12_7w1 ; 
# cesdw2: q12_1w2 q12_2w2 q12_3w2 q12_4w2 q12_5w2 q12_6w2 q12_7w2 ; 


#First, need to recode outcome variables as factors & stress items as integers for mo() 
stress.wide3 <- stress.wide2 %>% 
  mutate(
    pstthflt5w1f = factor(pstthflt5w1di, ordered=TRUE, levels = c(0,1)), 
    pstthfgt5w1f = factor(pstthfgt5w1di, ordered=TRUE, levels = c(0,1)), 
    pstthreatw1f = factor(pstthreatw1di, ordered=TRUE, levels = c(0,1)), 
    pstharmw1f = factor(pstharmw1di, ordered=TRUE, levels = c(0,1)), 
    pstusedrgw1f = factor(pstusedrgw1di, ordered=TRUE, levels = c(0,1)), 
    psthackw1f = factor(psthackw1di, ordered=TRUE, levels = c(0,1)), 
    pstanyw1f = factor(if_else(pstthflt5w1di == 1 | pstthfgt5w1di == 1 | pstthreatw1di == 1 |
                          pstharmw1di == 1 | pstusedrgw1di == 1 | psthackw1di == 1, 1, 0), 
                       ordered=TRUE, levels = c(0,1)),
    prjthflt5w1f = factor(prjthflt5w1di, ordered=TRUE, levels = c(0,1)), 
    prjthfgt5w1f = factor(prjthfgt5w1di, ordered=TRUE, levels = c(0,1)), 
    prjthreatw1f = factor(prjthreatw1di, ordered=TRUE, levels = c(0,1)), 
    prjharmw1f = factor(prjharmw1di, ordered=TRUE, levels = c(0,1)), 
    prjusedrgw1f = factor(prjusedrgw1di, ordered=TRUE, levels = c(0,1)), 
    prjhackw1f = factor(prjhackw1di, ordered=TRUE, levels = c(0,1)), 
    prjanyw1f = factor(if_else(prjthflt5w1di == 1 | prjthfgt5w1di == 1 | prjthreatw1di == 1 |
                          prjharmw1di == 1 | prjusedrgw1di == 1 | prjhackw1di == 1, 1, 0), 
                       ordered=TRUE, levels = c(0,1)),
    # pstcrmvarw1 = pstthflt5w1f + pstthfgt5w1f + pstthreatw1f + 
    #   pstharmw1f + pstusedrgw1f + psthackw1f, 
    # pstcrmvarw1f = factor(pstcrmvarw1, ordered=TRUE, levels = c(0,1,2,3,4,5,6)),
    # prjcrmvarw1 = prjthflt5w1f + prjthfgt5w1f + prjthreatw1f + 
    #   prjharmw1f + prjusedrgw1f + prjhackw1f, 
    # prjcrmvarw1f = factor(prjcrmvarw1, ordered=TRUE, levels = c(0,1,2,3,4,5,6)),
    depcantgow1di = if_else(depcantgow1 %in% c(4,5), 1, 0),  
      depcantgow1f = factor(depcantgow1di, ordered=TRUE, levels = c(0,1)),
    depeffortw1di = if_else(depeffortw1 %in% c(4,5), 1, 0),  
      depeffortw1f = factor(depeffortw1di, ordered=TRUE, levels = c(0,1)),
    deplonelyw1di = if_else(deplonelyw1 %in% c(4,5), 1, 0),  
      deplonelyw1f = factor(deplonelyw1di, ordered=TRUE, levels = c(0,1)),
    depbluesw1di = if_else(depbluesw1 %in% c(4,5), 1, 0),  
      depbluesw1f = factor(depbluesw1di, ordered=TRUE, levels = c(0,1)),
    depunfairw1di = if_else(depunfairw1 %in% c(4,5), 1, 0),  
      depunfairw1f = factor(depunfairw1di, ordered=TRUE, levels = c(0,1)),
    depmistrtw1di = if_else(depmistrtw1 %in% c(4,5), 1, 0),  
      depmistrtw1f = factor(depmistrtw1di, ordered=TRUE, levels = c(0,1)),
    depbetrayw1di = if_else(depbetrayw1 %in% c(4,5), 1, 0),  
      depbetrayw1f = factor(depbetrayw1di, ordered=TRUE, levels = c(0,1)),
    stmonyw1i = recode(stmonyw1f,
            "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    sttranw1i = recode(sttranw1f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    strespw1i = recode(strespw1f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    stfairw1i = recode(stfairw1f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    stjobw1i = recode(stjobw1f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    stthftw1i = recode(stthftw1f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    stmugw1i = recode(stmugw1f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer()
    )

#ordered cat predictor - remaining stress subscales & general stress

# #stress subscales - levels of ordered factors
# levels(stress.wide3$ssperw1f)
# levels(stress.wide3$ssjobw1f)
# levels(stress.wide3$ssvicw1f)
# summary(stress.wide3$ssgenw1)
#   table(stress.wide3$ssgenw1)

# head(stress.wide3)

# make sure it worked
# stress.wide3 %>% janitor::tabyl("depcantgow1f")
# stress.wide3 %>% janitor::tabyl("depeffortw1f")
# stress.wide3 %>% janitor::tabyl("deplonelyw1f")
# stress.wide3 %>% janitor::tabyl("depbluesw1f")
# stress.wide3 %>% janitor::tabyl("depunfairw1f")
# stress.wide3 %>% janitor::tabyl("depmistrtw1f")
# stress.wide3 %>% janitor::tabyl("depbetrayw1f")
# stress.wide3 %>% 
#   distinct(stmonyw1f, stmonyw1i) %>% 
#   arrange(stmonyw1i)  
# stress.wide3 %>% 
#   distinct(sttranw1f, sttranw1i) %>% 
#   arrange(sttranw1i)  
# stress.wide3 %>% 
#   distinct(strespw1f, strespw1i) %>% 
#   arrange(strespw1i)  
# stress.wide3 %>% 
#   distinct(stfairw1f, stfairw1i) %>% 
#   arrange(stfairw1i)  
# stress.wide3 %>% 
#   distinct(stjobw1f, stjobw1i) %>% 
#   arrange(stjobw1i)  
# stress.wide3 %>% 
#   distinct(stthftw1f, stthftw1i) %>% 
#   arrange(stthftw1i)  
# stress.wide3 %>% 
#   distinct(stmugw1f, stmugw1i) %>% 
#   arrange(stmugw1i)  

Next, we visualize frequency distributions for the dichotomous items measuring past participation in six crimes, future intent to participate in six crimes, and seven indicators of negative emotions (four classic CESD depressive symptoms and three “criminogenic” negative emotions). Given the extreme rarity of self-reported crime in these data, we also add a binary indicator of any past participation or future intent to engage in any of the six measured criminal behaviors. Later, and in our “Stress in Bangladesh” paper, we limit focus to criminal intent and negative emotions and drop the past crime behaviors. Though models of past crime and criminal intent tend to generate comparable patterns, past crime items fail to properly establish causal order and, thus, estimates from models predicting past crime are less plausibly interpreted as estimates of the underlying causal processes examined here.

4.2 Supp. Figure 1 - Outcome Distributions

The distributions for each of the six past crime items, six projected crime items, and seven depressive symptom items are shown in the supplemental figure below.

#NOTE: Consider "stacked" bar charts with 21 crime/dep outcome on y axix & a single bar displaying prop 1 or 0

#Exemplar  plot
# ggplot(data = stress.wide3, aes(y = pstthflt5w1f, fill=pstthflt5w1f)) +
#   geom_bar(aes(y = pstthflt5w1f, fill=factor(pstthflt5w1f), stat="count")) +
#   coord_cartesian(expand = FALSE, xlim=c(0,450)) +
#   scale_fill_scico_d(palette = "lajolla", begin=.8, end=.4,
#                      guide = guide_legend(reverse = TRUE),
#                      labels = c("0", "1+"))

# myplot <- ggplot(tips, aes(day)) + 
#           geom_bar(aes(y = (..count..)/sum(..count..))) + 
#           scale_y_continuous(labels=scales::percent) +
#   ylab("relative frequencies")
#Try this with  xlab("Relative frequencies")

psty = c("pstthflt5w1f", "pstthfgt5w1f", "pstthreatw1f", "pstharmw1f", 
         "pstusedrgw1f", "psthackw1f") 


#Create function to plot crime items
plot_outcome <- function(outcome_data, outcome_item, y_label) {
ggplot(data = outcome_data, aes(y = {{outcome_item}}, fill={{outcome_item}})) +
  geom_bar(aes(y = {{outcome_item}}), stat="count") + 
  coord_cartesian(expand = FALSE, xlim=c(0,500)) +
  scale_fill_scico_d(palette = "lajolla", begin=.8, end=.4, 
                     guide = guide_legend(reverse = TRUE),
                     labels = c("0", "1"))+ 
  ylab(y_label) + 
  theme(axis.title.y=element_text(size=8), 
        axis.title.x = element_blank(),
        legend.position="none") + 
  scale_x_continuous(limit=c(-16,500), breaks=c("0"=0,".1"=0.1*489,".2"=0.2*489,
                                                  ".3"=0.3*489,".4"=0.4*489,
                                                  ".5"=0.5*489, ".6"=0.6*489, 
                                                  ".7"=0.7*489, ".8"=0.8*489,
                                                ".9"=0.9*489)) 
}


#Plot outcome items using function
pstthflt5w1fplot <- plot_outcome(stress.wide3, pstthflt5w1f, "Past Theft <5BAM") 
pstthfgt5w1fplot <- plot_outcome(stress.wide3, pstthfgt5w1f, "Past Theft >5BAM") 
pstthreatw1fplot <- plot_outcome(stress.wide3, pstthreatw1f, "Past Threat")  
pstharmw1fplot <- plot_outcome(stress.wide3, pstharmw1f, "Past Harm")
pstusedrgw1fplot <- plot_outcome(stress.wide3, pstusedrgw1f, "Past Use Drugs") 
psthackw1fplot <- plot_outcome(stress.wide3, psthackw1f, "Past Hack") 
pstanyw1fplot <- plot_outcome(stress.wide3, pstanyw1f, "Any Past Crime") 
prjthflt5w1fplot <- plot_outcome(stress.wide3, prjthflt5w1f, "Theft <5BAM Intent") 
prjthfgt5w1fplot <- plot_outcome(stress.wide3, prjthfgt5w1f, "Theft >5BAM Intent") 
prjthreatw1fplot <- plot_outcome(stress.wide3, prjthreatw1f, "Threat Intent") 
prjharmw1fplot <- plot_outcome(stress.wide3, prjharmw1f, "Harm Intent") 
prjusedrgw1fplot <- plot_outcome(stress.wide3, prjusedrgw1f, "Use Drugs Intent") 
prjhackw1fplot <- plot_outcome(stress.wide3, prjhackw1f, "Hack Intent") 
prjanyw1fplot <- plot_outcome(stress.wide3, prjanyw1f, "Any Crime Intent") 
depcantgow1fplot <- plot_outcome(stress.wide3, depcantgow1f, "Can't Get Going") 
depeffortw1fplot <- plot_outcome(stress.wide3, depeffortw1f, "Everything Effort") 
deplonelyw1fplot <- plot_outcome(stress.wide3, deplonelyw1f, "Lonely") 
depbluesw1fplot <- plot_outcome(stress.wide3, depbluesw1f, "Can't Shake Blues") 
depunfairw1fplot <- plot_outcome(stress.wide3, depunfairw1f, "Felt Life Unfair") 
depmistrtw1fplot <- plot_outcome(stress.wide3, depmistrtw1f, "Felt Mistreated") 
depbetrayw1fplot <- plot_outcome(stress.wide3, depbetrayw1f, "Felt Betrayed") 



#Combine separate plots with patchwork

OutcomeFig <- pstthflt5w1fplot + prjthflt5w1fplot + depcantgow1fplot + 
  pstthfgt5w1fplot + prjthfgt5w1fplot + depeffortw1fplot +  
  pstthreatw1fplot + prjthreatw1fplot + deplonelyw1fplot + 
  pstharmw1fplot + prjharmw1fplot + depbluesw1fplot + 
  pstusedrgw1fplot + prjusedrgw1fplot + depunfairw1fplot + 
  psthackw1fplot + prjhackw1fplot + depmistrtw1fplot + 
  pstanyw1fplot + prjanyw1fplot + depbetrayw1fplot + 
  plot_layout(ncol = 3) +
  plot_annotation(
    title = 'SUPPLEMENTAL FIGURE 1 Prevalence of Past Crime, Criminal Intent, & Negative\nEmotions (T1)', 
    # subtitle = 'Subtitle', 
    caption = 'Note: N=489 respondents participating at both survey waves.') &
  theme(plot.title = element_text(size=12, face="bold"),
        # plot.subtitle = element_text(size=12),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        )
OutcomeFig 

#Export to image
 ggsave("SuppFigure1.jpeg", OutcomeFig, width=6.5, height=9, path=here("Output"))

Prevalence is quite low for all items, with reports of past crime or criminal intent being especially rare compared to experiences with negative emotions. However, our collapsed indicators of “any” past or intended crime have prevalence rates that are more comparable to negative emotions items.

4.3 RQ2A: Stress-Outcome Correlations at T1: Traditional Between-Person Method

RQ2A: (Stress deficit; Between-person): Do individuals who report higher levels of subjective stress at Time 1 (T1) also have a higher probability of reporting criminal intentions or negative emotions compared to those reporting less stress at T1?

To answer this, we must move from describing stress distributions to examining stress as a theoretically posited predictor of crime and depressive symptoms. Recall, when we include the stress items as predictors, we will want to properly account for their ordinal nature in our models. We will do so by relying on thresholds from monotonic cumulative ordinal probit models rather than treating the stress items as continuous metric variables in regression models (the standard approach).

4.3.1 Posterior Predictive Checks for Bivariate Stress/Outcome Models

In the “Stress in Bangladesh” paper, we present results from a series of simple bivariate stress/outcome models that regress each outcome item, or each indicator of criminal intent and negative emotions, separately on each indicator of stress at T1 (see Figure 3). We specify a Bernoulli distribution with a logit link for each outcome item and monotonic cumulative ordinal probit thresholds for each stress predictor.. Below, we present code for these models as well as all results and posterior checks for each of those models used to answer RQ2 (bivariate associations between stress and crime/depressive symptom outcomes). For transparency’s sake, we also begin by presenting results (and later supplementary figures) from T1 models predicting past crime, though, as noted above, these models are not presented in the final paper.

4.3.2 Past crime items: Bivarate models

4.3.2.1 Bivariate Corr: T1 stmonyw1/past crime

#Bivariate: past crime items ~ mo(stmonyw1i)

# prior <- get_prior(mvbind(pstthflt5w1f, pstthfgt5w1f) ~ 1 + mo(stmonyw1i),  
#       data = stress.wide3, 
#       family = "bernoulli")


# prior1 <- c(prior(normal(0, 2), class = Intercept, resp = pstthflt5w1f),
#             prior(normal(0, 2), class = Intercept, resp = pstthfgt5w1f),
#             prior(normal(0, 2), class = Intercept, resp = pstthreatw1f),
#             prior(normal(0, 2), class = Intercept, resp = pstharmw1f),
#             prior(normal(0, 2), class = Intercept, resp = pstusedrgw1f),
#             prior(normal(0, 2), class = Intercept, resp = psthackw1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = pstthflt5w1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = pstthfgt5w1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = pstthreatw1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = pstharmw1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = pstusedrgw1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = psthackw1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = pstthflt5w1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = pstthfgt5w1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = pstthreatw1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = pstharmw1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = pstusedrgw1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = psthackw1f)
# )

#Vectorize priors:

#list of colnames for past crime DVs  
pstdv_names <- noquote(c("pstthflt5w1f", "pstthfgt5w1f", "pstthreatw1f", "pstharmw1f", 
                           "pstusedrgw1f", "psthackw1f"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = pstdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmonyw1i', 
                  resp = pstdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmonyw1i1', 
                  resp = pstdv_names))

# NOTE: consider using future::plan(multisession()) & rstan for parallelizing models
# plan(multiprocess(workers=nCoresphys)) #multiprocess depricated

# if (file.exists(here("Models","allpstcrime_stmony_fit.rds"))) {
#   allpstcrime.stmony.fit <- readRDS("Models/allpstcrime_stmony_fit.rds")
# } else {}
  #Manual caching unnecessary - use file & file_refit built into brms 

allpstcrime.stmony.fit <- 
  brm(
      mvbind(pstthflt5w1f, pstthfgt5w1f, pstthreatw1f, pstharmw1f, pstusedrgw1f, psthackw1f) ~ 1 + mo(stmonyw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      # threads = threading(2), #within-chain threading may speed up intensive models      
      backend = "cmdstanr", #may need to reinstall RStan
      # future = TRUE, #requires rstan not cmdstanr
      seed = 8675309,
      file = "Models/allpstcrime_stmony_fit",
      file_refit = "on_change"
      )


#Update function to call all ppchecks for bivar past crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="pstthflt5w1f")
  ppcheckdv2 <-pp_check(modelfit, resp="pstthfgt5w1f")
  ppcheckdv3 <-pp_check(modelfit, resp="pstthreatw1f")
  ppcheckdv4 <-pp_check(modelfit, resp="pstharmw1f")
  ppcheckdv5 <-pp_check(modelfit, resp="pstusedrgw1f")
  ppcheckdv6 <-pp_check(modelfit, resp="psthackw1f")
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95) +
    labs(title = "Coefficient plot",
         subtitle = "Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80%, and 95% intervals")

  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, 
                    ppcheckdv3, ppcheckdv4, ppcheckdv5, ppcheckdv6, 
                    plotcoefs, plotcoefs2)
  return(allchecks)
}

out.allpstcrime.stmony.fit <- ppchecks(allpstcrime.stmony.fit)

# plot fit
# plot(allpstcrime.stmony.fit, variable = "^bsp_", 
                # regex = TRUE, nvariables=3, ask=FALSE)

 # mcmc_plot(allpstcrime.stmony.fit, variable = "^bsp_", regex = TRUE)
4.3.2.1.1 Coefficient plot (intervals)
out.allpstcrime.stmony.fit[[10]]

4.3.2.1.2 Coefficient plot (distributions)
out.allpstcrime.stmony.fit[[9]]

4.3.2.1.3 PPcheck (density)
p1 <- out.allpstcrime.stmony.fit[[3]] + labs(title = "Past Theft <5BAM (T1)") 
p2 <- out.allpstcrime.stmony.fit[[4]] + labs(title = "Past Theft >5BAM (T1)")
p3 <- out.allpstcrime.stmony.fit[[5]] + labs(title = "Past Threat (T1)")
p4 <- out.allpstcrime.stmony.fit[[6]] + labs(title = "Past Harm (T1)")
p5 <- out.allpstcrime.stmony.fit[[7]] + labs(title = "Past Use Drugs (T1)")
p6 <- out.allpstcrime.stmony.fit[[8]] + labs(title = "Past Hack (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.2.1.4 Fit summary
out.allpstcrime.stmony.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: pstthflt5w1f ~ 1 + mo(stmonyw1i) 
##          pstthfgt5w1f ~ 1 + mo(stmonyw1i) 
##          pstthreatw1f ~ 1 + mo(stmonyw1i) 
##          pstharmw1f ~ 1 + mo(stmonyw1i) 
##          pstusedrgw1f ~ 1 + mo(stmonyw1i) 
##          psthackw1f ~ 1 + mo(stmonyw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_Intercept      -1.93      0.29    -2.53    -1.39 1.00     2992
## pstthfgt5w1f_Intercept      -2.03      0.30    -2.64    -1.45 1.00     3227
## pstthreatw1f_Intercept      -3.15      0.40    -4.00    -2.41 1.00     3446
## pstharmw1f_Intercept        -2.48      0.35    -3.19    -1.80 1.00     2843
## pstusedrgw1f_Intercept      -2.71      0.36    -3.46    -2.04 1.00     3177
## psthackw1f_Intercept        -3.31      0.43    -4.20    -2.50 1.00     3791
## pstthflt5w1f_mostmonyw1i     0.04      0.11    -0.17     0.27 1.00     3162
## pstthfgt5w1f_mostmonyw1i    -0.04      0.12    -0.27     0.21 1.00     3372
## pstthreatw1f_mostmonyw1i     0.09      0.15    -0.20     0.40 1.00     3514
## pstharmw1f_mostmonyw1i      -0.04      0.14    -0.30     0.26 1.00     2893
## pstusedrgw1f_mostmonyw1i     0.03      0.14    -0.25     0.32 1.00     3087
## psthackw1f_mostmonyw1i       0.02      0.17    -0.29     0.36 1.01     3766
##                          Tail_ESS
## pstthflt5w1f_Intercept       2893
## pstthfgt5w1f_Intercept       3189
## pstthreatw1f_Intercept       2542
## pstharmw1f_Intercept         2498
## pstusedrgw1f_Intercept       2940
## psthackw1f_Intercept         3248
## pstthflt5w1f_mostmonyw1i     3157
## pstthfgt5w1f_mostmonyw1i     3210
## pstthreatw1f_mostmonyw1i     2433
## pstharmw1f_mostmonyw1i       2624
## pstusedrgw1f_mostmonyw1i     2833
## psthackw1f_mostmonyw1i       3058
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_mostmonyw1i1[1]     0.26      0.15     0.04     0.60 1.00     5468
## pstthflt5w1f_mostmonyw1i1[2]     0.23      0.14     0.03     0.58 1.00     5433
## pstthflt5w1f_mostmonyw1i1[3]     0.24      0.14     0.03     0.57 1.00     6220
## pstthflt5w1f_mostmonyw1i1[4]     0.26      0.14     0.04     0.58 1.00     5685
## pstthfgt5w1f_mostmonyw1i1[1]     0.25      0.14     0.04     0.57 1.00     6237
## pstthfgt5w1f_mostmonyw1i1[2]     0.27      0.16     0.04     0.63 1.00     4600
## pstthfgt5w1f_mostmonyw1i1[3]     0.23      0.14     0.03     0.55 1.00     6631
## pstthfgt5w1f_mostmonyw1i1[4]     0.24      0.15     0.03     0.57 1.00     5360
## pstthreatw1f_mostmonyw1i1[1]     0.26      0.15     0.04     0.60 1.00     5223
## pstthreatw1f_mostmonyw1i1[2]     0.23      0.14     0.03     0.56 1.00     5901
## pstthreatw1f_mostmonyw1i1[3]     0.24      0.14     0.03     0.55 1.00     7032
## pstthreatw1f_mostmonyw1i1[4]     0.27      0.14     0.05     0.59 1.00     6459
## pstharmw1f_mostmonyw1i1[1]       0.25      0.15     0.04     0.58 1.00     6962
## pstharmw1f_mostmonyw1i1[2]       0.26      0.15     0.04     0.60 1.00     4600
## pstharmw1f_mostmonyw1i1[3]       0.24      0.14     0.03     0.56 1.00     6241
## pstharmw1f_mostmonyw1i1[4]       0.25      0.15     0.04     0.58 1.00     4469
## pstusedrgw1f_mostmonyw1i1[1]     0.26      0.15     0.04     0.58 1.00     6840
## pstusedrgw1f_mostmonyw1i1[2]     0.24      0.15     0.03     0.58 1.00     5708
## pstusedrgw1f_mostmonyw1i1[3]     0.24      0.14     0.03     0.57 1.00     6729
## pstusedrgw1f_mostmonyw1i1[4]     0.26      0.15     0.04     0.59 1.00     5798
## psthackw1f_mostmonyw1i1[1]       0.26      0.15     0.04     0.59 1.00     6647
## psthackw1f_mostmonyw1i1[2]       0.24      0.15     0.03     0.57 1.00     7530
## psthackw1f_mostmonyw1i1[3]       0.24      0.14     0.04     0.56 1.00     6962
## psthackw1f_mostmonyw1i1[4]       0.26      0.15     0.04     0.59 1.00     5872
##                              Tail_ESS
## pstthflt5w1f_mostmonyw1i1[1]     2808
## pstthflt5w1f_mostmonyw1i1[2]     3194
## pstthflt5w1f_mostmonyw1i1[3]     3000
## pstthflt5w1f_mostmonyw1i1[4]     3261
## pstthfgt5w1f_mostmonyw1i1[1]     2713
## pstthfgt5w1f_mostmonyw1i1[2]     3124
## pstthfgt5w1f_mostmonyw1i1[3]     2640
## pstthfgt5w1f_mostmonyw1i1[4]     3023
## pstthreatw1f_mostmonyw1i1[1]     2046
## pstthreatw1f_mostmonyw1i1[2]     2443
## pstthreatw1f_mostmonyw1i1[3]     3193
## pstthreatw1f_mostmonyw1i1[4]     3251
## pstharmw1f_mostmonyw1i1[1]       2531
## pstharmw1f_mostmonyw1i1[2]       2939
## pstharmw1f_mostmonyw1i1[3]       2879
## pstharmw1f_mostmonyw1i1[4]       3253
## pstusedrgw1f_mostmonyw1i1[1]     2807
## pstusedrgw1f_mostmonyw1i1[2]     2640
## pstusedrgw1f_mostmonyw1i1[3]     2459
## pstusedrgw1f_mostmonyw1i1[4]     2964
## psthackw1f_mostmonyw1i1[1]       2891
## psthackw1f_mostmonyw1i1[2]       2920
## psthackw1f_mostmonyw1i1[3]       3268
## psthackw1f_mostmonyw1i1[4]       2676
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.2.1.5 Prior summary
out.allpstcrime.stmony.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      psthackw1f              
##        normal(0, 0.25)         b  mostmonyw1i         psthackw1f              
##                 (flat)         b                      pstharmw1f              
##        normal(0, 0.25)         b  mostmonyw1i         pstharmw1f              
##                 (flat)         b                    pstthfgt5w1f              
##        normal(0, 0.25)         b  mostmonyw1i       pstthfgt5w1f              
##                 (flat)         b                    pstthflt5w1f              
##        normal(0, 0.25)         b  mostmonyw1i       pstthflt5w1f              
##                 (flat)         b                    pstthreatw1f              
##        normal(0, 0.25)         b  mostmonyw1i       pstthreatw1f              
##                 (flat)         b                    pstusedrgw1f              
##        normal(0, 0.25)         b  mostmonyw1i       pstusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      psthackw1f              
##           normal(0, 2) Intercept                      pstharmw1f              
##           normal(0, 2) Intercept                    pstthfgt5w1f              
##           normal(0, 2) Intercept                    pstthflt5w1f              
##           normal(0, 2) Intercept                    pstthreatw1f              
##           normal(0, 2) Intercept                    pstusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1         psthackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1         pstharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       pstthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       pstthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       pstthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       pstusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.2.2 Bivariate Corr: T1 sttranw1/past crime

#Bivariate: past crime items ~ mo(sttranw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = pstdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mosttranw1i', 
                  resp = pstdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mosttranw1i1', 
                  resp = pstdv_names))

allpstcrime.sttran.fit <- brm(
  mvbind(pstthflt5w1f, pstthfgt5w1f, pstthreatw1f, pstharmw1f, pstusedrgw1f, psthackw1f) ~ 1 + mo(sttranw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allpstcrime_sttran_fit",
      file_refit = "on_change"
  )
out.allpstcrime.sttran.fit <- ppchecks(allpstcrime.sttran.fit)
4.3.2.2.1 Coefficient plot (intervals)
out.allpstcrime.sttran.fit[[10]]

4.3.2.2.2 Coefficient plot (distributions)
out.allpstcrime.sttran.fit[[9]]

4.3.2.2.3 PPcheck (density)
p1 <- out.allpstcrime.sttran.fit[[3]] + labs(title = "Past Theft <5BAM (T1)") 
p2 <- out.allpstcrime.sttran.fit[[4]] + labs(title = "Past Theft >5BAM (T1)")
p3 <- out.allpstcrime.sttran.fit[[5]] + labs(title = "Past Threat (T1)")
p4 <- out.allpstcrime.sttran.fit[[6]] + labs(title = "Past Harm (T1)")
p5 <- out.allpstcrime.sttran.fit[[7]] + labs(title = "Past Use Drugs (T1)")
p6 <- out.allpstcrime.sttran.fit[[8]] + labs(title = "Past Hack (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.2.2.4 Fit summary
out.allpstcrime.sttran.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: pstthflt5w1f ~ 1 + mo(sttranw1i) 
##          pstthfgt5w1f ~ 1 + mo(sttranw1i) 
##          pstthreatw1f ~ 1 + mo(sttranw1i) 
##          pstharmw1f ~ 1 + mo(sttranw1i) 
##          pstusedrgw1f ~ 1 + mo(sttranw1i) 
##          psthackw1f ~ 1 + mo(sttranw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_Intercept      -1.88      0.29    -2.41    -1.24 1.00     3190
## pstthfgt5w1f_Intercept      -2.19      0.32    -2.81    -1.56 1.00     3069
## pstthreatw1f_Intercept      -3.17      0.40    -3.97    -2.39 1.00     3433
## pstharmw1f_Intercept        -2.35      0.37    -3.08    -1.61 1.00     3161
## pstusedrgw1f_Intercept      -2.81      0.39    -3.61    -2.06 1.00     3234
## psthackw1f_Intercept        -3.15      0.43    -4.01    -2.35 1.00     3531
## pstthflt5w1f_mosttranw1i     0.03      0.12    -0.22     0.25 1.00     3094
## pstthfgt5w1f_mosttranw1i     0.04      0.13    -0.22     0.29 1.00     3349
## pstthreatw1f_mosttranw1i     0.11      0.15    -0.20     0.41 1.00     3513
## pstharmw1f_mosttranw1i      -0.09      0.15    -0.37     0.20 1.00     3252
## pstusedrgw1f_mosttranw1i     0.08      0.16    -0.22     0.40 1.00     2864
## psthackw1f_mosttranw1i      -0.05      0.16    -0.35     0.27 1.00     3281
##                          Tail_ESS
## pstthflt5w1f_Intercept       2794
## pstthfgt5w1f_Intercept       2458
## pstthreatw1f_Intercept       2682
## pstharmw1f_Intercept         2603
## pstusedrgw1f_Intercept       3021
## psthackw1f_Intercept         2555
## pstthflt5w1f_mosttranw1i     2835
## pstthfgt5w1f_mosttranw1i     2769
## pstthreatw1f_mosttranw1i     2585
## pstharmw1f_mosttranw1i       2893
## pstusedrgw1f_mosttranw1i     3059
## psthackw1f_mosttranw1i       2632
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_mosttranw1i1[1]     0.26      0.15     0.04     0.60 1.00     5617
## pstthflt5w1f_mosttranw1i1[2]     0.23      0.14     0.03     0.57 1.00     7525
## pstthflt5w1f_mosttranw1i1[3]     0.24      0.14     0.03     0.58 1.00     6841
## pstthflt5w1f_mosttranw1i1[4]     0.27      0.15     0.04     0.60 1.00     5623
## pstthfgt5w1f_mosttranw1i1[1]     0.26      0.15     0.04     0.59 1.00     6506
## pstthfgt5w1f_mosttranw1i1[2]     0.23      0.14     0.03     0.55 1.00     8372
## pstthfgt5w1f_mosttranw1i1[3]     0.24      0.14     0.04     0.56 1.00     7284
## pstthfgt5w1f_mosttranw1i1[4]     0.27      0.15     0.04     0.61 1.00     5683
## pstthreatw1f_mosttranw1i1[1]     0.24      0.14     0.04     0.56 1.00     5745
## pstthreatw1f_mosttranw1i1[2]     0.23      0.14     0.03     0.55 1.00     6804
## pstthreatw1f_mosttranw1i1[3]     0.25      0.15     0.03     0.58 1.00     6329
## pstthreatw1f_mosttranw1i1[4]     0.28      0.16     0.04     0.63 1.00     6932
## pstharmw1f_mosttranw1i1[1]       0.26      0.14     0.04     0.58 1.00     5677
## pstharmw1f_mosttranw1i1[2]       0.28      0.15     0.04     0.62 1.00     5089
## pstharmw1f_mosttranw1i1[3]       0.24      0.14     0.03     0.55 1.00     7652
## pstharmw1f_mosttranw1i1[4]       0.23      0.14     0.03     0.56 1.00     4586
## pstusedrgw1f_mosttranw1i1[1]     0.26      0.15     0.04     0.59 1.00     6222
## pstusedrgw1f_mosttranw1i1[2]     0.22      0.14     0.03     0.54 1.00     5365
## pstusedrgw1f_mosttranw1i1[3]     0.22      0.14     0.03     0.54 1.00     6311
## pstusedrgw1f_mosttranw1i1[4]     0.30      0.17     0.04     0.65 1.00     4260
## psthackw1f_mosttranw1i1[1]       0.26      0.14     0.04     0.58 1.00     5490
## psthackw1f_mosttranw1i1[2]       0.25      0.14     0.04     0.57 1.00     5690
## psthackw1f_mosttranw1i1[3]       0.24      0.14     0.04     0.57 1.00     8421
## psthackw1f_mosttranw1i1[4]       0.25      0.14     0.04     0.56 1.00     6678
##                              Tail_ESS
## pstthflt5w1f_mosttranw1i1[1]     3225
## pstthflt5w1f_mosttranw1i1[2]     2765
## pstthflt5w1f_mosttranw1i1[3]     2825
## pstthflt5w1f_mosttranw1i1[4]     2929
## pstthfgt5w1f_mosttranw1i1[1]     2502
## pstthfgt5w1f_mosttranw1i1[2]     2353
## pstthfgt5w1f_mosttranw1i1[3]     2970
## pstthfgt5w1f_mosttranw1i1[4]     3354
## pstthreatw1f_mosttranw1i1[1]     2905
## pstthreatw1f_mosttranw1i1[2]     2814
## pstthreatw1f_mosttranw1i1[3]     3129
## pstthreatw1f_mosttranw1i1[4]     2721
## pstharmw1f_mosttranw1i1[1]       2419
## pstharmw1f_mosttranw1i1[2]       2875
## pstharmw1f_mosttranw1i1[3]       3000
## pstharmw1f_mosttranw1i1[4]       2836
## pstusedrgw1f_mosttranw1i1[1]     2650
## pstusedrgw1f_mosttranw1i1[2]     2935
## pstusedrgw1f_mosttranw1i1[3]     2859
## pstusedrgw1f_mosttranw1i1[4]     2850
## psthackw1f_mosttranw1i1[1]       2810
## psthackw1f_mosttranw1i1[2]       2655
## psthackw1f_mosttranw1i1[3]       3170
## psthackw1f_mosttranw1i1[4]       3134
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.2.2.5 Prior summary
out.allpstcrime.sttran.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      psthackw1f              
##        normal(0, 0.25)         b  mosttranw1i         psthackw1f              
##                 (flat)         b                      pstharmw1f              
##        normal(0, 0.25)         b  mosttranw1i         pstharmw1f              
##                 (flat)         b                    pstthfgt5w1f              
##        normal(0, 0.25)         b  mosttranw1i       pstthfgt5w1f              
##                 (flat)         b                    pstthflt5w1f              
##        normal(0, 0.25)         b  mosttranw1i       pstthflt5w1f              
##                 (flat)         b                    pstthreatw1f              
##        normal(0, 0.25)         b  mosttranw1i       pstthreatw1f              
##                 (flat)         b                    pstusedrgw1f              
##        normal(0, 0.25)         b  mosttranw1i       pstusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      psthackw1f              
##           normal(0, 2) Intercept                      pstharmw1f              
##           normal(0, 2) Intercept                    pstthfgt5w1f              
##           normal(0, 2) Intercept                    pstthflt5w1f              
##           normal(0, 2) Intercept                    pstthreatw1f              
##           normal(0, 2) Intercept                    pstusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1         psthackw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1         pstharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       pstthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       pstthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       pstthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       pstusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.2.3 Bivariate Corr: T1 strespw1/past crime

#Bivariate: past crime items ~ mo(strespw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = pstdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostrespw1i', 
                  resp = pstdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostrespw1i1', 
                  resp = pstdv_names))

allpstcrime.stresp.fit <- brm(
  mvbind(pstthflt5w1f, pstthfgt5w1f, pstthreatw1f, pstharmw1f, pstusedrgw1f, psthackw1f) ~ 1 + mo(strespw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allpstcrime_stresp_fit",
      file_refit = "on_change")
out.allpstcrime.stresp.fit <- ppchecks(allpstcrime.stresp.fit)
4.3.2.3.1 Coefficient plot (intervals)
out.allpstcrime.stresp.fit[[10]]

4.3.2.3.2 Coefficient plot (distributions)
out.allpstcrime.stresp.fit[[9]]

4.3.2.3.3 PPcheck (density)
p1 <- out.allpstcrime.stresp.fit[[3]] + labs(title = "Past Theft <5BAM (T1)") 
p2 <- out.allpstcrime.stresp.fit[[4]] + labs(title = "Past Theft >5BAM (T1)")
p3 <- out.allpstcrime.stresp.fit[[5]] + labs(title = "Past Threat (T1)")
p4 <- out.allpstcrime.stresp.fit[[6]] + labs(title = "Past Harm (T1)")
p5 <- out.allpstcrime.stresp.fit[[7]] + labs(title = "Past Use Drugs (T1)")
p6 <- out.allpstcrime.stresp.fit[[8]] + labs(title = "Past Hack (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.2.3.4 Fit summary
out.allpstcrime.stresp.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: pstthflt5w1f ~ 1 + mo(strespw1i) 
##          pstthfgt5w1f ~ 1 + mo(strespw1i) 
##          pstthreatw1f ~ 1 + mo(strespw1i) 
##          pstharmw1f ~ 1 + mo(strespw1i) 
##          pstusedrgw1f ~ 1 + mo(strespw1i) 
##          psthackw1f ~ 1 + mo(strespw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_Intercept      -2.42      0.28    -3.02    -1.92 1.00     3486
## pstthfgt5w1f_Intercept      -2.50      0.31    -3.18    -1.93 1.00     4723
## pstthreatw1f_Intercept      -3.36      0.38    -4.16    -2.64 1.00     4553
## pstharmw1f_Intercept        -2.86      0.35    -3.63    -2.22 1.00     3905
## pstusedrgw1f_Intercept      -3.29      0.37    -4.06    -2.60 1.00     4476
## psthackw1f_Intercept        -3.40      0.41    -4.24    -2.66 1.00     5010
## pstthflt5w1f_mostrespw1i     0.24      0.09     0.07     0.42 1.00     3703
## pstthfgt5w1f_mostrespw1i     0.15      0.10    -0.04     0.36 1.00     4673
## pstthreatw1f_mostrespw1i     0.17      0.13    -0.08     0.42 1.00     4941
## pstharmw1f_mostrespw1i       0.12      0.11    -0.10     0.34 1.00     3981
## pstusedrgw1f_mostrespw1i     0.25      0.11     0.03     0.48 1.00     4756
## psthackw1f_mostrespw1i       0.06      0.14    -0.21     0.34 1.00     5004
##                          Tail_ESS
## pstthflt5w1f_Intercept       2597
## pstthfgt5w1f_Intercept       2857
## pstthreatw1f_Intercept       3134
## pstharmw1f_Intercept         2693
## pstusedrgw1f_Intercept       2955
## psthackw1f_Intercept         2671
## pstthflt5w1f_mostrespw1i     2731
## pstthfgt5w1f_mostrespw1i     2879
## pstthreatw1f_mostrespw1i     3124
## pstharmw1f_mostrespw1i       2907
## pstusedrgw1f_mostrespw1i     3127
## psthackw1f_mostrespw1i       3426
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_mostrespw1i1[1]     0.22      0.13     0.03     0.52 1.00     7913
## pstthflt5w1f_mostrespw1i1[2]     0.26      0.15     0.04     0.58 1.00     7742
## pstthflt5w1f_mostrespw1i1[3]     0.25      0.14     0.04     0.56 1.00     7768
## pstthflt5w1f_mostrespw1i1[4]     0.27      0.14     0.05     0.57 1.00     8553
## pstthfgt5w1f_mostrespw1i1[1]     0.29      0.16     0.05     0.63 1.00     6859
## pstthfgt5w1f_mostrespw1i1[2]     0.24      0.14     0.03     0.55 1.00     8499
## pstthfgt5w1f_mostrespw1i1[3]     0.23      0.14     0.03     0.54 1.00     7839
## pstthfgt5w1f_mostrespw1i1[4]     0.24      0.13     0.04     0.54 1.00     6889
## pstthreatw1f_mostrespw1i1[1]     0.24      0.14     0.03     0.57 1.00     8148
## pstthreatw1f_mostrespw1i1[2]     0.24      0.13     0.04     0.55 1.00     6830
## pstthreatw1f_mostrespw1i1[3]     0.26      0.15     0.04     0.59 1.00     7216
## pstthreatw1f_mostrespw1i1[4]     0.26      0.14     0.04     0.58 1.00     7220
## pstharmw1f_mostrespw1i1[1]       0.27      0.15     0.04     0.60 1.00     6900
## pstharmw1f_mostrespw1i1[2]       0.26      0.14     0.04     0.57 1.00     9042
## pstharmw1f_mostrespw1i1[3]       0.23      0.14     0.03     0.56 1.00     6819
## pstharmw1f_mostrespw1i1[4]       0.24      0.14     0.04     0.56 1.00     7185
## pstusedrgw1f_mostrespw1i1[1]     0.23      0.13     0.04     0.53 1.00     6997
## pstusedrgw1f_mostrespw1i1[2]     0.22      0.13     0.03     0.53 1.00     7594
## pstusedrgw1f_mostrespw1i1[3]     0.31      0.15     0.06     0.63 1.00     7061
## pstusedrgw1f_mostrespw1i1[4]     0.24      0.14     0.04     0.56 1.00     7387
## psthackw1f_mostrespw1i1[1]       0.26      0.15     0.03     0.61 1.00     6609
## psthackw1f_mostrespw1i1[2]       0.24      0.14     0.04     0.58 1.00     8017
## psthackw1f_mostrespw1i1[3]       0.25      0.14     0.04     0.57 1.00     6835
## psthackw1f_mostrespw1i1[4]       0.25      0.14     0.04     0.57 1.00     6695
##                              Tail_ESS
## pstthflt5w1f_mostrespw1i1[1]     2801
## pstthflt5w1f_mostrespw1i1[2]     2230
## pstthflt5w1f_mostrespw1i1[3]     2742
## pstthflt5w1f_mostrespw1i1[4]     3237
## pstthfgt5w1f_mostrespw1i1[1]     2254
## pstthfgt5w1f_mostrespw1i1[2]     2523
## pstthfgt5w1f_mostrespw1i1[3]     2897
## pstthfgt5w1f_mostrespw1i1[4]     2629
## pstthreatw1f_mostrespw1i1[1]     2746
## pstthreatw1f_mostrespw1i1[2]     2404
## pstthreatw1f_mostrespw1i1[3]     2795
## pstthreatw1f_mostrespw1i1[4]     2686
## pstharmw1f_mostrespw1i1[1]       2369
## pstharmw1f_mostrespw1i1[2]       2932
## pstharmw1f_mostrespw1i1[3]       2516
## pstharmw1f_mostrespw1i1[4]       3063
## pstusedrgw1f_mostrespw1i1[1]     2413
## pstusedrgw1f_mostrespw1i1[2]     2093
## pstusedrgw1f_mostrespw1i1[3]     2799
## pstusedrgw1f_mostrespw1i1[4]     2800
## psthackw1f_mostrespw1i1[1]       2556
## psthackw1f_mostrespw1i1[2]       2756
## psthackw1f_mostrespw1i1[3]       2432
## psthackw1f_mostrespw1i1[4]       2874
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.2.3.5 Prior summary
out.allpstcrime.stresp.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      psthackw1f              
##        normal(0, 0.25)         b  mostrespw1i         psthackw1f              
##                 (flat)         b                      pstharmw1f              
##        normal(0, 0.25)         b  mostrespw1i         pstharmw1f              
##                 (flat)         b                    pstthfgt5w1f              
##        normal(0, 0.25)         b  mostrespw1i       pstthfgt5w1f              
##                 (flat)         b                    pstthflt5w1f              
##        normal(0, 0.25)         b  mostrespw1i       pstthflt5w1f              
##                 (flat)         b                    pstthreatw1f              
##        normal(0, 0.25)         b  mostrespw1i       pstthreatw1f              
##                 (flat)         b                    pstusedrgw1f              
##        normal(0, 0.25)         b  mostrespw1i       pstusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      psthackw1f              
##           normal(0, 2) Intercept                      pstharmw1f              
##           normal(0, 2) Intercept                    pstthfgt5w1f              
##           normal(0, 2) Intercept                    pstthflt5w1f              
##           normal(0, 2) Intercept                    pstthreatw1f              
##           normal(0, 2) Intercept                    pstusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1         psthackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1         pstharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       pstthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       pstthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       pstthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       pstusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.2.4 Bivariate Corr: T1 stfairw1/past crime

#Bivariate: past crime items ~ mo(stfairw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = pstdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostfairw1i', 
                  resp = pstdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostfairw1i1', 
                  resp = pstdv_names))

allpstcrime.stfair.fit <- brm(
  mvbind(pstthflt5w1f, pstthfgt5w1f, pstthreatw1f, pstharmw1f, pstusedrgw1f, psthackw1f) ~ 1 + mo(stfairw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allpstcrime_stfair_fit",
      file_refit = "on_change"
  )
out.allpstcrime.stfair.fit <- ppchecks(allpstcrime.stfair.fit)
4.3.2.4.1 Coefficient plot (intervals)
out.allpstcrime.stfair.fit[[10]]

4.3.2.4.2 Coefficient plot (distributions)
out.allpstcrime.stfair.fit[[9]]

4.3.2.4.3 PPcheck (density)
p1 <- out.allpstcrime.stfair.fit[[3]] + labs(title = "Past Theft <5BAM (T1)") 
p2 <- out.allpstcrime.stfair.fit[[4]] + labs(title = "Past Theft >5BAM (T1)")
p3 <- out.allpstcrime.stfair.fit[[5]] + labs(title = "Past Threat (T1)")
p4 <- out.allpstcrime.stfair.fit[[6]] + labs(title = "Past Harm (T1)")
p5 <- out.allpstcrime.stfair.fit[[7]] + labs(title = "Past Use Drugs (T1)")
p6 <- out.allpstcrime.stfair.fit[[8]] + labs(title = "Past Hack (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.2.4.4 Fit summary
out.allpstcrime.stfair.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: pstthflt5w1f ~ 1 + mo(stfairw1i) 
##          pstthfgt5w1f ~ 1 + mo(stfairw1i) 
##          pstthreatw1f ~ 1 + mo(stfairw1i) 
##          pstharmw1f ~ 1 + mo(stfairw1i) 
##          pstusedrgw1f ~ 1 + mo(stfairw1i) 
##          psthackw1f ~ 1 + mo(stfairw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_Intercept      -2.41      0.26    -2.96    -1.92 1.00     4250
## pstthfgt5w1f_Intercept      -2.47      0.31    -3.13    -1.91 1.00     2873
## pstthreatw1f_Intercept      -3.49      0.41    -4.33    -2.72 1.00     3515
## pstharmw1f_Intercept        -3.00      0.36    -3.76    -2.36 1.00     2955
## pstusedrgw1f_Intercept      -3.28      0.39    -4.12    -2.57 1.00     3477
## psthackw1f_Intercept        -3.50      0.42    -4.38    -2.72 1.00     3426
## pstthflt5w1f_mostfairw1i     0.23      0.08     0.07     0.40 1.00     4191
## pstthfgt5w1f_mostfairw1i     0.13      0.10    -0.06     0.33 1.00     2926
## pstthreatw1f_mostfairw1i     0.21      0.13    -0.04     0.46 1.00     3769
## pstharmw1f_mostfairw1i       0.17      0.11    -0.04     0.39 1.00     3009
## pstusedrgw1f_mostfairw1i     0.23      0.12     0.01     0.47 1.00     3437
## psthackw1f_mostfairw1i       0.09      0.14    -0.17     0.36 1.00     3517
##                          Tail_ESS
## pstthflt5w1f_Intercept       2836
## pstthfgt5w1f_Intercept       2588
## pstthreatw1f_Intercept       2840
## pstharmw1f_Intercept         2617
## pstusedrgw1f_Intercept       2667
## psthackw1f_Intercept         3092
## pstthflt5w1f_mostfairw1i     2769
## pstthfgt5w1f_mostfairw1i     2344
## pstthreatw1f_mostfairw1i     2847
## pstharmw1f_mostfairw1i       2753
## pstusedrgw1f_mostfairw1i     2876
## psthackw1f_mostfairw1i       3325
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_mostfairw1i1[1]     0.20      0.12     0.03     0.50 1.00     6257
## pstthflt5w1f_mostfairw1i1[2]     0.23      0.13     0.04     0.53 1.00     8749
## pstthflt5w1f_mostfairw1i1[3]     0.26      0.14     0.04     0.57 1.00     6598
## pstthflt5w1f_mostfairw1i1[4]     0.30      0.14     0.06     0.60 1.00     6341
## pstthfgt5w1f_mostfairw1i1[1]     0.27      0.15     0.04     0.60 1.00     5255
## pstthfgt5w1f_mostfairw1i1[2]     0.25      0.14     0.04     0.58 1.00     8072
## pstthfgt5w1f_mostfairw1i1[3]     0.26      0.14     0.04     0.57 1.00     6849
## pstthfgt5w1f_mostfairw1i1[4]     0.22      0.13     0.03     0.53 1.00     6735
## pstthreatw1f_mostfairw1i1[1]     0.23      0.13     0.04     0.55 1.00     7258
## pstthreatw1f_mostfairw1i1[2]     0.25      0.14     0.04     0.55 1.00     6725
## pstthreatw1f_mostfairw1i1[3]     0.27      0.15     0.04     0.61 1.00     5776
## pstthreatw1f_mostfairw1i1[4]     0.25      0.14     0.04     0.58 1.00     7025
## pstharmw1f_mostfairw1i1[1]       0.24      0.14     0.03     0.57 1.00     6856
## pstharmw1f_mostfairw1i1[2]       0.25      0.14     0.05     0.56 1.00     6755
## pstharmw1f_mostfairw1i1[3]       0.28      0.15     0.04     0.62 1.00     6325
## pstharmw1f_mostfairw1i1[4]       0.23      0.13     0.03     0.54 1.00     7288
## pstusedrgw1f_mostfairw1i1[1]     0.23      0.14     0.03     0.54 1.00     7141
## pstusedrgw1f_mostfairw1i1[2]     0.26      0.14     0.04     0.57 1.00     7207
## pstusedrgw1f_mostfairw1i1[3]     0.31      0.16     0.06     0.65 1.00     5474
## pstusedrgw1f_mostfairw1i1[4]     0.20      0.12     0.03     0.50 1.00     6296
## psthackw1f_mostfairw1i1[1]       0.24      0.14     0.03     0.57 1.00     6462
## psthackw1f_mostfairw1i1[2]       0.25      0.15     0.03     0.58 1.00     6839
## psthackw1f_mostfairw1i1[3]       0.27      0.16     0.04     0.63 1.00     6228
## psthackw1f_mostfairw1i1[4]       0.23      0.14     0.03     0.56 1.00     5553
##                              Tail_ESS
## pstthflt5w1f_mostfairw1i1[1]     2304
## pstthflt5w1f_mostfairw1i1[2]     2783
## pstthflt5w1f_mostfairw1i1[3]     2695
## pstthflt5w1f_mostfairw1i1[4]     2987
## pstthfgt5w1f_mostfairw1i1[1]     2534
## pstthfgt5w1f_mostfairw1i1[2]     2927
## pstthfgt5w1f_mostfairw1i1[3]     2419
## pstthfgt5w1f_mostfairw1i1[4]     2026
## pstthreatw1f_mostfairw1i1[1]     2361
## pstthreatw1f_mostfairw1i1[2]     2848
## pstthreatw1f_mostfairw1i1[3]     3032
## pstthreatw1f_mostfairw1i1[4]     2806
## pstharmw1f_mostfairw1i1[1]       2033
## pstharmw1f_mostfairw1i1[2]       2918
## pstharmw1f_mostfairw1i1[3]       3075
## pstharmw1f_mostfairw1i1[4]       2763
## pstusedrgw1f_mostfairw1i1[1]     2968
## pstusedrgw1f_mostfairw1i1[2]     2825
## pstusedrgw1f_mostfairw1i1[3]     2919
## pstusedrgw1f_mostfairw1i1[4]     2843
## psthackw1f_mostfairw1i1[1]       2423
## psthackw1f_mostfairw1i1[2]       2484
## psthackw1f_mostfairw1i1[3]       2957
## psthackw1f_mostfairw1i1[4]       2474
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.2.4.5 Prior summary
out.allpstcrime.stfair.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      psthackw1f              
##        normal(0, 0.25)         b  mostfairw1i         psthackw1f              
##                 (flat)         b                      pstharmw1f              
##        normal(0, 0.25)         b  mostfairw1i         pstharmw1f              
##                 (flat)         b                    pstthfgt5w1f              
##        normal(0, 0.25)         b  mostfairw1i       pstthfgt5w1f              
##                 (flat)         b                    pstthflt5w1f              
##        normal(0, 0.25)         b  mostfairw1i       pstthflt5w1f              
##                 (flat)         b                    pstthreatw1f              
##        normal(0, 0.25)         b  mostfairw1i       pstthreatw1f              
##                 (flat)         b                    pstusedrgw1f              
##        normal(0, 0.25)         b  mostfairw1i       pstusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      psthackw1f              
##           normal(0, 2) Intercept                      pstharmw1f              
##           normal(0, 2) Intercept                    pstthfgt5w1f              
##           normal(0, 2) Intercept                    pstthflt5w1f              
##           normal(0, 2) Intercept                    pstthreatw1f              
##           normal(0, 2) Intercept                    pstusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1         psthackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1         pstharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       pstthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       pstthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       pstthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       pstusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.2.5 Bivariate Corr: T1 stjobw1/past crime

#Bivariate: past crime items ~ mo(stjobw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = pstdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostjobw1i', 
                  resp = pstdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostjobw1i1', 
                  resp = pstdv_names))

allpstcrime.stjob.fit <- brm(
  mvbind(pstthflt5w1f, pstthfgt5w1f, pstthreatw1f, pstharmw1f, pstusedrgw1f, psthackw1f) ~ 1 + mo(stjobw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allpstcrime_stjob_fit",
      file_refit = "on_change"
  )
out.allpstcrime.stjob.fit <- ppchecks(allpstcrime.stjob.fit)
4.3.2.5.1 Coefficient plot (intervals)
out.allpstcrime.stjob.fit[[10]]

4.3.2.5.2 Coefficient plot (distributions)
out.allpstcrime.stjob.fit[[9]]

4.3.2.5.3 PPcheck (density)
p1 <- out.allpstcrime.stjob.fit[[3]] + labs(title = "Past Theft <5BAM (T1)") 
p2 <- out.allpstcrime.stjob.fit[[4]] + labs(title = "Past Theft >5BAM (T1)")
p3 <- out.allpstcrime.stjob.fit[[5]] + labs(title = "Past Threat (T1)")
p4 <- out.allpstcrime.stjob.fit[[6]] + labs(title = "Past Harm (T1)")
p5 <- out.allpstcrime.stjob.fit[[7]] + labs(title = "Past Use Drugs (T1)")
p6 <- out.allpstcrime.stjob.fit[[8]] + labs(title = "Past Hack (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.2.5.4 Fit summary
out.allpstcrime.stjob.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: pstthflt5w1f ~ 1 + mo(stjobw1i) 
##          pstthfgt5w1f ~ 1 + mo(stjobw1i) 
##          pstthreatw1f ~ 1 + mo(stjobw1i) 
##          pstharmw1f ~ 1 + mo(stjobw1i) 
##          pstusedrgw1f ~ 1 + mo(stjobw1i) 
##          psthackw1f ~ 1 + mo(stjobw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_Intercept     -2.24      0.25    -2.77    -1.78 1.00     3805
## pstthfgt5w1f_Intercept     -2.16      0.27    -2.70    -1.67 1.00     3935
## pstthreatw1f_Intercept     -3.71      0.41    -4.53    -2.97 1.00     3965
## pstharmw1f_Intercept       -2.72      0.32    -3.40    -2.13 1.00     3585
## pstusedrgw1f_Intercept     -3.44      0.39    -4.27    -2.72 1.00     3835
## psthackw1f_Intercept       -4.11      0.48    -5.14    -3.24 1.00     3396
## pstthflt5w1f_mostjobw1i     0.17      0.09     0.00     0.34 1.00     4031
## pstthfgt5w1f_mostjobw1i     0.01      0.10    -0.18     0.20 1.00     3682
## pstthreatw1f_mostjobw1i     0.31      0.13     0.07     0.56 1.00     3885
## pstharmw1f_mostjobw1i       0.06      0.11    -0.15     0.29 1.00     3590
## pstusedrgw1f_mostjobw1i     0.31      0.12     0.07     0.56 1.00     3851
## psthackw1f_mostjobw1i       0.34      0.15     0.06     0.64 1.00     3324
##                         Tail_ESS
## pstthflt5w1f_Intercept      3063
## pstthfgt5w1f_Intercept      2828
## pstthreatw1f_Intercept      3144
## pstharmw1f_Intercept        2597
## pstusedrgw1f_Intercept      2989
## psthackw1f_Intercept        3115
## pstthflt5w1f_mostjobw1i     3247
## pstthfgt5w1f_mostjobw1i     3092
## pstthreatw1f_mostjobw1i     3028
## pstharmw1f_mostjobw1i       2880
## pstusedrgw1f_mostjobw1i     2883
## psthackw1f_mostjobw1i       2874
## 
## Monotonic Simplex Parameters:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_mostjobw1i1[1]     0.23      0.13     0.04     0.53 1.00     7169
## pstthflt5w1f_mostjobw1i1[2]     0.21      0.13     0.03     0.50 1.00     6519
## pstthflt5w1f_mostjobw1i1[3]     0.33      0.16     0.05     0.66 1.00     5986
## pstthflt5w1f_mostjobw1i1[4]     0.23      0.13     0.04     0.54 1.00     6576
## pstthfgt5w1f_mostjobw1i1[1]     0.25      0.15     0.04     0.59 1.00     5204
## pstthfgt5w1f_mostjobw1i1[2]     0.25      0.14     0.04     0.56 1.00     6651
## pstthfgt5w1f_mostjobw1i1[3]     0.25      0.15     0.03     0.61 1.00     6335
## pstthfgt5w1f_mostjobw1i1[4]     0.25      0.15     0.03     0.57 1.00     7548
## pstthreatw1f_mostjobw1i1[1]     0.22      0.13     0.03     0.51 1.00     7308
## pstthreatw1f_mostjobw1i1[2]     0.20      0.12     0.03     0.47 1.00     8685
## pstthreatw1f_mostjobw1i1[3]     0.28      0.15     0.05     0.60 1.00     6914
## pstthreatw1f_mostjobw1i1[4]     0.30      0.15     0.05     0.62 1.00     7305
## pstharmw1f_mostjobw1i1[1]       0.27      0.15     0.04     0.60 1.00     6281
## pstharmw1f_mostjobw1i1[2]       0.24      0.14     0.04     0.57 1.00     6940
## pstharmw1f_mostjobw1i1[3]       0.25      0.14     0.03     0.57 1.00     5702
## pstharmw1f_mostjobw1i1[4]       0.24      0.14     0.04     0.56 1.00     5546
## pstusedrgw1f_mostjobw1i1[1]     0.24      0.13     0.03     0.53 1.01     6796
## pstusedrgw1f_mostjobw1i1[2]     0.21      0.13     0.03     0.52 1.00     6596
## pstusedrgw1f_mostjobw1i1[3]     0.32      0.15     0.06     0.64 1.00     5934
## pstusedrgw1f_mostjobw1i1[4]     0.23      0.13     0.04     0.52 1.00     6568
## psthackw1f_mostjobw1i1[1]       0.22      0.13     0.03     0.53 1.00     7646
## psthackw1f_mostjobw1i1[2]       0.21      0.13     0.03     0.50 1.00     6905
## psthackw1f_mostjobw1i1[3]       0.31      0.16     0.05     0.64 1.00     6517
## psthackw1f_mostjobw1i1[4]       0.26      0.15     0.04     0.59 1.00     8080
##                             Tail_ESS
## pstthflt5w1f_mostjobw1i1[1]     2566
## pstthflt5w1f_mostjobw1i1[2]     2741
## pstthflt5w1f_mostjobw1i1[3]     2700
## pstthflt5w1f_mostjobw1i1[4]     2724
## pstthfgt5w1f_mostjobw1i1[1]     2478
## pstthfgt5w1f_mostjobw1i1[2]     2666
## pstthfgt5w1f_mostjobw1i1[3]     2858
## pstthfgt5w1f_mostjobw1i1[4]     2549
## pstthreatw1f_mostjobw1i1[1]     2809
## pstthreatw1f_mostjobw1i1[2]     2515
## pstthreatw1f_mostjobw1i1[3]     2810
## pstthreatw1f_mostjobw1i1[4]     2892
## pstharmw1f_mostjobw1i1[1]       2455
## pstharmw1f_mostjobw1i1[2]       2619
## pstharmw1f_mostjobw1i1[3]       2356
## pstharmw1f_mostjobw1i1[4]       2720
## pstusedrgw1f_mostjobw1i1[1]     2872
## pstusedrgw1f_mostjobw1i1[2]     2689
## pstusedrgw1f_mostjobw1i1[3]     2718
## pstusedrgw1f_mostjobw1i1[4]     3056
## psthackw1f_mostjobw1i1[1]       2654
## psthackw1f_mostjobw1i1[2]       2415
## psthackw1f_mostjobw1i1[3]       2620
## psthackw1f_mostjobw1i1[4]       2523
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.2.5.5 Prior summary
out.allpstcrime.stjob.fit[[2]]
##                  prior     class        coef group         resp dpar nlpar lb
##                 (flat)         b                                             
##                 (flat)         b                     psthackw1f              
##        normal(0, 0.25)         b  mostjobw1i         psthackw1f              
##                 (flat)         b                     pstharmw1f              
##        normal(0, 0.25)         b  mostjobw1i         pstharmw1f              
##                 (flat)         b                   pstthfgt5w1f              
##        normal(0, 0.25)         b  mostjobw1i       pstthfgt5w1f              
##                 (flat)         b                   pstthflt5w1f              
##        normal(0, 0.25)         b  mostjobw1i       pstthflt5w1f              
##                 (flat)         b                   pstthreatw1f              
##        normal(0, 0.25)         b  mostjobw1i       pstthreatw1f              
##                 (flat)         b                   pstusedrgw1f              
##        normal(0, 0.25)         b  mostjobw1i       pstusedrgw1f              
##                 (flat) Intercept                                             
##           normal(0, 2) Intercept                     psthackw1f              
##           normal(0, 2) Intercept                     pstharmw1f              
##           normal(0, 2) Intercept                   pstthfgt5w1f              
##           normal(0, 2) Intercept                   pstthflt5w1f              
##           normal(0, 2) Intercept                   pstthreatw1f              
##           normal(0, 2) Intercept                   pstusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1         psthackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1         pstharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       pstthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       pstthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       pstthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       pstusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.2.6 Bivariate Corr: T1 stthftw1/past crime

#Bivariate: past crime items ~ mo(stthftw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = pstdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostthftw1i', 
                  resp = pstdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostthftw1i1', 
                  resp = pstdv_names))

allpstcrime.stthft.fit <- brm(
  mvbind(pstthflt5w1f, pstthfgt5w1f, pstthreatw1f, pstharmw1f, pstusedrgw1f, psthackw1f) ~ 1 + mo(stthftw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allpstcrime_stthft_fit",
      file_refit = "on_change"
  )
out.allpstcrime.stthft.fit <- ppchecks(allpstcrime.stthft.fit)
4.3.2.6.1 Coefficient plot (intervals)
out.allpstcrime.stthft.fit[[10]]

4.3.2.6.2 Coefficient plot (distributions)
out.allpstcrime.stthft.fit[[9]]

4.3.2.6.3 PPcheck (density)
p1 <- out.allpstcrime.stthft.fit[[3]] + labs(title = "Past Theft <5BAM (T1)") 
p2 <- out.allpstcrime.stthft.fit[[4]] + labs(title = "Past Theft >5BAM (T1)")
p3 <- out.allpstcrime.stthft.fit[[5]] + labs(title = "Past Threat (T1)")
p4 <- out.allpstcrime.stthft.fit[[6]] + labs(title = "Past Harm (T1)")
p5 <- out.allpstcrime.stthft.fit[[7]] + labs(title = "Past Use Drugs (T1)")
p6 <- out.allpstcrime.stthft.fit[[8]] + labs(title = "Past Hack (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.2.6.4 Fit summary
out.allpstcrime.stthft.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: pstthflt5w1f ~ 1 + mo(stthftw1i) 
##          pstthfgt5w1f ~ 1 + mo(stthftw1i) 
##          pstthreatw1f ~ 1 + mo(stthftw1i) 
##          pstharmw1f ~ 1 + mo(stthftw1i) 
##          pstusedrgw1f ~ 1 + mo(stthftw1i) 
##          psthackw1f ~ 1 + mo(stthftw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_Intercept      -1.93      0.18    -2.30    -1.59 1.00     5467
## pstthfgt5w1f_Intercept      -2.27      0.20    -2.67    -1.87 1.00     5448
## pstthreatw1f_Intercept      -3.17      0.30    -3.81    -2.62 1.00     5005
## pstharmw1f_Intercept        -2.77      0.26    -3.30    -2.30 1.00     5631
## pstusedrgw1f_Intercept      -2.87      0.25    -3.38    -2.40 1.00     4720
## psthackw1f_Intercept        -3.22      0.30    -3.83    -2.63 1.00     5285
## pstthflt5w1f_mostthftw1i     0.07      0.10    -0.13     0.26 1.00     5146
## pstthfgt5w1f_mostthftw1i     0.11      0.11    -0.11     0.32 1.00     4889
## pstthreatw1f_mostthftw1i     0.15      0.14    -0.14     0.42 1.00     5367
## pstharmw1f_mostthftw1i       0.15      0.12    -0.08     0.39 1.00     5446
## pstusedrgw1f_mostthftw1i     0.16      0.13    -0.09     0.40 1.00     4864
## psthackw1f_mostthftw1i      -0.04      0.16    -0.37     0.27 1.00     5444
##                          Tail_ESS
## pstthflt5w1f_Intercept       2711
## pstthfgt5w1f_Intercept       3345
## pstthreatw1f_Intercept       2959
## pstharmw1f_Intercept         3005
## pstusedrgw1f_Intercept       2939
## psthackw1f_Intercept         2830
## pstthflt5w1f_mostthftw1i     2632
## pstthfgt5w1f_mostthftw1i     3194
## pstthreatw1f_mostthftw1i     3307
## pstharmw1f_mostthftw1i       3184
## pstusedrgw1f_mostthftw1i     3080
## psthackw1f_mostthftw1i       2805
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_mostthftw1i1[1]     0.23      0.14     0.03     0.55 1.00     7468
## pstthflt5w1f_mostthftw1i1[2]     0.25      0.14     0.04     0.56 1.00     6172
## pstthflt5w1f_mostthftw1i1[3]     0.27      0.15     0.04     0.59 1.00     7078
## pstthflt5w1f_mostthftw1i1[4]     0.26      0.15     0.03     0.58 1.00     5868
## pstthfgt5w1f_mostthftw1i1[1]     0.24      0.14     0.03     0.56 1.00     6130
## pstthfgt5w1f_mostthftw1i1[2]     0.26      0.15     0.04     0.58 1.00     6539
## pstthfgt5w1f_mostthftw1i1[3]     0.24      0.14     0.04     0.57 1.00     6425
## pstthfgt5w1f_mostthftw1i1[4]     0.26      0.15     0.04     0.59 1.00     6116
## pstthreatw1f_mostthftw1i1[1]     0.27      0.15     0.04     0.60 1.00     5510
## pstthreatw1f_mostthftw1i1[2]     0.25      0.14     0.04     0.57 1.00     6393
## pstthreatw1f_mostthftw1i1[3]     0.24      0.14     0.03     0.56 1.00     6292
## pstthreatw1f_mostthftw1i1[4]     0.24      0.14     0.03     0.57 1.00     5649
## pstharmw1f_mostthftw1i1[1]       0.25      0.14     0.04     0.57 1.00     6319
## pstharmw1f_mostthftw1i1[2]       0.27      0.15     0.04     0.60 1.00     6740
## pstharmw1f_mostthftw1i1[3]       0.23      0.14     0.03     0.55 1.00     5451
## pstharmw1f_mostthftw1i1[4]       0.24      0.14     0.03     0.57 1.00     5830
## pstusedrgw1f_mostthftw1i1[1]     0.24      0.14     0.03     0.55 1.00     5262
## pstusedrgw1f_mostthftw1i1[2]     0.24      0.14     0.03     0.56 1.00     5280
## pstusedrgw1f_mostthftw1i1[3]     0.27      0.15     0.04     0.61 1.00     6071
## pstusedrgw1f_mostthftw1i1[4]     0.24      0.14     0.04     0.56 1.00     6727
## psthackw1f_mostthftw1i1[1]       0.25      0.14     0.03     0.58 1.00     6062
## psthackw1f_mostthftw1i1[2]       0.24      0.14     0.03     0.56 1.00     6783
## psthackw1f_mostthftw1i1[3]       0.25      0.14     0.04     0.59 1.00     7526
## psthackw1f_mostthftw1i1[4]       0.26      0.15     0.04     0.61 1.00     6533
##                              Tail_ESS
## pstthflt5w1f_mostthftw1i1[1]     2527
## pstthflt5w1f_mostthftw1i1[2]     2890
## pstthflt5w1f_mostthftw1i1[3]     2744
## pstthflt5w1f_mostthftw1i1[4]     2557
## pstthfgt5w1f_mostthftw1i1[1]     2442
## pstthfgt5w1f_mostthftw1i1[2]     2704
## pstthfgt5w1f_mostthftw1i1[3]     3231
## pstthfgt5w1f_mostthftw1i1[4]     2979
## pstthreatw1f_mostthftw1i1[1]     2477
## pstthreatw1f_mostthftw1i1[2]     2419
## pstthreatw1f_mostthftw1i1[3]     2494
## pstthreatw1f_mostthftw1i1[4]     2869
## pstharmw1f_mostthftw1i1[1]       2706
## pstharmw1f_mostthftw1i1[2]       3082
## pstharmw1f_mostthftw1i1[3]       2651
## pstharmw1f_mostthftw1i1[4]       2720
## pstusedrgw1f_mostthftw1i1[1]     2892
## pstusedrgw1f_mostthftw1i1[2]     2267
## pstusedrgw1f_mostthftw1i1[3]     2451
## pstusedrgw1f_mostthftw1i1[4]     2767
## psthackw1f_mostthftw1i1[1]       3020
## psthackw1f_mostthftw1i1[2]       2802
## psthackw1f_mostthftw1i1[3]       2742
## psthackw1f_mostthftw1i1[4]       3062
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.2.6.5 Prior summary
out.allpstcrime.stthft.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      psthackw1f              
##        normal(0, 0.25)         b  mostthftw1i         psthackw1f              
##                 (flat)         b                      pstharmw1f              
##        normal(0, 0.25)         b  mostthftw1i         pstharmw1f              
##                 (flat)         b                    pstthfgt5w1f              
##        normal(0, 0.25)         b  mostthftw1i       pstthfgt5w1f              
##                 (flat)         b                    pstthflt5w1f              
##        normal(0, 0.25)         b  mostthftw1i       pstthflt5w1f              
##                 (flat)         b                    pstthreatw1f              
##        normal(0, 0.25)         b  mostthftw1i       pstthreatw1f              
##                 (flat)         b                    pstusedrgw1f              
##        normal(0, 0.25)         b  mostthftw1i       pstusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      psthackw1f              
##           normal(0, 2) Intercept                      pstharmw1f              
##           normal(0, 2) Intercept                    pstthfgt5w1f              
##           normal(0, 2) Intercept                    pstthflt5w1f              
##           normal(0, 2) Intercept                    pstthreatw1f              
##           normal(0, 2) Intercept                    pstusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1         psthackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1         pstharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       pstthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       pstthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       pstthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       pstusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.2.7 Bivariate Corr: T1 stmugw1/past crime

#Bivariate: past crime items ~ mo(stmugw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = pstdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmugw1i', 
                  resp = pstdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmugw1i1', 
                  resp = pstdv_names))

allpstcrime.stmug.fit <- brm(
  mvbind(pstthflt5w1f, pstthfgt5w1f, pstthreatw1f, pstharmw1f, pstusedrgw1f, psthackw1f) ~ 1 + mo(stmugw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allpstcrime_stmug_fit",
      file_refit = "on_change"
  )
out.allpstcrime.stmug.fit <- ppchecks(allpstcrime.stmug.fit)
4.3.2.7.1 Coefficient plot (intervals)
out.allpstcrime.stmug.fit[[10]]

4.3.2.7.2 Coefficient plot (distributions)
out.allpstcrime.stmug.fit[[9]]

4.3.2.7.3 PPcheck (density)
p1 <- out.allpstcrime.stmug.fit[[3]] + labs(title = "Past Theft <5BAM (T1)") 
p2 <- out.allpstcrime.stmug.fit[[4]] + labs(title = "Past Theft >5BAM (T1)")
p3 <- out.allpstcrime.stmug.fit[[5]] + labs(title = "Past Threat (T1)")
p4 <- out.allpstcrime.stmug.fit[[6]] + labs(title = "Past Harm (T1)")
p5 <- out.allpstcrime.stmug.fit[[7]] + labs(title = "Past Use Drugs (T1)")
p6 <- out.allpstcrime.stmug.fit[[8]] + labs(title = "Past Hack (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.2.7.4 Fit summary
out.allpstcrime.stmug.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: pstthflt5w1f ~ 1 + mo(stmugw1i) 
##          pstthfgt5w1f ~ 1 + mo(stmugw1i) 
##          pstthreatw1f ~ 1 + mo(stmugw1i) 
##          pstharmw1f ~ 1 + mo(stmugw1i) 
##          pstusedrgw1f ~ 1 + mo(stmugw1i) 
##          psthackw1f ~ 1 + mo(stmugw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_Intercept     -1.93      0.18    -2.31    -1.60 1.00     4997
## pstthfgt5w1f_Intercept     -2.32      0.21    -2.79    -1.93 1.00     4241
## pstthreatw1f_Intercept     -3.11      0.29    -3.73    -2.60 1.00     3986
## pstharmw1f_Intercept       -2.77      0.23    -3.26    -2.33 1.00     4833
## pstusedrgw1f_Intercept     -2.84      0.26    -3.37    -2.37 1.00     5146
## psthackw1f_Intercept       -3.40      0.31    -4.04    -2.85 1.00     4878
## pstthflt5w1f_mostmugw1i     0.08      0.11    -0.15     0.31 1.00     4860
## pstthfgt5w1f_mostmugw1i     0.16      0.12    -0.07     0.40 1.00     3981
## pstthreatw1f_mostmugw1i     0.12      0.16    -0.21     0.44 1.00     3791
## pstharmw1f_mostmugw1i       0.20      0.13    -0.06     0.46 1.00     5063
## pstusedrgw1f_mostmugw1i     0.18      0.15    -0.11     0.49 1.00     4672
## psthackw1f_mostmugw1i       0.15      0.17    -0.19     0.48 1.00     4309
##                         Tail_ESS
## pstthflt5w1f_Intercept      3185
## pstthfgt5w1f_Intercept      2789
## pstthreatw1f_Intercept      2692
## pstharmw1f_Intercept        3171
## pstusedrgw1f_Intercept      2830
## psthackw1f_Intercept        3292
## pstthflt5w1f_mostmugw1i     3184
## pstthfgt5w1f_mostmugw1i     3567
## pstthreatw1f_mostmugw1i     2766
## pstharmw1f_mostmugw1i       3064
## pstusedrgw1f_mostmugw1i     3008
## psthackw1f_mostmugw1i       3050
## 
## Monotonic Simplex Parameters:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## pstthflt5w1f_mostmugw1i1[1]     0.26      0.15     0.04     0.61 1.00     5458
## pstthflt5w1f_mostmugw1i1[2]     0.24      0.14     0.04     0.55 1.00     6252
## pstthflt5w1f_mostmugw1i1[3]     0.23      0.14     0.03     0.57 1.00     5679
## pstthflt5w1f_mostmugw1i1[4]     0.27      0.15     0.04     0.61 1.00     5843
## pstthfgt5w1f_mostmugw1i1[1]     0.31      0.16     0.05     0.63 1.00     5395
## pstthfgt5w1f_mostmugw1i1[2]     0.22      0.13     0.03     0.54 1.00     7049
## pstthfgt5w1f_mostmugw1i1[3]     0.21      0.13     0.03     0.52 1.00     5788
## pstthfgt5w1f_mostmugw1i1[4]     0.26      0.15     0.04     0.59 1.00     5418
## pstthreatw1f_mostmugw1i1[1]     0.30      0.16     0.05     0.63 1.00     4738
## pstthreatw1f_mostmugw1i1[2]     0.22      0.14     0.03     0.55 1.00     5399
## pstthreatw1f_mostmugw1i1[3]     0.23      0.14     0.03     0.55 1.00     5928
## pstthreatw1f_mostmugw1i1[4]     0.25      0.14     0.04     0.56 1.00     6365
## pstharmw1f_mostmugw1i1[1]       0.25      0.14     0.04     0.56 1.00     5731
## pstharmw1f_mostmugw1i1[2]       0.24      0.14     0.03     0.57 1.00     5368
## pstharmw1f_mostmugw1i1[3]       0.25      0.14     0.04     0.56 1.00     6598
## pstharmw1f_mostmugw1i1[4]       0.26      0.14     0.04     0.58 1.00     6466
## pstusedrgw1f_mostmugw1i1[1]     0.27      0.15     0.04     0.59 1.00     5819
## pstusedrgw1f_mostmugw1i1[2]     0.21      0.13     0.03     0.52 1.00     5816
## pstusedrgw1f_mostmugw1i1[3]     0.23      0.14     0.03     0.55 1.00     5943
## pstusedrgw1f_mostmugw1i1[4]     0.29      0.16     0.05     0.64 1.00     5484
## psthackw1f_mostmugw1i1[1]       0.27      0.15     0.04     0.60 1.00     5823
## psthackw1f_mostmugw1i1[2]       0.21      0.14     0.03     0.55 1.00     5672
## psthackw1f_mostmugw1i1[3]       0.24      0.14     0.04     0.58 1.00     5816
## psthackw1f_mostmugw1i1[4]       0.27      0.15     0.04     0.61 1.00     5853
##                             Tail_ESS
## pstthflt5w1f_mostmugw1i1[1]     2488
## pstthflt5w1f_mostmugw1i1[2]     2433
## pstthflt5w1f_mostmugw1i1[3]     2892
## pstthflt5w1f_mostmugw1i1[4]     2941
## pstthfgt5w1f_mostmugw1i1[1]     3269
## pstthfgt5w1f_mostmugw1i1[2]     3096
## pstthfgt5w1f_mostmugw1i1[3]     2566
## pstthfgt5w1f_mostmugw1i1[4]     2615
## pstthreatw1f_mostmugw1i1[1]     2939
## pstthreatw1f_mostmugw1i1[2]     2787
## pstthreatw1f_mostmugw1i1[3]     2746
## pstthreatw1f_mostmugw1i1[4]     3049
## pstharmw1f_mostmugw1i1[1]       2638
## pstharmw1f_mostmugw1i1[2]       2465
## pstharmw1f_mostmugw1i1[3]       2555
## pstharmw1f_mostmugw1i1[4]       2898
## pstusedrgw1f_mostmugw1i1[1]     3269
## pstusedrgw1f_mostmugw1i1[2]     3133
## pstusedrgw1f_mostmugw1i1[3]     2868
## pstusedrgw1f_mostmugw1i1[4]     3211
## psthackw1f_mostmugw1i1[1]       3000
## psthackw1f_mostmugw1i1[2]       2921
## psthackw1f_mostmugw1i1[3]       2781
## psthackw1f_mostmugw1i1[4]       2963
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.2.7.5 Prior summary
out.allpstcrime.stmug.fit[[2]]
##                  prior     class        coef group         resp dpar nlpar lb
##                 (flat)         b                                             
##                 (flat)         b                     psthackw1f              
##        normal(0, 0.25)         b  mostmugw1i         psthackw1f              
##                 (flat)         b                     pstharmw1f              
##        normal(0, 0.25)         b  mostmugw1i         pstharmw1f              
##                 (flat)         b                   pstthfgt5w1f              
##        normal(0, 0.25)         b  mostmugw1i       pstthfgt5w1f              
##                 (flat)         b                   pstthflt5w1f              
##        normal(0, 0.25)         b  mostmugw1i       pstthflt5w1f              
##                 (flat)         b                   pstthreatw1f              
##        normal(0, 0.25)         b  mostmugw1i       pstthreatw1f              
##                 (flat)         b                   pstusedrgw1f              
##        normal(0, 0.25)         b  mostmugw1i       pstusedrgw1f              
##                 (flat) Intercept                                             
##           normal(0, 2) Intercept                     psthackw1f              
##           normal(0, 2) Intercept                     pstharmw1f              
##           normal(0, 2) Intercept                   pstthfgt5w1f              
##           normal(0, 2) Intercept                   pstthflt5w1f              
##           normal(0, 2) Intercept                   pstthreatw1f              
##           normal(0, 2) Intercept                   pstusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1         psthackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1         pstharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       pstthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       pstthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       pstthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       pstusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.3 Criminal intent items: Bivariate models

Now let’s repeat the process of building simple bivariate models for criminal intent by regressing each intent item on each stress indicator. As with past crime, we will specify a Bernoulli distribution with a logit link.

4.3.3.1 Bivariate Corr: T1 stmonyw1/crim intent

#Bivariate: criminal intent items ~ mo(stmonyw1i)
 
# prior1 <- c(prior(normal(0, 2), class = Intercept, resp = prjthflt5w1f),
#             prior(normal(0, 2), class = Intercept, resp = prjthfgt5w1f),
#             prior(normal(0, 2), class = Intercept, resp = prjthreatw1f),
#             prior(normal(0, 2), class = Intercept, resp = prjharmw1f),
#             prior(normal(0, 2), class = Intercept, resp = prjusedrgw1f),
#             prior(normal(0, 2), class = Intercept, resp = prjhackw1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = prjthflt5w1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = prjthfgt5w1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = prjthreatw1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = prjharmw1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = prjusedrgw1f),
#             prior(normal(0, 0.25), class = b, coef = mostmonyw1i, resp = prjhackw1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = prjthflt5w1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = prjthfgt5w1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = prjthreatw1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = prjharmw1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = prjusedrgw1f),
#             prior(dirichlet(2, 2, 2, 2), class = simo, coef = mostmonyw1i1, resp = prjhackw1f)
# )

#Vectorize priors:

#list of colnames for projected crime DVs  
prjdv_names <- noquote(c("prjthflt5w1f", "prjthfgt5w1f", "prjthreatw1f", "prjharmw1f", 
                         "prjusedrgw1f", "prjhackw1f"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmonyw1i', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmonyw1i1', 
                  resp = prjdv_names))

allprjcrime.stmony.fit <- brm(
  mvbind(prjthflt5w1f, prjthfgt5w1f, prjthreatw1f, prjharmw1f, prjusedrgw1f, prjhackw1f) ~ 1 + mo(stmonyw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allprjcrime_stmony_fit",
      file_refit = "on_change"
  )

#Update function to call all ppchecks for bivar projected crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="prjthflt5w1f")
  ppcheckdv2 <-pp_check(modelfit, resp="prjthfgt5w1f")
  ppcheckdv3 <-pp_check(modelfit, resp="prjthreatw1f")
  ppcheckdv4 <-pp_check(modelfit, resp="prjharmw1f")
  ppcheckdv5 <-pp_check(modelfit, resp="prjusedrgw1f")
  ppcheckdv6 <-pp_check(modelfit, resp="prjhackw1f")
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95) +
    labs(title = "Coefficient plot",
         subtitle = "Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80%, and 95% intervals")

  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, 
                    ppcheckdv3, ppcheckdv4, ppcheckdv5, ppcheckdv6, 
                    plotcoefs, plotcoefs2)
  return(allchecks)
}

out.allprjcrime.stmony.fit <- ppchecks(allprjcrime.stmony.fit)
4.3.3.1.1 Coefficient plot (intervals)
out.allprjcrime.stmony.fit[[10]]

4.3.3.1.2 Coefficient plot (distributions)
out.allprjcrime.stmony.fit[[9]]

4.3.3.1.3 PPcheck (density)
p1 <- out.allprjcrime.stmony.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.allprjcrime.stmony.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.allprjcrime.stmony.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.allprjcrime.stmony.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.allprjcrime.stmony.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.allprjcrime.stmony.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.3.1.4 Fit summary
out.allprjcrime.stmony.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5w1f ~ 1 + mo(stmonyw1i) 
##          prjthfgt5w1f ~ 1 + mo(stmonyw1i) 
##          prjthreatw1f ~ 1 + mo(stmonyw1i) 
##          prjharmw1f ~ 1 + mo(stmonyw1i) 
##          prjusedrgw1f ~ 1 + mo(stmonyw1i) 
##          prjhackw1f ~ 1 + mo(stmonyw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_Intercept      -2.15      0.30    -2.77    -1.59 1.00     3484
## prjthfgt5w1f_Intercept      -2.37      0.31    -3.02    -1.79 1.00     2871
## prjthreatw1f_Intercept      -2.53      0.35    -3.24    -1.85 1.00     3507
## prjharmw1f_Intercept        -2.66      0.36    -3.38    -1.96 1.00     4205
## prjusedrgw1f_Intercept      -2.85      0.40    -3.67    -2.07 1.00     3512
## prjhackw1f_Intercept        -3.22      0.46    -4.12    -2.34 1.00     3721
## prjthflt5w1f_mostmonyw1i     0.01      0.12    -0.21     0.25 1.00     3333
## prjthfgt5w1f_mostmonyw1i     0.04      0.13    -0.19     0.29 1.00     3195
## prjthreatw1f_mostmonyw1i    -0.13      0.14    -0.40     0.16 1.00     3336
## prjharmw1f_mostmonyw1i      -0.20      0.15    -0.49     0.10 1.00     4322
## prjusedrgw1f_mostmonyw1i    -0.17      0.16    -0.47     0.17 1.00     3506
## prjhackw1f_mostmonyw1i      -0.10      0.18    -0.44     0.24 1.00     3616
##                          Tail_ESS
## prjthflt5w1f_Intercept       2690
## prjthfgt5w1f_Intercept       1986
## prjthreatw1f_Intercept       2651
## prjharmw1f_Intercept         3193
## prjusedrgw1f_Intercept       2641
## prjhackw1f_Intercept         2774
## prjthflt5w1f_mostmonyw1i     3036
## prjthfgt5w1f_mostmonyw1i     2871
## prjthreatw1f_mostmonyw1i     2796
## prjharmw1f_mostmonyw1i       3302
## prjusedrgw1f_mostmonyw1i     2598
## prjhackw1f_mostmonyw1i       2848
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_mostmonyw1i1[1]     0.26      0.15     0.03     0.60 1.00     6571
## prjthflt5w1f_mostmonyw1i1[2]     0.24      0.14     0.03     0.57 1.00     7815
## prjthflt5w1f_mostmonyw1i1[3]     0.24      0.14     0.03     0.56 1.00     7475
## prjthflt5w1f_mostmonyw1i1[4]     0.26      0.15     0.04     0.58 1.00     7101
## prjthfgt5w1f_mostmonyw1i1[1]     0.26      0.15     0.04     0.60 1.00     6105
## prjthfgt5w1f_mostmonyw1i1[2]     0.24      0.14     0.03     0.57 1.00     5347
## prjthfgt5w1f_mostmonyw1i1[3]     0.24      0.14     0.03     0.58 1.00     6666
## prjthfgt5w1f_mostmonyw1i1[4]     0.26      0.15     0.04     0.60 1.00     7077
## prjthreatw1f_mostmonyw1i1[1]     0.23      0.14     0.03     0.57 1.00     7117
## prjthreatw1f_mostmonyw1i1[2]     0.28      0.15     0.04     0.61 1.00     5452
## prjthreatw1f_mostmonyw1i1[3]     0.26      0.14     0.04     0.58 1.00     6609
## prjthreatw1f_mostmonyw1i1[4]     0.23      0.14     0.03     0.55 1.00     6066
## prjharmw1f_mostmonyw1i1[1]       0.23      0.14     0.04     0.55 1.00     7712
## prjharmw1f_mostmonyw1i1[2]       0.25      0.14     0.04     0.57 1.00     7507
## prjharmw1f_mostmonyw1i1[3]       0.30      0.16     0.05     0.63 1.00     5734
## prjharmw1f_mostmonyw1i1[4]       0.22      0.13     0.03     0.53 1.00     6381
## prjusedrgw1f_mostmonyw1i1[1]     0.23      0.13     0.03     0.53 1.00     7331
## prjusedrgw1f_mostmonyw1i1[2]     0.31      0.16     0.06     0.65 1.00     6542
## prjusedrgw1f_mostmonyw1i1[3]     0.25      0.14     0.04     0.57 1.00     6327
## prjusedrgw1f_mostmonyw1i1[4]     0.21      0.14     0.03     0.53 1.00     6066
## prjhackw1f_mostmonyw1i1[1]       0.26      0.15     0.04     0.59 1.00     5218
## prjhackw1f_mostmonyw1i1[2]       0.27      0.15     0.04     0.61 1.00     6124
## prjhackw1f_mostmonyw1i1[3]       0.23      0.14     0.03     0.54 1.00     6149
## prjhackw1f_mostmonyw1i1[4]       0.24      0.14     0.04     0.57 1.00     6132
##                              Tail_ESS
## prjthflt5w1f_mostmonyw1i1[1]     2362
## prjthflt5w1f_mostmonyw1i1[2]     2524
## prjthflt5w1f_mostmonyw1i1[3]     2627
## prjthflt5w1f_mostmonyw1i1[4]     2534
## prjthfgt5w1f_mostmonyw1i1[1]     2677
## prjthfgt5w1f_mostmonyw1i1[2]     1992
## prjthfgt5w1f_mostmonyw1i1[3]     2648
## prjthfgt5w1f_mostmonyw1i1[4]     2986
## prjthreatw1f_mostmonyw1i1[1]     2691
## prjthreatw1f_mostmonyw1i1[2]     2559
## prjthreatw1f_mostmonyw1i1[3]     2796
## prjthreatw1f_mostmonyw1i1[4]     2955
## prjharmw1f_mostmonyw1i1[1]       1940
## prjharmw1f_mostmonyw1i1[2]       2595
## prjharmw1f_mostmonyw1i1[3]       3122
## prjharmw1f_mostmonyw1i1[4]       3233
## prjusedrgw1f_mostmonyw1i1[1]     2637
## prjusedrgw1f_mostmonyw1i1[2]     3006
## prjusedrgw1f_mostmonyw1i1[3]     2785
## prjusedrgw1f_mostmonyw1i1[4]     2678
## prjhackw1f_mostmonyw1i1[1]       2900
## prjhackw1f_mostmonyw1i1[2]       3053
## prjhackw1f_mostmonyw1i1[3]       2900
## prjhackw1f_mostmonyw1i1[4]       2890
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.3.1.5 Prior summary
out.allprjcrime.stmony.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      prjhackw1f              
##        normal(0, 0.25)         b  mostmonyw1i         prjhackw1f              
##                 (flat)         b                      prjharmw1f              
##        normal(0, 0.25)         b  mostmonyw1i         prjharmw1f              
##                 (flat)         b                    prjthfgt5w1f              
##        normal(0, 0.25)         b  mostmonyw1i       prjthfgt5w1f              
##                 (flat)         b                    prjthflt5w1f              
##        normal(0, 0.25)         b  mostmonyw1i       prjthflt5w1f              
##                 (flat)         b                    prjthreatw1f              
##        normal(0, 0.25)         b  mostmonyw1i       prjthreatw1f              
##                 (flat)         b                    prjusedrgw1f              
##        normal(0, 0.25)         b  mostmonyw1i       prjusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      prjhackw1f              
##           normal(0, 2) Intercept                      prjharmw1f              
##           normal(0, 2) Intercept                    prjthfgt5w1f              
##           normal(0, 2) Intercept                    prjthflt5w1f              
##           normal(0, 2) Intercept                    prjthreatw1f              
##           normal(0, 2) Intercept                    prjusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1         prjhackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1         prjharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       prjthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       prjthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       prjthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       prjusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.3.2 Bivariate Corr: T1 sttranw1/crim intent

#Bivariate: criminal intent items ~ mo(sttranw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mosttranw1i', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mosttranw1i1', 
                  resp = prjdv_names))

allprjcrime.sttran.fit <- brm(
  mvbind(prjthflt5w1f, prjthfgt5w1f, prjthreatw1f, prjharmw1f, prjusedrgw1f, prjhackw1f) ~ 1 + mo(sttranw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allprjcrime_sttran_fit",
      file_refit = "on_change"
  )
out.allprjcrime.sttran.fit <- ppchecks(allprjcrime.sttran.fit)
4.3.3.2.1 Coefficient plot (intervals)
out.allprjcrime.sttran.fit[[10]]

4.3.3.2.2 Coefficient plot (distributions)
out.allprjcrime.sttran.fit[[9]]

4.3.3.2.3 PPcheck (density)
p1 <- out.allprjcrime.sttran.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.allprjcrime.sttran.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.allprjcrime.sttran.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.allprjcrime.sttran.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.allprjcrime.sttran.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.allprjcrime.sttran.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.3.2.4 Fit summary
out.allprjcrime.sttran.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5w1f ~ 1 + mo(sttranw1i) 
##          prjthfgt5w1f ~ 1 + mo(sttranw1i) 
##          prjthreatw1f ~ 1 + mo(sttranw1i) 
##          prjharmw1f ~ 1 + mo(sttranw1i) 
##          prjusedrgw1f ~ 1 + mo(sttranw1i) 
##          prjhackw1f ~ 1 + mo(sttranw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_Intercept      -1.99      0.31    -2.57    -1.36 1.00     3697
## prjthfgt5w1f_Intercept      -2.40      0.32    -3.02    -1.78 1.00     3676
## prjthreatw1f_Intercept      -2.70      0.37    -3.44    -1.96 1.00     3416
## prjharmw1f_Intercept        -2.59      0.40    -3.37    -1.79 1.00     3362
## prjusedrgw1f_Intercept      -3.06      0.41    -3.90    -2.28 1.00     3877
## prjhackw1f_Intercept        -3.33      0.47    -4.27    -2.39 1.00     3120
## prjthflt5w1f_mosttranw1i    -0.06      0.12    -0.30     0.17 1.00     3638
## prjthfgt5w1f_mosttranw1i     0.06      0.13    -0.19     0.30 1.00     3877
## prjthreatw1f_mosttranw1i    -0.04      0.15    -0.34     0.24 1.00     3602
## prjharmw1f_mosttranw1i      -0.22      0.16    -0.52     0.10 1.00     3664
## prjusedrgw1f_mosttranw1i    -0.06      0.16    -0.37     0.26 1.00     3947
## prjhackw1f_mosttranw1i      -0.04      0.18    -0.40     0.32 1.00     3432
##                          Tail_ESS
## prjthflt5w1f_Intercept       2704
## prjthfgt5w1f_Intercept       2889
## prjthreatw1f_Intercept       2657
## prjharmw1f_Intercept         2989
## prjusedrgw1f_Intercept       3130
## prjhackw1f_Intercept         2129
## prjthflt5w1f_mosttranw1i     2999
## prjthfgt5w1f_mosttranw1i     3209
## prjthreatw1f_mosttranw1i     2678
## prjharmw1f_mosttranw1i       3460
## prjusedrgw1f_mosttranw1i     3017
## prjhackw1f_mosttranw1i       3165
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_mosttranw1i1[1]     0.27      0.15     0.03     0.61 1.00     5118
## prjthflt5w1f_mosttranw1i1[2]     0.25      0.14     0.04     0.56 1.00     7251
## prjthflt5w1f_mosttranw1i1[3]     0.24      0.14     0.03     0.56 1.00     7215
## prjthflt5w1f_mosttranw1i1[4]     0.24      0.14     0.03     0.56 1.00     5177
## prjthfgt5w1f_mosttranw1i1[1]     0.25      0.15     0.03     0.59 1.00     5745
## prjthfgt5w1f_mosttranw1i1[2]     0.24      0.14     0.04     0.55 1.00     6604
## prjthfgt5w1f_mosttranw1i1[3]     0.24      0.14     0.04     0.56 1.00     6801
## prjthfgt5w1f_mosttranw1i1[4]     0.28      0.15     0.04     0.61 1.00     4829
## prjthreatw1f_mosttranw1i1[1]     0.26      0.15     0.04     0.59 1.00     6748
## prjthreatw1f_mosttranw1i1[2]     0.24      0.14     0.04     0.56 1.00     6576
## prjthreatw1f_mosttranw1i1[3]     0.25      0.14     0.03     0.56 1.00     6908
## prjthreatw1f_mosttranw1i1[4]     0.25      0.14     0.04     0.57 1.00     6029
## prjharmw1f_mosttranw1i1[1]       0.26      0.14     0.04     0.57 1.00     5831
## prjharmw1f_mosttranw1i1[2]       0.29      0.15     0.05     0.62 1.00     5557
## prjharmw1f_mosttranw1i1[3]       0.24      0.13     0.03     0.55 1.00     6579
## prjharmw1f_mosttranw1i1[4]       0.22      0.13     0.03     0.52 1.00     6348
## prjusedrgw1f_mosttranw1i1[1]     0.25      0.14     0.04     0.58 1.00     7972
## prjusedrgw1f_mosttranw1i1[2]     0.26      0.15     0.04     0.59 1.00     6531
## prjusedrgw1f_mosttranw1i1[3]     0.25      0.14     0.04     0.56 1.00     6098
## prjusedrgw1f_mosttranw1i1[4]     0.24      0.14     0.04     0.57 1.00     6881
## prjhackw1f_mosttranw1i1[1]       0.26      0.15     0.04     0.59 1.00     6531
## prjhackw1f_mosttranw1i1[2]       0.26      0.15     0.04     0.60 1.00     5651
## prjhackw1f_mosttranw1i1[3]       0.24      0.14     0.04     0.54 1.00     6715
## prjhackw1f_mosttranw1i1[4]       0.25      0.14     0.04     0.57 1.00     5016
##                              Tail_ESS
## prjthflt5w1f_mosttranw1i1[1]     2160
## prjthflt5w1f_mosttranw1i1[2]     2685
## prjthflt5w1f_mosttranw1i1[3]     3136
## prjthflt5w1f_mosttranw1i1[4]     3183
## prjthfgt5w1f_mosttranw1i1[1]     2595
## prjthfgt5w1f_mosttranw1i1[2]     2594
## prjthfgt5w1f_mosttranw1i1[3]     2595
## prjthfgt5w1f_mosttranw1i1[4]     2799
## prjthreatw1f_mosttranw1i1[1]     2534
## prjthreatw1f_mosttranw1i1[2]     2283
## prjthreatw1f_mosttranw1i1[3]     2858
## prjthreatw1f_mosttranw1i1[4]     3026
## prjharmw1f_mosttranw1i1[1]       2992
## prjharmw1f_mosttranw1i1[2]       2319
## prjharmw1f_mosttranw1i1[3]       2959
## prjharmw1f_mosttranw1i1[4]       2981
## prjusedrgw1f_mosttranw1i1[1]     3117
## prjusedrgw1f_mosttranw1i1[2]     2777
## prjusedrgw1f_mosttranw1i1[3]     3170
## prjusedrgw1f_mosttranw1i1[4]     2768
## prjhackw1f_mosttranw1i1[1]       2693
## prjhackw1f_mosttranw1i1[2]       2924
## prjhackw1f_mosttranw1i1[3]       3300
## prjhackw1f_mosttranw1i1[4]       2831
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.3.2.5 Prior summary
out.allprjcrime.sttran.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      prjhackw1f              
##        normal(0, 0.25)         b  mosttranw1i         prjhackw1f              
##                 (flat)         b                      prjharmw1f              
##        normal(0, 0.25)         b  mosttranw1i         prjharmw1f              
##                 (flat)         b                    prjthfgt5w1f              
##        normal(0, 0.25)         b  mosttranw1i       prjthfgt5w1f              
##                 (flat)         b                    prjthflt5w1f              
##        normal(0, 0.25)         b  mosttranw1i       prjthflt5w1f              
##                 (flat)         b                    prjthreatw1f              
##        normal(0, 0.25)         b  mosttranw1i       prjthreatw1f              
##                 (flat)         b                    prjusedrgw1f              
##        normal(0, 0.25)         b  mosttranw1i       prjusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      prjhackw1f              
##           normal(0, 2) Intercept                      prjharmw1f              
##           normal(0, 2) Intercept                    prjthfgt5w1f              
##           normal(0, 2) Intercept                    prjthflt5w1f              
##           normal(0, 2) Intercept                    prjthreatw1f              
##           normal(0, 2) Intercept                    prjusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1         prjhackw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1         prjharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       prjthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       prjthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       prjthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       prjusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.3.3 Bivariate Corr: T1 strespw1/crim intent

#Bivariate: criminal intent items ~ mo(strespw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostrespw1i', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostrespw1i1', 
                  resp = prjdv_names))


allprjcrime.stresp.fit <- brm(
  mvbind(prjthflt5w1f, prjthfgt5w1f, prjthreatw1f, prjharmw1f, prjusedrgw1f, prjhackw1f) ~ 1 + mo(strespw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allprjcrime_stresp_fit",
      file_refit = "on_change"
  )
out.allprjcrime.stresp.fit <- ppchecks(allprjcrime.stresp.fit)
4.3.3.3.1 Coefficient plot (intervals)
out.allprjcrime.stresp.fit[[10]]

4.3.3.3.2 Coefficient plot (distributions)
out.allprjcrime.stresp.fit[[9]]

4.3.3.3.3 PPcheck (density)
p1 <- out.allprjcrime.stresp.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.allprjcrime.stresp.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.allprjcrime.stresp.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.allprjcrime.stresp.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.allprjcrime.stresp.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.allprjcrime.stresp.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.3.3.4 Fit summary
out.allprjcrime.stresp.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5w1f ~ 1 + mo(strespw1i) 
##          prjthfgt5w1f ~ 1 + mo(strespw1i) 
##          prjthreatw1f ~ 1 + mo(strespw1i) 
##          prjharmw1f ~ 1 + mo(strespw1i) 
##          prjusedrgw1f ~ 1 + mo(strespw1i) 
##          prjhackw1f ~ 1 + mo(strespw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_Intercept      -2.55      0.30    -3.19    -2.00 1.00     4232
## prjthfgt5w1f_Intercept      -2.57      0.31    -3.19    -2.00 1.00     3996
## prjthreatw1f_Intercept      -3.31      0.39    -4.11    -2.60 1.00     4053
## prjharmw1f_Intercept        -3.24      0.39    -4.05    -2.50 1.00     4704
## prjusedrgw1f_Intercept      -3.56      0.41    -4.40    -2.83 1.00     3937
## prjhackw1f_Intercept        -3.66      0.43    -4.55    -2.88 1.00     3794
## prjthflt5w1f_mostrespw1i     0.17      0.10    -0.02     0.37 1.00     4308
## prjthfgt5w1f_mostrespw1i     0.11      0.10    -0.09     0.31 1.00     4114
## prjthreatw1f_mostrespw1i     0.21      0.12    -0.03     0.45 1.00     3837
## prjharmw1f_mostrespw1i       0.07      0.13    -0.18     0.33 1.00     4699
## prjusedrgw1f_mostrespw1i     0.15      0.13    -0.11     0.42 1.00     4097
## prjhackw1f_mostrespw1i       0.09      0.14    -0.19     0.38 1.00     4080
##                          Tail_ESS
## prjthflt5w1f_Intercept       3142
## prjthfgt5w1f_Intercept       2753
## prjthreatw1f_Intercept       2456
## prjharmw1f_Intercept         3161
## prjusedrgw1f_Intercept       2707
## prjhackw1f_Intercept         2906
## prjthflt5w1f_mostrespw1i     3249
## prjthfgt5w1f_mostrespw1i     2950
## prjthreatw1f_mostrespw1i     2554
## prjharmw1f_mostrespw1i       2859
## prjusedrgw1f_mostrespw1i     2697
## prjhackw1f_mostrespw1i       2844
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_mostrespw1i1[1]     0.26      0.14     0.04     0.59 1.00     7241
## prjthflt5w1f_mostrespw1i1[2]     0.25      0.14     0.04     0.55 1.00     8092
## prjthflt5w1f_mostrespw1i1[3]     0.25      0.14     0.04     0.56 1.00     7926
## prjthflt5w1f_mostrespw1i1[4]     0.24      0.13     0.04     0.54 1.00     6706
## prjthfgt5w1f_mostrespw1i1[1]     0.26      0.15     0.04     0.59 1.00     6544
## prjthfgt5w1f_mostrespw1i1[2]     0.25      0.14     0.04     0.58 1.00     7592
## prjthfgt5w1f_mostrespw1i1[3]     0.24      0.14     0.04     0.55 1.00     6316
## prjthfgt5w1f_mostrespw1i1[4]     0.24      0.13     0.04     0.55 1.00     6785
## prjthreatw1f_mostrespw1i1[1]     0.24      0.14     0.03     0.54 1.00     7615
## prjthreatw1f_mostrespw1i1[2]     0.25      0.14     0.04     0.56 1.00     7579
## prjthreatw1f_mostrespw1i1[3]     0.26      0.14     0.04     0.58 1.00     6500
## prjthreatw1f_mostrespw1i1[4]     0.25      0.14     0.04     0.57 1.00     6677
## prjharmw1f_mostrespw1i1[1]       0.26      0.15     0.04     0.60 1.00     7034
## prjharmw1f_mostrespw1i1[2]       0.25      0.14     0.03     0.58 1.00     6753
## prjharmw1f_mostrespw1i1[3]       0.24      0.14     0.03     0.57 1.00     7317
## prjharmw1f_mostrespw1i1[4]       0.25      0.14     0.04     0.57 1.00     6599
## prjusedrgw1f_mostrespw1i1[1]     0.24      0.14     0.04     0.56 1.00     7771
## prjusedrgw1f_mostrespw1i1[2]     0.24      0.14     0.03     0.57 1.00     7238
## prjusedrgw1f_mostrespw1i1[3]     0.27      0.15     0.04     0.61 1.00     6398
## prjusedrgw1f_mostrespw1i1[4]     0.25      0.15     0.04     0.58 1.00     7796
## prjhackw1f_mostrespw1i1[1]       0.25      0.15     0.04     0.59 1.00     9074
## prjhackw1f_mostrespw1i1[2]       0.25      0.14     0.04     0.56 1.00     7174
## prjhackw1f_mostrespw1i1[3]       0.24      0.14     0.04     0.58 1.00     6448
## prjhackw1f_mostrespw1i1[4]       0.25      0.14     0.04     0.57 1.00     5699
##                              Tail_ESS
## prjthflt5w1f_mostrespw1i1[1]     2869
## prjthflt5w1f_mostrespw1i1[2]     3001
## prjthflt5w1f_mostrespw1i1[3]     3092
## prjthflt5w1f_mostrespw1i1[4]     3003
## prjthfgt5w1f_mostrespw1i1[1]     2252
## prjthfgt5w1f_mostrespw1i1[2]     2396
## prjthfgt5w1f_mostrespw1i1[3]     3410
## prjthfgt5w1f_mostrespw1i1[4]     2626
## prjthreatw1f_mostrespw1i1[1]     2540
## prjthreatw1f_mostrespw1i1[2]     2649
## prjthreatw1f_mostrespw1i1[3]     2849
## prjthreatw1f_mostrespw1i1[4]     2802
## prjharmw1f_mostrespw1i1[1]       2469
## prjharmw1f_mostrespw1i1[2]       2697
## prjharmw1f_mostrespw1i1[3]       2893
## prjharmw1f_mostrespw1i1[4]       2695
## prjusedrgw1f_mostrespw1i1[1]     2544
## prjusedrgw1f_mostrespw1i1[2]     2714
## prjusedrgw1f_mostrespw1i1[3]     2906
## prjusedrgw1f_mostrespw1i1[4]     2924
## prjhackw1f_mostrespw1i1[1]       2769
## prjhackw1f_mostrespw1i1[2]       2877
## prjhackw1f_mostrespw1i1[3]       3024
## prjhackw1f_mostrespw1i1[4]       3104
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.3.3.5 Prior summary
out.allprjcrime.stresp.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      prjhackw1f              
##        normal(0, 0.25)         b  mostrespw1i         prjhackw1f              
##                 (flat)         b                      prjharmw1f              
##        normal(0, 0.25)         b  mostrespw1i         prjharmw1f              
##                 (flat)         b                    prjthfgt5w1f              
##        normal(0, 0.25)         b  mostrespw1i       prjthfgt5w1f              
##                 (flat)         b                    prjthflt5w1f              
##        normal(0, 0.25)         b  mostrespw1i       prjthflt5w1f              
##                 (flat)         b                    prjthreatw1f              
##        normal(0, 0.25)         b  mostrespw1i       prjthreatw1f              
##                 (flat)         b                    prjusedrgw1f              
##        normal(0, 0.25)         b  mostrespw1i       prjusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      prjhackw1f              
##           normal(0, 2) Intercept                      prjharmw1f              
##           normal(0, 2) Intercept                    prjthfgt5w1f              
##           normal(0, 2) Intercept                    prjthflt5w1f              
##           normal(0, 2) Intercept                    prjthreatw1f              
##           normal(0, 2) Intercept                    prjusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1         prjhackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1         prjharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       prjthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       prjthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       prjthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       prjusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.3.4 Bivariate Corr: T1 stfairw1/crim intent

#Bivariate: criminal intent items ~ mo(stfairw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostfairw1i', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostfairw1i1', 
                  resp = prjdv_names))


allprjcrime.stfair.fit <- brm(
  mvbind(prjthflt5w1f, prjthfgt5w1f, prjthreatw1f, prjharmw1f, prjusedrgw1f, prjhackw1f) ~ 1 + mo(stfairw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allprjcrime_stfair_fit",
      file_refit = "on_change"
  )
out.allprjcrime.stfair.fit <- ppchecks(allprjcrime.stfair.fit)
4.3.3.4.1 Coefficient plot (intervals)
out.allprjcrime.stfair.fit[[10]]

4.3.3.4.2 Coefficient plot (distributions)
out.allprjcrime.stfair.fit[[9]]

4.3.3.4.3 PPcheck (density)
p1 <- out.allprjcrime.stfair.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.allprjcrime.stfair.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.allprjcrime.stfair.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.allprjcrime.stfair.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.allprjcrime.stfair.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.allprjcrime.stfair.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.3.4.4 Fit summary
out.allprjcrime.stfair.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5w1f ~ 1 + mo(stfairw1i) 
##          prjthfgt5w1f ~ 1 + mo(stfairw1i) 
##          prjthreatw1f ~ 1 + mo(stfairw1i) 
##          prjharmw1f ~ 1 + mo(stfairw1i) 
##          prjusedrgw1f ~ 1 + mo(stfairw1i) 
##          prjhackw1f ~ 1 + mo(stfairw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_Intercept      -2.75      0.32    -3.42    -2.18 1.00     3991
## prjthfgt5w1f_Intercept      -2.76      0.31    -3.40    -2.17 1.00     4300
## prjthreatw1f_Intercept      -3.53      0.39    -4.35    -2.81 1.00     4444
## prjharmw1f_Intercept        -3.23      0.39    -4.06    -2.51 1.00     4002
## prjusedrgw1f_Intercept      -3.44      0.42    -4.34    -2.66 1.00     3904
## prjhackw1f_Intercept        -3.91      0.48    -4.90    -3.01 1.00     3949
## prjthflt5w1f_mostfairw1i     0.24      0.10     0.06     0.44 1.00     4532
## prjthfgt5w1f_mostfairw1i     0.19      0.10    -0.01     0.39 1.00     4425
## prjthreatw1f_mostfairw1i     0.28      0.12     0.05     0.52 1.00     3741
## prjharmw1f_mostfairw1i       0.07      0.13    -0.17     0.33 1.00     3956
## prjusedrgw1f_mostfairw1i     0.09      0.13    -0.16     0.36 1.00     3857
## prjhackw1f_mostfairw1i       0.19      0.15    -0.10     0.48 1.00     4159
##                          Tail_ESS
## prjthflt5w1f_Intercept       2198
## prjthfgt5w1f_Intercept       2683
## prjthreatw1f_Intercept       3073
## prjharmw1f_Intercept         2851
## prjusedrgw1f_Intercept       2810
## prjhackw1f_Intercept         2795
## prjthflt5w1f_mostfairw1i     2799
## prjthfgt5w1f_mostfairw1i     2899
## prjthreatw1f_mostfairw1i     3306
## prjharmw1f_mostfairw1i       3131
## prjusedrgw1f_mostfairw1i     2980
## prjhackw1f_mostfairw1i       2909
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_mostfairw1i1[1]     0.25      0.14     0.04     0.56 1.00     6001
## prjthflt5w1f_mostfairw1i1[2]     0.22      0.13     0.04     0.51 1.00     8112
## prjthflt5w1f_mostfairw1i1[3]     0.23      0.14     0.04     0.55 1.00     7096
## prjthflt5w1f_mostfairw1i1[4]     0.30      0.15     0.05     0.61 1.00     7778
## prjthfgt5w1f_mostfairw1i1[1]     0.24      0.13     0.04     0.54 1.00     8038
## prjthfgt5w1f_mostfairw1i1[2]     0.24      0.14     0.03     0.56 1.00     7433
## prjthfgt5w1f_mostfairw1i1[3]     0.24      0.14     0.04     0.56 1.00     8091
## prjthfgt5w1f_mostfairw1i1[4]     0.28      0.15     0.05     0.60 1.00     6527
## prjthreatw1f_mostfairw1i1[1]     0.21      0.12     0.03     0.51 1.00     8267
## prjthreatw1f_mostfairw1i1[2]     0.24      0.14     0.04     0.55 1.00     8298
## prjthreatw1f_mostfairw1i1[3]     0.25      0.14     0.04     0.56 1.00     6994
## prjthreatw1f_mostfairw1i1[4]     0.31      0.15     0.06     0.64 1.00     7787
## prjharmw1f_mostfairw1i1[1]       0.25      0.14     0.04     0.58 1.00     8067
## prjharmw1f_mostfairw1i1[2]       0.25      0.14     0.04     0.58 1.00     6918
## prjharmw1f_mostfairw1i1[3]       0.25      0.15     0.04     0.59 1.00     7931
## prjharmw1f_mostfairw1i1[4]       0.24      0.14     0.04     0.55 1.00     6872
## prjusedrgw1f_mostfairw1i1[1]     0.25      0.14     0.04     0.58 1.00     9948
## prjusedrgw1f_mostfairw1i1[2]     0.25      0.15     0.04     0.59 1.00     7962
## prjusedrgw1f_mostfairw1i1[3]     0.26      0.14     0.04     0.58 1.00     7592
## prjusedrgw1f_mostfairw1i1[4]     0.24      0.14     0.03     0.57 1.00     7723
## prjhackw1f_mostfairw1i1[1]       0.22      0.13     0.03     0.53 1.00     6906
## prjhackw1f_mostfairw1i1[2]       0.25      0.14     0.04     0.57 1.00     7537
## prjhackw1f_mostfairw1i1[3]       0.28      0.15     0.04     0.62 1.00     6839
## prjhackw1f_mostfairw1i1[4]       0.25      0.15     0.04     0.58 1.00     7244
##                              Tail_ESS
## prjthflt5w1f_mostfairw1i1[1]     2552
## prjthflt5w1f_mostfairw1i1[2]     2670
## prjthflt5w1f_mostfairw1i1[3]     2726
## prjthflt5w1f_mostfairw1i1[4]     2688
## prjthfgt5w1f_mostfairw1i1[1]     2738
## prjthfgt5w1f_mostfairw1i1[2]     2088
## prjthfgt5w1f_mostfairw1i1[3]     2824
## prjthfgt5w1f_mostfairw1i1[4]     2768
## prjthreatw1f_mostfairw1i1[1]     2814
## prjthreatw1f_mostfairw1i1[2]     2563
## prjthreatw1f_mostfairw1i1[3]     2858
## prjthreatw1f_mostfairw1i1[4]     2763
## prjharmw1f_mostfairw1i1[1]       2909
## prjharmw1f_mostfairw1i1[2]       2444
## prjharmw1f_mostfairw1i1[3]       2565
## prjharmw1f_mostfairw1i1[4]       3221
## prjusedrgw1f_mostfairw1i1[1]     2943
## prjusedrgw1f_mostfairw1i1[2]     2667
## prjusedrgw1f_mostfairw1i1[3]     2978
## prjusedrgw1f_mostfairw1i1[4]     2836
## prjhackw1f_mostfairw1i1[1]       2810
## prjhackw1f_mostfairw1i1[2]       2473
## prjhackw1f_mostfairw1i1[3]       2317
## prjhackw1f_mostfairw1i1[4]       2748
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.3.4.5 Prior summary
out.allprjcrime.stfair.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      prjhackw1f              
##        normal(0, 0.25)         b  mostfairw1i         prjhackw1f              
##                 (flat)         b                      prjharmw1f              
##        normal(0, 0.25)         b  mostfairw1i         prjharmw1f              
##                 (flat)         b                    prjthfgt5w1f              
##        normal(0, 0.25)         b  mostfairw1i       prjthfgt5w1f              
##                 (flat)         b                    prjthflt5w1f              
##        normal(0, 0.25)         b  mostfairw1i       prjthflt5w1f              
##                 (flat)         b                    prjthreatw1f              
##        normal(0, 0.25)         b  mostfairw1i       prjthreatw1f              
##                 (flat)         b                    prjusedrgw1f              
##        normal(0, 0.25)         b  mostfairw1i       prjusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      prjhackw1f              
##           normal(0, 2) Intercept                      prjharmw1f              
##           normal(0, 2) Intercept                    prjthfgt5w1f              
##           normal(0, 2) Intercept                    prjthflt5w1f              
##           normal(0, 2) Intercept                    prjthreatw1f              
##           normal(0, 2) Intercept                    prjusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1         prjhackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1         prjharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       prjthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       prjthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       prjthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       prjusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.3.5 Bivariate Corr: T1 stjobw1/crim intent

#Bivariate: criminal intent items ~ mo(stjobw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostjobw1i', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostjobw1i1', 
                  resp = prjdv_names))

allprjcrime.stjob.fit <- brm(
  mvbind(prjthflt5w1f, prjthfgt5w1f, prjthreatw1f, prjharmw1f, prjusedrgw1f, prjhackw1f) ~ 1 + mo(stjobw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/allprjcrime_stjob_fit",
      file_refit = "on_change"
  )
out.allprjcrime.stjob.fit <- ppchecks(allprjcrime.stjob.fit)
4.3.3.5.1 Coefficient plot (intervals)
out.allprjcrime.stjob.fit[[10]]

4.3.3.5.2 Coefficient plot (distributions)
out.allprjcrime.stjob.fit[[9]]

4.3.3.5.3 PPcheck (density)
p1 <- out.allprjcrime.stjob.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.allprjcrime.stjob.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.allprjcrime.stjob.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.allprjcrime.stjob.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.allprjcrime.stjob.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.allprjcrime.stjob.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.3.5.4 Fit summary
out.allprjcrime.stjob.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5w1f ~ 1 + mo(stjobw1i) 
##          prjthfgt5w1f ~ 1 + mo(stjobw1i) 
##          prjthreatw1f ~ 1 + mo(stjobw1i) 
##          prjharmw1f ~ 1 + mo(stjobw1i) 
##          prjusedrgw1f ~ 1 + mo(stjobw1i) 
##          prjhackw1f ~ 1 + mo(stjobw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_Intercept     -2.87      0.32    -3.54    -2.28 1.00     3587
## prjthfgt5w1f_Intercept     -3.10      0.34    -3.81    -2.49 1.00     3845
## prjthreatw1f_Intercept     -3.71      0.42    -4.59    -2.95 1.00     3699
## prjharmw1f_Intercept       -3.33      0.40    -4.15    -2.60 1.00     3128
## prjusedrgw1f_Intercept     -3.81      0.44    -4.76    -3.00 1.00     3384
## prjhackw1f_Intercept       -4.63      0.52    -5.74    -3.70 1.00     3660
## prjthflt5w1f_mostjobw1i     0.30      0.10     0.11     0.50 1.00     3856
## prjthfgt5w1f_mostjobw1i     0.33      0.10     0.13     0.54 1.00     3961
## prjthreatw1f_mostjobw1i     0.37      0.13     0.12     0.62 1.00     3779
## prjharmw1f_mostjobw1i       0.11      0.13    -0.14     0.37 1.00     3540
## prjusedrgw1f_mostjobw1i     0.24      0.14    -0.03     0.52 1.00     3041
## prjhackw1f_mostjobw1i       0.48      0.16     0.18     0.79 1.00     3555
##                         Tail_ESS
## prjthflt5w1f_Intercept      2729
## prjthfgt5w1f_Intercept      2478
## prjthreatw1f_Intercept      2753
## prjharmw1f_Intercept        2714
## prjusedrgw1f_Intercept      2962
## prjhackw1f_Intercept        2656
## prjthflt5w1f_mostjobw1i     3013
## prjthfgt5w1f_mostjobw1i     2849
## prjthreatw1f_mostjobw1i     2922
## prjharmw1f_mostjobw1i       2821
## prjusedrgw1f_mostjobw1i     3065
## prjhackw1f_mostjobw1i       2775
## 
## Monotonic Simplex Parameters:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_mostjobw1i1[1]     0.18      0.11     0.02     0.45 1.00     4640
## prjthflt5w1f_mostjobw1i1[2]     0.20      0.12     0.03     0.49 1.00     6269
## prjthflt5w1f_mostjobw1i1[3]     0.42      0.16     0.11     0.72 1.00     5628
## prjthflt5w1f_mostjobw1i1[4]     0.19      0.11     0.03     0.47 1.00     6821
## prjthfgt5w1f_mostjobw1i1[1]     0.18      0.11     0.02     0.45 1.00     7121
## prjthfgt5w1f_mostjobw1i1[2]     0.23      0.14     0.03     0.54 1.00     6704
## prjthfgt5w1f_mostjobw1i1[3]     0.35      0.16     0.08     0.68 1.00     5871
## prjthfgt5w1f_mostjobw1i1[4]     0.24      0.13     0.04     0.52 1.00     6596
## prjthreatw1f_mostjobw1i1[1]     0.20      0.12     0.03     0.47 1.00     6312
## prjthreatw1f_mostjobw1i1[2]     0.22      0.13     0.03     0.50 1.00     6621
## prjthreatw1f_mostjobw1i1[3]     0.30      0.15     0.06     0.61 1.00     6942
## prjthreatw1f_mostjobw1i1[4]     0.28      0.14     0.05     0.57 1.00     6596
## prjharmw1f_mostjobw1i1[1]       0.25      0.14     0.04     0.57 1.00     5805
## prjharmw1f_mostjobw1i1[2]       0.25      0.15     0.03     0.60 1.00     6321
## prjharmw1f_mostjobw1i1[3]       0.27      0.15     0.04     0.61 1.00     5408
## prjharmw1f_mostjobw1i1[4]       0.22      0.14     0.03     0.55 1.00     5669
## prjusedrgw1f_mostjobw1i1[1]     0.23      0.14     0.03     0.55 1.00     6843
## prjusedrgw1f_mostjobw1i1[2]     0.25      0.14     0.03     0.58 1.00     6942
## prjusedrgw1f_mostjobw1i1[3]     0.28      0.15     0.05     0.61 1.00     6209
## prjusedrgw1f_mostjobw1i1[4]     0.24      0.14     0.04     0.55 1.00     8515
## prjhackw1f_mostjobw1i1[1]       0.17      0.11     0.02     0.42 1.00     6447
## prjhackw1f_mostjobw1i1[2]       0.20      0.12     0.02     0.49 1.00     7177
## prjhackw1f_mostjobw1i1[3]       0.28      0.15     0.05     0.60 1.00     6916
## prjhackw1f_mostjobw1i1[4]       0.35      0.15     0.08     0.67 1.00     6385
##                             Tail_ESS
## prjthflt5w1f_mostjobw1i1[1]     2148
## prjthflt5w1f_mostjobw1i1[2]     2505
## prjthflt5w1f_mostjobw1i1[3]     3243
## prjthflt5w1f_mostjobw1i1[4]     2868
## prjthfgt5w1f_mostjobw1i1[1]     2441
## prjthfgt5w1f_mostjobw1i1[2]     2619
## prjthfgt5w1f_mostjobw1i1[3]     2605
## prjthfgt5w1f_mostjobw1i1[4]     2633
## prjthreatw1f_mostjobw1i1[1]     2639
## prjthreatw1f_mostjobw1i1[2]     2599
## prjthreatw1f_mostjobw1i1[3]     2950
## prjthreatw1f_mostjobw1i1[4]     2344
## prjharmw1f_mostjobw1i1[1]       2848
## prjharmw1f_mostjobw1i1[2]       2503
## prjharmw1f_mostjobw1i1[3]       2762
## prjharmw1f_mostjobw1i1[4]       2648
## prjusedrgw1f_mostjobw1i1[1]     2655
## prjusedrgw1f_mostjobw1i1[2]     2473
## prjusedrgw1f_mostjobw1i1[3]     2880
## prjusedrgw1f_mostjobw1i1[4]     2879
## prjhackw1f_mostjobw1i1[1]       2267
## prjhackw1f_mostjobw1i1[2]       2406
## prjhackw1f_mostjobw1i1[3]       3096
## prjhackw1f_mostjobw1i1[4]       2609
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.3.5.5 Prior summary
out.allprjcrime.stjob.fit[[2]]
##                  prior     class        coef group         resp dpar nlpar lb
##                 (flat)         b                                             
##                 (flat)         b                     prjhackw1f              
##        normal(0, 0.25)         b  mostjobw1i         prjhackw1f              
##                 (flat)         b                     prjharmw1f              
##        normal(0, 0.25)         b  mostjobw1i         prjharmw1f              
##                 (flat)         b                   prjthfgt5w1f              
##        normal(0, 0.25)         b  mostjobw1i       prjthfgt5w1f              
##                 (flat)         b                   prjthflt5w1f              
##        normal(0, 0.25)         b  mostjobw1i       prjthflt5w1f              
##                 (flat)         b                   prjthreatw1f              
##        normal(0, 0.25)         b  mostjobw1i       prjthreatw1f              
##                 (flat)         b                   prjusedrgw1f              
##        normal(0, 0.25)         b  mostjobw1i       prjusedrgw1f              
##                 (flat) Intercept                                             
##           normal(0, 2) Intercept                     prjhackw1f              
##           normal(0, 2) Intercept                     prjharmw1f              
##           normal(0, 2) Intercept                   prjthfgt5w1f              
##           normal(0, 2) Intercept                   prjthflt5w1f              
##           normal(0, 2) Intercept                   prjthreatw1f              
##           normal(0, 2) Intercept                   prjusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1         prjhackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1         prjharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       prjthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       prjthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       prjthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       prjusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.3.6 Bivariate Corr: T1 stthftw1/crim intent

#Bivariate: criminal intent items ~ mo(stthftw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostthftw1i', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostthftw1i1', 
                  resp = prjdv_names))

allprjcrime.stthft.fit <- brm(
  mvbind(prjthflt5w1f, prjthfgt5w1f, prjthreatw1f, prjharmw1f, prjusedrgw1f, prjhackw1f) ~ 1 + mo(stthftw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allprjcrime_stthft_fit",
      file_refit = "on_change"
  )
out.allprjcrime.stthft.fit <- ppchecks(allprjcrime.stthft.fit)
4.3.3.6.1 Coefficient plot (intervals)
out.allprjcrime.stthft.fit[[10]]

4.3.3.6.2 Coefficient plot (distributions)
out.allprjcrime.stthft.fit[[9]]

4.3.3.6.3 PPcheck (density)
p1 <- out.allprjcrime.stthft.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.allprjcrime.stthft.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.allprjcrime.stthft.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.allprjcrime.stthft.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.allprjcrime.stthft.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.allprjcrime.stthft.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.3.6.4 Fit summary
out.allprjcrime.stthft.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5w1f ~ 1 + mo(stthftw1i) 
##          prjthfgt5w1f ~ 1 + mo(stthftw1i) 
##          prjthreatw1f ~ 1 + mo(stthftw1i) 
##          prjharmw1f ~ 1 + mo(stthftw1i) 
##          prjusedrgw1f ~ 1 + mo(stthftw1i) 
##          prjhackw1f ~ 1 + mo(stthftw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_Intercept      -2.37      0.22    -2.83    -1.98 1.00     5040
## prjthfgt5w1f_Intercept      -2.63      0.24    -3.11    -2.19 1.00     5098
## prjthreatw1f_Intercept      -3.01      0.28    -3.57    -2.50 1.00     4906
## prjharmw1f_Intercept        -3.14      0.29    -3.74    -2.59 1.00     4003
## prjusedrgw1f_Intercept      -3.19      0.30    -3.83    -2.63 1.00     4766
## prjhackw1f_Intercept        -3.42      0.32    -4.07    -2.81 1.00     3739
## prjthflt5w1f_mostthftw1i     0.18      0.11    -0.04     0.39 1.00     4622
## prjthfgt5w1f_mostthftw1i     0.26      0.11     0.05     0.48 1.00     4735
## prjthreatw1f_mostthftw1i     0.16      0.13    -0.12     0.42 1.00     5003
## prjharmw1f_mostthftw1i       0.06      0.15    -0.24     0.35 1.00     4719
## prjusedrgw1f_mostthftw1i    -0.02      0.16    -0.33     0.28 1.00     4737
## prjhackw1f_mostthftw1i      -0.02      0.17    -0.35     0.30 1.00     4376
##                          Tail_ESS
## prjthflt5w1f_Intercept       2708
## prjthfgt5w1f_Intercept       2994
## prjthreatw1f_Intercept       2903
## prjharmw1f_Intercept         2896
## prjusedrgw1f_Intercept       2127
## prjhackw1f_Intercept         3110
## prjthflt5w1f_mostthftw1i     3231
## prjthfgt5w1f_mostthftw1i     2725
## prjthreatw1f_mostthftw1i     3428
## prjharmw1f_mostthftw1i       2943
## prjusedrgw1f_mostthftw1i     2306
## prjhackw1f_mostthftw1i       3243
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_mostthftw1i1[1]     0.25      0.14     0.04     0.55 1.00     5444
## prjthflt5w1f_mostthftw1i1[2]     0.23      0.13     0.04     0.53 1.00     5700
## prjthflt5w1f_mostthftw1i1[3]     0.29      0.15     0.05     0.61 1.00     6085
## prjthflt5w1f_mostthftw1i1[4]     0.23      0.13     0.03     0.53 1.00     6068
## prjthfgt5w1f_mostthftw1i1[1]     0.19      0.11     0.03     0.46 1.00     5641
## prjthfgt5w1f_mostthftw1i1[2]     0.28      0.15     0.04     0.60 1.00     5654
## prjthfgt5w1f_mostthftw1i1[3]     0.32      0.16     0.06     0.66 1.00     5617
## prjthfgt5w1f_mostthftw1i1[4]     0.21      0.12     0.03     0.50 1.00     5416
## prjthreatw1f_mostthftw1i1[1]     0.26      0.14     0.04     0.58 1.00     5747
## prjthreatw1f_mostthftw1i1[2]     0.23      0.13     0.03     0.54 1.00     5726
## prjthreatw1f_mostthftw1i1[3]     0.27      0.15     0.04     0.59 1.00     5361
## prjthreatw1f_mostthftw1i1[4]     0.24      0.14     0.04     0.56 1.00     6179
## prjharmw1f_mostthftw1i1[1]       0.25      0.14     0.04     0.57 1.00     4711
## prjharmw1f_mostthftw1i1[2]       0.24      0.14     0.04     0.56 1.00     6023
## prjharmw1f_mostthftw1i1[3]       0.25      0.14     0.04     0.59 1.00     5748
## prjharmw1f_mostthftw1i1[4]       0.26      0.15     0.04     0.58 1.00     5191
## prjusedrgw1f_mostthftw1i1[1]     0.24      0.14     0.04     0.55 1.00     5326
## prjusedrgw1f_mostthftw1i1[2]     0.24      0.14     0.03     0.57 1.00     5958
## prjusedrgw1f_mostthftw1i1[3]     0.25      0.14     0.04     0.58 1.00     5673
## prjusedrgw1f_mostthftw1i1[4]     0.27      0.15     0.04     0.61 1.00     5697
## prjhackw1f_mostthftw1i1[1]       0.25      0.15     0.03     0.59 1.00     5608
## prjhackw1f_mostthftw1i1[2]       0.24      0.14     0.04     0.56 1.00     5641
## prjhackw1f_mostthftw1i1[3]       0.25      0.14     0.04     0.57 1.00     5859
## prjhackw1f_mostthftw1i1[4]       0.26      0.14     0.04     0.57 1.00     5510
##                              Tail_ESS
## prjthflt5w1f_mostthftw1i1[1]     2291
## prjthflt5w1f_mostthftw1i1[2]     2814
## prjthflt5w1f_mostthftw1i1[3]     2682
## prjthflt5w1f_mostthftw1i1[4]     3024
## prjthfgt5w1f_mostthftw1i1[1]     2341
## prjthfgt5w1f_mostthftw1i1[2]     2224
## prjthfgt5w1f_mostthftw1i1[3]     3005
## prjthfgt5w1f_mostthftw1i1[4]     2878
## prjthreatw1f_mostthftw1i1[1]     2947
## prjthreatw1f_mostthftw1i1[2]     2630
## prjthreatw1f_mostthftw1i1[3]     3175
## prjthreatw1f_mostthftw1i1[4]     2883
## prjharmw1f_mostthftw1i1[1]       1957
## prjharmw1f_mostthftw1i1[2]       2268
## prjharmw1f_mostthftw1i1[3]       2913
## prjharmw1f_mostthftw1i1[4]       3059
## prjusedrgw1f_mostthftw1i1[1]     2565
## prjusedrgw1f_mostthftw1i1[2]     2878
## prjusedrgw1f_mostthftw1i1[3]     3021
## prjusedrgw1f_mostthftw1i1[4]     2989
## prjhackw1f_mostthftw1i1[1]       2609
## prjhackw1f_mostthftw1i1[2]       2512
## prjhackw1f_mostthftw1i1[3]       3138
## prjhackw1f_mostthftw1i1[4]       3278
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.3.6.5 Prior summary
out.allprjcrime.stthft.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                      prjhackw1f              
##        normal(0, 0.25)         b  mostthftw1i         prjhackw1f              
##                 (flat)         b                      prjharmw1f              
##        normal(0, 0.25)         b  mostthftw1i         prjharmw1f              
##                 (flat)         b                    prjthfgt5w1f              
##        normal(0, 0.25)         b  mostthftw1i       prjthfgt5w1f              
##                 (flat)         b                    prjthflt5w1f              
##        normal(0, 0.25)         b  mostthftw1i       prjthflt5w1f              
##                 (flat)         b                    prjthreatw1f              
##        normal(0, 0.25)         b  mostthftw1i       prjthreatw1f              
##                 (flat)         b                    prjusedrgw1f              
##        normal(0, 0.25)         b  mostthftw1i       prjusedrgw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                      prjhackw1f              
##           normal(0, 2) Intercept                      prjharmw1f              
##           normal(0, 2) Intercept                    prjthfgt5w1f              
##           normal(0, 2) Intercept                    prjthflt5w1f              
##           normal(0, 2) Intercept                    prjthreatw1f              
##           normal(0, 2) Intercept                    prjusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1         prjhackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1         prjharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       prjthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       prjthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       prjthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       prjusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.3.7 Bivariate Corr: T1 stmugw1/crim intent

#Bivariate: criminal items ~ mo(stmugw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmugw1i', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmugw1i1', 
                  resp = prjdv_names))

allprjcrime.stmug.fit <- brm(
  mvbind(prjthflt5w1f, prjthfgt5w1f, prjthreatw1f, prjharmw1f, prjusedrgw1f, prjhackw1f) ~ 1 + mo(stmugw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/allprjcrime_stmug_fit",
      file_refit = "on_change"
  )
out.allprjcrime.stmug.fit <- ppchecks(allprjcrime.stmug.fit)
4.3.3.7.1 Coefficient plot (intervals)
out.allprjcrime.stmug.fit[[10]]

4.3.3.7.2 Coefficient plot (distributions)
out.allprjcrime.stmug.fit[[9]]

4.3.3.7.3 PPcheck (density)
p1 <- out.allprjcrime.stmug.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.allprjcrime.stmug.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.allprjcrime.stmug.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.allprjcrime.stmug.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.allprjcrime.stmug.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.allprjcrime.stmug.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

4.3.3.7.4 Fit summary
out.allprjcrime.stmug.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5w1f ~ 1 + mo(stmugw1i) 
##          prjthfgt5w1f ~ 1 + mo(stmugw1i) 
##          prjthreatw1f ~ 1 + mo(stmugw1i) 
##          prjharmw1f ~ 1 + mo(stmugw1i) 
##          prjusedrgw1f ~ 1 + mo(stmugw1i) 
##          prjhackw1f ~ 1 + mo(stmugw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_Intercept     -2.18      0.20    -2.60    -1.83 1.00     4278
## prjthfgt5w1f_Intercept     -2.40      0.22    -2.85    -1.99 1.00     4421
## prjthreatw1f_Intercept     -2.85      0.24    -3.36    -2.41 1.00     4807
## prjharmw1f_Intercept       -3.05      0.27    -3.59    -2.55 1.00     4211
## prjusedrgw1f_Intercept     -3.36      0.29    -3.95    -2.82 1.00     4246
## prjhackw1f_Intercept       -3.46      0.31    -4.09    -2.87 1.00     4358
## prjthflt5w1f_mostmugw1i     0.03      0.13    -0.25     0.28 1.00     3797
## prjthfgt5w1f_mostmugw1i     0.09      0.13    -0.18     0.35 1.00     4262
## prjthreatw1f_mostmugw1i     0.05      0.15    -0.25     0.34 1.00     4473
## prjharmw1f_mostmugw1i      -0.01      0.17    -0.35     0.30 1.00     4426
## prjusedrgw1f_mostmugw1i     0.15      0.16    -0.16     0.46 1.00     4302
## prjhackw1f_mostmugw1i       0.02      0.17    -0.33     0.37 1.00     4564
##                         Tail_ESS
## prjthflt5w1f_Intercept      3283
## prjthfgt5w1f_Intercept      2927
## prjthreatw1f_Intercept      3014
## prjharmw1f_Intercept        2498
## prjusedrgw1f_Intercept      2687
## prjhackw1f_Intercept        3083
## prjthflt5w1f_mostmugw1i     2968
## prjthfgt5w1f_mostmugw1i     2968
## prjthreatw1f_mostmugw1i     3120
## prjharmw1f_mostmugw1i       3238
## prjusedrgw1f_mostmugw1i     2835
## prjhackw1f_mostmugw1i       3035
## 
## Monotonic Simplex Parameters:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5w1f_mostmugw1i1[1]     0.26      0.15     0.03     0.60 1.00     4525
## prjthflt5w1f_mostmugw1i1[2]     0.24      0.14     0.03     0.56 1.00     5148
## prjthflt5w1f_mostmugw1i1[3]     0.24      0.14     0.04     0.57 1.00     5248
## prjthflt5w1f_mostmugw1i1[4]     0.26      0.15     0.04     0.60 1.00     4676
## prjthfgt5w1f_mostmugw1i1[1]     0.27      0.15     0.05     0.60 1.00     4248
## prjthfgt5w1f_mostmugw1i1[2]     0.24      0.14     0.04     0.54 1.00     5361
## prjthfgt5w1f_mostmugw1i1[3]     0.23      0.14     0.04     0.55 1.00     5031
## prjthfgt5w1f_mostmugw1i1[4]     0.26      0.14     0.04     0.57 1.00     5331
## prjthreatw1f_mostmugw1i1[1]     0.25      0.15     0.04     0.57 1.00     5447
## prjthreatw1f_mostmugw1i1[2]     0.24      0.14     0.04     0.55 1.00     5705
## prjthreatw1f_mostmugw1i1[3]     0.25      0.14     0.04     0.57 1.00     5838
## prjthreatw1f_mostmugw1i1[4]     0.26      0.15     0.04     0.59 1.00     4895
## prjharmw1f_mostmugw1i1[1]       0.24      0.14     0.03     0.57 1.00     4802
## prjharmw1f_mostmugw1i1[2]       0.24      0.14     0.03     0.56 1.00     5548
## prjharmw1f_mostmugw1i1[3]       0.25      0.14     0.04     0.58 1.00     5357
## prjharmw1f_mostmugw1i1[4]       0.26      0.15     0.04     0.61 1.00     5081
## prjusedrgw1f_mostmugw1i1[1]     0.26      0.15     0.04     0.60 1.00     4708
## prjusedrgw1f_mostmugw1i1[2]     0.24      0.14     0.03     0.56 1.00     6133
## prjusedrgw1f_mostmugw1i1[3]     0.23      0.14     0.03     0.55 1.00     4968
## prjusedrgw1f_mostmugw1i1[4]     0.28      0.15     0.04     0.62 1.00     5544
## prjhackw1f_mostmugw1i1[1]       0.24      0.14     0.04     0.57 1.00     4814
## prjhackw1f_mostmugw1i1[2]       0.24      0.15     0.03     0.58 1.00     4907
## prjhackw1f_mostmugw1i1[3]       0.25      0.15     0.04     0.58 1.00     4976
## prjhackw1f_mostmugw1i1[4]       0.26      0.15     0.04     0.59 1.00     5089
##                             Tail_ESS
## prjthflt5w1f_mostmugw1i1[1]     2790
## prjthflt5w1f_mostmugw1i1[2]     2357
## prjthflt5w1f_mostmugw1i1[3]     3349
## prjthflt5w1f_mostmugw1i1[4]     3201
## prjthfgt5w1f_mostmugw1i1[1]     2655
## prjthfgt5w1f_mostmugw1i1[2]     2685
## prjthfgt5w1f_mostmugw1i1[3]     3287
## prjthfgt5w1f_mostmugw1i1[4]     3000
## prjthreatw1f_mostmugw1i1[1]     3073
## prjthreatw1f_mostmugw1i1[2]     2779
## prjthreatw1f_mostmugw1i1[3]     2916
## prjthreatw1f_mostmugw1i1[4]     2657
## prjharmw1f_mostmugw1i1[1]       2545
## prjharmw1f_mostmugw1i1[2]       2750
## prjharmw1f_mostmugw1i1[3]       2788
## prjharmw1f_mostmugw1i1[4]       3077
## prjusedrgw1f_mostmugw1i1[1]     2300
## prjusedrgw1f_mostmugw1i1[2]     2806
## prjusedrgw1f_mostmugw1i1[3]     2930
## prjusedrgw1f_mostmugw1i1[4]     2785
## prjhackw1f_mostmugw1i1[1]       2840
## prjhackw1f_mostmugw1i1[2]       2567
## prjhackw1f_mostmugw1i1[3]       2920
## prjhackw1f_mostmugw1i1[4]       3135
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.3.7.5 Prior summary
out.allprjcrime.stmug.fit[[2]]
##                  prior     class        coef group         resp dpar nlpar lb
##                 (flat)         b                                             
##                 (flat)         b                     prjhackw1f              
##        normal(0, 0.25)         b  mostmugw1i         prjhackw1f              
##                 (flat)         b                     prjharmw1f              
##        normal(0, 0.25)         b  mostmugw1i         prjharmw1f              
##                 (flat)         b                   prjthfgt5w1f              
##        normal(0, 0.25)         b  mostmugw1i       prjthfgt5w1f              
##                 (flat)         b                   prjthflt5w1f              
##        normal(0, 0.25)         b  mostmugw1i       prjthflt5w1f              
##                 (flat)         b                   prjthreatw1f              
##        normal(0, 0.25)         b  mostmugw1i       prjthreatw1f              
##                 (flat)         b                   prjusedrgw1f              
##        normal(0, 0.25)         b  mostmugw1i       prjusedrgw1f              
##                 (flat) Intercept                                             
##           normal(0, 2) Intercept                     prjhackw1f              
##           normal(0, 2) Intercept                     prjharmw1f              
##           normal(0, 2) Intercept                   prjthfgt5w1f              
##           normal(0, 2) Intercept                   prjthflt5w1f              
##           normal(0, 2) Intercept                   prjthreatw1f              
##           normal(0, 2) Intercept                   prjusedrgw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1         prjhackw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1         prjharmw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       prjthfgt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       prjthflt5w1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       prjthreatw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       prjusedrgw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.4 “Any” Crime items: Bivariate models

Now we will repeat the above process for “any” past and projected crime indicators. We did not want to include these items in the multivariate mvbind() models above for simultaneous modeling as the items are structurally correlated with the other outcome variables - i.e., they are composites and hence mathematical functions of the other binary items. Later, we will need to merge estimates from the “any” criminal intent models with those from the multivariate criminal intent item models to display them in Figure 3.

4.3.4.1 Bivariate Corr: T1 ANY past crime/all stress

#Bivariate: past crime items ~ mo(stressvars)

#Create function for repetitive prior settings
setmyprior <- function(mocoefname, simocoefname) {
  myprior <- c(
  set_prior('normal(0, 2)', class = 'Intercept'),
  set_prior('normal(0, 0.25)', class = 'b', coef = mocoefname),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = simocoefname))
  }

#Update function to call all ppchecks for bivar any crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit)
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95) + 
    coord_cartesian(xlim = c(-0.5, 0.5)) + vline_at(0, linetype = 3)
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95) + 
    coord_cartesian(xlim = c(-0.5, 0.5)) + vline_at(0, linetype = 3)

  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, 
                    plotcoefs, plotcoefs2)
  return(allchecks)
}

myprior <- setmyprior('mostmonyw1i', 'mostmonyw1i1')
anypstcrime.stmony.fit <- brm(pstanyw1f ~ 1 + mo(stmonyw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309, 
      file = "Models/anypstcrime_stmony_fit", file_refit = "on_change"
      )
out.anypstcrime.stmony.fit <- ppchecks(anypstcrime.stmony.fit)

myprior <- setmyprior('mosttranw1i', 'mosttranw1i1')
anypstcrime.sttran.fit <- brm(pstanyw1f ~ 1 + mo(sttranw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anypstcrime_sttran_fit", file_refit = "on_change"
      )
out.anypstcrime.sttran.fit <- ppchecks(anypstcrime.sttran.fit)

myprior <- setmyprior('mostrespw1i', 'mostrespw1i1')
anypstcrime.stresp.fit <- brm(pstanyw1f ~ 1 + mo(strespw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anypstcrime_stresp_fit", file_refit = "on_change"
      )
out.anypstcrime.stresp.fit <- ppchecks(anypstcrime.stresp.fit)

myprior <- setmyprior('mostfairw1i', 'mostfairw1i1')
anypstcrime.stfair.fit <- brm(pstanyw1f ~ 1 + mo(stfairw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anypstcrime_stfair_fit", file_refit = "on_change"
      )
out.anypstcrime.stfair.fit <- ppchecks(anypstcrime.stfair.fit)

myprior <- setmyprior('mostjobw1i', 'mostjobw1i1')
anypstcrime.stjob.fit <- brm(pstanyw1f ~ 1 + mo(stjobw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anypstcrime_stjob_fit", file_refit = "on_change"
      )
out.anypstcrime.stjob.fit <- ppchecks(anypstcrime.stjob.fit)

myprior <- setmyprior('mostthftw1i', 'mostthftw1i1')
anypstcrime.stthft.fit <- brm(pstanyw1f ~ 1 + mo(stthftw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anypstcrime_stthft_fit", file_refit = "on_change"
      )
out.anypstcrime.stthft.fit <- ppchecks(anypstcrime.stthft.fit)

myprior <- setmyprior('mostmugw1i', 'mostmugw1i1')
anypstcrime.stmug.fit <- brm(pstanyw1f ~ 1 + mo(stmugw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anypstcrime_stmug_fit", file_refit = "on_change"
      )
out.anypstcrime.stmug.fit <- ppchecks(anypstcrime.stmug.fit)
4.3.4.1.1 Coefficient plot (intervals)
p1 <- out.anypstcrime.stmony.fit[[5]]
p2 <- out.anypstcrime.sttran.fit[[5]]
p3 <- out.anypstcrime.stresp.fit[[5]]
p4 <- out.anypstcrime.stfair.fit[[5]]
p5 <- out.anypstcrime.stjob.fit[[5]]
p6 <- out.anypstcrime.stthft.fit[[5]]
p7 <- out.anypstcrime.stmug.fit[[5]]

playout <- '
AB
CD
E#
FG
'
p1 + p2 + p3 + p4 + p5 + p6 + p7 +
  plot_layout(design = playout) +
  plot_annotation(
  title = 'Coefficient plot',
  subtitle = 'Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80% (thick line), and 95% (thin line) intervals')

4.3.4.1.2 Coefficient plot (distributions)
p1 <- out.anypstcrime.stmony.fit[[4]]
p2 <- out.anypstcrime.sttran.fit[[4]]
p3 <- out.anypstcrime.stresp.fit[[4]]
p4 <- out.anypstcrime.stfair.fit[[4]]
p5 <- out.anypstcrime.stjob.fit[[4]]
p6 <- out.anypstcrime.stthft.fit[[4]]
p7 <- out.anypstcrime.stmug.fit[[4]]

playout <- '
AB
CD
E#
FG
'
p1 + p2 + p3 + p4 + p5 + p6 + p7 +
  plot_layout(design = playout) +
  plot_annotation(
  title = 'Coefficient plot',
  subtitle = 'Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% shaded intervals')

4.3.4.1.3 PPcheck (density)
p1 <- out.anypstcrime.stmony.fit[[3]] + labs(title = "Any past crime/stmony (T1)") 
p2 <- out.anypstcrime.sttran.fit[[3]] + labs(title = "Any pastcrime/sttran (T1)")
p3 <- out.anypstcrime.stresp.fit[[3]] + labs(title = "Any pastcrime/stresp (T1)")
p4 <- out.anypstcrime.stfair.fit[[3]] + labs(title = "Any pastcrime/stfair (T1)")
p5 <- out.anypstcrime.stjob.fit[[3]] + labs(title = "Any pastcrime/stjob (T1)")
p6 <- out.anypstcrime.stthft.fit[[3]] + labs(title = "Any pastcrime/stthft (T1)")
p7 <- out.anypstcrime.stmug.fit[[3]] + labs(title = "Any pastcrime/stmug (T1)")

(p1 + p2) / (p3 + p4) / (p5 + plot_spacer()) / (p6 + p7)

4.3.4.2 Fit + prior summaries (T1 Any past crime/all stress)

4.3.4.2.1 stmony
out.anypstcrime.stmony.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: pstanyw1f ~ 1 + mo(stmonyw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -1.34      0.27    -1.85    -0.78 1.00     1991     2113
## mostmonyw1i     0.02      0.11    -0.20     0.24 1.00     1959     2171
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostmonyw1i1[1]     0.25      0.14     0.04     0.58 1.00     3185     2212
## mostmonyw1i1[2]     0.25      0.17     0.03     0.64 1.00     2302     2532
## mostmonyw1i1[3]     0.23      0.14     0.03     0.56 1.00     3225     2870
## mostmonyw1i1[4]     0.27      0.16     0.03     0.62 1.00     2660     2407
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anypstcrime.stmony.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mostmonyw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.2.2 sttran
out.anypstcrime.sttran.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: pstanyw1f ~ 1 + mo(sttranw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -1.37      0.27    -1.87    -0.82 1.00     1623     1975
## mosttranw1i     0.04      0.12    -0.19     0.27 1.00     1606     2168
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mosttranw1i1[1]     0.25      0.14     0.04     0.56 1.00     2905     2170
## mosttranw1i1[2]     0.22      0.15     0.03     0.57 1.00     2130     2380
## mosttranw1i1[3]     0.22      0.13     0.03     0.54 1.00     3029     2045
## mosttranw1i1[4]     0.31      0.18     0.04     0.69 1.00     1874     2235
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anypstcrime.sttran.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mosttranw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.2.3 stresp
out.anypstcrime.stresp.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: pstanyw1f ~ 1 + mo(strespw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -1.73      0.24    -2.24    -1.29 1.00     2140     1915
## mostrespw1i     0.17      0.08     0.02     0.33 1.00     2289     1979
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostrespw1i1[1]     0.27      0.14     0.04     0.58 1.00     3046     1975
## mostrespw1i1[2]     0.25      0.14     0.04     0.56 1.00     3244     2452
## mostrespw1i1[3]     0.23      0.14     0.03     0.55 1.00     3610     2721
## mostrespw1i1[4]     0.26      0.14     0.04     0.56 1.00     3189     2247
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anypstcrime.stresp.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mostrespw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.2.4 stfair
out.anypstcrime.stfair.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: pstanyw1f ~ 1 + mo(stfairw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -1.71      0.22    -2.18    -1.29 1.00     2079     1762
## mostfairw1i     0.16      0.07     0.02     0.31 1.00     2128     1941
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostfairw1i1[1]     0.22      0.13     0.03     0.53 1.00     3546     2015
## mostfairw1i1[2]     0.25      0.14     0.04     0.57 1.00     3239     2018
## mostfairw1i1[3]     0.28      0.15     0.04     0.61 1.00     3576     2464
## mostfairw1i1[4]     0.25      0.14     0.04     0.57 1.00     3663     2540
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anypstcrime.stfair.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mostfairw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.2.5 stjob
out.anypstcrime.stjob.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: pstanyw1f ~ 1 + mo(stjobw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##            Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept     -1.69      0.21    -2.14    -1.29 1.00     2281     1968
## mostjobw1i     0.17      0.08     0.01     0.32 1.00     2437     2416
## 
## Monotonic Simplex Parameters:
##                Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostjobw1i1[1]     0.20      0.12     0.03     0.49 1.00     3213     2298
## mostjobw1i1[2]     0.19      0.12     0.03     0.47 1.00     2710     1834
## mostjobw1i1[3]     0.32      0.16     0.06     0.65 1.00     3395     2757
## mostjobw1i1[4]     0.29      0.15     0.05     0.61 1.00     3074     2702
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anypstcrime.stjob.fit[[2]]
##                  prior     class        coef group resp dpar nlpar lb ub
##                 (flat)         b                                        
##        normal(0, 0.25)         b  mostjobw1i                            
##           normal(0, 2) Intercept                                        
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.2.6 stthft
out.anypstcrime.stthft.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: pstanyw1f ~ 1 + mo(stthftw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -1.41      0.15    -1.72    -1.11 1.00     2815     2469
## mostthftw1i     0.07      0.09    -0.10     0.24 1.00     2884     2591
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostthftw1i1[1]     0.24      0.14     0.04     0.56 1.00     4045     2294
## mostthftw1i1[2]     0.24      0.14     0.04     0.55 1.00     4621     2665
## mostthftw1i1[3]     0.26      0.15     0.04     0.60 1.00     4534     2246
## mostthftw1i1[4]     0.26      0.15     0.03     0.59 1.00     4529     2908
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anypstcrime.stthft.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mostthftw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.2.7 stmug
out.anypstcrime.stmug.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: pstanyw1f ~ 1 + mo(stmugw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##            Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept     -1.42      0.15    -1.72    -1.14 1.00     2307     2594
## mostmugw1i     0.10      0.10    -0.10     0.30 1.00     2389     2734
## 
## Monotonic Simplex Parameters:
##                Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostmugw1i1[1]     0.26      0.14     0.04     0.57 1.00     3753     2317
## mostmugw1i1[2]     0.22      0.13     0.03     0.53 1.00     3892     2926
## mostmugw1i1[3]     0.24      0.14     0.04     0.56 1.00     4524     2855
## mostmugw1i1[4]     0.29      0.16     0.05     0.63 1.00     3842     2992
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anypstcrime.stmug.fit[[2]]
##                  prior     class        coef group resp dpar nlpar lb ub
##                 (flat)         b                                        
##        normal(0, 0.25)         b  mostmugw1i                            
##           normal(0, 2) Intercept                                        
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1                            
##   source
##  default
##     user
##     user
##     user

4.3.4.3 Bivariate Corr: T1 ANY crim intent/all stress

#Bivariate: past crime items ~ mo(stressvars)

myprior <- setmyprior('mostmonyw1i', 'mostmonyw1i1')
anyprjcrime.stmony.fit <- brm(prjanyw1f ~ 1 + mo(stmonyw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys,
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anyprjcrime_stmony_fit", file_refit = "on_change"
      )
out.anyprjcrime.stmony.fit <- ppchecks(anyprjcrime.stmony.fit)

myprior <- setmyprior('mosttranw1i', 'mosttranw1i1')
anyprjcrime.sttran.fit <- brm(prjanyw1f ~ 1 + mo(sttranw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anyprjcrime_sttran_fit", file_refit = "on_change"
      )
out.anyprjcrime.sttran.fit <- ppchecks(anyprjcrime.sttran.fit)

myprior <- setmyprior('mostrespw1i', 'mostrespw1i1')
anyprjcrime.stresp.fit <- brm(prjanyw1f ~ 1 + mo(strespw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anyprjcrime_stresp_fit", file_refit = "on_change"
      )
out.anyprjcrime.stresp.fit <- ppchecks(anyprjcrime.stresp.fit)

myprior <- setmyprior('mostfairw1i', 'mostfairw1i1')
anyprjcrime.stfair.fit <- brm(prjanyw1f ~ 1 + mo(stfairw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anyprjcrime_stfair_fit", file_refit = "on_change"
      )
out.anyprjcrime.stfair.fit <- ppchecks(anyprjcrime.stfair.fit)

myprior <- setmyprior('mostjobw1i', 'mostjobw1i1')
anyprjcrime.stjob.fit <- brm(prjanyw1f ~ 1 + mo(stjobw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anyprjcrime_stjob_fit", file_refit = "on_change"
      )
out.anyprjcrime.stjob.fit <- ppchecks(anyprjcrime.stjob.fit)

myprior <- setmyprior('mostthftw1i', 'mostthftw1i1')
anyprjcrime.stthft.fit <- brm(prjanyw1f ~ 1 + mo(stthftw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anyprjcrime_stthft_fit", file_refit = "on_change"
      )
out.anyprjcrime.stthft.fit <- ppchecks(anyprjcrime.stthft.fit)

myprior <- setmyprior('mostmugw1i', 'mostmugw1i1')
anyprjcrime.stmug.fit <- brm(prjanyw1f ~ 1 + mo(stmugw1i),  
      data = stress.wide3, family = "bernoulli", prior = myprior, 
      cores = nCoresphys, 
      chains = 4, backend = "cmdstanr", seed = 8675309,
      file = "Models/anyprjcrime_stmug_fit", file_refit = "on_change"
      )
out.anyprjcrime.stmug.fit <- ppchecks(anyprjcrime.stmug.fit)
4.3.4.3.1 Coefficient plot (intervals)
p1 <- out.anyprjcrime.stmony.fit[[5]]
p2 <- out.anyprjcrime.sttran.fit[[5]]
p3 <- out.anyprjcrime.stresp.fit[[5]]
p4 <- out.anyprjcrime.stfair.fit[[5]]
p5 <- out.anyprjcrime.stjob.fit[[5]]
p6 <- out.anyprjcrime.stthft.fit[[5]]
p7 <- out.anyprjcrime.stmug.fit[[5]]

playout <- '
AB
CD
E#
FG
'
p1 + p2 + p3 + p4 + p5 + p6 + p7 +
  plot_layout(design = playout) +
  plot_annotation(
  title = 'Coefficient plot',
  subtitle = 'Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80% (thick line), and 95% (thin line) intervals')

4.3.4.3.2 Coefficient plot (distributions)
p1 <- out.anyprjcrime.stmony.fit[[4]]
p2 <- out.anyprjcrime.sttran.fit[[4]]
p3 <- out.anyprjcrime.stresp.fit[[4]]
p4 <- out.anyprjcrime.stfair.fit[[4]]
p5 <- out.anyprjcrime.stjob.fit[[4]]
p6 <- out.anyprjcrime.stthft.fit[[4]]
p7 <- out.anyprjcrime.stmug.fit[[4]]

playout <- '
AB
CD
E#
FG
'
p1 + p2 + p3 + p4 + p5 + p6 + p7 +
  plot_layout(design = playout) +
  plot_annotation(
  title = 'Coefficient plot',
  subtitle = 'Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% shaded intervals')

4.3.4.3.3 PPcheck (density)
p1 <- out.anyprjcrime.stmony.fit[[3]] + labs(title = "Any crime intent/stmony (T1)") 
p2 <- out.anyprjcrime.sttran.fit[[3]] + labs(title = "Any crime intent/sttran (T1)")
p3 <- out.anyprjcrime.stresp.fit[[3]] + labs(title = "Any crime intent/stresp (T1)")
p4 <- out.anyprjcrime.stfair.fit[[3]] + labs(title = "Any crime intent/stfair (T1)")
p5 <- out.anyprjcrime.stjob.fit[[3]] + labs(title = "Any crime intent/stjob (T1)")
p6 <- out.anyprjcrime.stthft.fit[[3]] + labs(title = "Any crime intent/stthft (T1)")
p7 <- out.anyprjcrime.stmug.fit[[3]] + labs(title = "Any crime intent/stmug (T1)")

(p1 + p2) / (p3 + p4) / (p5 + plot_spacer()) / (p6 + p7)

4.3.4.4 Fit + prior summaries (T1 Any crime intent/all stress)

4.3.4.4.1 stmony
out.anyprjcrime.stmony.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjanyw1f ~ 1 + mo(stmonyw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -1.35      0.27    -1.87    -0.83 1.00     2316     2517
## mostmonyw1i    -0.12      0.10    -0.31     0.09 1.00     2266     2371
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostmonyw1i1[1]     0.25      0.14     0.04     0.56 1.00     3143     2231
## mostmonyw1i1[2]     0.33      0.17     0.05     0.68 1.00     2627     2236
## mostmonyw1i1[3]     0.20      0.13     0.03     0.51 1.00     3350     2453
## mostmonyw1i1[4]     0.21      0.13     0.03     0.54 1.00     3324     2251
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anyprjcrime.stmony.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mostmonyw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.4.2 sttran
out.anyprjcrime.sttran.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjanyw1f ~ 1 + mo(sttranw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -1.47      0.31    -2.09    -0.87 1.00     1793     2002
## mosttranw1i    -0.05      0.13    -0.28     0.22 1.00     1794     1666
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mosttranw1i1[1]     0.26      0.14     0.04     0.57 1.00     2631     2333
## mosttranw1i1[2]     0.28      0.16     0.04     0.62 1.00     2440     2557
## mosttranw1i1[3]     0.23      0.13     0.03     0.54 1.00     2887     2437
## mosttranw1i1[4]     0.23      0.16     0.02     0.61 1.00     2250     2361
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anyprjcrime.sttran.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mosttranw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.4.3 stresp
out.anyprjcrime.stresp.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjanyw1f ~ 1 + mo(strespw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -2.11      0.25    -2.65    -1.64 1.00     1599     2090
## mostrespw1i     0.20      0.08     0.04     0.37 1.00     1879     2273
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostrespw1i1[1]     0.26      0.14     0.04     0.56 1.00     3002     1762
## mostrespw1i1[2]     0.23      0.13     0.04     0.54 1.00     3591     2295
## mostrespw1i1[3]     0.23      0.13     0.03     0.53 1.00     3640     2597
## mostrespw1i1[4]     0.28      0.14     0.05     0.58 1.00     3615     2708
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anyprjcrime.stresp.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mostrespw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.4.4 stfair
out.anyprjcrime.stfair.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjanyw1f ~ 1 + mo(stfairw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -2.18      0.25    -2.69    -1.71 1.00     2012     1918
## mostfairw1i     0.23      0.08     0.07     0.39 1.00     2025     2008
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostfairw1i1[1]     0.21      0.13     0.03     0.51 1.00     3051     1957
## mostfairw1i1[2]     0.23      0.13     0.03     0.52 1.00     3345     2395
## mostfairw1i1[3]     0.23      0.14     0.03     0.55 1.00     3217     2244
## mostfairw1i1[4]     0.32      0.15     0.06     0.63 1.00     3478     2584
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anyprjcrime.stfair.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mostfairw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.4.5 stjob
out.anyprjcrime.stjob.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjanyw1f ~ 1 + mo(stjobw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##            Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept     -2.35      0.25    -2.86    -1.87 1.00     2195     1990
## mostjobw1i     0.31      0.08     0.15     0.47 1.00     2364     2031
## 
## Monotonic Simplex Parameters:
##                Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostjobw1i1[1]     0.15      0.09     0.02     0.37 1.00     2718     1951
## mostjobw1i1[2]     0.19      0.11     0.03     0.46 1.00     3421     2546
## mostjobw1i1[3]     0.42      0.16     0.11     0.71 1.00     3048     2695
## mostjobw1i1[4]     0.23      0.12     0.04     0.53 1.00     3119     2479
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anyprjcrime.stjob.fit[[2]]
##                  prior     class        coef group resp dpar nlpar lb ub
##                 (flat)         b                                        
##        normal(0, 0.25)         b  mostjobw1i                            
##           normal(0, 2) Intercept                                        
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.4.6 stthft
out.anyprjcrime.stthft.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjanyw1f ~ 1 + mo(stthftw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept      -1.75      0.17    -2.09    -1.41 1.00     3022     2660
## mostthftw1i     0.11      0.10    -0.08     0.30 1.00     2888     2558
## 
## Monotonic Simplex Parameters:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostthftw1i1[1]     0.22      0.14     0.03     0.54 1.00     3919     2616
## mostthftw1i1[2]     0.23      0.14     0.03     0.55 1.00     4351     2943
## mostthftw1i1[3]     0.29      0.16     0.04     0.64 1.00     3678     2421
## mostthftw1i1[4]     0.26      0.15     0.04     0.60 1.00     4018     2432
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anyprjcrime.stthft.fit[[2]]
##                  prior     class         coef group resp dpar nlpar lb ub
##                 (flat)         b                                         
##        normal(0, 0.25)         b  mostthftw1i                            
##           normal(0, 2) Intercept                                         
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1                            
##   source
##  default
##     user
##     user
##     user
4.3.4.4.7 stmug
out.anyprjcrime.stmug.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjanyw1f ~ 1 + mo(stmugw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##            Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept     -1.67      0.16    -1.99    -1.37 1.00     2591     2553
## mostmugw1i     0.06      0.11    -0.15     0.27 1.00     2764     2817
## 
## Monotonic Simplex Parameters:
##                Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostmugw1i1[1]     0.24      0.14     0.03     0.56 1.00     2880     1715
## mostmugw1i1[2]     0.23      0.14     0.03     0.54 1.00     3995     2593
## mostmugw1i1[3]     0.25      0.15     0.04     0.58 1.00     4760     2899
## mostmugw1i1[4]     0.28      0.15     0.05     0.62 1.00     3559     2848
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.anyprjcrime.stmug.fit[[2]]
##                  prior     class        coef group resp dpar nlpar lb ub
##                 (flat)         b                                        
##        normal(0, 0.25)         b  mostmugw1i                            
##           normal(0, 2) Intercept                                        
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1                            
##   source
##  default
##     user
##     user
##     user

4.3.5 Depressive Symptom Items: Bivariate models

Once again, we will repeat the process of building simple bivariate models for negative emotions by regressing each negative emotion item on each stress indicator. As with past crime, we will specify a Bernoulli distribution with a logit link and use monotonic cumulative ordinal probit thresholds for the stress predictors.

4.3.5.1 Bivariate Corr: T1 stmonyw1/negative emotions

#list of colnames for depressive symptom DVs  
depdv_names <- noquote(c("depcantgow1f", "depeffortw1f", "deplonelyw1f", "depbluesw1f", 
                           "depunfairw1f", "depmistrtw1f", "depbetrayw1f"))

#Bivariate: depressive symptom items ~ mo(stmonyw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmonyw1i', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmonyw1i1', 
                  resp = depdv_names))

alldepress.stmony.fit <- brm(
  mvbind(depcantgow1f, depeffortw1f, deplonelyw1f, depbluesw1f, depunfairw1f, depmistrtw1f, 
          depbetrayw1f) ~ 1 + mo(stmonyw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/alldepress_stmony_fit", 
      file_refit = "on_change"
  )

#Update function to call all ppchecks for bivar depressive symptom models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="depcantgow1f")
  ppcheckdv2 <-pp_check(modelfit, resp="depeffortw1f")
  ppcheckdv3 <-pp_check(modelfit, resp="deplonelyw1f")
  ppcheckdv4 <-pp_check(modelfit, resp="depbluesw1f")
  ppcheckdv5 <-pp_check(modelfit, resp="depunfairw1f")
  ppcheckdv6 <-pp_check(modelfit, resp="depmistrtw1f")
  ppcheckdv7 <-pp_check(modelfit, resp="depbetrayw1f")
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95) +
    labs(title = "Coefficient plot",
         subtitle = "Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, 
                    ppcheckdv3, ppcheckdv4, ppcheckdv5, ppcheckdv6, ppcheckdv7, 
                    plotcoefs, plotcoefs2)
  return(allchecks)
}

out.alldepress.stmony.fit <- ppchecks(alldepress.stmony.fit)
4.3.5.1.1 Coefficient plot (intervals)
out.alldepress.stmony.fit[[11]]

4.3.5.1.2 Coefficient plot (distributions)
out.alldepress.stmony.fit[[10]]

4.3.5.1.3 PPcheck (density)
p1 <- out.alldepress.stmony.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.alldepress.stmony.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.alldepress.stmony.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.alldepress.stmony.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.alldepress.stmony.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.alldepress.stmony.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.alldepress.stmony.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

4.3.5.1.4 Fit summary
out.alldepress.stmony.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgow1f ~ 1 + mo(stmonyw1i) 
##          depeffortw1f ~ 1 + mo(stmonyw1i) 
##          deplonelyw1f ~ 1 + mo(stmonyw1i) 
##          depbluesw1f ~ 1 + mo(stmonyw1i) 
##          depunfairw1f ~ 1 + mo(stmonyw1i) 
##          depmistrtw1f ~ 1 + mo(stmonyw1i) 
##          depbetrayw1f ~ 1 + mo(stmonyw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_Intercept      -0.83      0.21    -1.29    -0.46 1.00     3239
## depeffortw1f_Intercept      -2.06      0.29    -2.68    -1.52 1.00     3951
## deplonelyw1f_Intercept      -1.41      0.23    -1.90    -0.97 1.00     3336
## depbluesw1f_Intercept       -1.95      0.31    -2.63    -1.42 1.00     3458
## depunfairw1f_Intercept      -2.28      0.31    -2.94    -1.76 1.00     3288
## depmistrtw1f_Intercept      -2.22      0.38    -3.10    -1.59 1.00     3229
## depbetrayw1f_Intercept      -2.32      0.36    -3.12    -1.73 1.00     2874
## depcantgow1f_mostmonyw1i     0.22      0.08     0.06     0.39 1.00     3339
## depeffortw1f_mostmonyw1i     0.09      0.11    -0.13     0.31 1.00     4078
## deplonelyw1f_mostmonyw1i     0.07      0.10    -0.11     0.26 1.00     3653
## depbluesw1f_mostmonyw1i      0.20      0.11    -0.01     0.41 1.00     3502
## depunfairw1f_mostmonyw1i     0.36      0.10     0.18     0.57 1.00     3250
## depmistrtw1f_mostmonyw1i     0.23      0.12     0.01     0.49 1.00     3340
## depbetrayw1f_mostmonyw1i     0.25      0.12     0.05     0.49 1.00     2967
##                          Tail_ESS
## depcantgow1f_Intercept       2523
## depeffortw1f_Intercept       2583
## deplonelyw1f_Intercept       1995
## depbluesw1f_Intercept        2372
## depunfairw1f_Intercept       2646
## depmistrtw1f_Intercept       2229
## depbetrayw1f_Intercept       2528
## depcantgow1f_mostmonyw1i     2800
## depeffortw1f_mostmonyw1i     3014
## deplonelyw1f_mostmonyw1i     2840
## depbluesw1f_mostmonyw1i      2899
## depunfairw1f_mostmonyw1i     2597
## depmistrtw1f_mostmonyw1i     2140
## depbetrayw1f_mostmonyw1i     2712
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_mostmonyw1i1[1]     0.23      0.13     0.03     0.51 1.00     4017
## depcantgow1f_mostmonyw1i1[2]     0.16      0.11     0.02     0.42 1.00     5624
## depcantgow1f_mostmonyw1i1[3]     0.32      0.15     0.07     0.64 1.00     5034
## depcantgow1f_mostmonyw1i1[4]     0.28      0.14     0.05     0.59 1.00     4912
## depeffortw1f_mostmonyw1i1[1]     0.27      0.15     0.04     0.59 1.00     4737
## depeffortw1f_mostmonyw1i1[2]     0.22      0.13     0.03     0.53 1.00     4835
## depeffortw1f_mostmonyw1i1[3]     0.27      0.15     0.04     0.59 1.00     4903
## depeffortw1f_mostmonyw1i1[4]     0.25      0.14     0.04     0.57 1.00     5130
## deplonelyw1f_mostmonyw1i1[1]     0.27      0.15     0.04     0.59 1.00     4271
## deplonelyw1f_mostmonyw1i1[2]     0.22      0.13     0.03     0.54 1.00     4444
## deplonelyw1f_mostmonyw1i1[3]     0.24      0.14     0.04     0.55 1.00     5089
## deplonelyw1f_mostmonyw1i1[4]     0.28      0.15     0.04     0.62 1.00     5074
## depbluesw1f_mostmonyw1i1[1]      0.29      0.15     0.04     0.62 1.00     3982
## depbluesw1f_mostmonyw1i1[2]      0.27      0.14     0.05     0.58 1.00     4633
## depbluesw1f_mostmonyw1i1[3]      0.17      0.11     0.02     0.46 1.00     4464
## depbluesw1f_mostmonyw1i1[4]      0.27      0.14     0.05     0.58 1.00     5252
## depunfairw1f_mostmonyw1i1[1]     0.23      0.12     0.04     0.50 1.00     4121
## depunfairw1f_mostmonyw1i1[2]     0.15      0.09     0.02     0.36 1.00     5084
## depunfairw1f_mostmonyw1i1[3]     0.39      0.14     0.13     0.67 1.00     5356
## depunfairw1f_mostmonyw1i1[4]     0.23      0.12     0.04     0.50 1.00     5533
## depmistrtw1f_mostmonyw1i1[1]     0.34      0.16     0.07     0.67 1.00     3544
## depmistrtw1f_mostmonyw1i1[2]     0.22      0.13     0.03     0.52 1.00     4907
## depmistrtw1f_mostmonyw1i1[3]     0.21      0.13     0.03     0.51 1.00     4370
## depmistrtw1f_mostmonyw1i1[4]     0.23      0.13     0.03     0.52 1.00     5010
## depbetrayw1f_mostmonyw1i1[1]     0.33      0.16     0.06     0.65 1.00     3322
## depbetrayw1f_mostmonyw1i1[2]     0.18      0.11     0.03     0.44 1.00     4542
## depbetrayw1f_mostmonyw1i1[3]     0.27      0.14     0.05     0.58 1.00     4524
## depbetrayw1f_mostmonyw1i1[4]     0.22      0.13     0.04     0.50 1.00     4864
##                              Tail_ESS
## depcantgow1f_mostmonyw1i1[1]     2058
## depcantgow1f_mostmonyw1i1[2]     2601
## depcantgow1f_mostmonyw1i1[3]     2781
## depcantgow1f_mostmonyw1i1[4]     2580
## depeffortw1f_mostmonyw1i1[1]     2674
## depeffortw1f_mostmonyw1i1[2]     2691
## depeffortw1f_mostmonyw1i1[3]     2754
## depeffortw1f_mostmonyw1i1[4]     3335
## deplonelyw1f_mostmonyw1i1[1]     2308
## deplonelyw1f_mostmonyw1i1[2]     2820
## deplonelyw1f_mostmonyw1i1[3]     2935
## deplonelyw1f_mostmonyw1i1[4]     3145
## depbluesw1f_mostmonyw1i1[1]      2596
## depbluesw1f_mostmonyw1i1[2]      3041
## depbluesw1f_mostmonyw1i1[3]      3328
## depbluesw1f_mostmonyw1i1[4]      3393
## depunfairw1f_mostmonyw1i1[1]     2648
## depunfairw1f_mostmonyw1i1[2]     2508
## depunfairw1f_mostmonyw1i1[3]     3110
## depunfairw1f_mostmonyw1i1[4]     2666
## depmistrtw1f_mostmonyw1i1[1]     2793
## depmistrtw1f_mostmonyw1i1[2]     2014
## depmistrtw1f_mostmonyw1i1[3]     3064
## depmistrtw1f_mostmonyw1i1[4]     3106
## depbetrayw1f_mostmonyw1i1[1]     2685
## depbetrayw1f_mostmonyw1i1[2]     2845
## depbetrayw1f_mostmonyw1i1[3]     2678
## depbetrayw1f_mostmonyw1i1[4]     2904
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.5.1.5 Prior summary
out.alldepress.stmony.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                    depbetrayw1f              
##        normal(0, 0.25)         b  mostmonyw1i       depbetrayw1f              
##                 (flat)         b                     depbluesw1f              
##        normal(0, 0.25)         b  mostmonyw1i        depbluesw1f              
##                 (flat)         b                    depcantgow1f              
##        normal(0, 0.25)         b  mostmonyw1i       depcantgow1f              
##                 (flat)         b                    depeffortw1f              
##        normal(0, 0.25)         b  mostmonyw1i       depeffortw1f              
##                 (flat)         b                    deplonelyw1f              
##        normal(0, 0.25)         b  mostmonyw1i       deplonelyw1f              
##                 (flat)         b                    depmistrtw1f              
##        normal(0, 0.25)         b  mostmonyw1i       depmistrtw1f              
##                 (flat)         b                    depunfairw1f              
##        normal(0, 0.25)         b  mostmonyw1i       depunfairw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                    depbetrayw1f              
##           normal(0, 2) Intercept                     depbluesw1f              
##           normal(0, 2) Intercept                    depcantgow1f              
##           normal(0, 2) Intercept                    depeffortw1f              
##           normal(0, 2) Intercept                    deplonelyw1f              
##           normal(0, 2) Intercept                    depmistrtw1f              
##           normal(0, 2) Intercept                    depunfairw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       depbetrayw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1        depbluesw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       depcantgow1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       depeffortw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       deplonelyw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       depmistrtw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmonyw1i1       depunfairw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.5.2 Bivariate Corr: T1 sttranw1/negative emotions

#Bivariate: depressive symptom items ~ mo(sttranw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mosttranw1i', 
                  resp =depdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mosttranw1i1', 
                  resp =depdv_names))

alldepress.sttran.fit <- brm(
  mvbind(depcantgow1f, depeffortw1f, deplonelyw1f, depbluesw1f, depunfairw1f, depmistrtw1f, 
         depbetrayw1f) ~ 1 + mo(sttranw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/alldepress_sttran_fit", 
      file_refit = "on_change"
  )

out.alldepress.sttran.fit <- ppchecks(alldepress.sttran.fit)
4.3.5.2.1 Coefficient plot (intervals)
out.alldepress.sttran.fit[[11]]

4.3.5.2.2 Coefficient plot (distributions)
out.alldepress.sttran.fit[[10]]

4.3.5.2.3 PPcheck (density)
p1 <- out.alldepress.sttran.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.alldepress.sttran.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.alldepress.sttran.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.alldepress.sttran.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.alldepress.sttran.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.alldepress.sttran.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.alldepress.sttran.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

4.3.5.2.4 Fit summary
out.alldepress.sttran.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgow1f ~ 1 + mo(sttranw1i) 
##          depeffortw1f ~ 1 + mo(sttranw1i) 
##          deplonelyw1f ~ 1 + mo(sttranw1i) 
##          depbluesw1f ~ 1 + mo(sttranw1i) 
##          depunfairw1f ~ 1 + mo(sttranw1i) 
##          depmistrtw1f ~ 1 + mo(sttranw1i) 
##          depbetrayw1f ~ 1 + mo(sttranw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_Intercept      -0.82      0.25    -1.37    -0.41 1.00     2297
## depeffortw1f_Intercept      -1.94      0.28    -2.52    -1.42 1.00     2633
## deplonelyw1f_Intercept      -1.25      0.24    -1.71    -0.75 1.00     2810
## depbluesw1f_Intercept       -2.01      0.30    -2.64    -1.47 1.00     2467
## depunfairw1f_Intercept      -2.21      0.31    -2.92    -1.72 1.00     2458
## depmistrtw1f_Intercept      -1.68      0.28    -2.25    -1.14 1.00     2350
## depbetrayw1f_Intercept      -1.82      0.28    -2.40    -1.29 1.00     2433
## depcantgow1f_mosttranw1i     0.20      0.09     0.03     0.39 1.00     2388
## depeffortw1f_mosttranw1i     0.04      0.11    -0.17     0.25 1.00     2714
## deplonelyw1f_mosttranw1i    -0.01      0.10    -0.20     0.18 1.00     2786
## depbluesw1f_mosttranw1i      0.22      0.11     0.02     0.44 1.00     2586
## depunfairw1f_mosttranw1i     0.37      0.11     0.17     0.60 1.00     2649
## depmistrtw1f_mosttranw1i     0.02      0.11    -0.20     0.25 1.00     2372
## depbetrayw1f_mosttranw1i     0.05      0.11    -0.16     0.28 1.00     2443
##                          Tail_ESS
## depcantgow1f_Intercept       2376
## depeffortw1f_Intercept       2578
## deplonelyw1f_Intercept       2461
## depbluesw1f_Intercept        2462
## depunfairw1f_Intercept       2333
## depmistrtw1f_Intercept       2334
## depbetrayw1f_Intercept       2485
## depcantgow1f_mosttranw1i     2433
## depeffortw1f_mosttranw1i     2774
## deplonelyw1f_mosttranw1i     2670
## depbluesw1f_mosttranw1i      2726
## depunfairw1f_mosttranw1i     2817
## depmistrtw1f_mosttranw1i     2411
## depbetrayw1f_mosttranw1i     2795
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_mosttranw1i1[1]     0.27      0.15     0.04     0.58 1.00     3004
## depcantgow1f_mosttranw1i1[2]     0.19      0.12     0.03     0.47 1.00     4442
## depcantgow1f_mosttranw1i1[3]     0.25      0.14     0.04     0.56 1.00     4309
## depcantgow1f_mosttranw1i1[4]     0.28      0.14     0.05     0.59 1.00     4129
## depeffortw1f_mosttranw1i1[1]     0.26      0.15     0.04     0.59 1.00     5113
## depeffortw1f_mosttranw1i1[2]     0.25      0.14     0.04     0.57 1.00     5461
## depeffortw1f_mosttranw1i1[3]     0.24      0.14     0.04     0.57 1.00     5720
## depeffortw1f_mosttranw1i1[4]     0.26      0.14     0.04     0.57 1.00     4893
## deplonelyw1f_mosttranw1i1[1]     0.26      0.15     0.04     0.59 1.00     3676
## deplonelyw1f_mosttranw1i1[2]     0.24      0.14     0.03     0.56 1.00     5743
## deplonelyw1f_mosttranw1i1[3]     0.24      0.14     0.03     0.57 1.00     4723
## deplonelyw1f_mosttranw1i1[4]     0.26      0.15     0.04     0.58 1.00     4627
## depbluesw1f_mosttranw1i1[1]      0.22      0.13     0.03     0.51 1.00     3775
## depbluesw1f_mosttranw1i1[2]      0.34      0.16     0.07     0.66 1.00     4099
## depbluesw1f_mosttranw1i1[3]      0.18      0.11     0.03     0.46 1.00     4655
## depbluesw1f_mosttranw1i1[4]      0.26      0.14     0.04     0.57 1.00     4071
## depunfairw1f_mosttranw1i1[1]     0.22      0.12     0.03     0.48 1.00     3581
## depunfairw1f_mosttranw1i1[2]     0.16      0.10     0.02     0.39 1.00     4767
## depunfairw1f_mosttranw1i1[3]     0.23      0.12     0.04     0.49 1.00     4294
## depunfairw1f_mosttranw1i1[4]     0.39      0.14     0.12     0.67 1.00     4239
## depmistrtw1f_mosttranw1i1[1]     0.27      0.15     0.04     0.60 1.00     4586
## depmistrtw1f_mosttranw1i1[2]     0.24      0.14     0.04     0.55 1.00     4400
## depmistrtw1f_mosttranw1i1[3]     0.23      0.14     0.03     0.56 1.00     4087
## depmistrtw1f_mosttranw1i1[4]     0.26      0.15     0.04     0.62 1.00     3913
## depbetrayw1f_mosttranw1i1[1]     0.27      0.15     0.04     0.59 1.00     4430
## depbetrayw1f_mosttranw1i1[2]     0.24      0.14     0.03     0.56 1.00     5419
## depbetrayw1f_mosttranw1i1[3]     0.23      0.14     0.03     0.56 1.00     4113
## depbetrayw1f_mosttranw1i1[4]     0.26      0.15     0.04     0.60 1.00     4519
##                              Tail_ESS
## depcantgow1f_mosttranw1i1[1]     2472
## depcantgow1f_mosttranw1i1[2]     2621
## depcantgow1f_mosttranw1i1[3]     2498
## depcantgow1f_mosttranw1i1[4]     2954
## depeffortw1f_mosttranw1i1[1]     2724
## depeffortw1f_mosttranw1i1[2]     2907
## depeffortw1f_mosttranw1i1[3]     3136
## depeffortw1f_mosttranw1i1[4]     2935
## deplonelyw1f_mosttranw1i1[1]     2351
## deplonelyw1f_mosttranw1i1[2]     2859
## deplonelyw1f_mosttranw1i1[3]     3152
## deplonelyw1f_mosttranw1i1[4]     2457
## depbluesw1f_mosttranw1i1[1]      2213
## depbluesw1f_mosttranw1i1[2]      2625
## depbluesw1f_mosttranw1i1[3]      3027
## depbluesw1f_mosttranw1i1[4]      2564
## depunfairw1f_mosttranw1i1[1]     2513
## depunfairw1f_mosttranw1i1[2]     2469
## depunfairw1f_mosttranw1i1[3]     2294
## depunfairw1f_mosttranw1i1[4]     2729
## depmistrtw1f_mosttranw1i1[1]     2254
## depmistrtw1f_mosttranw1i1[2]     2986
## depmistrtw1f_mosttranw1i1[3]     2451
## depmistrtw1f_mosttranw1i1[4]     2985
## depbetrayw1f_mosttranw1i1[1]     2431
## depbetrayw1f_mosttranw1i1[2]     2264
## depbetrayw1f_mosttranw1i1[3]     2695
## depbetrayw1f_mosttranw1i1[4]     3060
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.5.2.5 Prior summary
out.alldepress.sttran.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                    depbetrayw1f              
##        normal(0, 0.25)         b  mosttranw1i       depbetrayw1f              
##                 (flat)         b                     depbluesw1f              
##        normal(0, 0.25)         b  mosttranw1i        depbluesw1f              
##                 (flat)         b                    depcantgow1f              
##        normal(0, 0.25)         b  mosttranw1i       depcantgow1f              
##                 (flat)         b                    depeffortw1f              
##        normal(0, 0.25)         b  mosttranw1i       depeffortw1f              
##                 (flat)         b                    deplonelyw1f              
##        normal(0, 0.25)         b  mosttranw1i       deplonelyw1f              
##                 (flat)         b                    depmistrtw1f              
##        normal(0, 0.25)         b  mosttranw1i       depmistrtw1f              
##                 (flat)         b                    depunfairw1f              
##        normal(0, 0.25)         b  mosttranw1i       depunfairw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                    depbetrayw1f              
##           normal(0, 2) Intercept                     depbluesw1f              
##           normal(0, 2) Intercept                    depcantgow1f              
##           normal(0, 2) Intercept                    depeffortw1f              
##           normal(0, 2) Intercept                    deplonelyw1f              
##           normal(0, 2) Intercept                    depmistrtw1f              
##           normal(0, 2) Intercept                    depunfairw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       depbetrayw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1        depbluesw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       depcantgow1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       depeffortw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       deplonelyw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       depmistrtw1f              
##  dirichlet(2, 2, 2, 2)      simo mosttranw1i1       depunfairw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.5.3 Bivariate Corr: T1 strespw1/negative emotions

#Bivariate: depressive symptom items ~ mo(strespw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostrespw1i', 
                  resp =depdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostrespw1i1', 
                  resp =depdv_names))

alldepress.stresp.fit <- brm(
  mvbind(depcantgow1f, depeffortw1f, deplonelyw1f, depbluesw1f, depunfairw1f, depmistrtw1f, 
         depbetrayw1f) ~ 1 + mo(strespw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/alldepress_stresp_fit", 
      file_refit = "on_change"
  )

out.alldepress.stresp.fit <- ppchecks(alldepress.stresp.fit)
4.3.5.3.1 Coefficient plot (intervals)
out.alldepress.stresp.fit[[11]]

4.3.5.3.2 Coefficient plot (distributions)
out.alldepress.stresp.fit[[10]]

4.3.5.3.3 PPcheck (density)
p1 <- out.alldepress.stresp.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.alldepress.stresp.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.alldepress.stresp.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.alldepress.stresp.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.alldepress.stresp.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.alldepress.stresp.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.alldepress.stresp.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

4.3.5.3.4 Fit summary
out.alldepress.stresp.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgow1f ~ 1 + mo(strespw1i) 
##          depeffortw1f ~ 1 + mo(strespw1i) 
##          deplonelyw1f ~ 1 + mo(strespw1i) 
##          depbluesw1f ~ 1 + mo(strespw1i) 
##          depunfairw1f ~ 1 + mo(strespw1i) 
##          depmistrtw1f ~ 1 + mo(strespw1i) 
##          depbetrayw1f ~ 1 + mo(strespw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_Intercept      -0.45      0.17    -0.79    -0.10 1.00     2751
## depeffortw1f_Intercept      -2.32      0.28    -2.92    -1.83 1.00     2781
## deplonelyw1f_Intercept      -1.87      0.30    -2.52    -1.34 1.00     2285
## depbluesw1f_Intercept       -1.57      0.23    -2.01    -1.12 1.00     3093
## depunfairw1f_Intercept      -1.58      0.24    -2.06    -1.08 1.00     2286
## depmistrtw1f_Intercept      -2.75      0.34    -3.49    -2.14 1.00     2575
## depbetrayw1f_Intercept      -2.70      0.38    -3.47    -2.03 1.00     2447
## depcantgow1f_mostrespw1i     0.02      0.06    -0.11     0.15 1.00     2920
## depeffortw1f_mostrespw1i     0.18      0.09     0.02     0.37 1.00     2876
## deplonelyw1f_mostrespw1i     0.23      0.09     0.06     0.42 1.00     2340
## depbluesw1f_mostrespw1i      0.04      0.09    -0.12     0.21 1.00     2792
## depunfairw1f_mostrespw1i     0.05      0.10    -0.13     0.24 1.00     2140
## depmistrtw1f_mostrespw1i     0.41      0.10     0.23     0.62 1.00     2664
## depbetrayw1f_mostrespw1i     0.35      0.11     0.16     0.57 1.00     2514
##                          Tail_ESS
## depcantgow1f_Intercept       2809
## depeffortw1f_Intercept       2373
## deplonelyw1f_Intercept       2664
## depbluesw1f_Intercept        2782
## depunfairw1f_Intercept       2251
## depmistrtw1f_Intercept       2108
## depbetrayw1f_Intercept       2719
## depcantgow1f_mostrespw1i     2874
## depeffortw1f_mostrespw1i     2812
## deplonelyw1f_mostrespw1i     2524
## depbluesw1f_mostrespw1i      2794
## depunfairw1f_mostrespw1i     2385
## depmistrtw1f_mostrespw1i     1939
## depbetrayw1f_mostrespw1i     2494
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_mostrespw1i1[1]     0.25      0.15     0.03     0.59 1.00     5087
## depcantgow1f_mostrespw1i1[2]     0.24      0.14     0.03     0.57 1.00     4930
## depcantgow1f_mostrespw1i1[3]     0.26      0.15     0.04     0.60 1.00     4729
## depcantgow1f_mostrespw1i1[4]     0.25      0.14     0.04     0.58 1.00     5625
## depeffortw1f_mostrespw1i1[1]     0.30      0.15     0.05     0.63 1.00     4268
## depeffortw1f_mostrespw1i1[2]     0.23      0.13     0.04     0.54 1.00     5251
## depeffortw1f_mostrespw1i1[3]     0.21      0.13     0.03     0.52 1.00     4363
## depeffortw1f_mostrespw1i1[4]     0.26      0.14     0.04     0.57 1.00     5014
## deplonelyw1f_mostrespw1i1[1]     0.41      0.17     0.09     0.74 1.00     3013
## deplonelyw1f_mostrespw1i1[2]     0.18      0.12     0.02     0.45 1.00     4165
## deplonelyw1f_mostrespw1i1[3]     0.20      0.12     0.03     0.50 1.00     4791
## deplonelyw1f_mostrespw1i1[4]     0.21      0.12     0.04     0.49 1.00     4611
## depbluesw1f_mostrespw1i1[1]      0.24      0.14     0.04     0.57 1.00     4524
## depbluesw1f_mostrespw1i1[2]      0.23      0.14     0.03     0.54 1.00     5549
## depbluesw1f_mostrespw1i1[3]      0.24      0.14     0.04     0.55 1.00     5897
## depbluesw1f_mostrespw1i1[4]      0.30      0.17     0.04     0.66 1.00     3716
## depunfairw1f_mostrespw1i1[1]     0.23      0.15     0.03     0.59 1.00     3578
## depunfairw1f_mostrespw1i1[2]     0.22      0.14     0.03     0.55 1.00     4260
## depunfairw1f_mostrespw1i1[3]     0.23      0.14     0.03     0.55 1.00     5342
## depunfairw1f_mostrespw1i1[4]     0.32      0.19     0.04     0.71 1.00     2545
## depmistrtw1f_mostrespw1i1[1]     0.27      0.13     0.05     0.54 1.00     3837
## depmistrtw1f_mostrespw1i1[2]     0.26      0.14     0.04     0.56 1.00     4543
## depmistrtw1f_mostrespw1i1[3]     0.25      0.13     0.05     0.55 1.00     5017
## depmistrtw1f_mostrespw1i1[4]     0.22      0.11     0.04     0.46 1.00     5771
## depbetrayw1f_mostrespw1i1[1]     0.35      0.16     0.08     0.66 1.00     3231
## depbetrayw1f_mostrespw1i1[2]     0.24      0.13     0.04     0.53 1.00     4543
## depbetrayw1f_mostrespw1i1[3]     0.26      0.13     0.05     0.56 1.00     4385
## depbetrayw1f_mostrespw1i1[4]     0.15      0.09     0.02     0.37 1.00     5321
##                              Tail_ESS
## depcantgow1f_mostrespw1i1[1]     2916
## depcantgow1f_mostrespw1i1[2]     2573
## depcantgow1f_mostrespw1i1[3]     3417
## depcantgow1f_mostrespw1i1[4]     2882
## depeffortw1f_mostrespw1i1[1]     2568
## depeffortw1f_mostrespw1i1[2]     2685
## depeffortw1f_mostrespw1i1[3]     2799
## depeffortw1f_mostrespw1i1[4]     3170
## deplonelyw1f_mostrespw1i1[1]     2368
## deplonelyw1f_mostrespw1i1[2]     2527
## deplonelyw1f_mostrespw1i1[3]     2708
## deplonelyw1f_mostrespw1i1[4]     2730
## depbluesw1f_mostrespw1i1[1]      2597
## depbluesw1f_mostrespw1i1[2]      2721
## depbluesw1f_mostrespw1i1[3]      2948
## depbluesw1f_mostrespw1i1[4]      3284
## depunfairw1f_mostrespw1i1[1]     2909
## depunfairw1f_mostrespw1i1[2]     2836
## depunfairw1f_mostrespw1i1[3]     2952
## depunfairw1f_mostrespw1i1[4]     2659
## depmistrtw1f_mostrespw1i1[1]     2560
## depmistrtw1f_mostrespw1i1[2]     2165
## depmistrtw1f_mostrespw1i1[3]     2674
## depmistrtw1f_mostrespw1i1[4]     2940
## depbetrayw1f_mostrespw1i1[1]     2327
## depbetrayw1f_mostrespw1i1[2]     2602
## depbetrayw1f_mostrespw1i1[3]     2923
## depbetrayw1f_mostrespw1i1[4]     3136
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.5.3.5 Prior summary
out.alldepress.stresp.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                    depbetrayw1f              
##        normal(0, 0.25)         b  mostrespw1i       depbetrayw1f              
##                 (flat)         b                     depbluesw1f              
##        normal(0, 0.25)         b  mostrespw1i        depbluesw1f              
##                 (flat)         b                    depcantgow1f              
##        normal(0, 0.25)         b  mostrespw1i       depcantgow1f              
##                 (flat)         b                    depeffortw1f              
##        normal(0, 0.25)         b  mostrespw1i       depeffortw1f              
##                 (flat)         b                    deplonelyw1f              
##        normal(0, 0.25)         b  mostrespw1i       deplonelyw1f              
##                 (flat)         b                    depmistrtw1f              
##        normal(0, 0.25)         b  mostrespw1i       depmistrtw1f              
##                 (flat)         b                    depunfairw1f              
##        normal(0, 0.25)         b  mostrespw1i       depunfairw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                    depbetrayw1f              
##           normal(0, 2) Intercept                     depbluesw1f              
##           normal(0, 2) Intercept                    depcantgow1f              
##           normal(0, 2) Intercept                    depeffortw1f              
##           normal(0, 2) Intercept                    deplonelyw1f              
##           normal(0, 2) Intercept                    depmistrtw1f              
##           normal(0, 2) Intercept                    depunfairw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       depbetrayw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1        depbluesw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       depcantgow1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       depeffortw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       deplonelyw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       depmistrtw1f              
##  dirichlet(2, 2, 2, 2)      simo mostrespw1i1       depunfairw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.5.4 Bivariate Corr: T1 stfairw1/negative emotions

#Bivariate: depressive symptom items ~ mo(stfairw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostfairw1i', 
                  resp =depdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostfairw1i1', 
                  resp =depdv_names))

alldepress.stfair.fit <- brm(
  mvbind(depcantgow1f, depeffortw1f, deplonelyw1f, depbluesw1f, depunfairw1f, depmistrtw1f, 
         depbetrayw1f) ~ 1 + mo(stfairw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/alldepress_stfair_fit", 
      file_refit = "on_change"
  )

out.alldepress.stfair.fit <- ppchecks(alldepress.stfair.fit)
4.3.5.4.1 Coefficient plot (intervals)
out.alldepress.stfair.fit[[11]]

4.3.5.4.2 Coefficient plot (distributions)
out.alldepress.stfair.fit[[10]]

4.3.5.4.3 PPcheck (density)
p1 <- out.alldepress.stfair.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.alldepress.stfair.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.alldepress.stfair.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.alldepress.stfair.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.alldepress.stfair.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.alldepress.stfair.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.alldepress.stfair.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

4.3.5.4.4 Fit summary
out.alldepress.stfair.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgow1f ~ 1 + mo(stfairw1i) 
##          depeffortw1f ~ 1 + mo(stfairw1i) 
##          deplonelyw1f ~ 1 + mo(stfairw1i) 
##          depbluesw1f ~ 1 + mo(stfairw1i) 
##          depunfairw1f ~ 1 + mo(stfairw1i) 
##          depmistrtw1f ~ 1 + mo(stfairw1i) 
##          depbetrayw1f ~ 1 + mo(stfairw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_Intercept      -0.53      0.17    -0.86    -0.19 1.00     2885
## depeffortw1f_Intercept      -2.29      0.30    -2.91    -1.75 1.00     2934
## deplonelyw1f_Intercept      -1.82      0.26    -2.38    -1.36 1.00     2461
## depbluesw1f_Intercept       -1.70      0.23    -2.17    -1.26 1.00     2713
## depunfairw1f_Intercept      -1.62      0.23    -2.06    -1.17 1.00     3018
## depmistrtw1f_Intercept      -2.79      0.36    -3.56    -2.16 1.00     2550
## depbetrayw1f_Intercept      -2.90      0.38    -3.68    -2.23 1.00     3024
## depcantgow1f_mostfairw1i     0.06      0.06    -0.06     0.17 1.00     2895
## depeffortw1f_mostfairw1i     0.17      0.09    -0.01     0.35 1.00     3092
## deplonelyw1f_mostfairw1i     0.21      0.08     0.06     0.37 1.00     2614
## depbluesw1f_mostfairw1i      0.09      0.08    -0.07     0.26 1.00     2464
## depunfairw1f_mostfairw1i     0.06      0.08    -0.11     0.21 1.00     3246
## depmistrtw1f_mostfairw1i     0.41      0.10     0.23     0.62 1.00     2667
## depbetrayw1f_mostfairw1i     0.41      0.10     0.22     0.63 1.00     3149
##                          Tail_ESS
## depcantgow1f_Intercept       2721
## depeffortw1f_Intercept       2557
## deplonelyw1f_Intercept       2037
## depbluesw1f_Intercept        2665
## depunfairw1f_Intercept       2878
## depmistrtw1f_Intercept       2436
## depbetrayw1f_Intercept       2406
## depcantgow1f_mostfairw1i     2404
## depeffortw1f_mostfairw1i     2696
## deplonelyw1f_mostfairw1i     2515
## depbluesw1f_mostfairw1i      2747
## depunfairw1f_mostfairw1i     2693
## depmistrtw1f_mostfairw1i     2378
## depbetrayw1f_mostfairw1i     2470
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_mostfairw1i1[1]     0.23      0.14     0.03     0.56 1.00     4833
## depcantgow1f_mostfairw1i1[2]     0.26      0.15     0.04     0.60 1.00     6028
## depcantgow1f_mostfairw1i1[3]     0.26      0.15     0.04     0.60 1.00     5226
## depcantgow1f_mostfairw1i1[4]     0.24      0.14     0.04     0.56 1.00     5245
## depeffortw1f_mostfairw1i1[1]     0.25      0.14     0.04     0.57 1.00     4405
## depeffortw1f_mostfairw1i1[2]     0.30      0.16     0.05     0.64 1.00     4481
## depeffortw1f_mostfairw1i1[3]     0.23      0.14     0.03     0.55 1.00     5345
## depeffortw1f_mostfairw1i1[4]     0.22      0.13     0.03     0.51 1.00     4574
## deplonelyw1f_mostfairw1i1[1]     0.29      0.15     0.05     0.61 1.00     4493
## deplonelyw1f_mostfairw1i1[2]     0.22      0.13     0.04     0.52 1.00     5061
## deplonelyw1f_mostfairw1i1[3]     0.28      0.15     0.05     0.60 1.00     5749
## deplonelyw1f_mostfairw1i1[4]     0.20      0.12     0.03     0.48 1.00     4709
## depbluesw1f_mostfairw1i1[1]      0.23      0.13     0.03     0.53 1.00     4302
## depbluesw1f_mostfairw1i1[2]      0.20      0.13     0.02     0.52 1.00     4512
## depbluesw1f_mostfairw1i1[3]      0.22      0.13     0.03     0.54 1.00     5617
## depbluesw1f_mostfairw1i1[4]      0.35      0.17     0.05     0.69 1.00     3516
## depunfairw1f_mostfairw1i1[1]     0.23      0.14     0.03     0.55 1.00     4449
## depunfairw1f_mostfairw1i1[2]     0.24      0.14     0.04     0.57 1.00     5520
## depunfairw1f_mostfairw1i1[3]     0.27      0.15     0.04     0.61 1.00     5659
## depunfairw1f_mostfairw1i1[4]     0.27      0.15     0.04     0.59 1.00     5484
## depmistrtw1f_mostfairw1i1[1]     0.25      0.13     0.04     0.54 1.00     3543
## depmistrtw1f_mostfairw1i1[2]     0.30      0.14     0.06     0.59 1.00     3869
## depmistrtw1f_mostfairw1i1[3]     0.24      0.13     0.04     0.54 1.00     4115
## depmistrtw1f_mostfairw1i1[4]     0.21      0.11     0.04     0.46 1.00     5639
## depbetrayw1f_mostfairw1i1[1]     0.28      0.14     0.05     0.58 1.00     4069
## depbetrayw1f_mostfairw1i1[2]     0.38      0.16     0.09     0.70 1.00     4074
## depbetrayw1f_mostfairw1i1[3]     0.19      0.11     0.03     0.45 1.00     4584
## depbetrayw1f_mostfairw1i1[4]     0.15      0.09     0.02     0.36 1.00     5559
##                              Tail_ESS
## depcantgow1f_mostfairw1i1[1]     2210
## depcantgow1f_mostfairw1i1[2]     2861
## depcantgow1f_mostfairw1i1[3]     3015
## depcantgow1f_mostfairw1i1[4]     2914
## depeffortw1f_mostfairw1i1[1]     2559
## depeffortw1f_mostfairw1i1[2]     2498
## depeffortw1f_mostfairw1i1[3]     3019
## depeffortw1f_mostfairw1i1[4]     2952
## deplonelyw1f_mostfairw1i1[1]     2892
## deplonelyw1f_mostfairw1i1[2]     2404
## deplonelyw1f_mostfairw1i1[3]     2923
## deplonelyw1f_mostfairw1i1[4]     3066
## depbluesw1f_mostfairw1i1[1]      2257
## depbluesw1f_mostfairw1i1[2]      2646
## depbluesw1f_mostfairw1i1[3]      2889
## depbluesw1f_mostfairw1i1[4]      3141
## depunfairw1f_mostfairw1i1[1]     2254
## depunfairw1f_mostfairw1i1[2]     2551
## depunfairw1f_mostfairw1i1[3]     3215
## depunfairw1f_mostfairw1i1[4]     2953
## depmistrtw1f_mostfairw1i1[1]     2039
## depmistrtw1f_mostfairw1i1[2]     2495
## depmistrtw1f_mostfairw1i1[3]     2672
## depmistrtw1f_mostfairw1i1[4]     3358
## depbetrayw1f_mostfairw1i1[1]     2592
## depbetrayw1f_mostfairw1i1[2]     2207
## depbetrayw1f_mostfairw1i1[3]     3093
## depbetrayw1f_mostfairw1i1[4]     3223
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.5.4.5 Prior summary
out.alldepress.stfair.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                    depbetrayw1f              
##        normal(0, 0.25)         b  mostfairw1i       depbetrayw1f              
##                 (flat)         b                     depbluesw1f              
##        normal(0, 0.25)         b  mostfairw1i        depbluesw1f              
##                 (flat)         b                    depcantgow1f              
##        normal(0, 0.25)         b  mostfairw1i       depcantgow1f              
##                 (flat)         b                    depeffortw1f              
##        normal(0, 0.25)         b  mostfairw1i       depeffortw1f              
##                 (flat)         b                    deplonelyw1f              
##        normal(0, 0.25)         b  mostfairw1i       deplonelyw1f              
##                 (flat)         b                    depmistrtw1f              
##        normal(0, 0.25)         b  mostfairw1i       depmistrtw1f              
##                 (flat)         b                    depunfairw1f              
##        normal(0, 0.25)         b  mostfairw1i       depunfairw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                    depbetrayw1f              
##           normal(0, 2) Intercept                     depbluesw1f              
##           normal(0, 2) Intercept                    depcantgow1f              
##           normal(0, 2) Intercept                    depeffortw1f              
##           normal(0, 2) Intercept                    deplonelyw1f              
##           normal(0, 2) Intercept                    depmistrtw1f              
##           normal(0, 2) Intercept                    depunfairw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       depbetrayw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1        depbluesw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       depcantgow1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       depeffortw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       deplonelyw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       depmistrtw1f              
##  dirichlet(2, 2, 2, 2)      simo mostfairw1i1       depunfairw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.5.5 Bivariate Corr: T1 stjobw1/negative emotions

#Bivariate: depressive symptom items ~ mo(stjobw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostjobw1i', 
                  resp =depdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostjobw1i1', 
                  resp =depdv_names))

alldepress.stjob.fit <- brm(
  mvbind(depcantgow1f, depeffortw1f, deplonelyw1f, depbluesw1f, depunfairw1f, depmistrtw1f, 
         depbetrayw1f) ~ 1 + mo(stjobw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/alldepress_stjob_fit", 
      file_refit = "on_change"
  )

out.alldepress.stjob.fit <- ppchecks(alldepress.stjob.fit)
4.3.5.5.1 Coefficient plot (intervals)
out.alldepress.stjob.fit[[11]]

4.3.5.5.2 Coefficient plot (distributions)
out.alldepress.stjob.fit[[10]]

4.3.5.5.3 PPcheck (density)
p1 <- out.alldepress.stjob.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.alldepress.stjob.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.alldepress.stjob.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.alldepress.stjob.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.alldepress.stjob.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.alldepress.stjob.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.alldepress.stjob.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

4.3.5.5.4 Fit summary
out.alldepress.stjob.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgow1f ~ 1 + mo(stjobw1i) 
##          depeffortw1f ~ 1 + mo(stjobw1i) 
##          deplonelyw1f ~ 1 + mo(stjobw1i) 
##          depbluesw1f ~ 1 + mo(stjobw1i) 
##          depunfairw1f ~ 1 + mo(stjobw1i) 
##          depmistrtw1f ~ 1 + mo(stjobw1i) 
##          depbetrayw1f ~ 1 + mo(stjobw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_Intercept     -0.13      0.17    -0.47     0.21 1.00     4391
## depeffortw1f_Intercept     -2.12      0.26    -2.67    -1.64 1.00     4507
## deplonelyw1f_Intercept     -1.22      0.21    -1.62    -0.81 1.00     4223
## depbluesw1f_Intercept      -1.58      0.22    -2.01    -1.18 1.00     4166
## depunfairw1f_Intercept     -1.60      0.22    -2.04    -1.18 1.00     3754
## depmistrtw1f_Intercept     -1.73      0.24    -2.22    -1.29 1.00     3755
## depbetrayw1f_Intercept     -2.05      0.27    -2.62    -1.57 1.00     3540
## depcantgow1f_mostjobw1i    -0.12      0.06    -0.24     0.01 1.00     4300
## depeffortw1f_mostjobw1i     0.12      0.10    -0.07     0.31 1.00     4181
## deplonelyw1f_mostjobw1i    -0.02      0.08    -0.17     0.14 1.00     4214
## depbluesw1f_mostjobw1i      0.04      0.08    -0.11     0.19 1.00     4234
## depunfairw1f_mostjobw1i     0.05      0.08    -0.10     0.22 1.00     2941
## depmistrtw1f_mostjobw1i     0.04      0.09    -0.13     0.20 1.00     4493
## depbetrayw1f_mostjobw1i     0.14      0.09    -0.03     0.34 1.00     3460
##                         Tail_ESS
## depcantgow1f_Intercept      3016
## depeffortw1f_Intercept      3191
## deplonelyw1f_Intercept      3002
## depbluesw1f_Intercept       3074
## depunfairw1f_Intercept      3507
## depmistrtw1f_Intercept      2993
## depbetrayw1f_Intercept      2296
## depcantgow1f_mostjobw1i     3135
## depeffortw1f_mostjobw1i     2872
## deplonelyw1f_mostjobw1i     3133
## depbluesw1f_mostjobw1i      3264
## depunfairw1f_mostjobw1i     3386
## depmistrtw1f_mostjobw1i     3110
## depbetrayw1f_mostjobw1i     2557
## 
## Monotonic Simplex Parameters:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_mostjobw1i1[1]     0.18      0.12     0.02     0.46 1.00     7209
## depcantgow1f_mostjobw1i1[2]     0.32      0.16     0.05     0.66 1.00     6678
## depcantgow1f_mostjobw1i1[3]     0.30      0.16     0.05     0.65 1.00     7316
## depcantgow1f_mostjobw1i1[4]     0.20      0.12     0.03     0.50 1.00     6812
## depeffortw1f_mostjobw1i1[1]     0.25      0.14     0.04     0.56 1.00     7920
## depeffortw1f_mostjobw1i1[2]     0.21      0.13     0.03     0.53 1.00     7496
## depeffortw1f_mostjobw1i1[3]     0.23      0.14     0.03     0.53 1.00     7376
## depeffortw1f_mostjobw1i1[4]     0.31      0.16     0.05     0.65 1.00     6658
## deplonelyw1f_mostjobw1i1[1]     0.26      0.15     0.04     0.60 1.00     6826
## deplonelyw1f_mostjobw1i1[2]     0.25      0.15     0.04     0.58 1.00     7311
## deplonelyw1f_mostjobw1i1[3]     0.24      0.14     0.04     0.58 1.00     7840
## deplonelyw1f_mostjobw1i1[4]     0.25      0.15     0.04     0.59 1.00     6821
## depbluesw1f_mostjobw1i1[1]      0.26      0.15     0.04     0.58 1.00     6378
## depbluesw1f_mostjobw1i1[2]      0.25      0.14     0.04     0.57 1.00     6991
## depbluesw1f_mostjobw1i1[3]      0.25      0.15     0.03     0.59 1.00     6846
## depbluesw1f_mostjobw1i1[4]      0.24      0.14     0.03     0.56 1.00     6569
## depunfairw1f_mostjobw1i1[1]     0.24      0.14     0.04     0.56 1.00     8183
## depunfairw1f_mostjobw1i1[2]     0.23      0.13     0.03     0.53 1.00     6426
## depunfairw1f_mostjobw1i1[3]     0.24      0.14     0.03     0.56 1.00     8784
## depunfairw1f_mostjobw1i1[4]     0.30      0.17     0.04     0.65 1.00     5856
## depmistrtw1f_mostjobw1i1[1]     0.27      0.15     0.04     0.61 1.00     7118
## depmistrtw1f_mostjobw1i1[2]     0.23      0.14     0.03     0.56 1.00     5530
## depmistrtw1f_mostjobw1i1[3]     0.24      0.14     0.03     0.58 1.00     7046
## depmistrtw1f_mostjobw1i1[4]     0.26      0.15     0.03     0.59 1.00     6976
## depbetrayw1f_mostjobw1i1[1]     0.30      0.16     0.05     0.65 1.00     5560
## depbetrayw1f_mostjobw1i1[2]     0.19      0.12     0.02     0.49 1.00     6800
## depbetrayw1f_mostjobw1i1[3]     0.21      0.13     0.03     0.52 1.00     6806
## depbetrayw1f_mostjobw1i1[4]     0.30      0.16     0.05     0.65 1.00     5939
##                             Tail_ESS
## depcantgow1f_mostjobw1i1[1]     2834
## depcantgow1f_mostjobw1i1[2]     2707
## depcantgow1f_mostjobw1i1[3]     3202
## depcantgow1f_mostjobw1i1[4]     3130
## depeffortw1f_mostjobw1i1[1]     2483
## depeffortw1f_mostjobw1i1[2]     2634
## depeffortw1f_mostjobw1i1[3]     2991
## depeffortw1f_mostjobw1i1[4]     3106
## deplonelyw1f_mostjobw1i1[1]     3058
## deplonelyw1f_mostjobw1i1[2]     2649
## deplonelyw1f_mostjobw1i1[3]     2724
## deplonelyw1f_mostjobw1i1[4]     3205
## depbluesw1f_mostjobw1i1[1]      2502
## depbluesw1f_mostjobw1i1[2]      2893
## depbluesw1f_mostjobw1i1[3]      2730
## depbluesw1f_mostjobw1i1[4]      2772
## depunfairw1f_mostjobw1i1[1]     2917
## depunfairw1f_mostjobw1i1[2]     2399
## depunfairw1f_mostjobw1i1[3]     3015
## depunfairw1f_mostjobw1i1[4]     3075
## depmistrtw1f_mostjobw1i1[1]     2838
## depmistrtw1f_mostjobw1i1[2]     3057
## depmistrtw1f_mostjobw1i1[3]     2769
## depmistrtw1f_mostjobw1i1[4]     2794
## depbetrayw1f_mostjobw1i1[1]     2591
## depbetrayw1f_mostjobw1i1[2]     2575
## depbetrayw1f_mostjobw1i1[3]     3292
## depbetrayw1f_mostjobw1i1[4]     3041
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.5.5.5 Prior summary
out.alldepress.stjob.fit[[2]]
##                  prior     class        coef group         resp dpar nlpar lb
##                 (flat)         b                                             
##                 (flat)         b                   depbetrayw1f              
##        normal(0, 0.25)         b  mostjobw1i       depbetrayw1f              
##                 (flat)         b                    depbluesw1f              
##        normal(0, 0.25)         b  mostjobw1i        depbluesw1f              
##                 (flat)         b                   depcantgow1f              
##        normal(0, 0.25)         b  mostjobw1i       depcantgow1f              
##                 (flat)         b                   depeffortw1f              
##        normal(0, 0.25)         b  mostjobw1i       depeffortw1f              
##                 (flat)         b                   deplonelyw1f              
##        normal(0, 0.25)         b  mostjobw1i       deplonelyw1f              
##                 (flat)         b                   depmistrtw1f              
##        normal(0, 0.25)         b  mostjobw1i       depmistrtw1f              
##                 (flat)         b                   depunfairw1f              
##        normal(0, 0.25)         b  mostjobw1i       depunfairw1f              
##                 (flat) Intercept                                             
##           normal(0, 2) Intercept                   depbetrayw1f              
##           normal(0, 2) Intercept                    depbluesw1f              
##           normal(0, 2) Intercept                   depcantgow1f              
##           normal(0, 2) Intercept                   depeffortw1f              
##           normal(0, 2) Intercept                   deplonelyw1f              
##           normal(0, 2) Intercept                   depmistrtw1f              
##           normal(0, 2) Intercept                   depunfairw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       depbetrayw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1        depbluesw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       depcantgow1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       depeffortw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       deplonelyw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       depmistrtw1f              
##  dirichlet(2, 2, 2, 2)      simo mostjobw1i1       depunfairw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.5.6 Bivariate Corr: T1 stthftw1/negative emotions

#Bivariate: depressive symptom items ~ mo(stthftw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostthftw1i', 
                  resp =depdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostthftw1i1', 
                  resp =depdv_names))

alldepress.stthft.fit <- brm(
  mvbind(depcantgow1f, depeffortw1f, deplonelyw1f, depbluesw1f, depunfairw1f, depmistrtw1f, 
         depbetrayw1f) ~ 1 + mo(stthftw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/alldepress_stthft_fit", 
      file_refit = "on_change"
  )

out.alldepress.stthft.fit <- ppchecks(alldepress.stthft.fit)
4.3.5.6.1 Coefficient plot (intervals)
out.alldepress.stthft.fit[[11]]

4.3.5.6.2 Coefficient plot (distributions)
out.alldepress.stthft.fit[[10]]

4.3.5.6.3 PPcheck (density)
p1 <- out.alldepress.stthft.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.alldepress.stthft.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.alldepress.stthft.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.alldepress.stthft.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.alldepress.stthft.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.alldepress.stthft.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.alldepress.stthft.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

4.3.5.6.4 Fit summary
out.alldepress.stthft.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgow1f ~ 1 + mo(stthftw1i) 
##          depeffortw1f ~ 1 + mo(stthftw1i) 
##          deplonelyw1f ~ 1 + mo(stthftw1i) 
##          depbluesw1f ~ 1 + mo(stthftw1i) 
##          depunfairw1f ~ 1 + mo(stthftw1i) 
##          depmistrtw1f ~ 1 + mo(stthftw1i) 
##          depbetrayw1f ~ 1 + mo(stthftw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_Intercept      -0.49      0.13    -0.75    -0.23 1.00     5628
## depeffortw1f_Intercept      -1.94      0.18    -2.31    -1.59 1.00     5537
## deplonelyw1f_Intercept      -1.61      0.17    -1.95    -1.30 1.00     5560
## depbluesw1f_Intercept       -1.53      0.17    -1.85    -1.20 1.00     4612
## depunfairw1f_Intercept      -1.53      0.17    -1.87    -1.20 1.00     5684
## depmistrtw1f_Intercept      -1.94      0.21    -2.38    -1.55 1.00     5364
## depbetrayw1f_Intercept      -2.11      0.22    -2.56    -1.71 1.00     5790
## depcantgow1f_mostthftw1i     0.08      0.08    -0.07     0.24 1.00     5314
## depeffortw1f_mostthftw1i     0.07      0.10    -0.14     0.27 1.00     4635
## deplonelyw1f_mostthftw1i     0.29      0.09     0.12     0.47 1.00     6407
## depbluesw1f_mostthftw1i      0.04      0.10    -0.16     0.25 1.00     4218
## depunfairw1f_mostthftw1i     0.04      0.10    -0.16     0.25 1.00     5113
## depmistrtw1f_mostthftw1i     0.19      0.10     0.00     0.38 1.00     5614
## depbetrayw1f_mostthftw1i     0.27      0.09     0.08     0.45 1.00     6153
##                          Tail_ESS
## depcantgow1f_Intercept       3278
## depeffortw1f_Intercept       2958
## deplonelyw1f_Intercept       2812
## depbluesw1f_Intercept        2843
## depunfairw1f_Intercept       3094
## depmistrtw1f_Intercept       3450
## depbetrayw1f_Intercept       2955
## depcantgow1f_mostthftw1i     3110
## depeffortw1f_mostthftw1i     2852
## deplonelyw1f_mostthftw1i     3089
## depbluesw1f_mostthftw1i      3427
## depunfairw1f_mostthftw1i     3215
## depmistrtw1f_mostthftw1i     2630
## depbetrayw1f_mostthftw1i     3330
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_mostthftw1i1[1]     0.25      0.15     0.04     0.58 1.00     8169
## depcantgow1f_mostthftw1i1[2]     0.24      0.14     0.04     0.56 1.00     7489
## depcantgow1f_mostthftw1i1[3]     0.25      0.14     0.04     0.57 1.00     6620
## depcantgow1f_mostthftw1i1[4]     0.26      0.15     0.04     0.60 1.00     7254
## depeffortw1f_mostthftw1i1[1]     0.23      0.14     0.03     0.58 1.00     6541
## depeffortw1f_mostthftw1i1[2]     0.24      0.14     0.04     0.56 1.00     7741
## depeffortw1f_mostthftw1i1[3]     0.27      0.15     0.04     0.61 1.00     6774
## depeffortw1f_mostthftw1i1[4]     0.26      0.15     0.04     0.60 1.00     7232
## deplonelyw1f_mostthftw1i1[1]     0.19      0.11     0.03     0.45 1.00     7225
## deplonelyw1f_mostthftw1i1[2]     0.23      0.12     0.04     0.52 1.00     7385
## deplonelyw1f_mostthftw1i1[3]     0.35      0.15     0.08     0.66 1.00     7005
## deplonelyw1f_mostthftw1i1[4]     0.23      0.12     0.04     0.49 1.00     6987
## depbluesw1f_mostthftw1i1[1]      0.23      0.14     0.03     0.55 1.00     7504
## depbluesw1f_mostthftw1i1[2]      0.22      0.14     0.03     0.55 1.00     6062
## depbluesw1f_mostthftw1i1[3]      0.28      0.16     0.04     0.63 1.00     4883
## depbluesw1f_mostthftw1i1[4]      0.27      0.15     0.04     0.60 1.00     6327
## depunfairw1f_mostthftw1i1[1]     0.23      0.14     0.03     0.57 1.00     6126
## depunfairw1f_mostthftw1i1[2]     0.23      0.14     0.03     0.56 1.00     7070
## depunfairw1f_mostthftw1i1[3]     0.26      0.15     0.04     0.61 1.00     6558
## depunfairw1f_mostthftw1i1[4]     0.28      0.16     0.04     0.64 1.00     5274
## depmistrtw1f_mostthftw1i1[1]     0.34      0.16     0.06     0.67 1.00     5952
## depmistrtw1f_mostthftw1i1[2]     0.22      0.13     0.03     0.53 1.00     7440
## depmistrtw1f_mostthftw1i1[3]     0.20      0.12     0.03     0.48 1.00     6469
## depmistrtw1f_mostthftw1i1[4]     0.24      0.14     0.03     0.54 1.00     6953
## depbetrayw1f_mostthftw1i1[1]     0.29      0.14     0.05     0.59 1.00     6586
## depbetrayw1f_mostthftw1i1[2]     0.30      0.15     0.06     0.62 1.00     7299
## depbetrayw1f_mostthftw1i1[3]     0.20      0.12     0.03     0.47 1.00     7814
## depbetrayw1f_mostthftw1i1[4]     0.20      0.11     0.03     0.48 1.00     6879
##                              Tail_ESS
## depcantgow1f_mostthftw1i1[1]     2747
## depcantgow1f_mostthftw1i1[2]     2759
## depcantgow1f_mostthftw1i1[3]     2080
## depcantgow1f_mostthftw1i1[4]     3034
## depeffortw1f_mostthftw1i1[1]     2584
## depeffortw1f_mostthftw1i1[2]     2858
## depeffortw1f_mostthftw1i1[3]     3009
## depeffortw1f_mostthftw1i1[4]     2939
## deplonelyw1f_mostthftw1i1[1]     2845
## deplonelyw1f_mostthftw1i1[2]     2482
## deplonelyw1f_mostthftw1i1[3]     2903
## deplonelyw1f_mostthftw1i1[4]     3007
## depbluesw1f_mostthftw1i1[1]      3144
## depbluesw1f_mostthftw1i1[2]      2403
## depbluesw1f_mostthftw1i1[3]      2669
## depbluesw1f_mostthftw1i1[4]      2979
## depunfairw1f_mostthftw1i1[1]     2800
## depunfairw1f_mostthftw1i1[2]     2467
## depunfairw1f_mostthftw1i1[3]     2808
## depunfairw1f_mostthftw1i1[4]     2546
## depmistrtw1f_mostthftw1i1[1]     2897
## depmistrtw1f_mostthftw1i1[2]     2945
## depmistrtw1f_mostthftw1i1[3]     3059
## depmistrtw1f_mostthftw1i1[4]     2898
## depbetrayw1f_mostthftw1i1[1]     2515
## depbetrayw1f_mostthftw1i1[2]     2822
## depbetrayw1f_mostthftw1i1[3]     2827
## depbetrayw1f_mostthftw1i1[4]     2817
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.5.6.5 Prior summary
out.alldepress.stthft.fit[[2]]
##                  prior     class         coef group         resp dpar nlpar lb
##                 (flat)         b                                              
##                 (flat)         b                    depbetrayw1f              
##        normal(0, 0.25)         b  mostthftw1i       depbetrayw1f              
##                 (flat)         b                     depbluesw1f              
##        normal(0, 0.25)         b  mostthftw1i        depbluesw1f              
##                 (flat)         b                    depcantgow1f              
##        normal(0, 0.25)         b  mostthftw1i       depcantgow1f              
##                 (flat)         b                    depeffortw1f              
##        normal(0, 0.25)         b  mostthftw1i       depeffortw1f              
##                 (flat)         b                    deplonelyw1f              
##        normal(0, 0.25)         b  mostthftw1i       deplonelyw1f              
##                 (flat)         b                    depmistrtw1f              
##        normal(0, 0.25)         b  mostthftw1i       depmistrtw1f              
##                 (flat)         b                    depunfairw1f              
##        normal(0, 0.25)         b  mostthftw1i       depunfairw1f              
##                 (flat) Intercept                                              
##           normal(0, 2) Intercept                    depbetrayw1f              
##           normal(0, 2) Intercept                     depbluesw1f              
##           normal(0, 2) Intercept                    depcantgow1f              
##           normal(0, 2) Intercept                    depeffortw1f              
##           normal(0, 2) Intercept                    deplonelyw1f              
##           normal(0, 2) Intercept                    depmistrtw1f              
##           normal(0, 2) Intercept                    depunfairw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       depbetrayw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1        depbluesw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       depcantgow1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       depeffortw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       deplonelyw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       depmistrtw1f              
##  dirichlet(2, 2, 2, 2)      simo mostthftw1i1       depunfairw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user

4.3.5.7 Bivariate Corr: T1 stmugw1/negative emotions

#Bivariate: depressive symptom items ~ mo(stmugw1i)

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmugw1i', 
                  resp =depdv_names),
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmugw1i1', 
                  resp =depdv_names))

alldepress.stmug.fit <- brm(
  mvbind(depcantgow1f, depeffortw1f, deplonelyw1f, depbluesw1f, depunfairw1f, depmistrtw1f, 
         depbetrayw1f) ~ 1 + mo(stmugw1i),  
      data = stress.wide3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/alldepress_stmug_fit", 
      file_refit = "on_change"
  )

out.alldepress.stmug.fit <- ppchecks(alldepress.stmug.fit)
4.3.5.7.1 Coefficient plot (intervals)
out.alldepress.stmug.fit[[11]]

4.3.5.7.2 Coefficient plot (distributions)
out.alldepress.stmug.fit[[10]]

4.3.5.7.3 PPcheck (density)
p1 <- out.alldepress.stmug.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.alldepress.stmug.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.alldepress.stmug.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.alldepress.stmug.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.alldepress.stmug.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.alldepress.stmug.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.alldepress.stmug.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

4.3.5.7.4 Fit summary
out.alldepress.stmug.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgow1f ~ 1 + mo(stmugw1i) 
##          depeffortw1f ~ 1 + mo(stmugw1i) 
##          deplonelyw1f ~ 1 + mo(stmugw1i) 
##          depbluesw1f ~ 1 + mo(stmugw1i) 
##          depunfairw1f ~ 1 + mo(stmugw1i) 
##          depmistrtw1f ~ 1 + mo(stmugw1i) 
##          depbetrayw1f ~ 1 + mo(stmugw1i) 
##    Data: stress.wide3 (Number of observations: 489) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Regression Coefficients:
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_Intercept     -0.45      0.12    -0.69    -0.22 1.00     5005
## depeffortw1f_Intercept     -2.03      0.18    -2.40    -1.69 1.00     5277
## deplonelyw1f_Intercept     -1.55      0.15    -1.84    -1.27 1.00     5842
## depbluesw1f_Intercept      -1.52      0.15    -1.82    -1.21 1.00     5060
## depunfairw1f_Intercept     -1.55      0.15    -1.85    -1.26 1.00     4828
## depmistrtw1f_Intercept     -2.37      0.24    -2.86    -1.94 1.00     4394
## depbetrayw1f_Intercept     -2.38      0.23    -2.86    -1.94 1.00     4598
## depcantgow1f_mostmugw1i     0.06      0.09    -0.12     0.23 1.00     4123
## depeffortw1f_mostmugw1i     0.18      0.12    -0.04     0.42 1.00     4452
## deplonelyw1f_mostmugw1i     0.32      0.11     0.13     0.54 1.00     4545
## depbluesw1f_mostmugw1i      0.04      0.11    -0.18     0.28 1.00     3715
## depunfairw1f_mostmugw1i     0.08      0.11    -0.13     0.31 1.00     4096
## depmistrtw1f_mostmugw1i     0.50      0.10     0.31     0.70 1.00     5011
## depbetrayw1f_mostmugw1i     0.46      0.10     0.27     0.66 1.00     4796
##                         Tail_ESS
## depcantgow1f_Intercept      3457
## depeffortw1f_Intercept      2909
## deplonelyw1f_Intercept      3333
## depbluesw1f_Intercept       3140
## depunfairw1f_Intercept      3278
## depmistrtw1f_Intercept      2983
## depbetrayw1f_Intercept      2968
## depcantgow1f_mostmugw1i     3266
## depeffortw1f_mostmugw1i     3039
## deplonelyw1f_mostmugw1i     2725
## depbluesw1f_mostmugw1i      3255
## depunfairw1f_mostmugw1i     2995
## depmistrtw1f_mostmugw1i     3076
## depbetrayw1f_mostmugw1i     3167
## 
## Monotonic Simplex Parameters:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgow1f_mostmugw1i1[1]     0.25      0.14     0.03     0.58 1.00     6296
## depcantgow1f_mostmugw1i1[2]     0.26      0.15     0.04     0.58 1.00     6819
## depcantgow1f_mostmugw1i1[3]     0.23      0.14     0.04     0.56 1.00     7007
## depcantgow1f_mostmugw1i1[4]     0.27      0.15     0.04     0.60 1.00     6006
## depeffortw1f_mostmugw1i1[1]     0.25      0.14     0.04     0.56 1.00     6802
## depeffortw1f_mostmugw1i1[2]     0.20      0.13     0.03     0.50 1.00     7382
## depeffortw1f_mostmugw1i1[3]     0.26      0.14     0.04     0.58 1.00     6612
## depeffortw1f_mostmugw1i1[4]     0.29      0.15     0.05     0.62 1.00     6412
## deplonelyw1f_mostmugw1i1[1]     0.18      0.11     0.03     0.43 1.00     7230
## deplonelyw1f_mostmugw1i1[2]     0.25      0.13     0.04     0.54 1.00     6692
## deplonelyw1f_mostmugw1i1[3]     0.29      0.15     0.06     0.62 1.00     7298
## deplonelyw1f_mostmugw1i1[4]     0.27      0.15     0.05     0.59 1.00     5887
## depbluesw1f_mostmugw1i1[1]      0.22      0.14     0.03     0.56 1.00     5371
## depbluesw1f_mostmugw1i1[2]      0.23      0.14     0.04     0.55 1.00     6510
## depbluesw1f_mostmugw1i1[3]      0.27      0.15     0.04     0.61 1.00     6657
## depbluesw1f_mostmugw1i1[4]      0.27      0.15     0.04     0.62 1.00     6852
## depunfairw1f_mostmugw1i1[1]     0.20      0.14     0.02     0.53 1.00     5047
## depunfairw1f_mostmugw1i1[2]     0.25      0.14     0.04     0.57 1.00     6302
## depunfairw1f_mostmugw1i1[3]     0.27      0.15     0.04     0.61 1.00     6280
## depunfairw1f_mostmugw1i1[4]     0.27      0.15     0.04     0.60 1.00     6642
## depmistrtw1f_mostmugw1i1[1]     0.38      0.12     0.14     0.62 1.00     5343
## depmistrtw1f_mostmugw1i1[2]     0.25      0.12     0.05     0.50 1.00     5756
## depmistrtw1f_mostmugw1i1[3]     0.21      0.10     0.04     0.44 1.00     8034
## depmistrtw1f_mostmugw1i1[4]     0.16      0.09     0.03     0.38 1.00     6288
## depbetrayw1f_mostmugw1i1[1]     0.39      0.13     0.14     0.64 1.00     5235
## depbetrayw1f_mostmugw1i1[2]     0.22      0.12     0.04     0.49 1.00     6298
## depbetrayw1f_mostmugw1i1[3]     0.23      0.12     0.05     0.48 1.00     6223
## depbetrayw1f_mostmugw1i1[4]     0.16      0.09     0.02     0.37 1.00     6743
##                             Tail_ESS
## depcantgow1f_mostmugw1i1[1]     2347
## depcantgow1f_mostmugw1i1[2]     2965
## depcantgow1f_mostmugw1i1[3]     2649
## depcantgow1f_mostmugw1i1[4]     2105
## depeffortw1f_mostmugw1i1[1]     2880
## depeffortw1f_mostmugw1i1[2]     3445
## depeffortw1f_mostmugw1i1[3]     2704
## depeffortw1f_mostmugw1i1[4]     3096
## deplonelyw1f_mostmugw1i1[1]     2655
## deplonelyw1f_mostmugw1i1[2]     2747
## deplonelyw1f_mostmugw1i1[3]     2909
## deplonelyw1f_mostmugw1i1[4]     2975
## depbluesw1f_mostmugw1i1[1]      2668
## depbluesw1f_mostmugw1i1[2]      2558
## depbluesw1f_mostmugw1i1[3]      2864
## depbluesw1f_mostmugw1i1[4]      3102
## depunfairw1f_mostmugw1i1[1]     2950
## depunfairw1f_mostmugw1i1[2]     2921
## depunfairw1f_mostmugw1i1[3]     2915
## depunfairw1f_mostmugw1i1[4]     2835
## depmistrtw1f_mostmugw1i1[1]     2819
## depmistrtw1f_mostmugw1i1[2]     2789
## depmistrtw1f_mostmugw1i1[3]     3199
## depmistrtw1f_mostmugw1i1[4]     3031
## depbetrayw1f_mostmugw1i1[1]     2800
## depbetrayw1f_mostmugw1i1[2]     2504
## depbetrayw1f_mostmugw1i1[3]     3141
## depbetrayw1f_mostmugw1i1[4]     2873
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
4.3.5.7.5 Prior summary
out.alldepress.stmug.fit[[2]]
##                  prior     class        coef group         resp dpar nlpar lb
##                 (flat)         b                                             
##                 (flat)         b                   depbetrayw1f              
##        normal(0, 0.25)         b  mostmugw1i       depbetrayw1f              
##                 (flat)         b                    depbluesw1f              
##        normal(0, 0.25)         b  mostmugw1i        depbluesw1f              
##                 (flat)         b                   depcantgow1f              
##        normal(0, 0.25)         b  mostmugw1i       depcantgow1f              
##                 (flat)         b                   depeffortw1f              
##        normal(0, 0.25)         b  mostmugw1i       depeffortw1f              
##                 (flat)         b                   deplonelyw1f              
##        normal(0, 0.25)         b  mostmugw1i       deplonelyw1f              
##                 (flat)         b                   depmistrtw1f              
##        normal(0, 0.25)         b  mostmugw1i       depmistrtw1f              
##                 (flat)         b                   depunfairw1f              
##        normal(0, 0.25)         b  mostmugw1i       depunfairw1f              
##                 (flat) Intercept                                             
##           normal(0, 2) Intercept                   depbetrayw1f              
##           normal(0, 2) Intercept                    depbluesw1f              
##           normal(0, 2) Intercept                   depcantgow1f              
##           normal(0, 2) Intercept                   depeffortw1f              
##           normal(0, 2) Intercept                   deplonelyw1f              
##           normal(0, 2) Intercept                   depmistrtw1f              
##           normal(0, 2) Intercept                   depunfairw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       depbetrayw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1        depbluesw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       depcantgow1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       depeffortw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       deplonelyw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       depmistrtw1f              
##  dirichlet(2, 2, 2, 2)      simo mostmugw1i1       depunfairw1f              
##  ub  source
##     default
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##     default
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
##        user
save(stress.wide3, file = here("1_Data_Files/Datasets/stress_wide3.Rdata"))

5 Visualizing T1 correlations (RQ2A)

(RMD FILE: BDK_2023_Stress_4_T1corr_viz)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

5.1 Visualizing “bivariate” T1 associations

Now that we have estimated all these bivariate models, we need a way to efficiently visualize all these associations. Let’s start by visualizing the association between one of the seven stress items and all six past crime items. We will start by grabbing and plotting a full range of posterior predicted expected crime probabilities for each stress category, using the stmonyw1i item as an example. For a good description of differences across the types of posterior predictions you can request, see Andrew Heiss’s blog.

5.1.1 PP Exp Past Crime Probability Distributions by Stress Category

#load stress.wide (from Fig1 Rmd) 
load(here("1_Data_Files/Datasets/stress_wide.Rdata"))

stress.wide <- zap_labels(stress.wide)
stress.wide <- zap_label(stress.wide)

load(here("1_Data_Files/Datasets/stress_wide2.Rdata"))
load(here("1_Data_Files/Datasets/stress_wide3.Rdata"))

#load bivariate brms model fits 
#past crime
allpstcrime.stmony.fit <- readRDS(here("Models/allpstcrime_stmony_fit.rds"))
allpstcrime.sttran.fit <- readRDS(here("Models/allpstcrime_sttran_fit.rds"))
allpstcrime.stresp.fit <- readRDS(here("Models/allpstcrime_stresp_fit.rds"))
allpstcrime.stfair.fit <- readRDS(here("Models/allpstcrime_stfair_fit.rds"))
allpstcrime.stjob.fit <- readRDS(here("Models/allpstcrime_stjob_fit.rds"))
allpstcrime.stthft.fit <- readRDS(here("Models/allpstcrime_stthft_fit.rds"))
allpstcrime.stmug.fit <- readRDS(here("Models/allpstcrime_stmug_fit.rds"))
anypstcrime.stmony.fit <- readRDS(here("Models/anypstcrime_stmony_fit.rds"))
anypstcrime.sttran.fit <- readRDS(here("Models/anypstcrime_sttran_fit.rds"))
anypstcrime.stresp.fit <- readRDS(here("Models/anypstcrime_stresp_fit.rds"))
anypstcrime.stfair.fit <- readRDS(here("Models/anypstcrime_stfair_fit.rds"))
anypstcrime.stjob.fit <- readRDS(here("Models/anypstcrime_stjob_fit.rds"))
anypstcrime.stthft.fit <- readRDS(here("Models/anypstcrime_stthft_fit.rds"))
anypstcrime.stmug.fit <- readRDS(here("Models/anypstcrime_stmug_fit.rds"))
#criminal intent
allprjcrime.stmony.fit <- readRDS(here("Models/allprjcrime_stmony_fit.rds"))
allprjcrime.sttran.fit <- readRDS(here("Models/allprjcrime_sttran_fit.rds"))
allprjcrime.stresp.fit <- readRDS(here("Models/allprjcrime_stresp_fit.rds"))
allprjcrime.stfair.fit <- readRDS(here("Models/allprjcrime_stfair_fit.rds"))
allprjcrime.stjob.fit <- readRDS(here("Models/allprjcrime_stjob_fit.rds"))
allprjcrime.stthft.fit <- readRDS(here("Models/allprjcrime_stthft_fit.rds"))
allprjcrime.stmug.fit <- readRDS(here("Models/allprjcrime_stmug_fit.rds"))
anyprjcrime.stmony.fit <- readRDS(here("Models/anyprjcrime_stmony_fit.rds"))
anyprjcrime.sttran.fit <- readRDS(here("Models/anyprjcrime_sttran_fit.rds"))
anyprjcrime.stresp.fit <- readRDS(here("Models/anyprjcrime_stresp_fit.rds"))
anyprjcrime.stfair.fit <- readRDS(here("Models/anyprjcrime_stfair_fit.rds"))
anyprjcrime.stjob.fit <- readRDS(here("Models/anyprjcrime_stjob_fit.rds"))
anyprjcrime.stthft.fit <- readRDS(here("Models/anyprjcrime_stthft_fit.rds"))
anyprjcrime.stmug.fit <- readRDS(here("Models/anyprjcrime_stmug_fit.rds"))
#negative emotions
alldepress.stmony.fit <- readRDS(here("Models/alldepress_stmony_fit.rds"))
alldepress.sttran.fit <- readRDS(here("Models/alldepress_sttran_fit.rds"))
alldepress.stresp.fit <- readRDS(here("Models/alldepress_stresp_fit.rds"))
alldepress.stfair.fit <- readRDS(here("Models/alldepress_stfair_fit.rds"))
alldepress.stjob.fit <- readRDS(here("Models/alldepress_stjob_fit.rds"))
alldepress.stthft.fit <- readRDS(here("Models/alldepress_stthft_fit.rds"))
alldepress.stmug.fit <- readRDS(here("Models/alldepress_stmug_fit.rds"))
# http://mjskay.github.io/tidybayes/articles/tidy-brms.html
theme_set(theme_tidybayes())
epred.stmony <- stress.wide3 %>%
  data_grid(stmonyw1i) %>%
  add_epred_draws(allpstcrime.stmony.fit) 

#epred
ggplot(data=epred.stmony, aes(y= .epred, x= stmonyw1i)) +
  facet_wrap(~ .category, nrow=3, ncol=2, ) +
  scale_x_continuous(breaks=c(1,2,3,4,5), name="Stress: Money") +
  scale_y_continuous(name="Posterior expected probability of crime")+
  stat_halfeye(.width=.95, size=.5) +
  coord_flip(ylim=c(0,.3))

This is certainly an informative summary of the association between stress about money and each of the six binary past crime items. However, we have six more stress items, multiplied by two more dependent variables, and again by each of our four community groups. That is a lot of figures - just to summarize bivariate associations at T1! Then, we have change correlations and other analyses. We need a more efficient way to summarize these six associations. We can start by extracting the most pertinent information from these predictive distributions - the fitted (median) posterior probability estimates and uncertainty intervals, then plot them using a simpler stat interval format.

5.1.2 PP Exp Past Crime Probability Est/Intervals by Stress Category

#function to find & drop leading zeroes (used for x-axis label)
dropLeadingZero <- function(l){
  str_replace(l, '0(?=.)', '')
}

#fitted median_qi
fitted.stmony <- stress.wide3 %>%
  data_grid(stmonyw1i) %>%
  add_epred_draws(allpstcrime.stmony.fit) %>% 
  median_qi(.epred)

pstcrimelabs <- c("pstthflt5w1f"="Theft <5BAM", 
              "pstthfgt5w1f"="Theft >5BAM", 
              "pstthreatw1f"="Threaten", 
              "pstharmw1f"="Phys. harm",
              "pstusedrgw1f"="Use drugs",
              "psthackw1f"="Hack info.")

ggplot(data=fitted.stmony, 
       aes(x= .epred, y= stmonyw1i, xmin=.lower, xmax=.upper)) +
  facet_wrap(~ .category, nrow=1,  
             labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  scale_y_continuous(breaks=c(1,2,3,4,5), 
                     name="Stress: Money") +
  scale_x_continuous(breaks=c(0,.1,.2,.3,.4), 
                     labels = dropLeadingZero, name="Posterior expected probability of past crime at T1") +
  geom_pointinterval() +
  coord_cartesian(xlim=c(0,.4))

#fitted values in figure below replicate those plotted in the posterior expectation predictions above

That condenses our summary plots while still retaining most of the useful information. But again, we have a LOT more information to add. Let’s try dropping a couple categories from our stress item to further condense things.

5.1.3 PP Exp Past Crime Probability Est/Intervals by Stress Category (Condensed)

stress3catlabs <- c("1"="Never",
                    "3"="Sometimes",
                    "5"="Very often")

ggplot(data=droplevels(subset(fitted.stmony, stmonyw1i %in% c(1,3,5))), 
       aes(x= .epred, y= stmonyw1i, xmin=.lower, xmax=.upper)) +
  facet_wrap(~ .category, nrow=1,  
             labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  scale_y_continuous(breaks=c(1,3,5), 
                     labels = stress3catlabs, name="Stress: Money") +
  scale_x_continuous(breaks=c(0,.1,.2,.3,.4), 
                     labels = dropLeadingZero, name="Posterior expected probability of past crime at T1") +
  geom_pointinterval() +
  coord_cartesian(xlim=c(0,.4))

Even better. We could combine six more plots like this - one for each of our stress items - into a single plot to summarize the associations between stress and crime at T1 in the full sample. But we also have to estimate these associations in our community subsamples. Perhaps we can condense things even further. Instead of plotting distributions of predicted values for specific stress categories, we could instead plot something akin to a regression beta coefficient, as is found in a typical forest plot of effect sizes. However, rather than simply visualizing the model’s outputted b for each stress item (like we did above after building each model), which summarizes associations with the latent DV on the log odds scale, we will want to do some transformations to maximize the meaningfulness or interpretive utility of our summary plots.

One benefit of specifying the cumulative ordinal distribution for our IV with brms built-in mo() function is that the beta coefficient from these brms ordinal IV models is comparable in interpretation to the beta from a classic logistic regression model - it represents the average increase in the log odds of the latent DV associated with a one threshold unit increase in the ordinal IV (see Buerkner). From this beta, we can calculate a “maximum” effect size by multiplying the beta coefficient by the number of ordinal IV thresholds (see McElreath; Kurz), which represents the estimated increase or decrease in Y associated with increasing from the lowest IV response category (minimum subjective stress, or Never) to the highest IV response category (maximum subjective stress, or Very often). This “max” estimate is useful for interpreting the theoretical “maximum effect” of a predictor that can be expected given the data and priors; it is also useful for comparing estimated effects of variables with different response scales. Such a max transformation would also be useful as a normalized counterfactual comparison in interpreting longitudinal change score associations representing the predicted effect of increasing (decreasing) from minimum to maximum (or vice versa) stress on changes in the probability of crime. However, as a counterfactual comparison, it is important to consider whether such a comparison might be based on implausible out-of-sample predictions - that is, we may not observe any “maximum” changes from the lowest (highest) stress response category to the highest (lowest) stress response category in our two-year panel data.

For now, let’s try it to get a sense of how we might examine a maximum contrast. We’ll start by estimating the “maximum” effect of stress about money at T1 (stmonyw1) on past theft less than 5BAM at T1 (pstthflt5w1), followed by the same maximum contrast estimate for stress about assault (stmugw1).

5.1.4 PP “Maximum” Effect Size of Stress on Past Crime (beta)

Maximum contrast estimate for stress about money at T1 (stmonyw1) and past theft less than 5BAM at T1 (pstthflt5w1).

#https://bookdown.org/content/4857/monsters-and-mixtures.html#ordered-categorical-predictors

#From Kurz: 
  #"To clarify, the b in this section is what we’re calling βE in the current example and Bürkner and Charpentier used ζi in place of McElreath’s δj. The upshot of all this is that if we’d like to compare the summary of our b12.6 to the results McElreath reported for his m12.6, we’ll need to multiply our moedu_new by 7."

# posterior_samples(allpstcrime.stmony.fit) %>%
#   glimpse()

as_draws_df(allpstcrime.stmony.fit) %>% 
  transmute(bE = bsp_pstthflt5w1f_mostmonyw1i * 4) %>% 
  median_qi(.width = .95) %>%  
  mutate_if(is.double, round, digits = 2)
## # A tibble: 1 × 6
##      bE .lower .upper .width .point .interval
##   <dbl>  <dbl>  <dbl>  <dbl> <chr>  <chr>    
## 1  0.15   -0.7   1.09   0.95 median qi

Estimated maximum effect for stress about assault at T1 (stmugw1) and past theft less than 5BAM at T1 (pstthflt5w1).

as_draws_df(allpstcrime.stmug.fit) %>% 
  transmute(bE = bsp_pstthflt5w1f_mostmugw1i * 4) %>% 
  median_qi(.width = .95) %>%  
  mutate_if(is.double, round, digits = 2)
## # A tibble: 1 × 6
##      bE .lower .upper .width .point .interval
##   <dbl>  <dbl>  <dbl>  <dbl> <chr>  <chr>    
## 1  0.33  -0.61   1.24   0.95 median qi

5.1.5 PP “Maximum” Effect Size of Stress on Past Crime (5-1 category contrast pred margins)

As above, we could continue to generate posterior samples for every stress/crime item combination, then calculate predicted probabilities and their differences for certain contrasts (e.g., stress = 1 versus = 5).

However, another way to approach summarizing each association would be to estimate and plot the predictive margins, or the predicted probabilities for each crime item, at all response levels of each stress item, from the current model fits. We can use the marginal_effects function from brms (and tidybayes) to do this.

Note that the name is a bit misleading. This function indeed calculates predictive margins on the outcome scale by stress category in a bivariate model like ours. However, when additional covariates are included in the model, the marginal effects function does not output marginalized predictions used to calculate average marginal effects (AME) - that is, predictions are not marginalized over all values of other covariates. Rather, the function outputs conditional predicted probabilities, or conditional predictive margins, which are used to calculate the simpler marginal effects at representative values (MER) instead. (For more information, see Andrew Heiss’s excellent explanation.) So, when we add additional predictors to our model, we will want to change to an alternative approach for estimating average marginal effects, such as with the “marginaleffects” package.

#marginal_effects command technically outputs conditional effects, 
# http://paul-buerkner.github.io/brms/reference/marginal_effects.html
  # aka marginal effects at representative values (MERs)
  # not an issue in bivariate model w/o covariates
  # BUT, when those are added, ideally we would marginalize out effects of covars
  # by averaging effect of IV "A" on y (E[y|A] across all values of covars B, C, etc. 
  # See also: https://github.com/paul-buerkner/brms/issues/552
  # http://htmlpreview.github.io/?https://github.com/mjskay/uncertainty-examples/blob/master/marginal-effects_categorical-predictor.html

## plot all marginal effects
p.mer.mony.pstcrim <- plot(conditional_effects(allpstcrime.stmony.fit), ask = FALSE)

p.mer.mony.pstcrim$pstthflt5w1f.pstthflt5w1f_stmonyw1i + 
  p.mer.mony.pstcrim$pstthfgt5w1f.pstthfgt5w1f_stmonyw1i + 
  p.mer.mony.pstcrim$pstthreatw1f.pstthreatw1f_stmonyw1i +
  p.mer.mony.pstcrim$pstharmw1f.pstharmw1f_stmonyw1i + 
  p.mer.mony.pstcrim$pstusedrgw1f.pstusedrgw1f_stmonyw1i + 
  p.mer.mony.pstcrim$psthackw1f.psthackw1f_stmonyw1i +
        plot_layout(ncol = 3)

  plot_annotation(
    title = 'MER, Stress abt Money on Past Crime')
## $title
## [1] "MER, Stress abt Money on Past Crime"
## 
## $subtitle
## NULL
## 
## $caption
## NULL
## 
## $tag_levels
## NULL
## 
## $tag_prefix
## NULL
## 
## $tag_suffix
## NULL
## 
## $tag_sep
## NULL
## 
## $theme
##  Named list()
##  - attr(*, "class")= chr [1:2] "theme" "gg"
##  - attr(*, "complete")= logi FALSE
##  - attr(*, "validate")= logi TRUE
## 
## attr(,"class")
## [1] "plot_annotation"
# For AMEs intead (equivalent w/out covariates), try:
# allpstcrime.stmony.mfx <- marginaleffects(allpstcrime.stmony.fit)
# summary(allpstcrime.stmony.mfx)

# save posterior draws for plotting
# allpstcrime.stmony.mfx <- marginaleffects(allpstcrime.stmony.fit) %>%
#   posteriordraws()

# or for AME manual approach with tidybayes compare_levels, see:
# https://htmlpreview.github.io/?https://github.com/mjskay/uncertainty-examples/blob/master/marginal-effects_categorical-predictor.html#differences-in-ames

Alternatively, we could calculate and display the posterior distribution for the difference in expected proportions between two specific categories of stress. To do this, we might begin by plotting the posterior distribution of expected values for the probability of each crime item, or the posterior distributions for predictive margins, for each stress response category. Then, as mentioned before, we might narrow our focus to estimating and visualizing the “maximum” marginal effect by contrasting expected probabilities from the lowest (1=never) and highest (5=very often) stress categories. We can follow by taking the posterior difference distribution for these two contrasts.

First, let’s plot the posterior predictions for all five stress response categories and all six past crime items. These plots are inspired by Matthew Kay’s impressive efforts here.

plotpredmarg_stmony_pstcrim_T1 = stress.wide3 %>%
  data_grid(stmonyw1i) %>%                            # condition on everything
  add_epred_draws(allpstcrime.stmony.fit, value = "E[y|stmonyw1i]") %>%  # get conditional expectations
  ggplot(aes(y = paste0("E[y|stmonyw1i = ", stmonyw1i, "]"), x = `E[y|stmonyw1i]`, fill = stmonyw1i)) +
  stat_halfeye() +
  xlim(0, .35) +
  facet_grid(rows=vars(.category), cols=NULL,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  ylab(NULL) +
  xlab("E[y|stmonyw1i], bivariate") +
  geom_vline(xintercept = c(0, 1))
plotpredmarg_stmony_pstcrim_T1

As the plot shows, the predicted probability of past crime does not appear to vary much across the stress about money response categories. As such, we would expect the contrasts, or marginal effects, to be very small, with posterior predictive difference distributions centered close to and spanning “zero” difference in predicted probability of crime. Let’s begin by plotting all possible contrasts (e.g., 1=never vs. 2=rarely; 1=never* vs. 3=sometimes, etc.). Then we can narrow in on specific meaningful contrasts, such as 1=never vs. 5=very often representing the “maximum marginal effect” of the stress about money item on past crime.

#updated tidybayes to 3.0 & redone using add_epred_draws instead of add_fitted_draws 

#use efficient & transparent caching
  # https://bookdown.org/yihui/rmarkdown-cookbook/cache-rds.html

predmarg_stmony_pstcrim_T1 = stress.wide3 %>%
  data_grid(stmonyw1i) %>%                # get draws for each stress item response cat
  # add_fitted_draws(allpstcrime.stmony.fit) %>%  # add_fitted_draws depricated in tidybayes 3.0 
  add_epred_draws(allpstcrime.stmony.fit) %>%  # getting expected values by stress cat
  group_by(.category, stmonyw1i, .draw)   # grouping by crime type (multivar DVs)

# we can use compare_levels to calculate the mean difference
  # (changed .value to .epred after updating to add_epred_draws)
margeffs_stmony_pstcrim_T1 = xfun::cache_rds({ 
  predmarg_stmony_pstcrim_T1 %>%
  compare_levels(.epred, by = stmonyw1i) %>%         # pairwise differences in `E[y|A]`, by levels of A
  rename(`difference in E[y|stress]` = `.epred`)         # give this column a more accurate name
}, file = "cache_4_1a")

# plot all stress response category contrasts (10)   
margeffs_stmony_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stress]`, y = stmonyw1i)) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.15,.15))

As expected, these marginal effect contrasts all center around zero.

Focusing on the maximum marginal effect, or the “5-1” contrast, seemed like a good idea for interpretive reasons. After all, if we want to ensure that stress process theories are given the benefit of doubt, then the maximum marginal effect estimate seems like a good place to start. However, as the figure above shows, this contrast also has the widest uncertainty intervals. This should be expected considering how uncertainty bands around the predictive margins increased at the ends of the stress response distribution in our “MER” line plots above.

On its face, a disperse uncertainty interval around the maximum marginal effect, hereafter “MaxME”, essentially tells us that a wide range of predictive differences in crime probabilities are plausible - in this case, including differences in negative and positive directions - between those who reportedly never versus very often stress about money. This is perhaps unsurprising given the relative rarity of our crime outcomes; it might also be a quite appropriate, informative, and parsimonious summary of the very weak or null magnitudes observed for these stress/past crime associations. For now, let’s focus on the “MaxME” contrast (in our case, the “5-1” contrast) as planned. We can revisit this decision if we deem the contrast to be problematic (e.g., exhibiting exaggerated uncertainty relative to other contrasts) or otherwise non-representative for the associations we are summarizing and then consider a shift to more complex alternatives.

#MME short for MaxME
MME_stmony_pstcrim_T1 = xfun::cache_rds({
  predmarg_stmony_pstcrim_T1 %>%
    filter(stmonyw1i=="1" | stmonyw1i=="5") %>%
  compare_levels(.epred, by = stmonyw1i) %>%         # pairwise differences in `E[y|A]`, by levels of A
  rename(`difference in E[y|stmonyw1i]` = `.epred`, 'MME' = 'stmonyw1i')    # rename cols 
}, file="cache_4_2")

  #NOTE: may need t explicitly call dplyr::filter 
  #see: https://hackernoon.com/silly-r-errors-and-the-silly-reasons-im-probably-getting-them-c6bd9ada59c

# plot only maximum stress response category contrast, or MME (5-1)   
MME_stmony_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stmonyw1i]`, y = 'MME')) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.25, .25) +
  ylab("Stress:\nMoney") +
  coord_cartesian(xlim=c(-.15,.15))

# alt plot - stat_lineinterval (change label: 'MME' = `5 - 1`)
# MME_stmony_pstcrim_T1 %>% 
#   ggplot(aes(x = `difference in E[y|stmonyw1i]`, y = 'MME')) +
#   facet_wrap(~.category, nrow=1,
#                labeller = labeller(.category= as_labeller(pstcrimelabs))) +
#   stat_pointinterval(.width=.95) +
#   geom_vline(xintercept = 0, linetype = "dashed") +
#   xlim(-.25, .25) +
#   ylab("Stress:\nMoney") +
#   coord_cartesian(xlim=c(-.15,.15))  

This is what a MaxME effect estimate looks like with our ordinal stress items. Again, this is a parsimonious summary of the “maximum” marginal association between an ordinal (stress) IV and a binary outcome.

We could add additional rows for each of the remaining stress items. However, earlier, I expressed reservations about the utility of this effect estimate in our particular application. Thinking ahead, this effect estimate might be especially problematic when we examine change correlations from T1 to T2. After all, as Figure 1 shows, within-person increases or decreases in stress from T1 to T2 (across a 2-yr interval) are rarely as large or larger than two categories (e.g., from 1=never to 3=sometimes, or from 2=rarely to 4=often, or from 3=sometimes to 5=very often). Rather, most people report the same level of stress or a one-threshold response category change, which can be seen in Figure 1 above and in the bar charts below.

p1 <- ggplot(stress.wide, aes(stmonych12)) +
  geom_bar()

p2 <- ggplot(stress.wide, aes(sttranch12)) +
  geom_bar()

p3 <- ggplot(stress.wide, aes(strespch12)) +
  geom_bar()

p4 <- ggplot(stress.wide, aes(stfairch12)) +
  geom_bar()

p5 <- ggplot(stress.wide, aes(stjobch12)) +
  geom_bar()

p6 <- ggplot(stress.wide, aes(stthftch12)) +
  geom_bar()

p7 <- ggplot(stress.wide, aes(stmugch12)) +
  geom_bar()

(p1 + p2) / (p3 + p4) / (p5 + plot_spacer()) / (p6 + p7)

5.2 Practically Large Marginal Effects (PLME)

Given this, rather than focusing on “maximum” effects, it might be wiser to select instead an effect estimate that observes such plausible real-world limits to the types of large yet actually-occurring changes that might be observed in nature. Since, in our particular case, anything larger than a one-category change in subjective stress across waves appears uncommon regardless of stress type, then attempts to estimate “maximum” effects or other large-difference category contrasts may result in especially noisy, uncertain, or incomparable estimates when we move to modeling change later. Rather, an alternative standard one-category contrast such as “4-3” might be better for our purposes, since the overwhelming majority of changes in stress from T1 to T2 actually occurring in our data are one-category changes. Meanwhile, a two-category change such as “4-2” might represent a “practically large” stress contrast, given that this is the largest change observed for most stress items across waves. Even better, we could calculate a combined/average posterior predictive difference distribution for multiple contrasts - for instance, an average of all two-unit response category jumps, including “5-3”, “4-2”, and “3-1” - to estimate an average difference in expected crime probability across stress differences of a magnitude that are in line with the largest within-person changes in stress observed from T1 to T2 in these data.

We might refer to the process of determining such an estimated average difference in probabilities across all one-unit or two-unit contrasts as akin to identifying an appropriate “practically large marginal effect” (PLME), as it represents an estimate of the potential (theoretically causal) effect of increasing or decreasing an IV (stress) up or down a large amount relative to change magnitudes that are typically observed in nature.

In our case, we will start with the average of one-category contrasts to permit comparison with a two-category PLME. The average one-category contrast corresponds to typical regression-style interpretations, since it is interpreted as the average difference in the posterior predicted probability of crime across all one-category contrasts in stress. We will then move to the average two-category PLME estimates. Note that when modeling other theorized causes, the identified PLME contrast might be different; for instance, if three-category changes in another predictor variable representing a theorized cause were more commonly observed in one’s data, then an average of all three-category contrasts might be identified as an appropriate “practically large marginal effect” for that variable.

In addition to its interpretive appeal, a “PLME” estimate might have better or more robust distributional properties across all the stress/outcome item contrasts we will be making (e.g., six more stress items; criminal intent & negative emotions; repeating all with T2-T1 change correlations), as it might be less noisy than “maximum” contrasts where X or Y item distributions or joint XY distributions might result in noisy estimates due, for instance, to low joint cell frequencies. Let’s give it a shot.

First, we will generate data containing all 10 posterior contrasts.

Also, before plotting these together, remember that “any” past crime item? We also want to pull contrasts from those models and combine them with contrasts from the individual criminal intent outcome models so we can add them to Figure 3 later. Let’s do that now as well.

5.2.1 Predictive Marginal Contrasts (Past Crime)

#Get predictive margins data
  #could not get a function to work, so typing all separately :/

#NOTE: stmonyw1i draws saved above, but redone to add all past crime

predmarg_stmony_pstcrim_T1 = stress.wide3 %>%
  data_grid(stmonyw1i) %>%
  add_epred_draws(allpstcrime.stmony.fit) %>%  
  group_by(.category, stmonyw1i, .draw)

predmarg_sttran_pstcrim_T1 = stress.wide3 %>%
  data_grid(sttranw1i) %>%
  add_epred_draws(allpstcrime.sttran.fit) %>%  
  group_by(.category, sttranw1i, .draw)

predmarg_stresp_pstcrim_T1 = stress.wide3 %>%
  data_grid(strespw1i) %>%
  add_epred_draws(allpstcrime.stresp.fit) %>%  
  group_by(.category, strespw1i, .draw)

predmarg_stfair_pstcrim_T1 = stress.wide3 %>%
  data_grid(stfairw1i) %>%
  add_epred_draws(allpstcrime.stfair.fit) %>%  
  group_by(.category, stfairw1i, .draw)

predmarg_stjob_pstcrim_T1 = stress.wide3 %>%
  data_grid(stjobw1i) %>%
  add_epred_draws(allpstcrime.stjob.fit) %>%  
  group_by(.category, stjobw1i, .draw)

predmarg_stthft_pstcrim_T1 = stress.wide3 %>%
  data_grid(stthftw1i) %>%
  add_epred_draws(allpstcrime.stthft.fit) %>%  
  group_by(.category, stthftw1i, .draw)

predmarg_stmug_pstcrim_T1 = stress.wide3 %>%
  data_grid(stmugw1i) %>%
  add_epred_draws(allpstcrime.stmug.fit) %>%  
  group_by(.category, stmugw1i, .draw)


#function to get epred draws from "any past crime" models
epred_anycrm <- function(mydata, mystressvar, myoutcomevar, mymodelfit) {
mydata %>%
  data_grid({{mystressvar}}) %>%
  mutate(.category=myoutcomevar) %>%
  add_epred_draws(mymodelfit) %>% 
  group_by({{mystressvar}}, .draw)  
}

#get "any past crime" epred draws & merge w/individual outcome epred data
predmarg_stmony_anypstcrim_T1 =epred_anycrm(stress.wide3, stmonyw1i, 
                                             "pstanyw1f", anypstcrime.stmony.fit)
predmarg_stmony_pstcrim_T1 <- bind_rows(predmarg_stmony_pstcrim_T1, 
                                        predmarg_stmony_anypstcrim_T1) 
rm(predmarg_stmony_anypstcrim_T1) #clean environment

predmarg_sttran_anypstcrim_T1 =epred_anycrm(stress.wide3, sttranw1i, 
                                             "pstanyw1f", anypstcrime.sttran.fit)
predmarg_sttran_pstcrim_T1 <- bind_rows(predmarg_sttran_pstcrim_T1, 
                                        predmarg_sttran_anypstcrim_T1)
rm(predmarg_sttran_anypstcrim_T1) 

predmarg_stresp_anypstcrim_T1 =epred_anycrm(stress.wide3, strespw1i, 
                                             "pstanyw1f", anypstcrime.stresp.fit)
predmarg_stresp_pstcrim_T1 <- bind_rows(predmarg_stresp_pstcrim_T1, 
                                        predmarg_stresp_anypstcrim_T1)
rm(predmarg_stresp_anypstcrim_T1) 

predmarg_stfair_anypstcrim_T1 =epred_anycrm(stress.wide3, stfairw1i, 
                                             "pstanyw1f", anypstcrime.stfair.fit)
predmarg_stfair_pstcrim_T1 <- bind_rows(predmarg_stfair_pstcrim_T1, 
                                        predmarg_stfair_anypstcrim_T1)
rm(predmarg_stfair_anypstcrim_T1) 

predmarg_stjob_anypstcrim_T1 =epred_anycrm(stress.wide3, stjobw1i, 
                                             "pstanyw1f", anypstcrime.stjob.fit)
predmarg_stjob_pstcrim_T1 <- bind_rows(predmarg_stjob_pstcrim_T1, 
                                        predmarg_stjob_anypstcrim_T1)
rm(predmarg_stjob_anypstcrim_T1) 

predmarg_stthft_anypstcrim_T1 =epred_anycrm(stress.wide3, stthftw1i, 
                                             "pstanyw1f", anypstcrime.stthft.fit)
predmarg_stthft_pstcrim_T1 <- bind_rows(predmarg_stthft_pstcrim_T1, 
                                        predmarg_stthft_anypstcrim_T1)
rm(predmarg_stthft_anypstcrim_T1) 

predmarg_stmug_anypstcrim_T1 =epred_anycrm(stress.wide3, stmugw1i, 
                                             "pstanyw1f", anypstcrime.stmug.fit)
predmarg_stmug_pstcrim_T1 <- bind_rows(predmarg_stmug_pstcrim_T1, 
                                        predmarg_stmug_anypstcrim_T1)
rm(predmarg_stmug_anypstcrim_T1) 

#function to calculate mean difference contrast (marginal effect contrasts, or MEs) 
calc_MEs <- function(predmarg_data, xitem) {
  predmarg_data %>%
  compare_levels(.epred, by = xitem) %>%         
  rename(`difference in E[y|stress]` = `.epred`)  
}

#Warning - takes a while to generate these ME contrasts...
margeffs_stmony_pstcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stmony_pstcrim_T1, "stmonyw1i")}, file="cache_4_1")
margeffs_sttran_pstcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_sttran_pstcrim_T1, "sttranw1i")}, file="cache_4_3")
margeffs_stresp_pstcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stresp_pstcrim_T1, "strespw1i")}, file="cache_4_4")  
margeffs_stfair_pstcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stfair_pstcrim_T1, "stfairw1i")}, file="cache_4_5")
margeffs_stjob_pstcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stjob_pstcrim_T1, "stjobw1i")}, file="cache_4_6")
margeffs_stthft_pstcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stthft_pstcrim_T1, "stthftw1i")}, file="cache_4_7")
margeffs_stmug_pstcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stmug_pstcrim_T1, "stmugw1i")}, file="cache_4_8")

Now, let’s examine the plots for all ten possible effect contrasts again for stmonyw1 and the remaining six stress items.

5.2.2 Visualize all contrasts

5.2.2.0.1 Stress about money
# plot all stress response category contrasts (10)   

pstcrimelabs <- c("pstthflt5w1f"="Theft <5BAM", 
              "pstthfgt5w1f"="Theft >5BAM", 
              "pstthreatw1f"="Threaten", 
              "pstharmw1f"="Phys. harm",
              "pstusedrgw1f"="Use drugs",
              "psthackw1f"="Hack info.",
              "pstanyw1f"="Any crime")

#Money - all 10 contrasts
margeffs_stmony_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stress]`, y = stmonyw1i)) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.15,.15))

5.2.2.0.2 Stress about transportation
#Transportation - all 10 contrasts
margeffs_sttran_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stress]`, y = sttranw1i)) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.15,.15))

5.2.2.0.3 Stress about respect
#Respect - all 10 contrasts
margeffs_stresp_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stress]`, y = strespw1i)) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.15,.15))

5.2.2.0.4 Stress about fair treatment
#Fair - all 10 contrasts
margeffs_stfair_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stress]`, y = stfairw1i)) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.15,.15))

5.2.2.0.5 Stress about job
#Job - all 10 contrasts
margeffs_stjob_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stress]`, y = stjobw1i)) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.15,.15))

5.2.2.0.6 Stress about theft
#Theft - all 10 contrasts
margeffs_stthft_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stress]`, y = stthftw1i)) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.15,.15))

5.2.2.0.7 Stress about assault
#Assault - all 10 contrasts
margeffs_stmug_pstcrim_T1 %>% 
  ggplot(aes(x = `difference in E[y|stress]`, y = stmugw1i)) +
  facet_wrap(~.category, nrow=1,
               labeller = labeller(.category= as_labeller(pstcrimelabs))) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.15,.15))

These plots give us a full sense of the associations between each stress item and each past crime item by showing us the predicted differences in outcome probabilities across all possible stress item response contrasts. Remember, the goal is to get an informative yet more parsimonious summary effect estimate on the response scale (like these). We also want a summary that will permit consistent interpretation across these T1 associations and T2-T1 change associations. Finally, with respect to change correlations, we want a counterfactual effect estimate that respects real-world boundaries on the types of within-person changes that we can and do observe.

Still, this is too much information for our task; we need a meaningful yet more parsimonious summary of the predicted marginal effect contrasts. Toward this end, we start by plotting the averaged posterior predicted marginal effect for all one-category contrasts (5-4; 4-3; 3-2; 2-1) below.

5.2.3 ME1 - Limit Predictive Margins to 1-Category Contrasts

#Create diff data for each stress item (note, run everything before the "slice" command to check logic)

#stmony
PLME1_stmony_pstcrim_T1 = margeffs_stmony_pstcrim_T1 %>%
  filter(stmonyw1i=="5 - 4" | stmonyw1i=="4 - 3" | stmonyw1i=="3 - 2" | stmonyw1i=="2 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_onedif = mean(`difference in E[y|stress]`), #average selected contrasts
         stress_var = "Stress:\nMoney",
         dif_label = "difference in E[y|stress]") %>%
  slice_head() %>% # should have four identical average values for all contrasts, slice to keep first line only
  ungroup() %>%
  dplyr::select(-c(stmonyw1i, `difference in E[y|stress]`)) #drop first contrast, keep ave (mean_onediff)

#sttran
PLME1_sttran_pstcrim_T1 = margeffs_sttran_pstcrim_T1 %>%
  filter(sttranw1i=="5 - 4" | sttranw1i=="4 - 3" | sttranw1i=="3 - 2" | sttranw1i=="2 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_onedif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nTransport",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(sttranw1i, `difference in E[y|stress]`))

#stresp
PLME1_stresp_pstcrim_T1 = margeffs_stresp_pstcrim_T1 %>%
  filter(strespw1i=="5 - 4" | strespw1i=="4 - 3" | strespw1i=="3 - 2" | strespw1i=="2 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_onedif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nRespect",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(strespw1i, `difference in E[y|stress]`))

#stfair
PLME1_stfair_pstcrim_T1 = margeffs_stfair_pstcrim_T1 %>%
  filter(stfairw1i=="5 - 4" | stfairw1i=="4 - 3" | stfairw1i=="3 - 2" | stfairw1i=="2 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_onedif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nFair Trtmt",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stfairw1i, `difference in E[y|stress]`))

#stjob
PLME1_stjob_pstcrim_T1 = margeffs_stjob_pstcrim_T1 %>%
  filter(stjobw1i=="5 - 4" | stjobw1i=="4 - 3" | stjobw1i=="3 - 2" | stjobw1i=="2 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_onedif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nJob",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stjobw1i, `difference in E[y|stress]`))

#stthft
PLME1_stthft_pstcrim_T1 = margeffs_stthft_pstcrim_T1 %>%
  filter(stthftw1i=="5 - 4" | stthftw1i=="4 - 3" | stthftw1i=="3 - 2" | stthftw1i=="2 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_onedif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nTheft Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stthftw1i, `difference in E[y|stress]`))

#stmug
PLME1_stmug_pstcrim_T1 = margeffs_stmug_pstcrim_T1 %>%
  filter(stmugw1i=="5 - 4" | stmugw1i=="4 - 3" | stmugw1i=="3 - 2" | stmugw1i=="2 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_onedif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nAssault Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmugw1i, `difference in E[y|stress]`))

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
onedif_combined <- bind_rows(
  PLME1_stmony_pstcrim_T1,
  PLME1_sttran_pstcrim_T1,
  PLME1_stresp_pstcrim_T1,
  PLME1_stfair_pstcrim_T1,
  PLME1_stjob_pstcrim_T1,
  PLME1_stthft_pstcrim_T1,
  PLME1_stmug_pstcrim_T1)

#transform stress_var into reverse-ordered factor
onedif_combined2<- onedif_combined %>%
  mutate(
    stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nAssault Vctm",
                                    "Stress:\nTheft Vctm", 
                                    "Stress:\nJob",
                                    "Stress:\nFair Trtmt",
                                    "Stress:\nRespect",
                                    "Stress:\nTransport",
                                    "Stress:\nMoney"))
  )

#calculate row & col averages of P(mean_onedif) > 0 

#Rows: P(mean_onedif | Stress item) > 0
  #aka P(PLME>0|stress)

#View marginal probabilities
# onedif_combined2 %>%
#   group_by(stress_varf) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(mean_onedif>0),
#             p_gt0 = n_gt0 / n_ests)

  # Stress:\nMoney  0.54    
  # Stress:\nTransport  0.56    
  # Stress:\nRespect    0.90
  # Stress:\nFair Trtmt 0.93    
  # Stress:\nJob    0.89    
  # Stress:\nTheft Vctm 0.78    
  # Stress:\nAssault Vctm   0.85

#Cols: P(mean_onedif | Crime item) > 0
  #aka P(PLME>0|crime)

#View marginal probabilities
# onedif_combined2 %>%
#   group_by(.category) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(mean_onedif>0),
#             p_gt0 = n_gt0 / n_ests)

    # pstthflt5w1f  0.82    
    # pstthfgt5w1f  0.74    
    # pstthreatw1f  0.85    
    # pstharmw1f    0.71    
    # pstusedrgw1f  0.86    
    # psthackw1f    0.66              
    # pstanyw1f 0.83              

#Add these posterior probabilities into variable name

pstcrimelabsPT1 <- c(
  "pstthflt5w1f"="Theft <5BAM\nP(ME>0|col)\n=.82", 
  "pstthfgt5w1f"="Theft >5BAM\nP(ME>0|col)\n=.74", 
  "pstthreatw1f"="Threaten\nP(ME>0|col)\n=.85", 
  "pstharmw1f"="Phys. harm\nP(ME>0|col)\n=.71",
  "pstusedrgw1f"="Use drugs\nP(ME>0|col)\n=.86",
  "psthackw1f"="Hack info.\nP(ME>0|col)\n=.66",
  "pstanyw1f"="Any crime\nP(ME>0|col)\n=.83")
stress_varlabsPT1 <- c(
  "Stress:\nMoney" = "Stress: Money\nP(ME>0|row)\n=.54",
  "Stress:\nTransport" = "Stress: Transport\nP(ME>0|row)\n=.55",
  "Stress:\nRespect" = "Stress: Respect\nP(ME>0|row)=.89",
  "Stress:\nFair Trtmt" = "Stress: Fair Trtmt\nP(ME>0|row)\n=.92",
  "Stress:\nJob" = "Stress: Job\nP(ME>0|row)\n=0.87",
  "Stress:\nTheft Vctm" = "Stress: Theft\nP(ME>0|row)\n=0.78",
  "Stress:\nAssault Vctm"   = "Stress: Assault\nP(ME>0|row)\n=0.85")

# levels(twodif_combined2$stress_varf)

#Plot:

Fig3vME1 <- ggplot(onedif_combined2, aes(x = mean_onedif, y = stress_varf, 
                                         fill=after_stat(x > 0))) +  
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category= as_labeller(pstcrimelabsPT1))) +
  stat_halfeye(.width = .95) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  # xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.11,.11)) +
  scale_x_continuous(breaks=c(-.1,0,.1)) +
  xlab("Posterior Predicted Difference in E[y|stress]") + 
  scale_y_discrete(labels=stress_varlabsPT1) +
  scale_fill_manual(values = c("gray80", "#C34C4A")) + 
  plot_annotation(
    title = 'FIGURE 3vME1: \"Marginal Effect\" of 1-Category Difference in Stress on Past Crime at T1, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves.') & 
    theme(axis.title.y = element_blank(), 
        legend.position = "none",
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0)) 

Fig3vME1 

That is a good start. We managed to get all 42 posterior predicted difference distributions on one figure, and yet it remains relatively easy to read. But we also need to examine and communicate differences in these differences across communities. We will turn to that soon. First, let’s compare this plot with an alternative plot that presents our “practically large marginal effect” or PLME, estimated as the average expected difference in crime across all two-category contrasts (i.e., 5-3, 4-2, & 3-1) instead of all one-category contrasts.

Of course, since the contrast is larger (i.e. a two-unit difference instead of one-unit difference in stress), then plotted associations between stress and crime should display larger point estimates or expected differences in predicted probabilities of past crime. But what about the uncertainty intervals? How might those change? What about the marginal probabilities, or the average proportion of the posterior distributions that are greater than zero? We can answer these questions by extracting, averaging, and plotting all two-category contrasts instead.

5.2.4 ME2 - Combine Predictive Margins from 2-Category Contrasts (“PLME”)

#Create diff data for each stress item (note, run everything before the "slice" command to check logic)

#stmony
PLME2_stmony_pstcrim_T1 = margeffs_stmony_pstcrim_T1 %>%
  filter(stmonyw1i=="5 - 3" | stmonyw1i=="4 - 2" | stmonyw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nMoney",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmonyw1i, `difference in E[y|stress]`))

#sttran
PLME2_sttran_pstcrim_T1 = margeffs_sttran_pstcrim_T1 %>%
  filter(sttranw1i=="5 - 3" | sttranw1i=="4 - 2" | sttranw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nTransport",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(sttranw1i, `difference in E[y|stress]`))

#stresp
PLME2_stresp_pstcrim_T1 = margeffs_stresp_pstcrim_T1 %>%
  filter(strespw1i=="5 - 3" | strespw1i=="4 - 2" | strespw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nRespect",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(strespw1i, `difference in E[y|stress]`))

#stfair
PLME2_stfair_pstcrim_T1 = margeffs_stfair_pstcrim_T1 %>%
  filter(stfairw1i=="5 - 3" | stfairw1i=="4 - 2" | stfairw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nFair Trtmt",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stfairw1i, `difference in E[y|stress]`))

#stjob
PLME2_stjob_pstcrim_T1 = margeffs_stjob_pstcrim_T1 %>%
  filter(stjobw1i=="5 - 3" | stjobw1i=="4 - 2" | stjobw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nJob",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stjobw1i, `difference in E[y|stress]`))

#stthft
PLME2_stthft_pstcrim_T1 = margeffs_stthft_pstcrim_T1 %>%
  filter(stthftw1i=="5 - 3" | stthftw1i=="4 - 2" | stthftw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nTheft Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stthftw1i, `difference in E[y|stress]`))

#stmug
PLME2_stmug_pstcrim_T1 = margeffs_stmug_pstcrim_T1 %>%
  filter(stmugw1i=="5 - 3" | stmugw1i=="4 - 2" | stmugw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nAssault Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmugw1i, `difference in E[y|stress]`))

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
twodif_combined <- bind_rows(
  PLME2_stmony_pstcrim_T1,
  PLME2_sttran_pstcrim_T1,
  PLME2_stresp_pstcrim_T1,
  PLME2_stfair_pstcrim_T1,
  PLME2_stjob_pstcrim_T1,
  PLME2_stthft_pstcrim_T1,
  PLME2_stmug_pstcrim_T1)

#transform stress_var into reverse-ordered factor
twodif_combined2<- twodif_combined %>%
  mutate(
    stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nAssault Vctm",
                                    "Stress:\nTheft Vctm", 
                                    "Stress:\nJob",
                                    "Stress:\nFair Trtmt",
                                    "Stress:\nRespect",
                                    "Stress:\nTransport",
                                    "Stress:\nMoney")),
    .category = factor(.category, 
                       levels=c("pstthflt5w1f", "pstthfgt5w1f", "pstthreatw1f",
                                "pstharmw1f", "pstusedrgw1f", "psthackw1f", 
                                "pstanyw1f"))
  )



#calculate row & col averages of P(mean_twodif) > 0 

#Rows: P(mean_twodif | Stress item) > 0
  #aka P(PLME>0|stress)

#View marginal contrasts
# twodif_combined2 %>%
#   group_by(stress_varf) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(mean_twodif>0),
#             p_gt0 = n_gt0 / n_ests)

  # Stress:\nMoney  0.54    
  # Stress:\nTransport  0.56    
  # Stress:\nRespect    0.90    
  # Stress:\nFair Trtmt 0.93    
  # Stress:\nJob    0.89    
  # Stress:\nTheft Vctm 0.78    
  # Stress:\nAssault Vctm   0.85

#Cols: P(mean_twodif | Crime item) > 0
  #aka P(PLME>0|crime)

# twodif_combined2 %>%
#   group_by(.category) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(mean_twodif>0),
#             p_gt0 = n_gt0 / n_ests)

    # pstthflt5w1f  0.82    
    # pstthfgt5w1f  0.74    
    # pstthreatw1f  0.85    
    # pstharmw1f    0.71    
    # pstusedrgw1f  0.86    
    # psthackw1f    0.66
    # pstanyw1f   0.83

#Add these posterior probabilities into variable name

pstcrimelabsPT1 <- c(
  "pstthflt5w1f"="Theft <5BAM\nP(ME>0|col)\n=.82", 
  "pstthfgt5w1f"="Theft >5BAM\nP(ME>0|col)\n=.74", 
  "pstthreatw1f"="Threaten\nP(ME>0|col)\n=.85", 
  "pstharmw1f"="Phys. harm\nP(ME>0|col)\n=.71",
  "pstusedrgw1f"="Use drugs\nP(ME>0|col)\n=.86",
  "psthackw1f"="Hack info.\nP(ME>0|col)\n=.66",
  "pstanyw1f"="Any crime\nP(ME>0|col)\n=.83")
stress_varlabsPT1 <- c(
  "Stress:\nMoney" = "Stress: Money\nP(ME>0|row)\n=.54",
  "Stress:\nTransport" = "Stress: Transport\nP(ME>0|row)\n=.56",
  "Stress:\nRespect" = "Stress: Respect\nP(ME>0|row)=.90",
  "Stress:\nFair Trtmt" = "Stress: Fair Trtmt\nP(ME>0|row)\n=.93",
  "Stress:\nJob" = "Stress: Job\nP(ME>0|row)\n=0.89",
  "Stress:\nTheft Vctm" = "Stress: Theft\nP(ME>0|row)\n=0.78",
  "Stress:\nAssault Vctm"   = "Stress: Assault\nP(ME>0|row)\n=0.85")

# levels(twodif_combined2$stress_varf)

#Plot:
Fig3vPLME2 <- ggplot(twodif_combined2, aes(x = mean_twodif, y = stress_varf, fill=after_stat(x > 0))) +  
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category= as_labeller(pstcrimelabsPT1))) +
  stat_halfeye(.width = .95) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  # xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.11,.11)) + 
  scale_x_continuous(breaks=c(-.1,0,.1)) +
  xlab("Posterior Predicted Difference in E[y|stress]") + 
  scale_y_discrete(labels=stress_varlabsPT1) +
  scale_fill_manual(values = c("gray80", "#C34C4A")) + 
  plot_annotation(
    title = 'FIGURE 3v2: \"Practically Large Marginal Effect\" of 2-Category Difference in Stress on Past Crime at T1, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves.') & 
    theme(axis.title.y = element_blank(), 
        legend.position = "none",
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0)) 

Fig3vPLME2

As expected, the two-category PLME contrasts generated larger estimates of the difference in predicted probabilities of crime (i.e., point estimates further to the right of the dashed line at zero). However, these estimates also are proportionally more uncertain as well, as the row and column marginal posterior probabilities (that PLME2|stress item]>0 or PLME2|crime item]>0 ) remain the same in this case.

Now, let’s build upon this two-category PLME plot (Fig3vPLME2) and modify it a bit by adding shading to help communicate the magnitude of these differences using an alpha transparency scale linked to the probability that the difference is greater than zero for each posterior (i.e., the proportion of the posterior density to the right of zero).

5.3 Supp. Figure 2A: PLME Stress/Past Crime T1

#First, add p_gt0 variable used above to each stress/item combo in data (i.e. to each plot)
#Create alpha_scale variable =1 if p_gt0 < 0 (i.e., to be fully opaque) & =p_gt0 if p_gt0 > 1
twodif_combined3 <- twodif_combined2 %>%
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(mean_twodif>0),
         p_gt0 = n_gt0 / n_ests,
         gt0 = ifelse(mean_twodif>0, 1, 0),
         alpha_scale = ifelse(mean_twodif <=0, 1, p_gt0),
         rural.ses.med = as.factor("0")) #add to combine figures 3 & 4 later



#Using sequential color palette (scio = lajolla)
#Also note I'm using ggnewscale to add multiple fill palettes
SuppFigure2A <- ggplot(data = twodif_combined3, mapping = aes(x = mean_twodif, y = stress_varf)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category= as_labeller(pstcrimelabsPT1))) +
  stat_slab(mapping = aes(fill = p_gt0), .width = .95) +
  scale_fill_scico(palette = "lajolla", begin = .8, end = .3, #tells it where to start and end palette
                   name = "P(PLME > 0)", breaks = c(.1, .5, .9)) + 
  new_scale_fill() + #from ggnewscale
  stat_halfeye(mapping = aes(fill = after_stat(x > 0)), .width = .95, show.legend=FALSE) + 
  scale_fill_manual(values = c("grey80", "NA")) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  # xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.11,.16)) + 
  scale_x_continuous(breaks=c(-.1,0,.1)) +
  xlab("Posterior Predicted Difference in E[y|stress]") + 
  scale_y_discrete(labels=stress_varlabsPT1) +
  labs(
    title = 'SUPPLEMENTAL FIGURE 2A\nMarginal Effect of 2-Category Difference in Stress on Past Crime at T1, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves. "PLME" refers to "Practically Large Marginal Effect" of 2-category difference in stress on outcome. Darker shaded\nregions indicate larger proportion of posterior effect estimates are greater than zero (positive effect is more probable); grey shading indicates portion of posterior distribution of effect\nestimates equal to or less than zero.') +
  theme(axis.title.y = element_blank(), 
        axis.text.y = element_text(size=10),
        strip.text.x = element_text(size=10),
        legend.position = "bottom",
        strip.background = element_blank(),
        plot.title = element_text(size=12, face="bold"),
        plot.caption = element_text(size=8, hjust = 0),
        plot.title.position = "plot", 
        plot.caption.position =  "plot") 
SuppFigure2A

#Export to image
ggsave("SuppFigure2A.jpeg", width=9, height=6.5, path=here("Output"))

At the survey design stage, we included two indicators each for subjective stress from financial (money; transportation), interpersonal (respect; fair treatment), and victimization (theft; assault) sources, along with an item tapping job-related stress. Likewise, these T1 stress/past crime item correlations largely show comparable patterns for the item pairs tapping financial, interpersonal, and victimization stress, respectively.

Overall, these correlational patterns at T1 suggest modest associations between interpersonal stress items and five of six past crime items, excluding identity fraud. Job stress is modestly associated with past minor theft, verbal assault (threaten harm), drug use, and identity fraud (hack info). In contrast to theoretical expectations, victimization stress displays relatively weak and inconsistent associations with past crime at T1. Finally, in contrast to classic strain-based theorizing (cf. Merton; inflation-based arguments) and popular perceptions about the stress/crime relationship, financial stress is not associated with past crime at T1 in this sample.

Before examining whether these associations vary by community characteristics (rurality & SES), let’s repeat this process and generate a comparable figure for criminal intent.

5.3.1 Predictive Marginal Contrasts (Crim Intent)

#Get predictive margins data

predmarg_stmony_prjcrim_T1 = stress.wide3 %>%
  data_grid(stmonyw1i) %>%
  add_epred_draws(allprjcrime.stmony.fit) %>%  
  group_by(.category, stmonyw1i, .draw)

predmarg_sttran_prjcrim_T1 = stress.wide3 %>%
  data_grid(sttranw1i) %>%
  add_epred_draws(allprjcrime.sttran.fit) %>%  
  group_by(.category, sttranw1i, .draw)

predmarg_stresp_prjcrim_T1 = stress.wide3 %>%
  data_grid(strespw1i) %>%
  add_epred_draws(allprjcrime.stresp.fit) %>%  
  group_by(.category, strespw1i, .draw)

predmarg_stfair_prjcrim_T1 = stress.wide3 %>%
  data_grid(stfairw1i) %>%
  add_epred_draws(allprjcrime.stfair.fit) %>%  
  group_by(.category, stfairw1i, .draw)

predmarg_stjob_prjcrim_T1 = stress.wide3 %>%
  data_grid(stjobw1i) %>%
  add_epred_draws(allprjcrime.stjob.fit) %>%  
  group_by(.category, stjobw1i, .draw)

predmarg_stthft_prjcrim_T1 = stress.wide3 %>%
  data_grid(stthftw1i) %>%
  add_epred_draws(allprjcrime.stthft.fit) %>%  
  group_by(.category, stthftw1i, .draw)

predmarg_stmug_prjcrim_T1 = stress.wide3 %>%
  data_grid(stmugw1i) %>%
  add_epred_draws(allprjcrime.stmug.fit) %>%  
  group_by(.category, stmugw1i, .draw)


#function to get epred draws from "any crim intent" models
epred_anycrm <- function(mydata, mystressvar, myoutcomevar, mymodelfit) {
mydata %>%
  data_grid({{mystressvar}}) %>%
  mutate(.category=myoutcomevar) %>%
  add_epred_draws(mymodelfit) %>% 
  group_by({{mystressvar}}, .draw)  
}

#get "any crim intent" epred draws & merge w/individual outcome epred data
predmarg_stmony_anyprjcrim_T1 =epred_anycrm(stress.wide3, stmonyw1i, 
                                             "prjanyw1f", anyprjcrime.stmony.fit)
predmarg_stmony_prjcrim_T1 <- bind_rows(predmarg_stmony_prjcrim_T1, 
                                        predmarg_stmony_anyprjcrim_T1)
rm(predmarg_stmony_anyprjcrim_T1) #clean environment

predmarg_sttran_anyprjcrim_T1 =epred_anycrm(stress.wide3, sttranw1i, 
                                             "prjanyw1f", anyprjcrime.sttran.fit)
predmarg_sttran_prjcrim_T1 <- bind_rows(predmarg_sttran_prjcrim_T1, 
                                        predmarg_sttran_anyprjcrim_T1)
rm(predmarg_sttran_anyprjcrim_T1) 

predmarg_stresp_anyprjcrim_T1 =epred_anycrm(stress.wide3, strespw1i, 
                                             "prjanyw1f", anyprjcrime.stresp.fit)
predmarg_stresp_prjcrim_T1 <- bind_rows(predmarg_stresp_prjcrim_T1, 
                                        predmarg_stresp_anyprjcrim_T1)
rm(predmarg_stresp_anyprjcrim_T1) 

predmarg_stfair_anyprjcrim_T1 =epred_anycrm(stress.wide3, stfairw1i, 
                                             "prjanyw1f", anyprjcrime.stfair.fit)
predmarg_stfair_prjcrim_T1 <- bind_rows(predmarg_stfair_prjcrim_T1, 
                                        predmarg_stfair_anyprjcrim_T1)
rm(predmarg_stfair_anyprjcrim_T1) 

predmarg_stjob_anyprjcrim_T1 =epred_anycrm(stress.wide3, stjobw1i, 
                                             "prjanyw1f", anyprjcrime.stjob.fit)
predmarg_stjob_prjcrim_T1 <- bind_rows(predmarg_stjob_prjcrim_T1, 
                                        predmarg_stjob_anyprjcrim_T1)
rm(predmarg_stjob_anyprjcrim_T1) 

predmarg_stthft_anyprjcrim_T1 =epred_anycrm(stress.wide3, stthftw1i, 
                                             "prjanyw1f", anyprjcrime.stthft.fit)
predmarg_stthft_prjcrim_T1 <- bind_rows(predmarg_stthft_prjcrim_T1, 
                                        predmarg_stthft_anyprjcrim_T1)
rm(predmarg_stthft_anyprjcrim_T1) 

predmarg_stmug_anyprjcrim_T1 =epred_anycrm(stress.wide3, stmugw1i, 
                                             "prjanyw1f", anyprjcrime.stmug.fit)
predmarg_stmug_prjcrim_T1 <- bind_rows(predmarg_stmug_prjcrim_T1, 
                                        predmarg_stmug_anyprjcrim_T1)
rm(predmarg_stmug_anyprjcrim_T1) 

#function to calculate mean difference contrast (marginal effect contrasts, or MEs) 
calc_MEs <- function(predmarg_data, xitem) {
  predmarg_data %>%
  compare_levels(.epred, by = xitem) %>%         
  rename(`difference in E[y|stress]` = `.epred`)  
}

#Warning - takes a while to generate these ME contrasts...
margeffs_stmony_prjcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stmony_prjcrim_T1, "stmonyw1i")}, file="cache_4_9")
margeffs_sttran_prjcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_sttran_prjcrim_T1, "sttranw1i")}, file="cache_4_10")
margeffs_stresp_prjcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stresp_prjcrim_T1, "strespw1i")}, file="cache_4_11")  
margeffs_stfair_prjcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stfair_prjcrim_T1, "stfairw1i")}, file="cache_4_12")
margeffs_stjob_prjcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stjob_prjcrim_T1, "stjobw1i")}, file="cache_4_13")
margeffs_stthft_prjcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stthft_prjcrim_T1, "stthftw1i")}, file="cache_4_14")
margeffs_stmug_prjcrim_T1 = xfun::cache_rds({calc_MEs(predmarg_stmug_prjcrim_T1, "stmugw1i")}, file="cache_4_15")

5.4 Supp. Figure 2B: PLME Stress/Criminal Intent T1

#Create diff data for each stress item (note, run everything before the "slice" command to check logic)

#stmony
PLME2_stmony_prjcrim_T1 = margeffs_stmony_prjcrim_T1 %>%
  filter(stmonyw1i=="5 - 3" | stmonyw1i=="4 - 2" | stmonyw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nMoney",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmonyw1i, `difference in E[y|stress]`))

#sttran
PLME2_sttran_prjcrim_T1 = margeffs_sttran_prjcrim_T1 %>%
  filter(sttranw1i=="5 - 3" | sttranw1i=="4 - 2" | sttranw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nTransport",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(sttranw1i, `difference in E[y|stress]`))

#stresp
PLME2_stresp_prjcrim_T1 = margeffs_stresp_prjcrim_T1 %>%
  filter(strespw1i=="5 - 3" | strespw1i=="4 - 2" | strespw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nRespect",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(strespw1i, `difference in E[y|stress]`))

#stfair
PLME2_stfair_prjcrim_T1 = margeffs_stfair_prjcrim_T1 %>%
  filter(stfairw1i=="5 - 3" | stfairw1i=="4 - 2" | stfairw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nFair Trtmt",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stfairw1i, `difference in E[y|stress]`))

#stjob
PLME2_stjob_prjcrim_T1 = margeffs_stjob_prjcrim_T1 %>%
  filter(stjobw1i=="5 - 3" | stjobw1i=="4 - 2" | stjobw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nJob",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stjobw1i, `difference in E[y|stress]`))

#stthft
PLME2_stthft_prjcrim_T1 = margeffs_stthft_prjcrim_T1 %>%
  filter(stthftw1i=="5 - 3" | stthftw1i=="4 - 2" | stthftw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nTheft Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stthftw1i, `difference in E[y|stress]`))

#stmug
PLME2_stmug_prjcrim_T1 = margeffs_stmug_prjcrim_T1 %>%
  filter(stmugw1i=="5 - 3" | stmugw1i=="4 - 2" | stmugw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nAssault Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmugw1i, `difference in E[y|stress]`))

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
twodif_combinedprj <- bind_rows(
  PLME2_stmony_prjcrim_T1,
  PLME2_sttran_prjcrim_T1,
  PLME2_stresp_prjcrim_T1,
  PLME2_stfair_prjcrim_T1,
  PLME2_stjob_prjcrim_T1,
  PLME2_stthft_prjcrim_T1,
  PLME2_stmug_prjcrim_T1)

#transform stress_var into reverse-ordered factor
twodif_combinedprj2<- twodif_combinedprj %>%
  mutate(
    stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nAssault Vctm",
                                    "Stress:\nTheft Vctm", 
                                    "Stress:\nJob",
                                    "Stress:\nFair Trtmt",
                                    "Stress:\nRespect",
                                    "Stress:\nTransport",
                                    "Stress:\nMoney"))
  )

#calculate row & col averages of P(mean_twodif) > 0 

#Rows: P(mean_twodif | Stress item) > 0
  #aka P(PLME>0|stress)

#View marginal probabilities
# twodif_combinedprj2 %>%
#   group_by(stress_varf) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(mean_twodif>0),
#             p_gt0 = n_gt0 / n_ests) 

  # Stress:\nMoney  0.28
  # Stress:\nTransport  0.36    
  # Stress:\nRespect    0.87
  # Stress:\nFair Trtmt 0.91    
  # Stress:\nJob    0.96    
  # Stress:\nTheft Vctm 0.76    
  # Stress:\nAssault Vctm   0.65

#Cols: P(mean_twodif | Crime item) > 0
  #aka P(PLME>0|crime)

#View marginal probabilities
# twodif_combinedprj2 %>%
#   group_by(.category) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(mean_twodif>0),
#             p_gt0 = n_gt0 / n_ests) 

    # prjthflt5w1f  0.77    
    # prjthfgt5w1f  0.84    
    # prjthreatw1f  0.71
    # prjharmw1f    0.51
    # prjusedrgw1f  0.63    
    # prjhackw1f    0.62
    # prjanyw1f  0.72

#Add these posterior probabilities into variable name

prjcrimelabsPT1 <- c(
  "prjthflt5w1f"="Theft <5BAM\nP(ME>0|col)\n=.77", 
  "prjthfgt5w1f"="Theft >5BAM\nP(ME>0|col)\n=.84", 
  "prjthreatw1f"="Threaten\nP(ME>0|col)\n=.71", 
  "prjharmw1f"="Phys. harm\nP(ME>0|col)\n=.51",
  "prjusedrgw1f"="Use drugs\nP(ME>0|col)\n=.63",
  "prjhackw1f"="Hack info.\nP(ME>0|col)\n=.62", 
  "prjanyw1f"="Any crime\nP(ME>0|col)\n=.72")
stress_varlabsPT1 <- c(
  "Stress:\nMoney" = "Stress: Money\nP(ME>0|row)\n=.28",
  "Stress:\nTransport" = "Stress: Transport\nP(ME>0|row)\n=.36",
  "Stress:\nRespect" = "Stress: Respect\nP(ME>0|row)=.87",
  "Stress:\nFair Trtmt" = "Stress: Fair Trtmt\nP(ME>0|row)\n=.91",
  "Stress:\nJob" = "Stress: Job\nP(ME>0|row)\n=0.96",
  "Stress:\nTheft Vctm" = "Stress: Theft\nP(ME>0|row)\n=0.76",
  "Stress:\nAssault Vctm"   = "Stress: Assault\nP(ME>0|row)\n=0.65")


#First, add p_gt0 variable used above to each stress/item combo in data (i.e. to each plot)
#Create alpha_scale variable =1 if p_gt0 < 0 (i.e., to be fully opaque) & =p_gt0 if p_gt0 > 1
twodif_combinedprj3 <- twodif_combinedprj2 %>%
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(mean_twodif>0),
         p_gt0 = n_gt0 / n_ests,
         gt0 = ifelse(mean_twodif>0, 1, 0),
         alpha_scale = ifelse(mean_twodif <=0, 1, p_gt0), 
         rural.ses.med = as.factor("0")) %>% #add to combine overall & community-specific figures later
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5w1f", "prjthfgt5w1f", "prjthreatw1f",
                                "prjharmw1f", "prjusedrgw1f", "prjhackw1f", 
                                "prjanyw1f"))
  )


#Using sequential color palette (scio = lajolla)
#Also using ggnewscale to add multiple fill palettes
SuppFigure2B <- ggplot(data = twodif_combinedprj3, mapping = aes(x = mean_twodif, y = stress_varf)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category= as_labeller(prjcrimelabsPT1))) +
  stat_slab(mapping = aes(fill = p_gt0), .width = .95) +
 scale_fill_scico(palette = "lajolla", begin = .8, end = .3, #tells it where to start and end palette
                   name = "P(PLME > 0)", breaks = c(.1, .5, .9)) + 
   new_scale_fill() + #from ggnewscale
  stat_halfeye(mapping = aes(fill = after_stat(x > 0)), .width = .95, show.legend=FALSE) + 
  scale_fill_manual(values = c("grey80", "NA")) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  # xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.11,.16)) + 
  scale_x_continuous(breaks=c(-.1,0,.1)) +
  xlab("Posterior Predicted Difference in E[y|stress]") + 
  scale_y_discrete(labels=stress_varlabsPT1) +
  labs(
    title = 'SUPPLEMENTAL FIGURE 2B\nMarginal Effect of 2-Category Difference in Stress on Criminal Intent at T1, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves. "PLME" refers to "Practically Large Marginal Effect" of 2-category difference in stress on outcome. Darker shaded\nregions indicate larger proportion of posterior effect estimates are greater than zero (positive effect is more probable); grey shading indicates portion of posterior distribution of effect\nestimates equal to or less than zero.') +
  theme(axis.title.y = element_blank(), 
        axis.text.y = element_text(size=10),
        strip.text.x = element_text(size=10),
        legend.position = "bottom",
        strip.background = element_blank(),
        plot.title = element_text(size=12, face="bold"),
        plot.caption = element_text(size=8, hjust = 0),
        plot.title.position = "plot", 
        plot.caption.position =  "plot") 
SuppFigure2B

# Export to image
ggsave("SuppFigure2B.jpeg", width=9, height=6.5, path=here("Output"))

Now we repeat this process yet again to generate a comparable bivariate association plot for stress and negative emotions.

5.4.1 Predictive Marginal Contrasts (negative emotions)

#Get predictive margins data

predmarg_stmony_depress_T1 = stress.wide3 %>%
  data_grid(stmonyw1i) %>%
  add_epred_draws(alldepress.stmony.fit) %>%  
  group_by(.category, stmonyw1i, .draw)

predmarg_sttran_depress_T1 = stress.wide3 %>%
  data_grid(sttranw1i) %>%
  add_epred_draws(alldepress.sttran.fit) %>%  
  group_by(.category, sttranw1i, .draw)

predmarg_stresp_depress_T1 = stress.wide3 %>%
  data_grid(strespw1i) %>%
  add_epred_draws(alldepress.stresp.fit) %>%  
  group_by(.category, strespw1i, .draw)

predmarg_stfair_depress_T1 = stress.wide3 %>%
  data_grid(stfairw1i) %>%
  add_epred_draws(alldepress.stfair.fit) %>%  
  group_by(.category, stfairw1i, .draw)

predmarg_stjob_depress_T1 = stress.wide3 %>%
  data_grid(stjobw1i) %>%
  add_epred_draws(alldepress.stjob.fit) %>%  
  group_by(.category, stjobw1i, .draw)

predmarg_stthft_depress_T1 = stress.wide3 %>%
  data_grid(stthftw1i) %>%
  add_epred_draws(alldepress.stthft.fit) %>%  
  group_by(.category, stthftw1i, .draw)

predmarg_stmug_depress_T1 = stress.wide3 %>%
  data_grid(stmugw1i) %>%
  add_epred_draws(alldepress.stmug.fit) %>%  
  group_by(.category, stmugw1i, .draw)


#function to calculate mean difference contrast (marginal effect contrasts, or MEs) 
calc_MEs <- function(predmarg_data, xitem) {
  predmarg_data %>%
  compare_levels(.epred, by = xitem) %>%         
  rename(`difference in E[y|stress]` = `.epred`)  
}

#Warning - takes a while to generate these ME contrasts...
margeffs_stmony_depress_T1 = xfun::cache_rds({calc_MEs(predmarg_stmony_depress_T1, "stmonyw1i")}, file="cache_4_16")
margeffs_sttran_depress_T1 = xfun::cache_rds({calc_MEs(predmarg_sttran_depress_T1, "sttranw1i")}, file="cache_4_17")
margeffs_stresp_depress_T1 = xfun::cache_rds({calc_MEs(predmarg_stresp_depress_T1, "strespw1i")}, file="cache_4_18") 
margeffs_stfair_depress_T1 = xfun::cache_rds({calc_MEs(predmarg_stfair_depress_T1, "stfairw1i")}, file="cache_4_19")
margeffs_stjob_depress_T1 = xfun::cache_rds({calc_MEs(predmarg_stjob_depress_T1, "stjobw1i")}, file="cache_4_20")
margeffs_stthft_depress_T1 = xfun::cache_rds({calc_MEs(predmarg_stthft_depress_T1, "stthftw1i")}, file="cache_4_21")
margeffs_stmug_depress_T1 = xfun::cache_rds({calc_MEs(predmarg_stmug_depress_T1, "stmugw1i")}, file="cache_4_22")

5.5 Supp. Figure 2C: PLME Stress/negative emotions T1

#Create diff data for each stress item (note, run everything before the "slice" command to check logic)

#stmony
PLME2_stmony_depress_T1 = margeffs_stmony_depress_T1 %>%
  filter(stmonyw1i=="5 - 3" | stmonyw1i=="4 - 2" | stmonyw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nMoney",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmonyw1i, `difference in E[y|stress]`))

#sttran
PLME2_sttran_depress_T1 = margeffs_sttran_depress_T1 %>%
  filter(sttranw1i=="5 - 3" | sttranw1i=="4 - 2" | sttranw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nTransport",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(sttranw1i, `difference in E[y|stress]`))

#stresp
PLME2_stresp_depress_T1 = margeffs_stresp_depress_T1 %>%
  filter(strespw1i=="5 - 3" | strespw1i=="4 - 2" | strespw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nRespect",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(strespw1i, `difference in E[y|stress]`))

#stfair
PLME2_stfair_depress_T1 = margeffs_stfair_depress_T1 %>%
  filter(stfairw1i=="5 - 3" | stfairw1i=="4 - 2" | stfairw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nFair Trtmt",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stfairw1i, `difference in E[y|stress]`))

#stjob
PLME2_stjob_depress_T1 = margeffs_stjob_depress_T1 %>%
  filter(stjobw1i=="5 - 3" | stjobw1i=="4 - 2" | stjobw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nJob",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stjobw1i, `difference in E[y|stress]`))

#stthft
PLME2_stthft_depress_T1 = margeffs_stthft_depress_T1 %>%
  filter(stthftw1i=="5 - 3" | stthftw1i=="4 - 2" | stthftw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nTheft Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stthftw1i, `difference in E[y|stress]`))

#stmug
PLME2_stmug_depress_T1 = margeffs_stmug_depress_T1 %>%
  filter(stmugw1i=="5 - 3" | stmugw1i=="4 - 2" | stmugw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nAssault Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmugw1i, `difference in E[y|stress]`))

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
twodif_combineddep <- bind_rows(
  PLME2_stmony_depress_T1,
  PLME2_sttran_depress_T1,
  PLME2_stresp_depress_T1,
  PLME2_stfair_depress_T1,
  PLME2_stjob_depress_T1,
  PLME2_stthft_depress_T1,
  PLME2_stmug_depress_T1)

#transform stress_var into reverse-ordered factor
twodif_combineddep2<- twodif_combineddep %>%
  mutate(
    stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nAssault Vctm",
                                    "Stress:\nTheft Vctm", 
                                    "Stress:\nJob",
                                    "Stress:\nFair Trtmt",
                                    "Stress:\nRespect",
                                    "Stress:\nTransport",
                                    "Stress:\nMoney"))
  )

#calculate row & col averages of P(mean_twodif) > 0 

#Rows: P(mean_twodif | Stress item) > 0
  #aka P(PLME>0|stress)

#View marginal probabilities
# twodif_combineddep2 %>%
#   group_by(stress_varf) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(mean_twodif>0),
#             p_gt0 = n_gt0 / n_ests) 

  # Stress:\nMoney  0.93
  # Stress:\nTransport  0.76    
  # Stress:\nRespect    0.86
  # Stress:\nFair Trtmt 0.92    
  # Stress:\nJob    0.62    
  # Stress:\nTheft Vctm 0.84    
  # Stress:\nAssault Vctm   0.87


#Cols: P(mean_twodif | Crime item) > 0
  #aka P(PLME>0|crime)

#View marginal probabilities
# twodif_combineddep2 %>%
#   group_by(.category) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(mean_twodif>0),
#             p_gt0 = n_gt0 / n_ests) 

# depcantgow1f      0.73    
# depeffortw1f      0.86    
# deplonelyw1f      0.81    
# depbluesw1f       0.78    
# depunfairw1f      0.80    
# depmistrtw1f      0.88    
# depbetrayw1f      0.94

#Add these posterior probabilities into variable name

depresslabsPT1 <- c(
  "depcantgow1f"="Can't go\nP(ME>0|col)\n=.73", 
  "depeffortw1f"="Effort\nP(ME>0|col)\n=.86", 
  "deplonelyw1f"="Lonely\nP(ME>0|col)\n=.81", 
  "depbluesw1f"="Blues\nP(ME>0|col)\n=.78",
  "depunfairw1f"="Unfair\nP(ME>0|col)\n=.80",
  "depmistrtw1f"="Mistreated\nP(ME>0|col)\n=.88",
  "depbetrayw1f"="Betrayed\nP(ME>0|col)\n=.94")
stress_varlabsPT1 <- c(
  "Stress:\nMoney" = "Stress: Money\nP(ME>0|row)\n=.31",
  "Stress:\nTransport" = "Stress: Transport\nP(ME>0|row)\n=.37",
  "Stress:\nRespect" = "Stress: Respect\nP(ME>0|row)=.85",
  "Stress:\nFair Trtmt" = "Stress: Fair Trtmt\nP(ME>0|row)\n=.89",
  "Stress:\nJob" = "Stress: Job\nP(ME>0|row)\n=0.96",
  "Stress:\nTheft Vctm" = "Stress: Theft\nP(ME>0|row)\n=0.74",
  "Stress:\nAssault Vctm"   = "Stress: Assault\nP(ME>0|row)\n=0.65")


#First, add p_gt0 variable used above to each stress/item combo in data (i.e. to each plot)
#Create alpha_scale variable =1 if p_gt0 < 0 (i.e., to be fully opaque) & =p_gt0 if p_gt0 > 1
twodif_combineddep3 <- twodif_combineddep2 %>%
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(mean_twodif>0),
         p_gt0 = n_gt0 / n_ests,
         gt0 = ifelse(mean_twodif>0, 1, 0),
         alpha_scale = ifelse(mean_twodif <=0, 1, p_gt0), 
         rural.ses.med = as.factor("0")) #add to combine figures 3 & 4 later

#Using sequential color palette (scio = lajolla)
#Also using ggnewscale to add multiple fill palettes
SuppFigure2C <- ggplot(data = twodif_combineddep3, mapping = aes(x = mean_twodif, y = stress_varf)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category= as_labeller(depresslabsPT1))) +
  stat_slab(mapping = aes(fill = p_gt0), .width = .95) +
 scale_fill_scico(palette = "lajolla", begin = .8, end = .3, #tells it where to start and end palette
                   name = "P(PLME > 0)", breaks = c(.1, .5, .9)) + 
  new_scale_fill() + #from ggnewscale
  stat_halfeye(mapping = aes(fill = after_stat(x > 0)), .width = .95, show.legend=FALSE) + 
  scale_fill_manual(values = c("grey80", "NA")) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  # xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.25,.25)) + 
  scale_x_continuous(breaks=c(-.2,0,.2)) +
  xlab("Posterior Predicted Difference in E[y|stress]") + 
  scale_y_discrete(labels=stress_varlabsPT1) +
  labs(
    title = 'SUPPLEMENTAL FIGURE 2C\nMarginal Effect of 2-Category Difference in Stress on Negative Emotions at T1, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves. "PLME" refers to "Practically Large Marginal Effect" of 2-category difference in stress on outcome. Darker shaded\nregions indicate larger proportion of posterior effect estimates are greater than zero (positive effect is more probable); grey shading indicates portion of posterior distribution of effect\nestimates equal to or less than zero.') +
  theme(axis.title.y = element_blank(), 
        axis.text.y = element_text(size=10),
        strip.text.x = element_text(size=10),
        legend.position = "bottom",
        strip.background = element_blank(),
        plot.title = element_text(size=12, face="bold"),
        plot.caption = element_text(size=8, hjust = 0),
        plot.title.position = "plot", 
        plot.caption.position =  "plot") 
SuppFigure2C

#Export to image
ggsave("SuppFigure2C.jpeg", width=9, height=6.5, path=here("Output"))

Note the x-axis scales are different for the depressive symptom bivariate association plot. This is to accommodate the larger differences in predicted outcome probabilities associated with a two-category change in stress in these plots relative to the crime plots. This suggests stronger associations between stress and negative emotions versus crime items, which may in part also reflect the fact that negative emotions are more prevalent (higher overall outcome probabilities).

As we mentioned above, at the survey design stage, we included two indicators each for subjective stress from financial (money; transportation), relational (respect; fair treatment), and victimization (theft; assault) sources, along with an item tapping job-related stress. Once again, these T1 stress/past crime item correlations largely show comparable patterns for the item pairs tapping financial, interpersonal, and victimization stress, respectively.

Additionally, patterns are largely consistent across conceptually similar crime item pairs (theft; violence). Hence, to make the presentation of results more manageable, we could try reducing these results to a single plot by averaging the PLME (2-category) contrasts for the conceptually similar stress and crime item pairs. We could also collapse marginal contrasts for the first four classic CESD depressive symptom items together (can’t get going; effort; lonely; blues), as well as collapse marginal contrasts for the last three negative emotions that are theorized as especially criminogenic (unfair; mistreated; betrayed). However, lacking strong theoretical rationale for doing so, we pursue these possibilities below in supplementary figures, while cautioning that they are merely an exploratory exercise in descriptive data reduction.

Specifically, in supplementary figures below, we simply average the marginal posterior probability expectations. For an alternative approach (e.g., with more items), we could consider building a multilevel model where item is a nesting or grouping level. Alternatively, since our posterior predictive averaging approach is akin to posterior predictive stacking (see also here) with equal or uniform model weights specified (i.e., an equal number of predictive draws per model), we could instead consider weighting the number of posterior draws for each model’s predictive distribution by a vector of model-specific weights that optimizes the (loo-)predictive average logged score of the stacked prediction.

Again, we lack strong theoretical or empirical reasons for assuming the collapsed items reflect a common data generating process that can be modeled appropriately with joint parameters in a multilevel framework. Also, at this stage, our aim is not to maximize predictive performance; rather, it is simply to simplify presentation of item-level stress/outcome associations by collapsing or combining similar stress/outcome pairings with the goal of assessing whether correlational patterns in the data are consistent with or contradict theoretical expectations. Hence, a simple stacking approach with equal model weights effectively communicates estimate magnitudes and the degree of uncertainty surrounding the collapsed estimates. For instance, the displayed posterior distribution of marginal effect contrasts will be unimodal wherever model contrasts of differences in predicted probabilities are similar across collapsed stress/outcome pairings. In contrast, multimodal posterior distributions imply that estimates of the marginal effect contrast varies across the collapsed stress/outcome item pairs. Think of it like presenting an unweighted meta-analytic average estimate (and distribution of estimates) across all models or a select group of models.

Finally, patterns to this point are quite similar across past crime and criminal intent plots, and criminal intent establishes more appropriate causal ordering and thus provides much stronger grounds for causal inference (i.e., past crime occurred before and may have caused presently reported stress). Hence, from this point forward, we will will focus on results from models predicting criminal intent and negative emotions.

5.6 Supp. Figure 2X: PLME “Stacked” Stress/Outcomes T1

# Compare to naive Bayes classifier or Bayesian model averaging (BMA) 
# w/multiple modes over various x models
  # See last comment here:
  # https://statmodeling.stat.columbia.edu/2021/12/18/use-stacking-rather-than-bayesian-model-averaging/

# Akin to "stacking" posterior pred dist but specifying equal model weights
  # Consider if BMA w/predictive weights is more desirable for aims: 
  # https://www.ajordannafa.com/blog/2022/05/24/bma-ames/
    # also includes example of way more efficient modeling (see "Estimation")
    # combine multiple datasets w/diff stress vars, outcome, etc. in list
    # then apply same formula (or diff formula) to list of datasets!

#begin caching
# xfun::cache_rds({

#Create diff data for each stress item (note, run everything before the "slice" command to check logic)

#stmony models - drop "any" outcome, then collapse like outcomes & stress_var (financial)
tempdata <- margeffs_stmony_prjcrim_T1 %>%
  dplyr::filter(.category != "prjanyw1f") %>% 
  mutate(
    .category = as.factor(.category)
    )
PLME_stmony_outcomes_T1 <- 
  rbind(tempdata, margeffs_stmony_depress_T1) %>%
  mutate(
    .category = forcats::fct_collapse(.category,
      "prjtheftw1" = c("prjthflt5w1f", "prjthfgt5w1f"),
      "prjviolw1" = c("prjthreatw1f", "prjharmw1f"),
      "prjusedrgw1f" = "prjusedrgw1f",
      "prjhackw1f" = "prjhackw1f",
      "depsymw1" = c("depcantgow1f", "depeffortw1f", "deplonelyw1f", "depbluesw1f"),
      "negemow1" = c("depunfairw1f", "depmistrtw1f", "depbetrayw1f"))
    ) %>% 
  filter(stmonyw1i=="5 - 3" | stmonyw1i=="4 - 2" | stmonyw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nFinancial",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmonyw1i, `difference in E[y|stress]`))

#sttran models - drop "any" outcome, collapse outcomes & stress var (financial)
tempdata <- margeffs_sttran_prjcrim_T1 %>% 
  dplyr::filter(.category != "prjanyw1f") %>% 
  mutate(
    .category = as.factor(.category)
    )
PLME_sttran_outcomes_T1 <-  
  rbind(tempdata, margeffs_sttran_depress_T1) %>%
  mutate(
    .category = forcats::fct_collapse(.category,
      "prjtheftw1" = c("prjthflt5w1f", "prjthfgt5w1f"),
      "prjviolw1" = c("prjthreatw1f", "prjharmw1f"),
      "prjusedrgw1f" = "prjusedrgw1f",
      "prjhackw1f" = "prjhackw1f",
      "depsymw1" = c("depcantgow1f", "depeffortw1f", "deplonelyw1f", "depbluesw1f"),
      "negemow1" = c("depunfairw1f", "depmistrtw1f", "depbetrayw1f"))
    ) %>%
  filter(sttranw1i=="5 - 3" | sttranw1i=="4 - 2" | sttranw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nFinancial",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(sttranw1i, `difference in E[y|stress]`))

#stresp - drop "any" outcome, collapse outcomes & stress var (financial)
tempdata <- margeffs_stresp_prjcrim_T1 %>% 
  dplyr::filter(.category != "prjanyw1f") %>% 
  mutate(
    .category = as.factor(.category)
    )
PLME_stresp_outcomes_T1 <- 
  rbind(tempdata, margeffs_stresp_depress_T1) %>%
  mutate(
    .category = forcats::fct_collapse(.category,
      "prjtheftw1" = c("prjthflt5w1f", "prjthfgt5w1f"),
      "prjviolw1" = c("prjthreatw1f", "prjharmw1f"),
      "prjusedrgw1f" = "prjusedrgw1f",
      "prjhackw1f" = "prjhackw1f",
      "depsymw1" = c("depcantgow1f", "depeffortw1f", "deplonelyw1f", "depbluesw1f"),
      "negemow1" = c("depunfairw1f", "depmistrtw1f", "depbetrayw1f"))
    ) %>% 
  filter(strespw1i=="5 - 3" | strespw1i=="4 - 2" | strespw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nRelational",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(strespw1i, `difference in E[y|stress]`))

#stfair - drop "any" outcome, collapse outcomes & stress var (financial)
tempdata <- margeffs_stfair_prjcrim_T1 %>%
  dplyr::filter(.category != "prjanyw1f") %>% 
  mutate(
    .category = as.factor(.category)
    )
PLME_stfair_outcomes_T1 <- 
  rbind(tempdata, margeffs_stfair_depress_T1) %>%
  mutate(
    .category = forcats::fct_collapse(.category,
      "prjtheftw1" = c("prjthflt5w1f", "prjthfgt5w1f"),
      "prjviolw1" = c("prjthreatw1f", "prjharmw1f"),
      "prjusedrgw1f" = "prjusedrgw1f",
      "prjhackw1f" = "prjhackw1f",
      "depsymw1" = c("depcantgow1f", "depeffortw1f", "deplonelyw1f", "depbluesw1f"),
      "negemow1" = c("depunfairw1f", "depmistrtw1f", "depbetrayw1f"))
    ) %>% 
  filter(stfairw1i=="5 - 3" | stfairw1i=="4 - 2" | stfairw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nRelational",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stfairw1i, `difference in E[y|stress]`))

#stjob - drop "any" outcome, collapse outcomes 
tempdata <- margeffs_stjob_prjcrim_T1 %>%
  dplyr::filter(.category != "prjanyw1f") %>% 
  mutate(
    .category = as.factor(.category)
    )
PLME_stjob_outcomes_T1 <- 
  rbind(tempdata, margeffs_stjob_depress_T1) %>%
  mutate(
    .category = forcats::fct_collapse(.category,
      "prjtheftw1" = c("prjthflt5w1f", "prjthfgt5w1f"),
      "prjviolw1" = c("prjthreatw1f", "prjharmw1f"),
      "prjusedrgw1f" = "prjusedrgw1f",
      "prjhackw1f" = "prjhackw1f",
      "depsymw1" = c("depcantgow1f", "depeffortw1f", "deplonelyw1f", "depbluesw1f"),
      "negemow1" = c("depunfairw1f", "depmistrtw1f", "depbetrayw1f"))
    ) %>% 
  filter(stjobw1i=="5 - 3" | stjobw1i=="4 - 2" | stjobw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nJob",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stjobw1i, `difference in E[y|stress]`))

#stthft - drop "any" outcome, collapse outcomes & stress var (financial)
tempdata <- margeffs_stthft_prjcrim_T1 %>%
  dplyr::filter(.category != "prjanyw1f") %>% 
  mutate(
    .category = as.factor(.category)
    )
PLME_stthft_outcomes_T1 <- 
  rbind(tempdata, margeffs_stthft_depress_T1) %>%
  mutate(
    .category = forcats::fct_collapse(.category,
      "prjtheftw1" = c("prjthflt5w1f", "prjthfgt5w1f"),
      "prjviolw1" = c("prjthreatw1f", "prjharmw1f"),
      "prjusedrgw1f" = "prjusedrgw1f",
      "prjhackw1f" = "prjhackw1f",
      "depsymw1" = c("depcantgow1f", "depeffortw1f", "deplonelyw1f", "depbluesw1f"),
      "negemow1" = c("depunfairw1f", "depmistrtw1f", "depbetrayw1f"))
    ) %>% 
  filter(stthftw1i=="5 - 3" | stthftw1i=="4 - 2" | stthftw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nCrime Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stthftw1i, `difference in E[y|stress]`))

#stmug - drop "any" outcome, collapse outcomes & stress var (financial)
tempdata <- margeffs_stmug_prjcrim_T1 %>% 
  dplyr::filter(.category != "prjanyw1f") %>% 
  mutate(
    .category = as.factor(.category)
    )
PLME_stmug_outcomes_T1 <- 
  rbind(tempdata, margeffs_stmug_depress_T1) %>%
  mutate(
    .category = forcats::fct_collapse(.category,
      "prjtheftw1" = c("prjthflt5w1f", "prjthfgt5w1f"),
      "prjviolw1" = c("prjthreatw1f", "prjharmw1f"),
      "prjusedrgw1f" = "prjusedrgw1f",
      "prjhackw1f" = "prjhackw1f",
      "depsymw1" = c("depcantgow1f", "depeffortw1f", "deplonelyw1f", "depbluesw1f"),
      "negemow1" = c("depunfairw1f", "depmistrtw1f", "depbetrayw1f"))
    ) %>% 
  filter(stmugw1i=="5 - 3" | stmugw1i=="4 - 2" | stmugw1i=="3 - 1") %>%
  group_by(.category, .draw) %>%
  mutate(mean_twodif = mean(`difference in E[y|stress]`),
         stress_var = "Stress:\nCrime Vctm",
         dif_label = "difference in E[y|stress]") %>%
slice_head() %>%
  ungroup() %>%
  dplyr::select(-c(stmugw1i, `difference in E[y|stress]`))

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
twodif_combineddvs <- bind_rows(
  PLME_stmony_outcomes_T1,
  PLME_sttran_outcomes_T1,
  PLME_stresp_outcomes_T1,
  PLME_stfair_outcomes_T1,
  PLME_stjob_outcomes_T1,
  PLME_stthft_outcomes_T1,
  PLME_stmug_outcomes_T1)

#transform stress_var into reverse-ordered factor
twodif_combineddvs2<- twodif_combineddvs %>%
  mutate(
    stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nCrime Vctm",
                                    "Stress:\nJob",
                                    "Stress:\nRelational",
                                    "Stress:\nFinancial"))
  )

#calculate row & col averages of P(mean_twodif) > 0 

#Rows: P(mean_twodif | Stress item) > 0
  #aka P(PLME>0|stress)

twodif_combineddvs2 %>%
  group_by(stress_varf) %>%
  summarise(n_ests = n(),
            n_gt0 = sum(mean_twodif>0),
            p_gt0 = n_gt0 / n_ests) 
## # A tibble: 4 × 4
##   stress_varf           n_ests n_gt0 p_gt0
##   <ord>                  <int> <int> <dbl>
## 1 "Stress:\nCrime Vctm"  48000 38362 0.799
## 2 "Stress:\nJob"         24000 20601 0.858
## 3 "Stress:\nRelational"  48000 44630 0.930
## 4 "Stress:\nFinancial"   48000 25660 0.535
# Stress:\nCrime Vctm   0.80    
# Stress:\nJob  24000   0.86    
# Stress:\nRelational   0.93    
# Stress:\nFinancial    0.54    

#Cols: P(mean_twodif | Crime item) > 0
  #aka P(PLME>0|crime)

twodif_combineddvs2 %>%
  group_by(.category) %>%
  summarise(n_ests = n(),
            n_gt0 = sum(mean_twodif>0),
            p_gt0 = n_gt0 / n_ests) 
## # A tibble: 6 × 4
##   .category    n_ests n_gt0 p_gt0
##   <fct>         <int> <int> <dbl>
## 1 prjhackw1f    28000 17447 0.623
## 2 prjviolw1     28000 18502 0.661
## 3 prjtheftw1    28000 23183 0.828
## 4 prjusedrgw1f  28000 17448 0.623
## 5 depsymw1      28000 25029 0.894
## 6 negemow1      28000 27644 0.987
# prjtheftw1    0.83    
# prjviolw1 0.66    
# prjusedrgw1f  0.63    
# prjhackw1f    0.62    
# depsymw1  0.89    
# negemow1  0.99    

#Add these posterior probabilities into variable name

outcomelabsPT1 <- c(
  "prjtheftw1"="Theft\nIntent\nP(ME>0|col)\n=.83", 
  "prjviolw1"="Violence\nIntent\nP(ME>0|col)\n=.66", 
  "prjusedrgw1f"="Use drugs\nIntent\nP(ME>0|col)\n=.63", 
  "prjhackw1f"="Hack info.\nIntent\nP(ME>0|col)\n=.62",
  "depsymw1"="Depressive\nSymptoms\nP(ME>0|col)\n=.89",
  "negemow1"="Criminogenic\nEmotions\nP(ME>0|col)\n=.99")
stress_varlabsPT1 <- c(
  "Stress:\nFinancial" = "Stress: Financial\nP(ME>0|row)\n=.54",
  "Stress:\nRelational" = "Stress: Personal\nP(ME>0|row)\n=.93",
  "Stress:\nJob" = "Stress: Job\nP(ME>0|row)\n=0.86",
  "Stress:\nCrime Vctm" = "Stress: Crime Vctm\nP(ME>0|row)\n=0.80")


#First, add p_gt0 variable used above to each stress/item combo in data (i.e. to each plot)
#Create alpha_scale variable =1 if p_gt0 < 0 (i.e., to be fully opaque) & =p_gt0 if p_gt0 > 1
twodif_combineddvs3 <- twodif_combineddvs2 %>%
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(mean_twodif>0),
         p_gt0 = n_gt0 / n_ests,
         gt0 = ifelse(mean_twodif>0, 1, 0),
         alpha_scale = ifelse(mean_twodif <=0, 1, p_gt0), 
         rural.ses.med = as.factor("0")) #add to combine figures 3 & 4 later

# }, file="cache_4_23") #end caching 

#Using sequential color palette (scio = lajolla)
#using ggnewscale to add multiple fill palettes (could also use ggh4x)
#using ggh4x to set custom xlim coords for each facet
SuppFigure2XX <- ggplot(data = twodif_combineddvs3, mapping = aes(x = mean_twodif, y = stress_varf)) + 
  facet_wrap(~.category, nrow=1, scales="free_x", 
             labeller = labeller(.category= as_labeller(outcomelabsPT1))) +
  stat_slab(mapping = aes(fill = p_gt0), .width = .95) +
 scale_fill_scico(palette = "lajolla", begin = .8, end = .3, #tells it where to start and end palette
                   name = "P(PLME > 0)", breaks = c(.1, .5, .9), labels = dropLeadingZero) + 
  new_scale_fill() + #from ggnewscale
  stat_halfeye(mapping = aes(fill = after_stat(x > 0)), .width = .95, show.legend=FALSE) + 
  scale_fill_manual(values = c("grey80", "NA")) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlab("Posterior Predicted Difference in E[y|stress]") + 
  scale_y_discrete(labels=stress_varlabsPT1) +
  facetted_pos_scales(
    x = list(
      .category %in% c("prjtheftw1", "prjviolw1", "prjusedrgw1f", "prjhackw1f") ~
        scale_x_continuous(breaks=c(-.1,-.05,0,.05,.1), 
                           limits = c(-.11,.11), labels = dropLeadingZero),
      .category %in% c("depsymw1", "negemow1") ~
        scale_x_continuous(breaks=c(-.05,0,.05,.1, .15), 
                           limits = c(-.06,.16), labels = dropLeadingZero)
    ) ) +
  labs(
    title = 'SUPP. FIGURE 2D: Marginal Effects of 2-Category Stress Difference on "Stacked" Outcome Probabilities at T1, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves. Estimates derived from 14 multivariate Bayesian logistic regression models, with each of seven \ncombined criminal intent outcomes (using `brms::mvbind()`) and each of seven combined negative emotion outcomes separately specifying a single T1 stress \ntype as a predictor. Stress items were specified as monotonic ordinal predictors with a cumulative probit link function. Models were estimated in brms with \nfour chains and 4000 total post-warmup posterior draws. Practically Large Marginal Effect (PLME) parameter distributions were first estimated from the \nexpectation of the posterior predictive distribution for each model by averaging predicted probability difference distributions for all 2-category stress contrasts \n(5-3; 4-2; 3-1) for each bivariate item pair. The final displayed PLME posterior parameter estimate distributions were then generated by "stacking" to \naverage posterior PLME estimates across models with conceptually similar outcome (e.g., Depressive Symptoms) and stress (e.g., Financial) item groupings.') + 
  theme(axis.title.y = element_blank(), 
        axis.text.y = element_text(size=10, hjust=1),
        legend.position = "bottom",
        strip.background = element_blank(),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0)) 
SuppFigure2XX 

#Export to image
# ggsave("SuppFigure2XX.jpeg", width=9, height=6.5, path=here("Output"))

The above figure essentially displays results of simple Bayesian model averaging (BMA) of posterior probabilities across conceptually similar models. Typical BMA approaches move beyond simple averages to weight model-specific posterior probabilities by indicators of the model’s relative fit or predictive performance (e.g., stacking; loo; waic).

However, again, our goal here is not to select the “best” model; rather, it is to describe correlational patterns between various stress and outcome types while communicating uncertainty in estimates. Here, we essentially assigned equal weights to each model when averaging posterior probabilities, which requires strong independence assumptions and assumes all models are equally probable.

Let’s now turn to within-person change models and “fixed effects” estimates.

save(twodif_combineddvs3, file = here("1_Data_Files/Datasets/twodif_combineddvs3.Rdata"))
save(twodif_combinedprj3, file = here("1_Data_Files/Datasets/twodif_combinedprj3.Rdata")) #NEED TO RUN
save(twodif_combineddep3, file = here("1_Data_Files/Datasets/twodif_combineddep3.Rdata")) #NEED TO RUN

6 Modeling change (T2-T1) correlations (RQ2B)

(RMD FILE: BDK_2023_Stress_5_Chgcorr_mods)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

6.1 Between-person vs within-person estimates

Descriptively, the cross-sectional T1 effect estimates above reveal between-person differences in expected outcome probabilities across participants reporting different ordinal responses to stress items. Such between-person descriptive differences are not reliable estimates of causal effects of stress on crime. For instance, as causal effect estimates, they are potentially confounded by unmeasured sources of heterogeneity; they may also reflect selection or reverse causality processes. Though causal modeling with observational data is possible, it requires a precise theory that comprehensively identifies confounders and colliders as well as mediators of the focal causal process.

Meanwhile, within-person (T2-T1 or “fixed”) effects describe average correlations between within-person changes in stress and outcome responses. These estimates essentially control for time-stable (e.g., between-person) sources of confounding are blocked in estimation, which has made them a popular alternative for generating causal inferences from observational data. Additionally, within-person correlations can be estimated simultaneously and compared with between-person estimates using a “between-within” or “hybrid modeling approach.

However, such estimates do not rule out time-varying sources of confounding, nor do they necessarily isolate selection or reverse causality processes; additionally, such estimates assess average within-person change correlations over a very specific time lag (in this case, changes over a two-year interval). Thus, though they have clear advantages to strictly estimating between-person associations, within-person change correlations from observational data should also be interpreted descriptively and should not be used to make strong causal inferences. Like cross-sectional analyses of observational data, within-person change results that are consistent with theoretical expectations may have been generated by the theorized causal process, and/or they may have been generated by one or more alternative and possibly contradictory processes.

Given our rich description aims, we estimate both between-person difference and within-person change associations. Doing so will allow us to compare them and assess whether researchers might draw different inferences from these different sets of estimates.

6.2 RQ2B: Stress-Outcome Change Correlations from T1 to T2: Within-Person Method

RQ2B: (Stress deficit; Within-person): Are within-person increases in subjective stress from T1 to T2 (i.e., T2-T1) correlated with within-person increases (T2-T1) in the probability of reporting criminal intent or negative emotions?

6.2.1 Transform data from wide to long format

#load stress.wide (from Fig1 Rmd) 
load(here("1_Data_Files/Datasets/stress_wide.Rdata"))

stress.wide <- zap_labels(stress.wide)
stress.wide <- zap_label(stress.wide)

load(here("1_Data_Files/Datasets/stress_wide2.Rdata"))
load(here("1_Data_Files/Datasets/stress_wide3.Rdata"))

#T1 posterior PLME contrasts
load(here("1_Data_Files/Datasets/twodif_combineddvs3.Rdata"))
load(here("1_Data_Files/Datasets/twodif_combinedprj3.Rdata"))
load(here("1_Data_Files/Datasets/twodif_combineddep3.Rdata"))

First, we need to manipulate key variables from the second wave of data. For instance, outcome variables should be transformed into factors, while stress items must be integers for ordinal predictor specification in brms. Then we select variables to retain and reshape the data from wide to long format (two rows per person - one for each wave) in anticipation of building multilevel within/between models. With everything we will be doing, this is the place where we will restrict focus to the more temporally appropriate criminal intent items (alongside depressive symptoms) and ignore past crime items.

#First, need to recode T2 outcome variables as factors & T2 stress items as integers for mo() 
stress.wide4 <- stress.wide3 %>% 
  mutate(
    pstthflt5w2f = factor(pstthflt5w2di, ordered=TRUE, levels = c(0,1)), 
    pstthfgt5w2f = factor(pstthfgt5w2di, ordered=TRUE, levels = c(0,1)), 
    pstthreatw2f = factor(pstthreatw2di, ordered=TRUE, levels = c(0,1)), 
    pstharmw2f = factor(pstharmw2di, ordered=TRUE, levels = c(0,1)), 
    pstusedrgw2f = factor(pstusedrgw2di, ordered=TRUE, levels = c(0,1)), 
    psthackw2f = factor(psthackw2di, ordered=TRUE, levels = c(0,1)), 
    prjthflt5w2f = factor(prjthflt5w2di, ordered=TRUE, levels = c(0,1)), 
    prjthfgt5w2f = factor(prjthfgt5w2di, ordered=TRUE, levels = c(0,1)), 
    prjthreatw2f = factor(prjthreatw2di, ordered=TRUE, levels = c(0,1)), 
    prjharmw2f = factor(prjharmw2di, ordered=TRUE, levels = c(0,1)), 
    prjusedrgw2f = factor(prjusedrgw2di, ordered=TRUE, levels = c(0,1)), 
    prjhackw2f = factor(prjhackw2di, ordered=TRUE, levels = c(0,1)), 
    prjanyw2f = factor(if_else(prjthflt5w2di == 1 | prjthfgt5w2di == 1 | prjthreatw2di == 1 |
                          prjharmw2di == 1 | prjusedrgw2di == 1 | prjhackw2di == 1, 1, 0), 
                       ordered=TRUE, levels = c(0,1)),
    depcantgow2di = if_else(depcantgow2 %in% c(4,5), 1, 0),  
      depcantgow2f = factor(depcantgow2di, ordered=TRUE, levels = c(0,1)),
    depeffortw2di = if_else(depeffortw2 %in% c(4,5), 1, 0),  
      depeffortw2f = factor(depeffortw2di, ordered=TRUE, levels = c(0,1)),
    deplonelyw2di = if_else(deplonelyw2 %in% c(4,5), 1, 0),  
      deplonelyw2f = factor(deplonelyw2di, ordered=TRUE, levels = c(0,1)),
    depbluesw2di = if_else(depbluesw2 %in% c(4,5), 1, 0),  
      depbluesw2f = factor(depbluesw2di, ordered=TRUE, levels = c(0,1)),
    depunfairw2di = if_else(depunfairw2 %in% c(4,5), 1, 0),  
      depunfairw2f = factor(depunfairw2di, ordered=TRUE, levels = c(0,1)),
    depmistrtw2di = if_else(depmistrtw2 %in% c(4,5), 1, 0),  
      depmistrtw2f = factor(depmistrtw2di, ordered=TRUE, levels = c(0,1)),
    depbetrayw2di = if_else(depbetrayw2 %in% c(4,5), 1, 0),  
      depbetrayw2f = factor(depbetrayw2di, ordered=TRUE, levels = c(0,1)),
    stmonyw2f = factor(stmonyw2, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    sttranw2f = factor(sttranw2, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    strespw2f = factor(strespw2, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stfairw2f = factor(stfairw2, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stjobw2f = factor(stjobw2, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stthftw2f = factor(stthftw2, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stmugw2f = factor(stmugw2, ordered=TRUE, levels = c(1, 2, 3, 4, 5)),
    stmonyw2i = recode(stmonyw2f,
            "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    sttranw2i = recode(sttranw2f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    strespw2i = recode(strespw2f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    stfairw2i = recode(stfairw2f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    stjobw2i = recode(stjobw2f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    stthftw2i = recode(stthftw2f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(),
    stmugw2i = recode(stmugw2f,
        "1" = 1, "2" = 2, "3" = 3, "4" = 4, "5" = 5) %>% 
       as.integer(), 
    fnhdav12 = (osfinaw1 + osfinaw2)/2, 
    fnhddvw1i = osfinaw1 - fnhdav12,  
    fnhddvw2i = osfinaw2 - fnhdav12
    ) %>% 
  rename(
    depunfairordw1 = depunfairw1, 
    depmistrtordw1 = depmistrtw1, 
    depbetrayordw1 = depbetrayw1, 
    depunfairordw2 = depunfairw2, 
    depmistrtordw2 = depmistrtw2, 
    depbetrayordw2 = depbetrayw2
  ) %>%
  dplyr::select(c(
    id, female, rural, area_id, agew1, educw1, kidsw1, marriedw1, 
    fnhdav12, fnhddvw1i, fnhddvw2i, L2sesw1, 
    rural.ses.avg, rural.ses.med, rural.ses.med2,
    stmonyw1i, sttranw1i, strespw1i, stfairw1i, stjobw1i, stthftw1i, stmugw1i,
    stmonyw2i, sttranw2i, strespw2i, stfairw2i, stjobw2i, stthftw2i, stmugw2i,
    pstthflt5w1f, pstthfgt5w1f, pstthreatw1f, 
    pstharmw1f, pstusedrgw1f, psthackw1f, 
    pstthflt5w2f, pstthfgt5w2f, pstthreatw2f, 
    pstharmw2f, pstusedrgw2f, psthackw2f, 
    prjthflt5w1f, prjthfgt5w1f, prjthreatw1f, 
    prjharmw1f, prjusedrgw1f, prjhackw1f, prjanyw1f, 
    prjthflt5w2f, prjthfgt5w2f, prjthreatw2f, 
    prjharmw2f, prjusedrgw2f, prjhackw2f, prjanyw2f,
    depcantgow1f, depeffortw1f, deplonelyw1f, depbluesw1f, 
    depunfairw1f, depmistrtw1f, depbetrayw1f, 
    depcantgow2f, depeffortw2f, deplonelyw2f, depbluesw2f, 
    depunfairw2f, depmistrtw2f, depbetrayw2f,
    depunfairordw1, depmistrtordw1, depbetrayordw1, 
    depunfairordw2, depmistrtordw2, depbetrayordw2)) 


scale2x <- function(x, na.rm = FALSE) (x*2)

stress.long <- stress.wide4 %>%
  pivot_longer(
    cols = !c(id, female, rural, area_id, agew1, educw1, kidsw1, marriedw1,
       fnhdav12, L2sesw1, 
       rural.ses.avg, rural.ses.med, rural.ses.med2),
    names_to = c(".value","year"),  #splits each varname into new var + year
    names_pattern = "(.*?)w(\\d)"   #use regex +  names_pattern to split varname
  ) %>%  #newvar = text up to 'w' (drop w; not in group), year is next digit
  group_by(id) %>% #create cross-time ave stress variables (av12)
  mutate(across(stmony:stmug, mean, .names = "{col}_av12")) %>%   
  ungroup() %>% 
  mutate(across(stmony_av12:stmug_av12, scale2x, .names = "{col}x2")) %>% #mult 2x av12 vars to make whole integers
  mutate(across(stmony_av12x2:stmug_av12x2, as.integer)) %>% #convert av12 vars to integers for mo()
  mutate(
    stmony_dev = stmony - stmony_av12,
    sttran_dev = sttran - sttran_av12,
    stresp_dev = stresp - stresp_av12,
    stfair_dev = stfair - stfair_av12,
    stjob_dev = stjob - stjob_av12,
    stthft_dev = stthft - stthft_av12,
    stmug_dev = stmug - stmug_av12
  ) %>% #create stress deviation scores from within-person cross-time avg  
  mutate(across(stmony_dev:stmug_dev, scale2x, .names = "{col}x2")) %>% #mult 2x dev vars to make whole integers (representing +/- unit stress change)
  mutate(across(stmony_devx2:stmug_devx2, ~ifelse(.<=-2, -2, .))) %>% #recode to cap 2x changes at +/-2 
  mutate(across(stmony_devx2:stmug_devx2, ~ifelse(.>=2, 2, .))) %>% #recode to cap 2x changes at +/-2
  mutate(across(stmony_devx2:stmug_devx2, as.integer)) #convert devx2 vars to integers for mo()

#NOTE: very few ids had stress changes <-2 or >2, so collapsed max changes to +/- 2 

# stress_devx2 scores have 5 levels so 4 ordered thresholds

  # table(stress.long$stmony_devx2)
  # table(stress.long$sttran_devx2)
  # table(stress.long$stresp_devx2)
  # table(stress.long$stfair_devx2)
  # table(stress.long$stjob_devx2)
  # table(stress.long$stthft_devx2)
  # table(stress.long$stmug_devx2)

# stress_av12x2 scores have 9 levels so 9 ordered thresholds

  # table(stress.long$stmony_av12x2)
  # table(stress.long$sttran_av12x2)
  # table(stress.long$stresp_av12x2)
  # table(stress.long$stfair_av12x2)
  # table(stress.long$stjob_av12x2)
  # table(stress.long$stthft_av12x2)
  # table(stress.long$stmug_av12x2)

#view amount of change in specific crim intent & "any" crim intent 
tempdata <- stress.wide %>% 
  mutate(
    prjthflt5ch12 = prjthflt5w2di - prjthflt5w1di, 
    prjthfgt5ch12 = prjthfgt5w2di - prjthfgt5w1di, 
    prjthreatch12 = prjthreatw2di - prjthreatw1di, 
    prjharmch12 = prjharmw2di - prjharmw1di,
    prjusedrgch12 = prjusedrgw2di - prjusedrgw1di, 
    prjhackch12 = prjhackw2di - prjhackw1di)

p1 <- ggplot(tempdata, aes(prjthflt5ch12)) + geom_bar(fill="#E99D53")
p2 <- ggplot(tempdata, aes(prjthfgt5ch12)) + geom_bar(fill="#E99D53")
p3 <- ggplot(tempdata, aes(prjthreatch12)) + geom_bar(fill="#E99D53")
p4 <- ggplot(tempdata, aes(prjharmch12)) + geom_bar(fill="#E99D53")
p5 <- ggplot(tempdata, aes(prjusedrgch12)) + geom_bar(fill="#E99D53")
p6 <- ggplot(tempdata, aes(prjhackch12)) + geom_bar(fill="#E99D53")

# table(tempdata$prjthflt5ch12)
# table(tempdata$prjthfgt5ch12)
# table(tempdata$prjthreatch12)
# table(tempdata$prjharmch12)
# table(tempdata$prjusedrgch12)
# table(tempdata$prjhackch12)

tempdata <- stress.wide4 %>% 
  mutate(
    prjanyw1 = as.integer(prjanyw1f), 
    prjanyw2 = as.integer(prjanyw2f), 
    prjchg12 = prjanyw2 - prjanyw1
  )

p7 <- ggplot(tempdata, aes(prjchg12)) + geom_bar(fill="#E99D53")

# table(tempdata$prjchg12)

#NOTE - change in criminal intent across waves is very rare (as is "1" on crim intent)

(p1 | p2 | p3 | p4) / (p5 | p6 | p7 | plot_spacer())

tempdata <- stress.wide %>% 
  mutate(
    prjthflt5ch12 = prjthflt5w2di - prjthflt5w1di, 
    prjthfgt5ch12 = prjthfgt5w2di - prjthfgt5w1di, 
    prjthreatch12 = prjthreatw2di - prjthreatw1di, 
    prjharmch12 = prjharmw2di - prjharmw1di,
    prjusedrgch12 = prjusedrgw2di - prjusedrgw1di, 
    prjhackch12 = prjhackw2di - prjhackw1di)

p1b <- ggplot(tempdata, aes(x=prjthflt5ch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p2b <- ggplot(tempdata, aes(x=prjthfgt5ch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p3b <- ggplot(tempdata, aes(x=prjthreatch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p4b <- ggplot(tempdata, aes(x=prjharmch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p5b <- ggplot(tempdata, aes(x=prjusedrgch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p6b <- ggplot(tempdata, aes(x=prjhackch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)

tempdata <- stress.wide4 %>% 
  mutate(
    prjanyw1 = as.integer(prjanyw1f), 
    prjanyw2 = as.integer(prjanyw2f), 
    prjchg12 = prjanyw2 - prjanyw1
  )

p7b <- ggplot(tempdata, aes(x=prjchg12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)

# table(tempdata$prjchg12)

#NOTE - change in criminal intent across waves is very rare (as is "1" on crim intent)

pdesign <- "1234 \n 5678" 

p1b + p2b + p3b + p4b + p5b + p6b + p7b + guide_area() + 
  plot_layout(design = pdesign, guides='collect')

As expected, there is relatively little variation in criminal intent changes, which means we should be wary when interpreting results due to potentially low signal-to-noise ratio. As we hoped, the “any crime” item shows a bit more variability overall and among both urban and rural residents.

Before moving to modeling, let’s take a quick look at stress changes by rural/urban residence as well.

tempdata <- stress.wide %>% 
  mutate(
    stmonych12 = stmonyw2 - stmonyw1, 
    sttranch12 = sttranw2 - sttranw1, 
    strespch12 = strespw2 - strespw1, 
    stfairch12 = stfairw2 - stfairw1,
    stjobch12 = stjobw2 - stjobw1, 
    stthftch12 = stthftw2 - stthftw1, 
    stmugch12 = stmugw2 - stmugw1)

p1s <- ggplot(tempdata, aes(x=stmonych12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p2s <- ggplot(tempdata, aes(x=sttranch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p3s <- ggplot(tempdata, aes(x=strespch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p4s <- ggplot(tempdata, aes(x=stfairch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p5s <- ggplot(tempdata, aes(x=stjobch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p6s <- ggplot(tempdata, aes(x=stthftch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)
p7s <- ggplot(tempdata, aes(x=stmugch12, y= ..prop.., fill=as.factor(rural))) +
  geom_bar(position = "dodge") + 
  scale_fill_scico_d(palette = "lajolla", , begin = .8, end = .3)

# table(tempdata$prjchg12)

#NOTE - change in criminal intent across waves is very rare (as is "1" on crim intent)

pdesign <- "1234 \n 5678" 

p1s + p2s + p3s + p4s + p5s + p6s + p7s + guide_area() + 
  plot_layout(design = pdesign, guides='collect')

There is much more variability in subjective stress change items than in criminal intent items, overall and separately among both rural and urban residents. So, perhaps unsurprisingly, subjective stress reports change across waves but criminal intent is much more rare and is more stable over time.

6.2.2 Criminal intent: Bivariate Change models

Refer to Kurz’s similar application with a binary IV.

As we noted earlier, very few respondents reported stress reductions or increases across the two waves greater than two units (on Likert-type stress items ranging from 1 to 5). In fact, even two-unit changes in either direction across the two waves were quite rare. So, as part of the data wrangling above, the few changes greater than two units were collapsed to a maximum category of (+/-)2.

Now we are ready to build the basic within/between models. As before, we will specify multivariate logistic brms models w/monotonic ordinal predictors. However, these will be multilevel “between/within” models with a random intercept, which allows outcome probabilities to vary across individuals. We do not add a fixed effect for time (i.e., latent growth curve) to avoid inappropriately partialling out any causal effects of systematic changes in stress across waves that might be absorbed by an estimator for population-level outcome trends over time (although inclusion only very slightly attenuates estimated change associations).

For more information about different models for two-wave data, see Kurz’s excellent posts here and here. For more information about estimating between/within models in R, see here and here.

The “between” part of a between/within multilevel model indicates that we will include a person-level average stress score (\(\overline{X_i}\), or cross-time average X value for individual i) as a L2 predictor to estimate between-person stress/outcome correlations. The “within” part indicates that we will also include the within-person deviation from the person level mean (\((X_{ij} - \overline{Xi})\), or difference between X value for individual i at time j and individual i’s cross-time X value) as a L1 predictor. This within-person deviation score estimates the association between changes in X (stress) and changes in an outcome; also known as a “fixed effects” estimator, this estimate differences out all time stable effects of time-invariant (observed or unobserved) confounders.

Both the within and between variables were specified as monotonic ordinal predictors with brms built-in cumulative probit link function (mo()). To do this, recall our predictors need to be formatted as integers. Hence, in data wrangling above, we multiplied stress L2 and L1 predictors by two and then transformed them to integers. Hence, rather than being scaled from ‘1’ to ‘5’ with 0.5-unit increments, the cross-time average L2 stress items now range from ‘2’ to ‘10’ with 1-unit increments. Likewise, after rescaling, a 1-unit stress change on the original scale (e.g., increase from 2 to 3) is represented by -1 at year 1 and 1 at year 2 (rather than -.5 and .5). The scaling of the units is inconsequential since the estimated effects of ordinal increases are modeled across latent thresholds anyway.

6.2.2.1 B/W Change Corr: stmony/crim intent

#Bivariate Change: criminal intent items ~ mo(stmony)
 
#Vectorize priors:

#list of colnames for projected crime DVs  
prjdv_names <- noquote(c("prjthflt5", "prjthfgt5", "prjthreat", "prjharm", 
                         "prjusedrg", "prjhack"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmony_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostmony_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmony_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostmony_av12x21', 
                  resp = prjdv_names)
  )

# drop year from model to avoid inappropriately partially out systematic stress change differences.  
  # also, with two waves, can only add random int OR random slope for year
chg.prjcrime.stmony.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/chg_prjcrime_stmony_fit",
      file_refit = "on_change"
  )

#Update function to call all ppchecks for bivar projected crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="prjthflt5")
  ppcheckdv2 <-pp_check(modelfit, resp="prjthfgt5")
  ppcheckdv3 <-pp_check(modelfit, resp="prjthreat")
  ppcheckdv4 <-pp_check(modelfit, resp="prjharm")
  ppcheckdv5 <-pp_check(modelfit, resp="prjusedrg")
  ppcheckdv6 <-pp_check(modelfit, resp="prjhack")
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95) +
    labs(title = "Coefficient plot",
         subtitle = "Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, 
                    ppcheckdv3, ppcheckdv4, ppcheckdv5, ppcheckdv6, 
                    plotcoefs, plotcoefs2)
  return(allchecks)
}

out.chg.prjcrime.stmony.fit <- ppchecks(chg.prjcrime.stmony.fit)
6.2.2.1.1 Coefficient plot (intervals)
out.chg.prjcrime.stmony.fit[[10]]

6.2.2.1.2 Coefficient plot (distributions)
out.chg.prjcrime.stmony.fit[[9]]

6.2.2.1.3 PPcheck (density)
p1 <- out.chg.prjcrime.stmony.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.chg.prjcrime.stmony.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.chg.prjcrime.stmony.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.chg.prjcrime.stmony.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.chg.prjcrime.stmony.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.chg.prjcrime.stmony.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

6.2.2.1.4 Fit summary
out.chg.prjcrime.stmony.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          prjthreat ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          prjharm ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          prjusedrg ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          prjhack ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     4.59      0.64     3.44     5.89 1.00     1491
## sd(prjthfgt5_Intercept)     3.83      0.56     2.84     5.02 1.00     1012
## sd(prjthreat_Intercept)     3.57      0.59     2.53     4.86 1.00     1523
## sd(prjharm_Intercept)       2.98      0.55     2.01     4.16 1.00     1053
## sd(prjusedrg_Intercept)     3.25      0.56     2.23     4.43 1.00     1640
## sd(prjhack_Intercept)       0.87      0.55     0.04     2.05 1.01      411
##                         Tail_ESS
## sd(prjthflt5_Intercept)     1984
## sd(prjthfgt5_Intercept)     1722
## sd(prjthreat_Intercept)     2427
## sd(prjharm_Intercept)       2437
## sd(prjusedrg_Intercept)     2214
## sd(prjhack_Intercept)       1178
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_Intercept          -5.87      0.85    -7.62    -4.29 1.01     1982
## prjthfgt5_Intercept          -5.65      0.80    -7.29    -4.16 1.00     1928
## prjthreat_Intercept          -5.91      0.93    -7.86    -4.21 1.00     2330
## prjharm_Intercept            -5.36      0.90    -7.23    -3.74 1.00     1705
## prjusedrg_Intercept          -5.84      0.92    -7.79    -4.09 1.00     2490
## prjhack_Intercept            -4.10      0.69    -5.63    -2.86 1.00     1545
## prjthflt5_mostmony_devx2      0.20      0.17    -0.16     0.52 1.00     4336
## prjthflt5_mostmony_av12x2    -0.04      0.10    -0.23     0.15 1.00     2714
## prjthfgt5_mostmony_devx2      0.27      0.16    -0.06     0.58 1.00     4547
## prjthfgt5_mostmony_av12x2    -0.01      0.09    -0.19     0.16 1.00     3047
## prjthreat_mostmony_devx2     -0.07      0.19    -0.45     0.31 1.00     5597
## prjthreat_mostmony_av12x2    -0.09      0.10    -0.28     0.11 1.00     3780
## prjharm_mostmony_devx2       -0.07      0.19    -0.47     0.29 1.00     4985
## prjharm_mostmony_av12x2      -0.12      0.09    -0.29     0.06 1.00     4373
## prjusedrg_mostmony_devx2     -0.15      0.20    -0.52     0.23 1.00     6376
## prjusedrg_mostmony_av12x2    -0.06      0.10    -0.24     0.13 1.00     3620
## prjhack_mostmony_devx2        0.06      0.19    -0.34     0.42 1.00     4748
## prjhack_mostmony_av12x2      -0.04      0.08    -0.21     0.12 1.00     5592
##                           Tail_ESS
## prjthflt5_Intercept           2534
## prjthfgt5_Intercept           2921
## prjthreat_Intercept           2395
## prjharm_Intercept             2841
## prjusedrg_Intercept           2835
## prjhack_Intercept             1978
## prjthflt5_mostmony_devx2      2045
## prjthflt5_mostmony_av12x2     3001
## prjthfgt5_mostmony_devx2      2946
## prjthfgt5_mostmony_av12x2     3119
## prjthreat_mostmony_devx2      2868
## prjthreat_mostmony_av12x2     2584
## prjharm_mostmony_devx2        2294
## prjharm_mostmony_av12x2       2831
## prjusedrg_mostmony_devx2      3288
## prjusedrg_mostmony_av12x2     2815
## prjhack_mostmony_devx2        2378
## prjhack_mostmony_av12x2       2998
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## prjthflt5_mostmony_devx21[1]      0.22      0.14     0.03     0.54 1.00
## prjthflt5_mostmony_devx21[2]      0.26      0.14     0.04     0.58 1.00
## prjthflt5_mostmony_devx21[3]      0.29      0.16     0.04     0.63 1.00
## prjthflt5_mostmony_devx21[4]      0.23      0.14     0.03     0.55 1.00
## prjthflt5_mostmony_av12x21[1]     0.13      0.08     0.02     0.32 1.00
## prjthflt5_mostmony_av12x21[2]     0.13      0.08     0.02     0.34 1.00
## prjthflt5_mostmony_av12x21[3]     0.13      0.08     0.02     0.32 1.00
## prjthflt5_mostmony_av12x21[4]     0.12      0.08     0.02     0.31 1.00
## prjthflt5_mostmony_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## prjthflt5_mostmony_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## prjthflt5_mostmony_av12x21[7]     0.12      0.08     0.01     0.32 1.00
## prjthflt5_mostmony_av12x21[8]     0.12      0.08     0.02     0.30 1.00
## prjthfgt5_mostmony_devx21[1]      0.20      0.13     0.03     0.49 1.00
## prjthfgt5_mostmony_devx21[2]      0.30      0.15     0.05     0.62 1.00
## prjthfgt5_mostmony_devx21[3]      0.28      0.15     0.05     0.59 1.00
## prjthfgt5_mostmony_devx21[4]      0.22      0.13     0.03     0.53 1.00
## prjthfgt5_mostmony_av12x21[1]     0.13      0.08     0.02     0.32 1.00
## prjthfgt5_mostmony_av12x21[2]     0.13      0.08     0.02     0.33 1.00
## prjthfgt5_mostmony_av12x21[3]     0.13      0.08     0.02     0.32 1.00
## prjthfgt5_mostmony_av12x21[4]     0.12      0.08     0.02     0.32 1.00
## prjthfgt5_mostmony_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## prjthfgt5_mostmony_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## prjthfgt5_mostmony_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## prjthfgt5_mostmony_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mostmony_devx21[1]      0.27      0.15     0.04     0.60 1.00
## prjthreat_mostmony_devx21[2]      0.24      0.14     0.03     0.56 1.00
## prjthreat_mostmony_devx21[3]      0.24      0.14     0.04     0.57 1.00
## prjthreat_mostmony_devx21[4]      0.25      0.15     0.04     0.59 1.00
## prjthreat_mostmony_av12x21[1]     0.13      0.08     0.02     0.32 1.00
## prjthreat_mostmony_av12x21[2]     0.12      0.08     0.02     0.32 1.00
## prjthreat_mostmony_av12x21[3]     0.13      0.08     0.02     0.32 1.00
## prjthreat_mostmony_av12x21[4]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mostmony_av12x21[5]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mostmony_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mostmony_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mostmony_av12x21[8]     0.12      0.08     0.02     0.31 1.00
## prjharm_mostmony_devx21[1]        0.27      0.15     0.04     0.60 1.00
## prjharm_mostmony_devx21[2]        0.24      0.14     0.03     0.57 1.00
## prjharm_mostmony_devx21[3]        0.23      0.14     0.03     0.56 1.00
## prjharm_mostmony_devx21[4]        0.26      0.15     0.04     0.60 1.00
## prjharm_mostmony_av12x21[1]       0.12      0.08     0.02     0.31 1.00
## prjharm_mostmony_av12x21[2]       0.12      0.08     0.01     0.32 1.00
## prjharm_mostmony_av12x21[3]       0.13      0.08     0.02     0.32 1.00
## prjharm_mostmony_av12x21[4]       0.13      0.08     0.02     0.33 1.00
## prjharm_mostmony_av12x21[5]       0.13      0.08     0.02     0.33 1.00
## prjharm_mostmony_av12x21[6]       0.14      0.09     0.02     0.35 1.00
## prjharm_mostmony_av12x21[7]       0.12      0.08     0.02     0.31 1.00
## prjharm_mostmony_av12x21[8]       0.11      0.07     0.02     0.29 1.00
## prjusedrg_mostmony_devx21[1]      0.27      0.15     0.04     0.61 1.00
## prjusedrg_mostmony_devx21[2]      0.25      0.15     0.04     0.58 1.00
## prjusedrg_mostmony_devx21[3]      0.23      0.13     0.03     0.54 1.00
## prjusedrg_mostmony_devx21[4]      0.25      0.15     0.04     0.58 1.00
## prjusedrg_mostmony_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## prjusedrg_mostmony_av12x21[2]     0.13      0.08     0.02     0.32 1.00
## prjusedrg_mostmony_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## prjusedrg_mostmony_av12x21[4]     0.13      0.08     0.02     0.33 1.00
## prjusedrg_mostmony_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## prjusedrg_mostmony_av12x21[6]     0.12      0.08     0.02     0.32 1.00
## prjusedrg_mostmony_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## prjusedrg_mostmony_av12x21[8]     0.12      0.08     0.02     0.32 1.00
## prjhack_mostmony_devx21[1]        0.25      0.14     0.04     0.58 1.00
## prjhack_mostmony_devx21[2]        0.24      0.14     0.04     0.55 1.00
## prjhack_mostmony_devx21[3]        0.26      0.14     0.04     0.58 1.00
## prjhack_mostmony_devx21[4]        0.25      0.14     0.04     0.57 1.00
## prjhack_mostmony_av12x21[1]       0.13      0.08     0.02     0.32 1.00
## prjhack_mostmony_av12x21[2]       0.13      0.08     0.02     0.33 1.00
## prjhack_mostmony_av12x21[3]       0.13      0.08     0.01     0.33 1.00
## prjhack_mostmony_av12x21[4]       0.12      0.08     0.02     0.32 1.00
## prjhack_mostmony_av12x21[5]       0.12      0.08     0.01     0.30 1.00
## prjhack_mostmony_av12x21[6]       0.12      0.08     0.02     0.31 1.00
## prjhack_mostmony_av12x21[7]       0.12      0.08     0.02     0.31 1.00
## prjhack_mostmony_av12x21[8]       0.12      0.08     0.02     0.32 1.00
##                               Bulk_ESS Tail_ESS
## prjthflt5_mostmony_devx21[1]      4940     2069
## prjthflt5_mostmony_devx21[2]      4958     2353
## prjthflt5_mostmony_devx21[3]      4346     2559
## prjthflt5_mostmony_devx21[4]      5674     2411
## prjthflt5_mostmony_av12x21[1]     5639     2488
## prjthflt5_mostmony_av12x21[2]     5022     2561
## prjthflt5_mostmony_av12x21[3]     6539     2758
## prjthflt5_mostmony_av12x21[4]     6718     2355
## prjthflt5_mostmony_av12x21[5]     7046     2625
## prjthflt5_mostmony_av12x21[6]     4234     2310
## prjthflt5_mostmony_av12x21[7]     5660     2839
## prjthflt5_mostmony_av12x21[8]     5002     3127
## prjthfgt5_mostmony_devx21[1]      7068     3215
## prjthfgt5_mostmony_devx21[2]      4678     2776
## prjthfgt5_mostmony_devx21[3]      5041     2769
## prjthfgt5_mostmony_devx21[4]      6731     2790
## prjthfgt5_mostmony_av12x21[1]     5319     2487
## prjthfgt5_mostmony_av12x21[2]     6610     2693
## prjthfgt5_mostmony_av12x21[3]     5287     2216
## prjthfgt5_mostmony_av12x21[4]     5870     2165
## prjthfgt5_mostmony_av12x21[5]     6238     2416
## prjthfgt5_mostmony_av12x21[6]     5453     2779
## prjthfgt5_mostmony_av12x21[7]     5508     2509
## prjthfgt5_mostmony_av12x21[8]     6166     2977
## prjthreat_mostmony_devx21[1]      5739     2493
## prjthreat_mostmony_devx21[2]      7266     2072
## prjthreat_mostmony_devx21[3]      6132     2871
## prjthreat_mostmony_devx21[4]      6892     2986
## prjthreat_mostmony_av12x21[1]     6119     2632
## prjthreat_mostmony_av12x21[2]     6249     2572
## prjthreat_mostmony_av12x21[3]     4460     2337
## prjthreat_mostmony_av12x21[4]     5565     2505
## prjthreat_mostmony_av12x21[5]     5752     2261
## prjthreat_mostmony_av12x21[6]     5070     2855
## prjthreat_mostmony_av12x21[7]     5215     2742
## prjthreat_mostmony_av12x21[8]     5178     2468
## prjharm_mostmony_devx21[1]        6258     2519
## prjharm_mostmony_devx21[2]        5892     2512
## prjharm_mostmony_devx21[3]        4650     2398
## prjharm_mostmony_devx21[4]        5089     2594
## prjharm_mostmony_av12x21[1]       5000     1879
## prjharm_mostmony_av12x21[2]       6111     2297
## prjharm_mostmony_av12x21[3]       6402     2171
## prjharm_mostmony_av12x21[4]       6620     2899
## prjharm_mostmony_av12x21[5]       5990     2712
## prjharm_mostmony_av12x21[6]       6090     2645
## prjharm_mostmony_av12x21[7]       6688     3073
## prjharm_mostmony_av12x21[8]       6351     2694
## prjusedrg_mostmony_devx21[1]      5728     2436
## prjusedrg_mostmony_devx21[2]      6212     2589
## prjusedrg_mostmony_devx21[3]      5025     2658
## prjusedrg_mostmony_devx21[4]      6039     2813
## prjusedrg_mostmony_av12x21[1]     5792     2165
## prjusedrg_mostmony_av12x21[2]     6063     2709
## prjusedrg_mostmony_av12x21[3]     5607     2727
## prjusedrg_mostmony_av12x21[4]     4863     2286
## prjusedrg_mostmony_av12x21[5]     4984     2261
## prjusedrg_mostmony_av12x21[6]     5710     2817
## prjusedrg_mostmony_av12x21[7]     5293     3042
## prjusedrg_mostmony_av12x21[8]     5817     2972
## prjhack_mostmony_devx21[1]        6384     2228
## prjhack_mostmony_devx21[2]        5713     2598
## prjhack_mostmony_devx21[3]        4777     2593
## prjhack_mostmony_devx21[4]        4461     2381
## prjhack_mostmony_av12x21[1]       6203     2637
## prjhack_mostmony_av12x21[2]       6448     2866
## prjhack_mostmony_av12x21[3]       5061     1903
## prjhack_mostmony_av12x21[4]       6829     2611
## prjhack_mostmony_av12x21[5]       5258     1834
## prjhack_mostmony_av12x21[6]       5805     2763
## prjhack_mostmony_av12x21[7]       5737     2855
## prjhack_mostmony_av12x21[8]       5432     3024
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.2.1.5 Prior summary
out.chg.prjcrime.stmony.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                          prjhack
##                   normal(0, 0.125)         b  mostmony_av12x2         prjhack
##                    normal(0, 0.25)         b   mostmony_devx2         prjhack
##                             (flat)         b                          prjharm
##                   normal(0, 0.125)         b  mostmony_av12x2         prjharm
##                    normal(0, 0.25)         b   mostmony_devx2         prjharm
##                             (flat)         b                        prjthfgt5
##                   normal(0, 0.125)         b  mostmony_av12x2       prjthfgt5
##                    normal(0, 0.25)         b   mostmony_devx2       prjthfgt5
##                             (flat)         b                        prjthflt5
##                   normal(0, 0.125)         b  mostmony_av12x2       prjthflt5
##                    normal(0, 0.25)         b   mostmony_devx2       prjthflt5
##                             (flat)         b                        prjthreat
##                   normal(0, 0.125)         b  mostmony_av12x2       prjthreat
##                    normal(0, 0.25)         b   mostmony_devx2       prjthreat
##                             (flat)         b                        prjusedrg
##                   normal(0, 0.125)         b  mostmony_av12x2       prjusedrg
##                    normal(0, 0.25)         b   mostmony_devx2       prjusedrg
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                          prjhack
##                       normal(0, 2) Intercept                          prjharm
##                       normal(0, 2) Intercept                        prjthfgt5
##                       normal(0, 2) Intercept                        prjthflt5
##                       normal(0, 2) Intercept                        prjthreat
##                       normal(0, 2) Intercept                        prjusedrg
##               student_t(3, 0, 2.5)        sd                          prjhack
##               student_t(3, 0, 2.5)        sd                          prjharm
##               student_t(3, 0, 2.5)        sd                        prjthfgt5
##               student_t(3, 0, 2.5)        sd                        prjthflt5
##               student_t(3, 0, 2.5)        sd                        prjthreat
##               student_t(3, 0, 2.5)        sd                        prjusedrg
##               student_t(3, 0, 2.5)        sd                     id   prjhack
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjhack
##               student_t(3, 0, 2.5)        sd                     id   prjharm
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjharm
##               student_t(3, 0, 2.5)        sd                     id prjthfgt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthfgt5
##               student_t(3, 0, 2.5)        sd                     id prjthflt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthflt5
##               student_t(3, 0, 2.5)        sd                     id prjthreat
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthreat
##               student_t(3, 0, 2.5)        sd                     id prjusedrg
##               student_t(3, 0, 2.5)        sd        Intercept    id prjusedrg
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21         prjhack
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21         prjhack
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21         prjharm
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21         prjharm
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       prjthfgt5
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       prjthfgt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       prjthflt5
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       prjthflt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       prjthreat
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       prjthreat
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       prjusedrg
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.2.2 B/W Change Corr: sttran/crim intent

#Bivariate Change: criminal intent items ~ mo(sttran)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mosttran_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mosttran_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mosttran_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mosttran_av12x21', 
                  resp = prjdv_names)
  )

chg.prjcrime.sttran.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/chg_prjcrime_sttran_fit",
      file_refit = "on_change"
  )
out.chg.prjcrime.sttran.fit <- ppchecks(chg.prjcrime.sttran.fit)
6.2.2.2.1 Coefficient plot (intervals)
out.chg.prjcrime.sttran.fit[[10]]

6.2.2.2.2 Coefficient plot (distributions)
out.chg.prjcrime.sttran.fit[[9]]

6.2.2.2.3 PPcheck (density)
p1 <- out.chg.prjcrime.sttran.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.chg.prjcrime.sttran.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.chg.prjcrime.sttran.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.chg.prjcrime.sttran.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.chg.prjcrime.sttran.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.chg.prjcrime.sttran.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

6.2.2.2.4 Fit summary
out.chg.prjcrime.sttran.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          prjthfgt5 ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          prjthreat ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          prjharm ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          prjusedrg ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          prjhack ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     4.57      0.65     3.45     6.00 1.00     1496
## sd(prjthfgt5_Intercept)     3.81      0.55     2.86     5.00 1.00     1111
## sd(prjthreat_Intercept)     3.59      0.59     2.56     4.90 1.00     1614
## sd(prjharm_Intercept)       3.05      0.53     2.11     4.20 1.00     1720
## sd(prjusedrg_Intercept)     3.26      0.58     2.26     4.49 1.00     1565
## sd(prjhack_Intercept)       0.92      0.56     0.04     2.09 1.00      675
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2124
## sd(prjthfgt5_Intercept)     2379
## sd(prjthreat_Intercept)     2140
## sd(prjharm_Intercept)       2572
## sd(prjusedrg_Intercept)     2195
## sd(prjhack_Intercept)       1477
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_Intercept          -5.25      0.84    -7.09    -3.69 1.00     2118
## prjthfgt5_Intercept          -5.03      0.75    -6.60    -3.63 1.00     1640
## prjthreat_Intercept          -5.86      0.96    -7.86    -4.11 1.00     2283
## prjharm_Intercept            -4.78      0.91    -6.66    -3.05 1.00     2287
## prjusedrg_Intercept          -5.62      0.96    -7.66    -3.91 1.00     1956
## prjhack_Intercept            -3.67      0.73    -5.20    -2.30 1.00     1873
## prjthflt5_mosttran_devx2      0.01      0.17    -0.34     0.34 1.00     3645
## prjthflt5_mosttran_av12x2    -0.10      0.10    -0.30     0.10 1.00     2865
## prjthfgt5_mosttran_devx2      0.02      0.17    -0.33     0.36 1.00     4867
## prjthfgt5_mosttran_av12x2    -0.03      0.10    -0.23     0.15 1.00     2472
## prjthreat_mosttran_devx2     -0.21      0.18    -0.58     0.15 1.00     5342
## prjthreat_mosttran_av12x2    -0.04      0.10    -0.24     0.16 1.00     3338
## prjharm_mosttran_devx2       -0.34      0.19    -0.73     0.04 1.00     5086
## prjharm_mosttran_av12x2      -0.15      0.09    -0.33     0.04 1.00     3801
## prjusedrg_mosttran_devx2     -0.25      0.20    -0.63     0.13 1.00     5810
## prjusedrg_mosttran_av12x2    -0.07      0.10    -0.26     0.14 1.00     4254
## prjhack_mosttran_devx2       -0.24      0.19    -0.62     0.13 1.00     5013
## prjhack_mosttran_av12x2      -0.01      0.09    -0.18     0.16 1.00     4614
##                           Tail_ESS
## prjthflt5_Intercept           2121
## prjthfgt5_Intercept           2972
## prjthreat_Intercept           2504
## prjharm_Intercept             2310
## prjusedrg_Intercept           2329
## prjhack_Intercept             2313
## prjthflt5_mosttran_devx2      2294
## prjthflt5_mosttran_av12x2     2594
## prjthfgt5_mosttran_devx2      2880
## prjthfgt5_mosttran_av12x2     2347
## prjthreat_mosttran_devx2      3012
## prjthreat_mosttran_av12x2     2961
## prjharm_mosttran_devx2        2773
## prjharm_mosttran_av12x2       3044
## prjusedrg_mosttran_devx2      2733
## prjusedrg_mosttran_av12x2     3131
## prjhack_mosttran_devx2        2940
## prjhack_mosttran_av12x2       2774
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## prjthflt5_mosttran_devx21[1]      0.26      0.15     0.04     0.60 1.00
## prjthflt5_mosttran_devx21[2]      0.24      0.14     0.04     0.56 1.00
## prjthflt5_mosttran_devx21[3]      0.24      0.14     0.03     0.56 1.00
## prjthflt5_mosttran_devx21[4]      0.26      0.15     0.03     0.59 1.00
## prjthflt5_mosttran_av12x21[1]     0.13      0.08     0.02     0.34 1.00
## prjthflt5_mosttran_av12x21[2]     0.14      0.09     0.02     0.34 1.00
## prjthflt5_mosttran_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## prjthflt5_mosttran_av12x21[4]     0.13      0.08     0.02     0.31 1.00
## prjthflt5_mosttran_av12x21[5]     0.12      0.08     0.02     0.32 1.00
## prjthflt5_mosttran_av12x21[6]     0.12      0.08     0.02     0.32 1.00
## prjthflt5_mosttran_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## prjthflt5_mosttran_av12x21[8]     0.12      0.08     0.02     0.32 1.00
## prjthfgt5_mosttran_devx21[1]      0.26      0.14     0.04     0.59 1.00
## prjthfgt5_mosttran_devx21[2]      0.23      0.14     0.03     0.55 1.00
## prjthfgt5_mosttran_devx21[3]      0.24      0.14     0.03     0.57 1.00
## prjthfgt5_mosttran_devx21[4]      0.26      0.15     0.04     0.58 1.00
## prjthfgt5_mosttran_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## prjthfgt5_mosttran_av12x21[2]     0.13      0.08     0.02     0.34 1.00
## prjthfgt5_mosttran_av12x21[3]     0.13      0.08     0.02     0.32 1.00
## prjthfgt5_mosttran_av12x21[4]     0.13      0.08     0.02     0.32 1.00
## prjthfgt5_mosttran_av12x21[5]     0.12      0.07     0.02     0.30 1.00
## prjthfgt5_mosttran_av12x21[6]     0.12      0.08     0.02     0.32 1.00
## prjthfgt5_mosttran_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## prjthfgt5_mosttran_av12x21[8]     0.13      0.08     0.02     0.32 1.00
## prjthreat_mosttran_devx21[1]      0.27      0.15     0.04     0.60 1.00
## prjthreat_mosttran_devx21[2]      0.26      0.14     0.04     0.58 1.00
## prjthreat_mosttran_devx21[3]      0.23      0.14     0.04     0.55 1.00
## prjthreat_mosttran_devx21[4]      0.24      0.14     0.04     0.56 1.00
## prjthreat_mosttran_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mosttran_av12x21[2]     0.13      0.08     0.01     0.33 1.00
## prjthreat_mosttran_av12x21[3]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mosttran_av12x21[4]     0.12      0.08     0.02     0.32 1.00
## prjthreat_mosttran_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mosttran_av12x21[6]     0.12      0.08     0.01     0.32 1.00
## prjthreat_mosttran_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mosttran_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## prjharm_mosttran_devx21[1]        0.27      0.15     0.04     0.60 1.00
## prjharm_mosttran_devx21[2]        0.24      0.14     0.03     0.56 1.00
## prjharm_mosttran_devx21[3]        0.27      0.15     0.04     0.60 1.00
## prjharm_mosttran_devx21[4]        0.22      0.13     0.03     0.54 1.00
## prjharm_mosttran_av12x21[1]       0.12      0.08     0.02     0.31 1.00
## prjharm_mosttran_av12x21[2]       0.13      0.08     0.02     0.33 1.00
## prjharm_mosttran_av12x21[3]       0.13      0.08     0.02     0.33 1.00
## prjharm_mosttran_av12x21[4]       0.14      0.09     0.02     0.35 1.00
## prjharm_mosttran_av12x21[5]       0.14      0.08     0.02     0.34 1.00
## prjharm_mosttran_av12x21[6]       0.12      0.07     0.02     0.30 1.00
## prjharm_mosttran_av12x21[7]       0.11      0.07     0.01     0.29 1.00
## prjharm_mosttran_av12x21[8]       0.11      0.07     0.02     0.28 1.00
## prjusedrg_mosttran_devx21[1]      0.27      0.15     0.04     0.60 1.00
## prjusedrg_mosttran_devx21[2]      0.25      0.14     0.04     0.57 1.00
## prjusedrg_mosttran_devx21[3]      0.25      0.14     0.04     0.57 1.00
## prjusedrg_mosttran_devx21[4]      0.23      0.14     0.04     0.54 1.00
## prjusedrg_mosttran_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## prjusedrg_mosttran_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## prjusedrg_mosttran_av12x21[3]     0.13      0.09     0.02     0.33 1.00
## prjusedrg_mosttran_av12x21[4]     0.13      0.08     0.02     0.34 1.00
## prjusedrg_mosttran_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## prjusedrg_mosttran_av12x21[6]     0.12      0.08     0.02     0.30 1.00
## prjusedrg_mosttran_av12x21[7]     0.12      0.08     0.01     0.30 1.00
## prjusedrg_mosttran_av12x21[8]     0.12      0.08     0.02     0.31 1.00
## prjhack_mosttran_devx21[1]        0.27      0.15     0.04     0.60 1.00
## prjhack_mosttran_devx21[2]        0.26      0.15     0.04     0.60 1.00
## prjhack_mosttran_devx21[3]        0.23      0.14     0.03     0.55 1.00
## prjhack_mosttran_devx21[4]        0.24      0.14     0.03     0.55 1.00
## prjhack_mosttran_av12x21[1]       0.13      0.08     0.02     0.33 1.00
## prjhack_mosttran_av12x21[2]       0.13      0.08     0.02     0.32 1.00
## prjhack_mosttran_av12x21[3]       0.13      0.08     0.02     0.32 1.00
## prjhack_mosttran_av12x21[4]       0.12      0.08     0.02     0.32 1.00
## prjhack_mosttran_av12x21[5]       0.12      0.08     0.02     0.31 1.00
## prjhack_mosttran_av12x21[6]       0.12      0.08     0.02     0.31 1.00
## prjhack_mosttran_av12x21[7]       0.13      0.08     0.02     0.34 1.00
## prjhack_mosttran_av12x21[8]       0.13      0.08     0.02     0.32 1.00
##                               Bulk_ESS Tail_ESS
## prjthflt5_mosttran_devx21[1]      4854     2478
## prjthflt5_mosttran_devx21[2]      5554     2431
## prjthflt5_mosttran_devx21[3]      5300     3123
## prjthflt5_mosttran_devx21[4]      5527     3095
## prjthflt5_mosttran_av12x21[1]     4463     1744
## prjthflt5_mosttran_av12x21[2]     4789     2228
## prjthflt5_mosttran_av12x21[3]     5414     2774
## prjthflt5_mosttran_av12x21[4]     4924     2310
## prjthflt5_mosttran_av12x21[5]     5945     2544
## prjthflt5_mosttran_av12x21[6]     5684     2909
## prjthflt5_mosttran_av12x21[7]     5863     3012
## prjthflt5_mosttran_av12x21[8]     5104     2500
## prjthfgt5_mosttran_devx21[1]      5116     2618
## prjthfgt5_mosttran_devx21[2]      5365     2681
## prjthfgt5_mosttran_devx21[3]      5012     3035
## prjthfgt5_mosttran_devx21[4]      5111     2482
## prjthfgt5_mosttran_av12x21[1]     5472     2363
## prjthfgt5_mosttran_av12x21[2]     5667     2541
## prjthfgt5_mosttran_av12x21[3]     5096     2219
## prjthfgt5_mosttran_av12x21[4]     4880     2372
## prjthfgt5_mosttran_av12x21[5]     3964     2129
## prjthfgt5_mosttran_av12x21[6]     4654     2478
## prjthfgt5_mosttran_av12x21[7]     5147     2909
## prjthfgt5_mosttran_av12x21[8]     5592     2863
## prjthreat_mosttran_devx21[1]      5920     2128
## prjthreat_mosttran_devx21[2]      5819     2677
## prjthreat_mosttran_devx21[3]      5523     2914
## prjthreat_mosttran_devx21[4]      5395     2498
## prjthreat_mosttran_av12x21[1]     5466     2497
## prjthreat_mosttran_av12x21[2]     5260     2084
## prjthreat_mosttran_av12x21[3]     5191     2287
## prjthreat_mosttran_av12x21[4]     5249     2298
## prjthreat_mosttran_av12x21[5]     5224     1911
## prjthreat_mosttran_av12x21[6]     5197     2508
## prjthreat_mosttran_av12x21[7]     5690     3110
## prjthreat_mosttran_av12x21[8]     6208     2606
## prjharm_mosttran_devx21[1]        5678     2309
## prjharm_mosttran_devx21[2]        4946     2240
## prjharm_mosttran_devx21[3]        5892     2557
## prjharm_mosttran_devx21[4]        4962     2656
## prjharm_mosttran_av12x21[1]       5642     2260
## prjharm_mosttran_av12x21[2]       5048     2407
## prjharm_mosttran_av12x21[3]       4791     1988
## prjharm_mosttran_av12x21[4]       5429     2753
## prjharm_mosttran_av12x21[5]       4569     2855
## prjharm_mosttran_av12x21[6]       4920     2575
## prjharm_mosttran_av12x21[7]       5425     2904
## prjharm_mosttran_av12x21[8]       5347     3039
## prjusedrg_mosttran_devx21[1]      6687     2375
## prjusedrg_mosttran_devx21[2]      6636     3366
## prjusedrg_mosttran_devx21[3]      6129     2734
## prjusedrg_mosttran_devx21[4]      5663     2442
## prjusedrg_mosttran_av12x21[1]     5542     2183
## prjusedrg_mosttran_av12x21[2]     5241     2447
## prjusedrg_mosttran_av12x21[3]     5604     2640
## prjusedrg_mosttran_av12x21[4]     4791     2481
## prjusedrg_mosttran_av12x21[5]     4632     2535
## prjusedrg_mosttran_av12x21[6]     4703     2474
## prjusedrg_mosttran_av12x21[7]     5130     2804
## prjusedrg_mosttran_av12x21[8]     5020     2560
## prjhack_mosttran_devx21[1]        4333     2166
## prjhack_mosttran_devx21[2]        5979     2495
## prjhack_mosttran_devx21[3]        5627     2808
## prjhack_mosttran_devx21[4]        5347     3115
## prjhack_mosttran_av12x21[1]       4974     2083
## prjhack_mosttran_av12x21[2]       6043     2260
## prjhack_mosttran_av12x21[3]       5375     2363
## prjhack_mosttran_av12x21[4]       4694     2374
## prjhack_mosttran_av12x21[5]       5679     2756
## prjhack_mosttran_av12x21[6]       6127     2999
## prjhack_mosttran_av12x21[7]       5170     2699
## prjhack_mosttran_av12x21[8]       6062     2940
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.2.2.5 Prior summary
out.chg.prjcrime.sttran.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                          prjhack
##                   normal(0, 0.125)         b  mosttran_av12x2         prjhack
##                    normal(0, 0.25)         b   mosttran_devx2         prjhack
##                             (flat)         b                          prjharm
##                   normal(0, 0.125)         b  mosttran_av12x2         prjharm
##                    normal(0, 0.25)         b   mosttran_devx2         prjharm
##                             (flat)         b                        prjthfgt5
##                   normal(0, 0.125)         b  mosttran_av12x2       prjthfgt5
##                    normal(0, 0.25)         b   mosttran_devx2       prjthfgt5
##                             (flat)         b                        prjthflt5
##                   normal(0, 0.125)         b  mosttran_av12x2       prjthflt5
##                    normal(0, 0.25)         b   mosttran_devx2       prjthflt5
##                             (flat)         b                        prjthreat
##                   normal(0, 0.125)         b  mosttran_av12x2       prjthreat
##                    normal(0, 0.25)         b   mosttran_devx2       prjthreat
##                             (flat)         b                        prjusedrg
##                   normal(0, 0.125)         b  mosttran_av12x2       prjusedrg
##                    normal(0, 0.25)         b   mosttran_devx2       prjusedrg
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                          prjhack
##                       normal(0, 2) Intercept                          prjharm
##                       normal(0, 2) Intercept                        prjthfgt5
##                       normal(0, 2) Intercept                        prjthflt5
##                       normal(0, 2) Intercept                        prjthreat
##                       normal(0, 2) Intercept                        prjusedrg
##               student_t(3, 0, 2.5)        sd                          prjhack
##               student_t(3, 0, 2.5)        sd                          prjharm
##               student_t(3, 0, 2.5)        sd                        prjthfgt5
##               student_t(3, 0, 2.5)        sd                        prjthflt5
##               student_t(3, 0, 2.5)        sd                        prjthreat
##               student_t(3, 0, 2.5)        sd                        prjusedrg
##               student_t(3, 0, 2.5)        sd                     id   prjhack
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjhack
##               student_t(3, 0, 2.5)        sd                     id   prjharm
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjharm
##               student_t(3, 0, 2.5)        sd                     id prjthfgt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthfgt5
##               student_t(3, 0, 2.5)        sd                     id prjthflt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthflt5
##               student_t(3, 0, 2.5)        sd                     id prjthreat
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthreat
##               student_t(3, 0, 2.5)        sd                     id prjusedrg
##               student_t(3, 0, 2.5)        sd        Intercept    id prjusedrg
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21         prjhack
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21         prjhack
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21         prjharm
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21         prjharm
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       prjthfgt5
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       prjthfgt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       prjthflt5
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       prjthflt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       prjthreat
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       prjthreat
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       prjusedrg
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.2.3 B/W Change Corr: stresp/crim intent

#Bivariate Change: criminal intent items ~ mo(stresp)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostresp_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostresp_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostresp_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostresp_av12x21', 
                  resp = prjdv_names)
  )

chg.prjcrime.stresp.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stresp_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stresp.fit <- ppchecks(chg.prjcrime.stresp.fit)
6.2.2.3.1 Coefficient plot (intervals)
out.chg.prjcrime.stresp.fit[[10]]

6.2.2.3.2 Coefficient plot (distributions)
out.chg.prjcrime.stresp.fit[[9]]

6.2.2.3.3 PPcheck (density)
p1 <- out.chg.prjcrime.stresp.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.chg.prjcrime.stresp.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.chg.prjcrime.stresp.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.chg.prjcrime.stresp.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.chg.prjcrime.stresp.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.chg.prjcrime.stresp.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

6.2.2.3.4 Fit summary
out.chg.prjcrime.stresp.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          prjthreat ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          prjharm ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          prjusedrg ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          prjhack ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     4.35      0.62     3.27     5.66 1.00     1350
## sd(prjthfgt5_Intercept)     3.77      0.56     2.76     4.98 1.00     1157
## sd(prjthreat_Intercept)     3.23      0.54     2.28     4.37 1.00     1574
## sd(prjharm_Intercept)       2.89      0.53     1.94     4.02 1.00     1233
## sd(prjusedrg_Intercept)     3.01      0.55     2.05     4.18 1.00     1483
## sd(prjhack_Intercept)       0.85      0.54     0.05     1.96 1.01      597
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2213
## sd(prjthfgt5_Intercept)     1809
## sd(prjthreat_Intercept)     2219
## sd(prjharm_Intercept)       2340
## sd(prjusedrg_Intercept)     2322
## sd(prjhack_Intercept)       1582
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_Intercept          -5.64      0.79    -7.29    -4.16 1.00     2257
## prjthfgt5_Intercept          -5.18      0.78    -6.76    -3.72 1.00     1506
## prjthreat_Intercept          -6.24      0.87    -8.02    -4.60 1.00     2322
## prjharm_Intercept            -5.74      0.86    -7.57    -4.19 1.00     2022
## prjusedrg_Intercept          -6.12      0.84    -7.90    -4.54 1.00     2146
## prjhack_Intercept            -4.16      0.70    -5.65    -2.82 1.00     1889
## prjthflt5_mostresp_devx2     -0.22      0.17    -0.56     0.10 1.00     4307
## prjthflt5_mostresp_av12x2     0.13      0.08    -0.04     0.29 1.00     2455
## prjthfgt5_mostresp_devx2     -0.18      0.17    -0.53     0.13 1.00     4504
## prjthfgt5_mostresp_av12x2     0.09      0.08    -0.06     0.24 1.00     2757
## prjthreat_mostresp_devx2     -0.30      0.18    -0.67     0.05 1.00     4797
## prjthreat_mostresp_av12x2     0.17      0.08     0.01     0.34 1.00     3202
## prjharm_mostresp_devx2       -0.24      0.18    -0.62     0.12 1.00     4241
## prjharm_mostresp_av12x2       0.07      0.08    -0.10     0.23 1.00     3702
## prjusedrg_mostresp_devx2     -0.34      0.18    -0.70     0.00 1.00     4610
## prjusedrg_mostresp_av12x2     0.15      0.08    -0.02     0.31 1.00     3473
## prjhack_mostresp_devx2       -0.25      0.19    -0.62     0.12 1.00     3625
## prjhack_mostresp_av12x2       0.11      0.07    -0.03     0.25 1.00     4500
##                           Tail_ESS
## prjthflt5_Intercept           2694
## prjthfgt5_Intercept           2516
## prjthreat_Intercept           2524
## prjharm_Intercept             2501
## prjusedrg_Intercept           2439
## prjhack_Intercept             1924
## prjthflt5_mostresp_devx2      3083
## prjthflt5_mostresp_av12x2     3058
## prjthfgt5_mostresp_devx2      2879
## prjthfgt5_mostresp_av12x2     2773
## prjthreat_mostresp_devx2      2900
## prjthreat_mostresp_av12x2     3012
## prjharm_mostresp_devx2        2813
## prjharm_mostresp_av12x2       3133
## prjusedrg_mostresp_devx2      2988
## prjusedrg_mostresp_av12x2     3021
## prjhack_mostresp_devx2        3065
## prjhack_mostresp_av12x2       2807
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## prjthflt5_mostresp_devx21[1]      0.29      0.16     0.05     0.63 1.00
## prjthflt5_mostresp_devx21[2]      0.24      0.14     0.04     0.56 1.00
## prjthflt5_mostresp_devx21[3]      0.21      0.13     0.03     0.53 1.00
## prjthflt5_mostresp_devx21[4]      0.25      0.15     0.04     0.58 1.00
## prjthflt5_mostresp_av12x21[1]     0.12      0.08     0.02     0.32 1.00
## prjthflt5_mostresp_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## prjthflt5_mostresp_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## prjthflt5_mostresp_av12x21[4]     0.12      0.08     0.02     0.31 1.00
## prjthflt5_mostresp_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## prjthflt5_mostresp_av12x21[6]     0.13      0.08     0.02     0.34 1.00
## prjthflt5_mostresp_av12x21[7]     0.13      0.08     0.02     0.33 1.00
## prjthflt5_mostresp_av12x21[8]     0.12      0.08     0.02     0.32 1.00
## prjthfgt5_mostresp_devx21[1]      0.29      0.16     0.04     0.64 1.00
## prjthfgt5_mostresp_devx21[2]      0.24      0.14     0.04     0.55 1.00
## prjthfgt5_mostresp_devx21[3]      0.21      0.14     0.03     0.55 1.00
## prjthfgt5_mostresp_devx21[4]      0.26      0.15     0.03     0.60 1.00
## prjthfgt5_mostresp_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## prjthfgt5_mostresp_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## prjthfgt5_mostresp_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## prjthfgt5_mostresp_av12x21[4]     0.12      0.08     0.02     0.32 1.00
## prjthfgt5_mostresp_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## prjthfgt5_mostresp_av12x21[6]     0.13      0.08     0.02     0.34 1.00
## prjthfgt5_mostresp_av12x21[7]     0.13      0.08     0.02     0.32 1.00
## prjthfgt5_mostresp_av12x21[8]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mostresp_devx21[1]      0.28      0.15     0.04     0.62 1.00
## prjthreat_mostresp_devx21[2]      0.30      0.15     0.05     0.62 1.00
## prjthreat_mostresp_devx21[3]      0.20      0.13     0.03     0.50 1.00
## prjthreat_mostresp_devx21[4]      0.22      0.13     0.03     0.53 1.00
## prjthreat_mostresp_av12x21[1]     0.11      0.07     0.01     0.29 1.00
## prjthreat_mostresp_av12x21[2]     0.11      0.07     0.01     0.29 1.00
## prjthreat_mostresp_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mostresp_av12x21[4]     0.13      0.08     0.01     0.33 1.00
## prjthreat_mostresp_av12x21[5]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mostresp_av12x21[6]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mostresp_av12x21[7]     0.14      0.09     0.02     0.36 1.00
## prjthreat_mostresp_av12x21[8]     0.12      0.08     0.02     0.32 1.00
## prjharm_mostresp_devx21[1]        0.28      0.15     0.04     0.60 1.00
## prjharm_mostresp_devx21[2]        0.27      0.15     0.04     0.60 1.00
## prjharm_mostresp_devx21[3]        0.21      0.13     0.03     0.53 1.00
## prjharm_mostresp_devx21[4]        0.24      0.14     0.03     0.54 1.00
## prjharm_mostresp_av12x21[1]       0.12      0.08     0.02     0.32 1.00
## prjharm_mostresp_av12x21[2]       0.13      0.08     0.02     0.31 1.00
## prjharm_mostresp_av12x21[3]       0.13      0.08     0.02     0.32 1.00
## prjharm_mostresp_av12x21[4]       0.12      0.08     0.02     0.32 1.00
## prjharm_mostresp_av12x21[5]       0.13      0.08     0.02     0.33 1.00
## prjharm_mostresp_av12x21[6]       0.12      0.08     0.02     0.32 1.00
## prjharm_mostresp_av12x21[7]       0.13      0.08     0.02     0.32 1.00
## prjharm_mostresp_av12x21[8]       0.12      0.08     0.02     0.31 1.00
## prjusedrg_mostresp_devx21[1]      0.25      0.14     0.04     0.56 1.00
## prjusedrg_mostresp_devx21[2]      0.29      0.15     0.05     0.61 1.00
## prjusedrg_mostresp_devx21[3]      0.26      0.14     0.04     0.58 1.00
## prjusedrg_mostresp_devx21[4]      0.20      0.12     0.03     0.50 1.00
## prjusedrg_mostresp_av12x21[1]     0.11      0.07     0.01     0.29 1.00
## prjusedrg_mostresp_av12x21[2]     0.11      0.07     0.01     0.29 1.00
## prjusedrg_mostresp_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## prjusedrg_mostresp_av12x21[4]     0.13      0.08     0.02     0.32 1.00
## prjusedrg_mostresp_av12x21[5]     0.13      0.08     0.02     0.33 1.00
## prjusedrg_mostresp_av12x21[6]     0.13      0.08     0.02     0.34 1.00
## prjusedrg_mostresp_av12x21[7]     0.13      0.08     0.02     0.34 1.00
## prjusedrg_mostresp_av12x21[8]     0.14      0.08     0.02     0.34 1.00
## prjhack_mostresp_devx21[1]        0.30      0.16     0.05     0.64 1.00
## prjhack_mostresp_devx21[2]        0.24      0.14     0.03     0.56 1.00
## prjhack_mostresp_devx21[3]        0.22      0.13     0.03     0.53 1.00
## prjhack_mostresp_devx21[4]        0.24      0.14     0.04     0.56 1.00
## prjhack_mostresp_av12x21[1]       0.12      0.08     0.02     0.30 1.00
## prjhack_mostresp_av12x21[2]       0.12      0.08     0.02     0.31 1.00
## prjhack_mostresp_av12x21[3]       0.13      0.08     0.02     0.33 1.00
## prjhack_mostresp_av12x21[4]       0.13      0.08     0.02     0.32 1.00
## prjhack_mostresp_av12x21[5]       0.13      0.08     0.02     0.32 1.00
## prjhack_mostresp_av12x21[6]       0.13      0.08     0.02     0.32 1.00
## prjhack_mostresp_av12x21[7]       0.12      0.08     0.01     0.31 1.00
## prjhack_mostresp_av12x21[8]       0.12      0.08     0.02     0.31 1.00
##                               Bulk_ESS Tail_ESS
## prjthflt5_mostresp_devx21[1]      4602     2316
## prjthflt5_mostresp_devx21[2]      5270     2846
## prjthflt5_mostresp_devx21[3]      4659     2836
## prjthflt5_mostresp_devx21[4]      5018     2578
## prjthflt5_mostresp_av12x21[1]     4400     2295
## prjthflt5_mostresp_av12x21[2]     4950     2304
## prjthflt5_mostresp_av12x21[3]     4643     2370
## prjthflt5_mostresp_av12x21[4]     4609     2540
## prjthflt5_mostresp_av12x21[5]     5402     2349
## prjthflt5_mostresp_av12x21[6]     4988     2594
## prjthflt5_mostresp_av12x21[7]     5186     2818
## prjthflt5_mostresp_av12x21[8]     4756     2636
## prjthfgt5_mostresp_devx21[1]      5045     2615
## prjthfgt5_mostresp_devx21[2]      5290     2655
## prjthfgt5_mostresp_devx21[3]      4817     2761
## prjthfgt5_mostresp_devx21[4]      5062     2407
## prjthfgt5_mostresp_av12x21[1]     4724     2218
## prjthfgt5_mostresp_av12x21[2]     5619     2838
## prjthfgt5_mostresp_av12x21[3]     5814     2599
## prjthfgt5_mostresp_av12x21[4]     4962     2091
## prjthfgt5_mostresp_av12x21[5]     5491     2345
## prjthfgt5_mostresp_av12x21[6]     5528     2565
## prjthfgt5_mostresp_av12x21[7]     4036     2492
## prjthfgt5_mostresp_av12x21[8]     4909     2686
## prjthreat_mostresp_devx21[1]      5007     2363
## prjthreat_mostresp_devx21[2]      5009     2576
## prjthreat_mostresp_devx21[3]      4668     3217
## prjthreat_mostresp_devx21[4]      5189     2765
## prjthreat_mostresp_av12x21[1]     4334     2053
## prjthreat_mostresp_av12x21[2]     5111     2052
## prjthreat_mostresp_av12x21[3]     5791     2383
## prjthreat_mostresp_av12x21[4]     5631     2324
## prjthreat_mostresp_av12x21[5]     4952     2150
## prjthreat_mostresp_av12x21[6]     5229     2959
## prjthreat_mostresp_av12x21[7]     4523     2893
## prjthreat_mostresp_av12x21[8]     5467     2811
## prjharm_mostresp_devx21[1]        5046     2483
## prjharm_mostresp_devx21[2]        5544     2889
## prjharm_mostresp_devx21[3]        4937     3152
## prjharm_mostresp_devx21[4]        5134     2690
## prjharm_mostresp_av12x21[1]       4811     2390
## prjharm_mostresp_av12x21[2]       5712     2222
## prjharm_mostresp_av12x21[3]       5137     2628
## prjharm_mostresp_av12x21[4]       4574     2056
## prjharm_mostresp_av12x21[5]       4740     2170
## prjharm_mostresp_av12x21[6]       4225     2666
## prjharm_mostresp_av12x21[7]       5096     3176
## prjharm_mostresp_av12x21[8]       4518     2577
## prjusedrg_mostresp_devx21[1]      5132     2572
## prjusedrg_mostresp_devx21[2]      4121     2848
## prjusedrg_mostresp_devx21[3]      4920     2819
## prjusedrg_mostresp_devx21[4]      4811     2357
## prjusedrg_mostresp_av12x21[1]     4748     2102
## prjusedrg_mostresp_av12x21[2]     5172     2059
## prjusedrg_mostresp_av12x21[3]     3982     2057
## prjusedrg_mostresp_av12x21[4]     5958     2103
## prjusedrg_mostresp_av12x21[5]     5092     2663
## prjusedrg_mostresp_av12x21[6]     4955     2584
## prjusedrg_mostresp_av12x21[7]     5686     2820
## prjusedrg_mostresp_av12x21[8]     4791     2810
## prjhack_mostresp_devx21[1]        4959     2381
## prjhack_mostresp_devx21[2]        4833     2525
## prjhack_mostresp_devx21[3]        5036     2985
## prjhack_mostresp_devx21[4]        4744     2976
## prjhack_mostresp_av12x21[1]       5307     2175
## prjhack_mostresp_av12x21[2]       5627     2238
## prjhack_mostresp_av12x21[3]       4637     1944
## prjhack_mostresp_av12x21[4]       5006     2211
## prjhack_mostresp_av12x21[5]       4737     2430
## prjhack_mostresp_av12x21[6]       4646     2567
## prjhack_mostresp_av12x21[7]       5004     2745
## prjhack_mostresp_av12x21[8]       4925     2228
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.2.3.5 Prior summary
out.chg.prjcrime.stresp.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                          prjhack
##                   normal(0, 0.125)         b  mostresp_av12x2         prjhack
##                    normal(0, 0.25)         b   mostresp_devx2         prjhack
##                             (flat)         b                          prjharm
##                   normal(0, 0.125)         b  mostresp_av12x2         prjharm
##                    normal(0, 0.25)         b   mostresp_devx2         prjharm
##                             (flat)         b                        prjthfgt5
##                   normal(0, 0.125)         b  mostresp_av12x2       prjthfgt5
##                    normal(0, 0.25)         b   mostresp_devx2       prjthfgt5
##                             (flat)         b                        prjthflt5
##                   normal(0, 0.125)         b  mostresp_av12x2       prjthflt5
##                    normal(0, 0.25)         b   mostresp_devx2       prjthflt5
##                             (flat)         b                        prjthreat
##                   normal(0, 0.125)         b  mostresp_av12x2       prjthreat
##                    normal(0, 0.25)         b   mostresp_devx2       prjthreat
##                             (flat)         b                        prjusedrg
##                   normal(0, 0.125)         b  mostresp_av12x2       prjusedrg
##                    normal(0, 0.25)         b   mostresp_devx2       prjusedrg
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                          prjhack
##                       normal(0, 2) Intercept                          prjharm
##                       normal(0, 2) Intercept                        prjthfgt5
##                       normal(0, 2) Intercept                        prjthflt5
##                       normal(0, 2) Intercept                        prjthreat
##                       normal(0, 2) Intercept                        prjusedrg
##               student_t(3, 0, 2.5)        sd                          prjhack
##               student_t(3, 0, 2.5)        sd                          prjharm
##               student_t(3, 0, 2.5)        sd                        prjthfgt5
##               student_t(3, 0, 2.5)        sd                        prjthflt5
##               student_t(3, 0, 2.5)        sd                        prjthreat
##               student_t(3, 0, 2.5)        sd                        prjusedrg
##               student_t(3, 0, 2.5)        sd                     id   prjhack
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjhack
##               student_t(3, 0, 2.5)        sd                     id   prjharm
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjharm
##               student_t(3, 0, 2.5)        sd                     id prjthfgt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthfgt5
##               student_t(3, 0, 2.5)        sd                     id prjthflt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthflt5
##               student_t(3, 0, 2.5)        sd                     id prjthreat
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthreat
##               student_t(3, 0, 2.5)        sd                     id prjusedrg
##               student_t(3, 0, 2.5)        sd        Intercept    id prjusedrg
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21         prjhack
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21         prjhack
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21         prjharm
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21         prjharm
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       prjthfgt5
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       prjthfgt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       prjthflt5
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       prjthflt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       prjthreat
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       prjthreat
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       prjusedrg
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.2.4 B/W Change Corr: stfair/crim intent

#Bivariate Change: criminal intent items ~ mo(stfair)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostfair_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostfair_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostfair_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostfair_av12x21', 
                  resp = prjdv_names)
  )

chg.prjcrime.stfair.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stfair_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stfair.fit <- ppchecks(chg.prjcrime.stfair.fit)
6.2.2.4.1 Coefficient plot (intervals)
out.chg.prjcrime.stfair.fit[[10]]

6.2.2.4.2 Coefficient plot (distributions)
out.chg.prjcrime.stfair.fit[[9]]

6.2.2.4.3 PPcheck (density)
p1 <- out.chg.prjcrime.stfair.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.chg.prjcrime.stfair.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.chg.prjcrime.stfair.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.chg.prjcrime.stfair.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.chg.prjcrime.stfair.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.chg.prjcrime.stfair.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

6.2.2.4.4 Fit summary
out.chg.prjcrime.stfair.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          prjthreat ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          prjharm ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          prjusedrg ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          prjhack ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     4.15      0.59     3.16     5.42 1.00     1561
## sd(prjthfgt5_Intercept)     3.67      0.53     2.74     4.80 1.00     1544
## sd(prjthreat_Intercept)     3.32      0.56     2.35     4.54 1.00     1592
## sd(prjharm_Intercept)       2.99      0.54     2.02     4.13 1.01     1511
## sd(prjusedrg_Intercept)     3.11      0.56     2.11     4.27 1.00     1532
## sd(prjhack_Intercept)       0.80      0.52     0.04     1.90 1.00     1144
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2651
## sd(prjthfgt5_Intercept)     2481
## sd(prjthreat_Intercept)     2528
## sd(prjharm_Intercept)       2619
## sd(prjusedrg_Intercept)     2157
## sd(prjhack_Intercept)       1650
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_Intercept          -6.16      0.78    -7.77    -4.75 1.00     3330
## prjthfgt5_Intercept          -5.73      0.74    -7.21    -4.31 1.00     3281
## prjthreat_Intercept          -6.32      0.90    -8.11    -4.66 1.00     2980
## prjharm_Intercept            -5.70      0.88    -7.46    -4.07 1.00     2596
## prjusedrg_Intercept          -6.20      0.91    -8.05    -4.51 1.00     2771
## prjhack_Intercept            -4.30      0.67    -5.71    -3.09 1.00     2796
## prjthflt5_mostfair_devx2      0.03      0.18    -0.34     0.36 1.00     6884
## prjthflt5_mostfair_av12x2     0.17      0.08     0.01     0.33 1.00     3266
## prjthfgt5_mostfair_devx2      0.10      0.17    -0.26     0.42 1.00     6303
## prjthfgt5_mostfair_av12x2     0.11      0.08    -0.04     0.26 1.00     3415
## prjthreat_mostfair_devx2     -0.25      0.19    -0.63     0.11 1.00     6558
## prjthreat_mostfair_av12x2     0.14      0.08    -0.03     0.30 1.00     4742
## prjharm_mostfair_devx2       -0.24      0.19    -0.63     0.13 1.00     6230
## prjharm_mostfair_av12x2       0.03      0.08    -0.14     0.19 1.00     4747
## prjusedrg_mostfair_devx2     -0.22      0.20    -0.62     0.17 1.00     6495
## prjusedrg_mostfair_av12x2     0.09      0.08    -0.08     0.24 1.00     4770
## prjhack_mostfair_devx2       -0.22      0.19    -0.60     0.15 1.00     7087
## prjhack_mostfair_av12x2       0.12      0.07    -0.01     0.26 1.00     7155
##                           Tail_ESS
## prjthflt5_Intercept           3096
## prjthfgt5_Intercept           2972
## prjthreat_Intercept           2760
## prjharm_Intercept             2658
## prjusedrg_Intercept           3089
## prjhack_Intercept             2430
## prjthflt5_mostfair_devx2      3133
## prjthflt5_mostfair_av12x2     3215
## prjthfgt5_mostfair_devx2      3123
## prjthfgt5_mostfair_av12x2     3199
## prjthreat_mostfair_devx2      2967
## prjthreat_mostfair_av12x2     3454
## prjharm_mostfair_devx2        3191
## prjharm_mostfair_av12x2       3274
## prjusedrg_mostfair_devx2      2877
## prjusedrg_mostfair_av12x2     3320
## prjhack_mostfair_devx2        2814
## prjhack_mostfair_av12x2       3030
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## prjthflt5_mostfair_devx21[1]      0.26      0.15     0.04     0.61 1.00
## prjthflt5_mostfair_devx21[2]      0.24      0.14     0.03     0.56 1.00
## prjthflt5_mostfair_devx21[3]      0.24      0.15     0.03     0.58 1.00
## prjthflt5_mostfair_devx21[4]      0.26      0.15     0.04     0.59 1.00
## prjthflt5_mostfair_av12x21[1]     0.12      0.08     0.01     0.30 1.00
## prjthflt5_mostfair_av12x21[2]     0.12      0.07     0.02     0.30 1.00
## prjthflt5_mostfair_av12x21[3]     0.13      0.08     0.02     0.33 1.00
## prjthflt5_mostfair_av12x21[4]     0.12      0.08     0.02     0.30 1.00
## prjthflt5_mostfair_av12x21[5]     0.12      0.07     0.02     0.30 1.00
## prjthflt5_mostfair_av12x21[6]     0.13      0.08     0.02     0.33 1.00
## prjthflt5_mostfair_av12x21[7]     0.14      0.08     0.02     0.34 1.00
## prjthflt5_mostfair_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## prjthfgt5_mostfair_devx21[1]      0.24      0.14     0.03     0.57 1.00
## prjthfgt5_mostfair_devx21[2]      0.24      0.15     0.03     0.58 1.00
## prjthfgt5_mostfair_devx21[3]      0.27      0.15     0.04     0.59 1.00
## prjthfgt5_mostfair_devx21[4]      0.25      0.14     0.04     0.57 1.00
## prjthfgt5_mostfair_av12x21[1]     0.13      0.09     0.02     0.34 1.00
## prjthfgt5_mostfair_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## prjthfgt5_mostfair_av12x21[3]     0.13      0.08     0.02     0.33 1.00
## prjthfgt5_mostfair_av12x21[4]     0.12      0.08     0.02     0.30 1.00
## prjthfgt5_mostfair_av12x21[5]     0.12      0.08     0.01     0.30 1.00
## prjthfgt5_mostfair_av12x21[6]     0.13      0.08     0.02     0.33 1.00
## prjthfgt5_mostfair_av12x21[7]     0.13      0.08     0.02     0.32 1.00
## prjthfgt5_mostfair_av12x21[8]     0.13      0.08     0.02     0.32 1.00
## prjthreat_mostfair_devx21[1]      0.27      0.15     0.04     0.60 1.00
## prjthreat_mostfair_devx21[2]      0.25      0.14     0.04     0.57 1.00
## prjthreat_mostfair_devx21[3]      0.25      0.14     0.04     0.56 1.00
## prjthreat_mostfair_devx21[4]      0.23      0.14     0.03     0.55 1.00
## prjthreat_mostfair_av12x21[1]     0.12      0.08     0.02     0.30 1.00
## prjthreat_mostfair_av12x21[2]     0.11      0.07     0.02     0.28 1.00
## prjthreat_mostfair_av12x21[3]     0.12      0.08     0.02     0.30 1.00
## prjthreat_mostfair_av12x21[4]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mostfair_av12x21[5]     0.12      0.08     0.02     0.32 1.00
## prjthreat_mostfair_av12x21[6]     0.13      0.08     0.02     0.31 1.00
## prjthreat_mostfair_av12x21[7]     0.13      0.09     0.02     0.33 1.00
## prjthreat_mostfair_av12x21[8]     0.14      0.09     0.02     0.34 1.00
## prjharm_mostfair_devx21[1]        0.26      0.15     0.04     0.59 1.00
## prjharm_mostfair_devx21[2]        0.27      0.15     0.04     0.59 1.00
## prjharm_mostfair_devx21[3]        0.23      0.14     0.04     0.55 1.00
## prjharm_mostfair_devx21[4]        0.24      0.14     0.03     0.55 1.00
## prjharm_mostfair_av12x21[1]       0.13      0.08     0.02     0.31 1.00
## prjharm_mostfair_av12x21[2]       0.12      0.08     0.02     0.32 1.00
## prjharm_mostfair_av12x21[3]       0.13      0.08     0.02     0.33 1.00
## prjharm_mostfair_av12x21[4]       0.13      0.08     0.02     0.33 1.00
## prjharm_mostfair_av12x21[5]       0.12      0.08     0.02     0.31 1.00
## prjharm_mostfair_av12x21[6]       0.12      0.08     0.02     0.32 1.00
## prjharm_mostfair_av12x21[7]       0.12      0.08     0.01     0.31 1.00
## prjharm_mostfair_av12x21[8]       0.13      0.08     0.02     0.32 1.00
## prjusedrg_mostfair_devx21[1]      0.27      0.15     0.04     0.60 1.00
## prjusedrg_mostfair_devx21[2]      0.26      0.14     0.04     0.58 1.00
## prjusedrg_mostfair_devx21[3]      0.23      0.13     0.04     0.54 1.00
## prjusedrg_mostfair_devx21[4]      0.24      0.14     0.04     0.56 1.00
## prjusedrg_mostfair_av12x21[1]     0.12      0.08     0.02     0.31 1.00
## prjusedrg_mostfair_av12x21[2]     0.12      0.08     0.02     0.30 1.00
## prjusedrg_mostfair_av12x21[3]     0.13      0.08     0.02     0.32 1.00
## prjusedrg_mostfair_av12x21[4]     0.13      0.08     0.02     0.32 1.00
## prjusedrg_mostfair_av12x21[5]     0.12      0.08     0.02     0.33 1.00
## prjusedrg_mostfair_av12x21[6]     0.13      0.08     0.02     0.32 1.00
## prjusedrg_mostfair_av12x21[7]     0.13      0.08     0.02     0.33 1.00
## prjusedrg_mostfair_av12x21[8]     0.12      0.08     0.02     0.31 1.00
## prjhack_mostfair_devx21[1]        0.25      0.14     0.04     0.57 1.00
## prjhack_mostfair_devx21[2]        0.28      0.14     0.05     0.59 1.00
## prjhack_mostfair_devx21[3]        0.23      0.13     0.03     0.54 1.00
## prjhack_mostfair_devx21[4]        0.24      0.14     0.04     0.55 1.00
## prjhack_mostfair_av12x21[1]       0.11      0.07     0.02     0.30 1.00
## prjhack_mostfair_av12x21[2]       0.11      0.07     0.02     0.30 1.00
## prjhack_mostfair_av12x21[3]       0.12      0.08     0.02     0.32 1.00
## prjhack_mostfair_av12x21[4]       0.13      0.08     0.02     0.33 1.00
## prjhack_mostfair_av12x21[5]       0.13      0.08     0.02     0.33 1.00
## prjhack_mostfair_av12x21[6]       0.13      0.08     0.02     0.32 1.00
## prjhack_mostfair_av12x21[7]       0.14      0.09     0.02     0.35 1.00
## prjhack_mostfair_av12x21[8]       0.12      0.08     0.02     0.31 1.00
##                               Bulk_ESS Tail_ESS
## prjthflt5_mostfair_devx21[1]      7336     2401
## prjthflt5_mostfair_devx21[2]      7231     2442
## prjthflt5_mostfair_devx21[3]      6693     3268
## prjthflt5_mostfair_devx21[4]      6561     2750
## prjthflt5_mostfair_av12x21[1]     6450     2516
## prjthflt5_mostfair_av12x21[2]     6665     2585
## prjthflt5_mostfair_av12x21[3]     6714     2647
## prjthflt5_mostfair_av12x21[4]     6950     2721
## prjthflt5_mostfair_av12x21[5]     6215     2761
## prjthflt5_mostfair_av12x21[6]     7372     2276
## prjthflt5_mostfair_av12x21[7]     6887     2418
## prjthflt5_mostfair_av12x21[8]     6056     3192
## prjthfgt5_mostfair_devx21[1]      6068     2143
## prjthfgt5_mostfair_devx21[2]      8710     2919
## prjthfgt5_mostfair_devx21[3]      6349     3114
## prjthfgt5_mostfair_devx21[4]      6522     2884
## prjthfgt5_mostfair_av12x21[1]     7706     2727
## prjthfgt5_mostfair_av12x21[2]     7453     2553
## prjthfgt5_mostfair_av12x21[3]     6666     2380
## prjthfgt5_mostfair_av12x21[4]     7902     2690
## prjthfgt5_mostfair_av12x21[5]     7653     2986
## prjthfgt5_mostfair_av12x21[6]     7116     2403
## prjthfgt5_mostfair_av12x21[7]     7410     3357
## prjthfgt5_mostfair_av12x21[8]     6570     3244
## prjthreat_mostfair_devx21[1]      7575     2498
## prjthreat_mostfair_devx21[2]      7117     2986
## prjthreat_mostfair_devx21[3]      7333     2659
## prjthreat_mostfair_devx21[4]      7202     2444
## prjthreat_mostfair_av12x21[1]     7582     2472
## prjthreat_mostfair_av12x21[2]     7171     2611
## prjthreat_mostfair_av12x21[3]     6808     2467
## prjthreat_mostfair_av12x21[4]     7427     2491
## prjthreat_mostfair_av12x21[5]     6643     2569
## prjthreat_mostfair_av12x21[6]     6902     2989
## prjthreat_mostfair_av12x21[7]     5957     2740
## prjthreat_mostfair_av12x21[8]     6993     2927
## prjharm_mostfair_devx21[1]        8287     2693
## prjharm_mostfair_devx21[2]        6890     2993
## prjharm_mostfair_devx21[3]        5944     2781
## prjharm_mostfair_devx21[4]        7384     2608
## prjharm_mostfair_av12x21[1]       7642     2316
## prjharm_mostfair_av12x21[2]       7001     2029
## prjharm_mostfair_av12x21[3]       6844     2376
## prjharm_mostfair_av12x21[4]       6889     2541
## prjharm_mostfair_av12x21[5]       7121     2426
## prjharm_mostfair_av12x21[6]       8360     3025
## prjharm_mostfair_av12x21[7]       7521     2281
## prjharm_mostfair_av12x21[8]       6629     2652
## prjusedrg_mostfair_devx21[1]      8845     2356
## prjusedrg_mostfair_devx21[2]      7628     3116
## prjusedrg_mostfair_devx21[3]      7193     3114
## prjusedrg_mostfair_devx21[4]      7044     2773
## prjusedrg_mostfair_av12x21[1]     7642     2931
## prjusedrg_mostfair_av12x21[2]     6148     2410
## prjusedrg_mostfair_av12x21[3]     8072     2589
## prjusedrg_mostfair_av12x21[4]     7342     2457
## prjusedrg_mostfair_av12x21[5]     6792     2409
## prjusedrg_mostfair_av12x21[6]     6221     2987
## prjusedrg_mostfair_av12x21[7]     7765     2936
## prjusedrg_mostfair_av12x21[8]     6578     2837
## prjhack_mostfair_devx21[1]        6770     2785
## prjhack_mostfair_devx21[2]        7604     2312
## prjhack_mostfair_devx21[3]        6501     2981
## prjhack_mostfair_devx21[4]        7805     2710
## prjhack_mostfair_av12x21[1]       6544     2552
## prjhack_mostfair_av12x21[2]       7768     2876
## prjhack_mostfair_av12x21[3]       8069     2226
## prjhack_mostfair_av12x21[4]       6435     2328
## prjhack_mostfair_av12x21[5]       7735     2770
## prjhack_mostfair_av12x21[6]       7025     2538
## prjhack_mostfair_av12x21[7]       7469     2584
## prjhack_mostfair_av12x21[8]       6677     2969
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.2.4.5 Prior summary
out.chg.prjcrime.stfair.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                          prjhack
##                   normal(0, 0.125)         b  mostfair_av12x2         prjhack
##                    normal(0, 0.25)         b   mostfair_devx2         prjhack
##                             (flat)         b                          prjharm
##                   normal(0, 0.125)         b  mostfair_av12x2         prjharm
##                    normal(0, 0.25)         b   mostfair_devx2         prjharm
##                             (flat)         b                        prjthfgt5
##                   normal(0, 0.125)         b  mostfair_av12x2       prjthfgt5
##                    normal(0, 0.25)         b   mostfair_devx2       prjthfgt5
##                             (flat)         b                        prjthflt5
##                   normal(0, 0.125)         b  mostfair_av12x2       prjthflt5
##                    normal(0, 0.25)         b   mostfair_devx2       prjthflt5
##                             (flat)         b                        prjthreat
##                   normal(0, 0.125)         b  mostfair_av12x2       prjthreat
##                    normal(0, 0.25)         b   mostfair_devx2       prjthreat
##                             (flat)         b                        prjusedrg
##                   normal(0, 0.125)         b  mostfair_av12x2       prjusedrg
##                    normal(0, 0.25)         b   mostfair_devx2       prjusedrg
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                          prjhack
##                       normal(0, 2) Intercept                          prjharm
##                       normal(0, 2) Intercept                        prjthfgt5
##                       normal(0, 2) Intercept                        prjthflt5
##                       normal(0, 2) Intercept                        prjthreat
##                       normal(0, 2) Intercept                        prjusedrg
##               student_t(3, 0, 2.5)        sd                          prjhack
##               student_t(3, 0, 2.5)        sd                          prjharm
##               student_t(3, 0, 2.5)        sd                        prjthfgt5
##               student_t(3, 0, 2.5)        sd                        prjthflt5
##               student_t(3, 0, 2.5)        sd                        prjthreat
##               student_t(3, 0, 2.5)        sd                        prjusedrg
##               student_t(3, 0, 2.5)        sd                     id   prjhack
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjhack
##               student_t(3, 0, 2.5)        sd                     id   prjharm
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjharm
##               student_t(3, 0, 2.5)        sd                     id prjthfgt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthfgt5
##               student_t(3, 0, 2.5)        sd                     id prjthflt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthflt5
##               student_t(3, 0, 2.5)        sd                     id prjthreat
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthreat
##               student_t(3, 0, 2.5)        sd                     id prjusedrg
##               student_t(3, 0, 2.5)        sd        Intercept    id prjusedrg
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21         prjhack
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21         prjhack
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21         prjharm
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21         prjharm
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       prjthfgt5
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       prjthfgt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       prjthflt5
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       prjthflt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       prjthreat
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       prjthreat
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       prjusedrg
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.2.5 B/W Change Corr: stjob/crim intent

#Bivariate Change: criminal intent items ~ mo(stjob)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostjob_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostjob_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostjob_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostjob_av12x21', 
                  resp = prjdv_names)
  )

chg.prjcrime.stjob.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stjob_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stjob.fit <- ppchecks(chg.prjcrime.stjob.fit)
6.2.2.5.1 Coefficient plot (intervals)
out.chg.prjcrime.stjob.fit[[10]]

6.2.2.5.2 Coefficient plot (distributions)
out.chg.prjcrime.stjob.fit[[9]]

6.2.2.5.3 PPcheck (density)
p1 <- out.chg.prjcrime.stjob.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.chg.prjcrime.stjob.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.chg.prjcrime.stjob.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.chg.prjcrime.stjob.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.chg.prjcrime.stjob.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.chg.prjcrime.stjob.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

6.2.2.5.4 Fit summary
out.chg.prjcrime.stjob.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          prjthreat ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          prjharm ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          prjusedrg ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          prjhack ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     4.20      0.59     3.16     5.47 1.00     1179
## sd(prjthfgt5_Intercept)     3.51      0.51     2.62     4.62 1.01     1051
## sd(prjthreat_Intercept)     3.02      0.52     2.16     4.17 1.00     1275
## sd(prjharm_Intercept)       2.82      0.52     1.90     3.94 1.00     1363
## sd(prjusedrg_Intercept)     2.79      0.52     1.88     3.90 1.00     1191
## sd(prjhack_Intercept)       0.58      0.40     0.02     1.52 1.00      971
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2150
## sd(prjthfgt5_Intercept)     1979
## sd(prjthreat_Intercept)     2132
## sd(prjharm_Intercept)       2111
## sd(prjusedrg_Intercept)     2069
## sd(prjhack_Intercept)       1566
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_Intercept         -5.98      0.77    -7.55    -4.53 1.00     1706
## prjthfgt5_Intercept         -5.74      0.72    -7.27    -4.42 1.00     1815
## prjthreat_Intercept         -6.67      0.83    -8.43    -5.10 1.00     2328
## prjharm_Intercept           -6.12      0.86    -7.90    -4.51 1.00     2148
## prjusedrg_Intercept         -6.56      0.88    -8.40    -4.94 1.00     1681
## prjhack_Intercept           -5.36      0.67    -6.73    -4.12 1.00     2487
## prjthflt5_mostjob_devx2     -0.03      0.18    -0.40     0.31 1.00     3930
## prjthflt5_mostjob_av12x2     0.16      0.08    -0.01     0.32 1.00     2083
## prjthfgt5_mostjob_devx2      0.06      0.18    -0.30     0.40 1.00     4051
## prjthfgt5_mostjob_av12x2     0.17      0.07     0.02     0.31 1.00     2548
## prjthreat_mostjob_devx2     -0.05      0.20    -0.45     0.32 1.00     4262
## prjthreat_mostjob_av12x2     0.22      0.08     0.05     0.37 1.00     2692
## prjharm_mostjob_devx2       -0.08      0.19    -0.47     0.29 1.00     4371
## prjharm_mostjob_av12x2       0.10      0.08    -0.06     0.26 1.00     3598
## prjusedrg_mostjob_devx2     -0.06      0.20    -0.49     0.31 1.00     4089
## prjusedrg_mostjob_av12x2     0.19      0.08     0.02     0.34 1.00     3116
## prjhack_mostjob_devx2       -0.00      0.19    -0.40     0.37 1.00     4063
## prjhack_mostjob_av12x2       0.28      0.07     0.14     0.42 1.00     4350
##                          Tail_ESS
## prjthflt5_Intercept          2474
## prjthfgt5_Intercept          2539
## prjthreat_Intercept          2889
## prjharm_Intercept            2633
## prjusedrg_Intercept          2421
## prjhack_Intercept            2443
## prjthflt5_mostjob_devx2      2957
## prjthflt5_mostjob_av12x2     2202
## prjthfgt5_mostjob_devx2      2792
## prjthfgt5_mostjob_av12x2     2964
## prjthreat_mostjob_devx2      2589
## prjthreat_mostjob_av12x2     2785
## prjharm_mostjob_devx2        2827
## prjharm_mostjob_av12x2       3148
## prjusedrg_mostjob_devx2      2664
## prjusedrg_mostjob_av12x2     2684
## prjhack_mostjob_devx2        2575
## prjhack_mostjob_av12x2       2715
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_mostjob_devx21[1]      0.27      0.15     0.04     0.59 1.00     5099
## prjthflt5_mostjob_devx21[2]      0.23      0.14     0.03     0.55 1.00     4848
## prjthflt5_mostjob_devx21[3]      0.24      0.14     0.04     0.57 1.00     4336
## prjthflt5_mostjob_devx21[4]      0.26      0.15     0.04     0.60 1.00     5592
## prjthflt5_mostjob_av12x21[1]     0.11      0.07     0.01     0.28 1.00     4731
## prjthflt5_mostjob_av12x21[2]     0.11      0.07     0.01     0.27 1.00     4168
## prjthflt5_mostjob_av12x21[3]     0.11      0.07     0.02     0.28 1.00     4983
## prjthflt5_mostjob_av12x21[4]     0.12      0.07     0.02     0.30 1.00     5839
## prjthflt5_mostjob_av12x21[5]     0.13      0.08     0.02     0.33 1.00     5172
## prjthflt5_mostjob_av12x21[6]     0.15      0.09     0.02     0.37 1.00     5198
## prjthflt5_mostjob_av12x21[7]     0.14      0.08     0.02     0.34 1.00     4514
## prjthflt5_mostjob_av12x21[8]     0.14      0.08     0.02     0.34 1.00     5839
## prjthfgt5_mostjob_devx21[1]      0.25      0.15     0.04     0.59 1.00     5072
## prjthfgt5_mostjob_devx21[2]      0.25      0.15     0.03     0.59 1.00     4473
## prjthfgt5_mostjob_devx21[3]      0.23      0.14     0.04     0.56 1.00     5855
## prjthfgt5_mostjob_devx21[4]      0.26      0.15     0.04     0.59 1.00     6068
## prjthfgt5_mostjob_av12x21[1]     0.11      0.07     0.01     0.27 1.00     4948
## prjthfgt5_mostjob_av12x21[2]     0.11      0.08     0.01     0.30 1.00     4866
## prjthfgt5_mostjob_av12x21[3]     0.11      0.07     0.01     0.29 1.00     4945
## prjthfgt5_mostjob_av12x21[4]     0.12      0.08     0.02     0.31 1.00     4359
## prjthfgt5_mostjob_av12x21[5]     0.13      0.08     0.02     0.33 1.00     4992
## prjthfgt5_mostjob_av12x21[6]     0.15      0.09     0.02     0.36 1.00     4322
## prjthfgt5_mostjob_av12x21[7]     0.13      0.08     0.02     0.32 1.00     5535
## prjthfgt5_mostjob_av12x21[8]     0.15      0.09     0.02     0.36 1.00     4849
## prjthreat_mostjob_devx21[1]      0.26      0.15     0.04     0.59 1.00     4985
## prjthreat_mostjob_devx21[2]      0.24      0.14     0.03     0.57 1.00     5611
## prjthreat_mostjob_devx21[3]      0.24      0.14     0.03     0.55 1.00     4806
## prjthreat_mostjob_devx21[4]      0.26      0.15     0.04     0.60 1.00     6292
## prjthreat_mostjob_av12x21[1]     0.10      0.07     0.01     0.26 1.00     5422
## prjthreat_mostjob_av12x21[2]     0.11      0.07     0.02     0.27 1.00     6010
## prjthreat_mostjob_av12x21[3]     0.11      0.07     0.01     0.28 1.00     4952
## prjthreat_mostjob_av12x21[4]     0.11      0.07     0.01     0.30 1.00     4669
## prjthreat_mostjob_av12x21[5]     0.12      0.08     0.02     0.30 1.00     4783
## prjthreat_mostjob_av12x21[6]     0.14      0.09     0.02     0.35 1.00     5168
## prjthreat_mostjob_av12x21[7]     0.17      0.10     0.02     0.39 1.00     4755
## prjthreat_mostjob_av12x21[8]     0.15      0.09     0.02     0.35 1.00     5603
## prjharm_mostjob_devx21[1]        0.27      0.15     0.04     0.60 1.00     5206
## prjharm_mostjob_devx21[2]        0.24      0.14     0.04     0.57 1.00     5196
## prjharm_mostjob_devx21[3]        0.23      0.14     0.03     0.55 1.00     4964
## prjharm_mostjob_devx21[4]        0.26      0.15     0.04     0.59 1.00     5910
## prjharm_mostjob_av12x21[1]       0.12      0.08     0.02     0.31 1.00     4750
## prjharm_mostjob_av12x21[2]       0.12      0.08     0.01     0.32 1.00     5279
## prjharm_mostjob_av12x21[3]       0.12      0.08     0.02     0.31 1.00     5591
## prjharm_mostjob_av12x21[4]       0.13      0.08     0.02     0.32 1.00     5412
## prjharm_mostjob_av12x21[5]       0.12      0.08     0.02     0.31 1.00     5602
## prjharm_mostjob_av12x21[6]       0.13      0.09     0.02     0.34 1.00     4882
## prjharm_mostjob_av12x21[7]       0.13      0.09     0.02     0.34 1.00     5272
## prjharm_mostjob_av12x21[8]       0.12      0.08     0.01     0.30 1.00     5272
## prjusedrg_mostjob_devx21[1]      0.27      0.15     0.04     0.61 1.00     5290
## prjusedrg_mostjob_devx21[2]      0.24      0.14     0.04     0.58 1.00     5360
## prjusedrg_mostjob_devx21[3]      0.24      0.14     0.03     0.57 1.00     5531
## prjusedrg_mostjob_devx21[4]      0.26      0.14     0.04     0.58 1.00     5154
## prjusedrg_mostjob_av12x21[1]     0.10      0.07     0.01     0.27 1.00     5866
## prjusedrg_mostjob_av12x21[2]     0.11      0.07     0.02     0.29 1.00     5177
## prjusedrg_mostjob_av12x21[3]     0.12      0.08     0.02     0.30 1.00     5454
## prjusedrg_mostjob_av12x21[4]     0.11      0.07     0.02     0.29 1.00     5009
## prjusedrg_mostjob_av12x21[5]     0.13      0.08     0.01     0.33 1.00     6000
## prjusedrg_mostjob_av12x21[6]     0.14      0.09     0.02     0.35 1.00     3991
## prjusedrg_mostjob_av12x21[7]     0.16      0.10     0.02     0.40 1.00     4721
## prjusedrg_mostjob_av12x21[8]     0.12      0.08     0.02     0.31 1.00     5507
## prjhack_mostjob_devx21[1]        0.26      0.15     0.04     0.59 1.00     4924
## prjhack_mostjob_devx21[2]        0.24      0.14     0.03     0.55 1.00     6635
## prjhack_mostjob_devx21[3]        0.24      0.14     0.04     0.57 1.00     4414
## prjhack_mostjob_devx21[4]        0.26      0.14     0.04     0.57 1.00     5279
## prjhack_mostjob_av12x21[1]       0.09      0.06     0.01     0.24 1.00     4669
## prjhack_mostjob_av12x21[2]       0.09      0.06     0.01     0.24 1.00     4722
## prjhack_mostjob_av12x21[3]       0.11      0.07     0.01     0.26 1.00     4197
## prjhack_mostjob_av12x21[4]       0.10      0.07     0.01     0.26 1.00     5162
## prjhack_mostjob_av12x21[5]       0.12      0.08     0.02     0.31 1.00     5771
## prjhack_mostjob_av12x21[6]       0.15      0.09     0.02     0.36 1.00     4407
## prjhack_mostjob_av12x21[7]       0.20      0.11     0.03     0.43 1.00     4974
## prjhack_mostjob_av12x21[8]       0.15      0.08     0.02     0.35 1.00     4889
##                              Tail_ESS
## prjthflt5_mostjob_devx21[1]      2926
## prjthflt5_mostjob_devx21[2]      2400
## prjthflt5_mostjob_devx21[3]      2944
## prjthflt5_mostjob_devx21[4]      2821
## prjthflt5_mostjob_av12x21[1]     2165
## prjthflt5_mostjob_av12x21[2]     2283
## prjthflt5_mostjob_av12x21[3]     2600
## prjthflt5_mostjob_av12x21[4]     2822
## prjthflt5_mostjob_av12x21[5]     2603
## prjthflt5_mostjob_av12x21[6]     2932
## prjthflt5_mostjob_av12x21[7]     2995
## prjthflt5_mostjob_av12x21[8]     2981
## prjthfgt5_mostjob_devx21[1]      2472
## prjthfgt5_mostjob_devx21[2]      2106
## prjthfgt5_mostjob_devx21[3]      2812
## prjthfgt5_mostjob_devx21[4]      2699
## prjthfgt5_mostjob_av12x21[1]     2692
## prjthfgt5_mostjob_av12x21[2]     2083
## prjthfgt5_mostjob_av12x21[3]     2619
## prjthfgt5_mostjob_av12x21[4]     2445
## prjthfgt5_mostjob_av12x21[5]     2381
## prjthfgt5_mostjob_av12x21[6]     2473
## prjthfgt5_mostjob_av12x21[7]     3008
## prjthfgt5_mostjob_av12x21[8]     2957
## prjthreat_mostjob_devx21[1]      2930
## prjthreat_mostjob_devx21[2]      2292
## prjthreat_mostjob_devx21[3]      3020
## prjthreat_mostjob_devx21[4]      3038
## prjthreat_mostjob_av12x21[1]     2367
## prjthreat_mostjob_av12x21[2]     2527
## prjthreat_mostjob_av12x21[3]     2089
## prjthreat_mostjob_av12x21[4]     2652
## prjthreat_mostjob_av12x21[5]     2421
## prjthreat_mostjob_av12x21[6]     2614
## prjthreat_mostjob_av12x21[7]     2782
## prjthreat_mostjob_av12x21[8]     3177
## prjharm_mostjob_devx21[1]        2458
## prjharm_mostjob_devx21[2]        2185
## prjharm_mostjob_devx21[3]        2888
## prjharm_mostjob_devx21[4]        3014
## prjharm_mostjob_av12x21[1]       2352
## prjharm_mostjob_av12x21[2]       1992
## prjharm_mostjob_av12x21[3]       2689
## prjharm_mostjob_av12x21[4]       2614
## prjharm_mostjob_av12x21[5]       2687
## prjharm_mostjob_av12x21[6]       2668
## prjharm_mostjob_av12x21[7]       2392
## prjharm_mostjob_av12x21[8]       3008
## prjusedrg_mostjob_devx21[1]      2395
## prjusedrg_mostjob_devx21[2]      2587
## prjusedrg_mostjob_devx21[3]      2913
## prjusedrg_mostjob_devx21[4]      2786
## prjusedrg_mostjob_av12x21[1]     2532
## prjusedrg_mostjob_av12x21[2]     2603
## prjusedrg_mostjob_av12x21[3]     2707
## prjusedrg_mostjob_av12x21[4]     2476
## prjusedrg_mostjob_av12x21[5]     2614
## prjusedrg_mostjob_av12x21[6]     2698
## prjusedrg_mostjob_av12x21[7]     2916
## prjusedrg_mostjob_av12x21[8]     3089
## prjhack_mostjob_devx21[1]        2650
## prjhack_mostjob_devx21[2]        2951
## prjhack_mostjob_devx21[3]        2920
## prjhack_mostjob_devx21[4]        2746
## prjhack_mostjob_av12x21[1]       2188
## prjhack_mostjob_av12x21[2]       2520
## prjhack_mostjob_av12x21[3]       2288
## prjhack_mostjob_av12x21[4]       2287
## prjhack_mostjob_av12x21[5]       2368
## prjhack_mostjob_av12x21[6]       2287
## prjhack_mostjob_av12x21[7]       2932
## prjhack_mostjob_av12x21[8]       2732
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.2.5.5 Prior summary
out.chg.prjcrime.stjob.fit[[2]]
##                              prior     class            coef group      resp
##                             (flat)         b                                
##                             (flat)         b                         prjhack
##                   normal(0, 0.125)         b  mostjob_av12x2         prjhack
##                    normal(0, 0.25)         b   mostjob_devx2         prjhack
##                             (flat)         b                         prjharm
##                   normal(0, 0.125)         b  mostjob_av12x2         prjharm
##                    normal(0, 0.25)         b   mostjob_devx2         prjharm
##                             (flat)         b                       prjthfgt5
##                   normal(0, 0.125)         b  mostjob_av12x2       prjthfgt5
##                    normal(0, 0.25)         b   mostjob_devx2       prjthfgt5
##                             (flat)         b                       prjthflt5
##                   normal(0, 0.125)         b  mostjob_av12x2       prjthflt5
##                    normal(0, 0.25)         b   mostjob_devx2       prjthflt5
##                             (flat)         b                       prjthreat
##                   normal(0, 0.125)         b  mostjob_av12x2       prjthreat
##                    normal(0, 0.25)         b   mostjob_devx2       prjthreat
##                             (flat)         b                       prjusedrg
##                   normal(0, 0.125)         b  mostjob_av12x2       prjusedrg
##                    normal(0, 0.25)         b   mostjob_devx2       prjusedrg
##                             (flat) Intercept                                
##                       normal(0, 2) Intercept                         prjhack
##                       normal(0, 2) Intercept                         prjharm
##                       normal(0, 2) Intercept                       prjthfgt5
##                       normal(0, 2) Intercept                       prjthflt5
##                       normal(0, 2) Intercept                       prjthreat
##                       normal(0, 2) Intercept                       prjusedrg
##               student_t(3, 0, 2.5)        sd                         prjhack
##               student_t(3, 0, 2.5)        sd                         prjharm
##               student_t(3, 0, 2.5)        sd                       prjthfgt5
##               student_t(3, 0, 2.5)        sd                       prjthflt5
##               student_t(3, 0, 2.5)        sd                       prjthreat
##               student_t(3, 0, 2.5)        sd                       prjusedrg
##               student_t(3, 0, 2.5)        sd                    id   prjhack
##               student_t(3, 0, 2.5)        sd       Intercept    id   prjhack
##               student_t(3, 0, 2.5)        sd                    id   prjharm
##               student_t(3, 0, 2.5)        sd       Intercept    id   prjharm
##               student_t(3, 0, 2.5)        sd                    id prjthfgt5
##               student_t(3, 0, 2.5)        sd       Intercept    id prjthfgt5
##               student_t(3, 0, 2.5)        sd                    id prjthflt5
##               student_t(3, 0, 2.5)        sd       Intercept    id prjthflt5
##               student_t(3, 0, 2.5)        sd                    id prjthreat
##               student_t(3, 0, 2.5)        sd       Intercept    id prjthreat
##               student_t(3, 0, 2.5)        sd                    id prjusedrg
##               student_t(3, 0, 2.5)        sd       Intercept    id prjusedrg
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21         prjhack
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21         prjhack
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21         prjharm
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21         prjharm
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       prjthfgt5
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       prjthfgt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       prjthflt5
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       prjthflt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       prjthreat
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       prjthreat
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       prjusedrg
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.2.6 B/W Change Corr: stthft/crim intent

#Bivariate Change: criminal intent items ~ mo(stthft)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostthft_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostthft_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostthft_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostthft_av12x21', 
                  resp = prjdv_names)
  )

chg.prjcrime.stthft.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/chg_prjcrime_stthft_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stthft.fit <- ppchecks(chg.prjcrime.stthft.fit)
6.2.2.6.1 Coefficient plot (intervals)
out.chg.prjcrime.stthft.fit[[10]]

6.2.2.6.2 Coefficient plot (distributions)
out.chg.prjcrime.stthft.fit[[9]]

6.2.2.6.3 PPcheck (density)
p1 <- out.chg.prjcrime.stthft.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.chg.prjcrime.stthft.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.chg.prjcrime.stthft.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.chg.prjcrime.stthft.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.chg.prjcrime.stthft.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.chg.prjcrime.stthft.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

6.2.2.6.4 Fit summary
out.chg.prjcrime.stthft.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          prjthreat ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          prjharm ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          prjusedrg ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          prjhack ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     4.40      0.62     3.30     5.74 1.00     1311
## sd(prjthfgt5_Intercept)     3.60      0.52     2.68     4.71 1.00     1245
## sd(prjthreat_Intercept)     3.36      0.57     2.36     4.59 1.00     1557
## sd(prjharm_Intercept)       2.99      0.55     2.04     4.17 1.00     1222
## sd(prjusedrg_Intercept)     3.22      0.56     2.19     4.40 1.00     1639
## sd(prjhack_Intercept)       0.91      0.56     0.04     2.08 1.00     1105
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2389
## sd(prjthfgt5_Intercept)     2481
## sd(prjthreat_Intercept)     2059
## sd(prjharm_Intercept)       2254
## sd(prjusedrg_Intercept)     2138
## sd(prjhack_Intercept)       2049
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_Intercept          -5.53      0.77    -7.12    -4.12 1.00     2103
## prjthfgt5_Intercept          -5.26      0.71    -6.69    -3.92 1.00     2475
## prjthreat_Intercept          -5.96      0.87    -7.74    -4.35 1.00     2846
## prjharm_Intercept            -5.44      0.87    -7.15    -3.75 1.00     2459
## prjusedrg_Intercept          -6.00      0.90    -7.83    -4.34 1.00     2401
## prjhack_Intercept            -3.84      0.70    -5.37    -2.56 1.00     2277
## prjthflt5_mostthft_devx2     -0.12      0.18    -0.48     0.22 1.00     6388
## prjthflt5_mostthft_av12x2     0.11      0.09    -0.07     0.29 1.00     3073
## prjthfgt5_mostthft_devx2     -0.06      0.18    -0.41     0.30 1.00     5419
## prjthfgt5_mostthft_av12x2     0.17      0.08     0.01     0.34 1.00     3873
## prjthreat_mostthft_devx2     -0.26      0.20    -0.66     0.11 1.00     6454
## prjthreat_mostthft_av12x2     0.13      0.09    -0.06     0.31 1.00     4625
## prjharm_mostthft_devx2       -0.36      0.19    -0.74     0.01 1.00     6401
## prjharm_mostthft_av12x2       0.07      0.09    -0.11     0.24 1.00     4966
## prjusedrg_mostthft_devx2     -0.13      0.21    -0.55     0.27 1.00     6403
## prjusedrg_mostthft_av12x2    -0.03      0.09    -0.22     0.15 1.00     5010
## prjhack_mostthft_devx2       -0.19      0.20    -0.57     0.21 1.00     6871
## prjhack_mostthft_av12x2       0.02      0.08    -0.14     0.17 1.00     6406
##                           Tail_ESS
## prjthflt5_Intercept           3025
## prjthfgt5_Intercept           2754
## prjthreat_Intercept           2956
## prjharm_Intercept             2778
## prjusedrg_Intercept           2727
## prjhack_Intercept             2174
## prjthflt5_mostthft_devx2      2645
## prjthflt5_mostthft_av12x2     2917
## prjthfgt5_mostthft_devx2      2847
## prjthfgt5_mostthft_av12x2     3106
## prjthreat_mostthft_devx2      3155
## prjthreat_mostthft_av12x2     3371
## prjharm_mostthft_devx2        3251
## prjharm_mostthft_av12x2       3019
## prjusedrg_mostthft_devx2      2570
## prjusedrg_mostthft_av12x2     3269
## prjhack_mostthft_devx2        2947
## prjhack_mostthft_av12x2       3045
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## prjthflt5_mostthft_devx21[1]      0.27      0.15     0.04     0.62 1.00
## prjthflt5_mostthft_devx21[2]      0.25      0.14     0.04     0.57 1.00
## prjthflt5_mostthft_devx21[3]      0.23      0.14     0.03     0.55 1.00
## prjthflt5_mostthft_devx21[4]      0.25      0.15     0.03     0.58 1.00
## prjthflt5_mostthft_av12x21[1]     0.12      0.08     0.02     0.31 1.00
## prjthflt5_mostthft_av12x21[2]     0.12      0.07     0.02     0.30 1.00
## prjthflt5_mostthft_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## prjthflt5_mostthft_av12x21[4]     0.12      0.08     0.01     0.32 1.00
## prjthflt5_mostthft_av12x21[5]     0.14      0.09     0.02     0.36 1.00
## prjthflt5_mostthft_av12x21[6]     0.14      0.08     0.02     0.34 1.00
## prjthflt5_mostthft_av12x21[7]     0.12      0.07     0.02     0.29 1.00
## prjthflt5_mostthft_av12x21[8]     0.12      0.08     0.02     0.32 1.00
## prjthfgt5_mostthft_devx21[1]      0.27      0.15     0.04     0.62 1.00
## prjthfgt5_mostthft_devx21[2]      0.24      0.14     0.04     0.57 1.00
## prjthfgt5_mostthft_devx21[3]      0.23      0.14     0.03     0.56 1.00
## prjthfgt5_mostthft_devx21[4]      0.26      0.15     0.04     0.60 1.00
## prjthfgt5_mostthft_av12x21[1]     0.11      0.07     0.01     0.30 1.00
## prjthfgt5_mostthft_av12x21[2]     0.11      0.07     0.01     0.30 1.00
## prjthfgt5_mostthft_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## prjthfgt5_mostthft_av12x21[4]     0.13      0.08     0.02     0.33 1.00
## prjthfgt5_mostthft_av12x21[5]     0.15      0.09     0.02     0.36 1.00
## prjthfgt5_mostthft_av12x21[6]     0.14      0.09     0.02     0.34 1.00
## prjthfgt5_mostthft_av12x21[7]     0.12      0.08     0.02     0.30 1.00
## prjthfgt5_mostthft_av12x21[8]     0.11      0.07     0.02     0.29 1.00
## prjthreat_mostthft_devx21[1]      0.28      0.16     0.04     0.62 1.00
## prjthreat_mostthft_devx21[2]      0.28      0.15     0.05     0.60 1.00
## prjthreat_mostthft_devx21[3]      0.20      0.13     0.02     0.50 1.00
## prjthreat_mostthft_devx21[4]      0.24      0.14     0.03     0.55 1.00
## prjthreat_mostthft_av12x21[1]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mostthft_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mostthft_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## prjthreat_mostthft_av12x21[4]     0.12      0.08     0.02     0.32 1.00
## prjthreat_mostthft_av12x21[5]     0.14      0.09     0.02     0.35 1.00
## prjthreat_mostthft_av12x21[6]     0.13      0.08     0.02     0.33 1.00
## prjthreat_mostthft_av12x21[7]     0.13      0.08     0.02     0.32 1.00
## prjthreat_mostthft_av12x21[8]     0.11      0.07     0.01     0.29 1.00
## prjharm_mostthft_devx21[1]        0.26      0.15     0.04     0.60 1.00
## prjharm_mostthft_devx21[2]        0.30      0.15     0.05     0.63 1.00
## prjharm_mostthft_devx21[3]        0.22      0.13     0.03     0.52 1.00
## prjharm_mostthft_devx21[4]        0.22      0.13     0.03     0.51 1.00
## prjharm_mostthft_av12x21[1]       0.13      0.08     0.02     0.33 1.00
## prjharm_mostthft_av12x21[2]       0.13      0.08     0.02     0.32 1.00
## prjharm_mostthft_av12x21[3]       0.12      0.08     0.02     0.30 1.00
## prjharm_mostthft_av12x21[4]       0.12      0.08     0.02     0.32 1.00
## prjharm_mostthft_av12x21[5]       0.13      0.08     0.02     0.33 1.00
## prjharm_mostthft_av12x21[6]       0.12      0.08     0.01     0.32 1.00
## prjharm_mostthft_av12x21[7]       0.12      0.08     0.02     0.31 1.00
## prjharm_mostthft_av12x21[8]       0.12      0.08     0.02     0.32 1.00
## prjusedrg_mostthft_devx21[1]      0.28      0.16     0.04     0.63 1.00
## prjusedrg_mostthft_devx21[2]      0.24      0.14     0.04     0.56 1.00
## prjusedrg_mostthft_devx21[3]      0.23      0.14     0.03     0.54 1.00
## prjusedrg_mostthft_devx21[4]      0.25      0.15     0.04     0.59 1.00
## prjusedrg_mostthft_av12x21[1]     0.13      0.08     0.02     0.32 1.00
## prjusedrg_mostthft_av12x21[2]     0.13      0.08     0.02     0.32 1.00
## prjusedrg_mostthft_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## prjusedrg_mostthft_av12x21[4]     0.12      0.08     0.02     0.31 1.00
## prjusedrg_mostthft_av12x21[5]     0.12      0.08     0.02     0.32 1.00
## prjusedrg_mostthft_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## prjusedrg_mostthft_av12x21[7]     0.13      0.08     0.02     0.33 1.00
## prjusedrg_mostthft_av12x21[8]     0.13      0.09     0.02     0.34 1.00
## prjhack_mostthft_devx21[1]        0.27      0.15     0.04     0.61 1.00
## prjhack_mostthft_devx21[2]        0.26      0.14     0.04     0.58 1.00
## prjhack_mostthft_devx21[3]        0.24      0.14     0.04     0.55 1.00
## prjhack_mostthft_devx21[4]        0.23      0.14     0.03     0.57 1.00
## prjhack_mostthft_av12x21[1]       0.12      0.08     0.02     0.32 1.00
## prjhack_mostthft_av12x21[2]       0.13      0.08     0.02     0.32 1.00
## prjhack_mostthft_av12x21[3]       0.12      0.08     0.02     0.32 1.00
## prjhack_mostthft_av12x21[4]       0.12      0.08     0.02     0.31 1.00
## prjhack_mostthft_av12x21[5]       0.12      0.08     0.02     0.32 1.00
## prjhack_mostthft_av12x21[6]       0.13      0.08     0.02     0.31 1.00
## prjhack_mostthft_av12x21[7]       0.13      0.08     0.02     0.32 1.00
## prjhack_mostthft_av12x21[8]       0.13      0.08     0.02     0.33 1.00
##                               Bulk_ESS Tail_ESS
## prjthflt5_mostthft_devx21[1]      6288     2939
## prjthflt5_mostthft_devx21[2]      5984     2872
## prjthflt5_mostthft_devx21[3]      5756     2563
## prjthflt5_mostthft_devx21[4]      5679     2452
## prjthflt5_mostthft_av12x21[1]     6797     2696
## prjthflt5_mostthft_av12x21[2]     6238     2466
## prjthflt5_mostthft_av12x21[3]     7090     2644
## prjthflt5_mostthft_av12x21[4]     6209     2253
## prjthflt5_mostthft_av12x21[5]     5725     2318
## prjthflt5_mostthft_av12x21[6]     5920     2609
## prjthflt5_mostthft_av12x21[7]     6289     2561
## prjthflt5_mostthft_av12x21[8]     6163     3108
## prjthfgt5_mostthft_devx21[1]      7824     2972
## prjthfgt5_mostthft_devx21[2]      8102     2462
## prjthfgt5_mostthft_devx21[3]      5622     2979
## prjthfgt5_mostthft_devx21[4]      7338     2689
## prjthfgt5_mostthft_av12x21[1]     5881     2182
## prjthfgt5_mostthft_av12x21[2]     7160     2704
## prjthfgt5_mostthft_av12x21[3]     6575     2526
## prjthfgt5_mostthft_av12x21[4]     6470     2704
## prjthfgt5_mostthft_av12x21[5]     5689     2471
## prjthfgt5_mostthft_av12x21[6]     6240     2915
## prjthfgt5_mostthft_av12x21[7]     5793     2707
## prjthfgt5_mostthft_av12x21[8]     6224     2848
## prjthreat_mostthft_devx21[1]      5830     2859
## prjthreat_mostthft_devx21[2]      6296     2913
## prjthreat_mostthft_devx21[3]      5822     3428
## prjthreat_mostthft_devx21[4]      7452     2600
## prjthreat_mostthft_av12x21[1]     6878     2538
## prjthreat_mostthft_av12x21[2]     6017     2511
## prjthreat_mostthft_av12x21[3]     6948     2646
## prjthreat_mostthft_av12x21[4]     5806     2493
## prjthreat_mostthft_av12x21[5]     6655     2377
## prjthreat_mostthft_av12x21[6]     7058     2862
## prjthreat_mostthft_av12x21[7]     7508     3175
## prjthreat_mostthft_av12x21[8]     6183     2878
## prjharm_mostthft_devx21[1]        6972     2886
## prjharm_mostthft_devx21[2]        5980     2486
## prjharm_mostthft_devx21[3]        6095     3042
## prjharm_mostthft_devx21[4]        6071     2918
## prjharm_mostthft_av12x21[1]       6166     2675
## prjharm_mostthft_av12x21[2]       6780     2147
## prjharm_mostthft_av12x21[3]       5511     2385
## prjharm_mostthft_av12x21[4]       7399     2951
## prjharm_mostthft_av12x21[5]       5975     2495
## prjharm_mostthft_av12x21[6]       5639     2006
## prjharm_mostthft_av12x21[7]       5267     2723
## prjharm_mostthft_av12x21[8]       6585     3030
## prjusedrg_mostthft_devx21[1]      6998     3103
## prjusedrg_mostthft_devx21[2]      6428     2403
## prjusedrg_mostthft_devx21[3]      6766     2887
## prjusedrg_mostthft_devx21[4]      6617     2959
## prjusedrg_mostthft_av12x21[1]     6340     2467
## prjusedrg_mostthft_av12x21[2]     6720     2321
## prjusedrg_mostthft_av12x21[3]     6272     2849
## prjusedrg_mostthft_av12x21[4]     6186     2431
## prjusedrg_mostthft_av12x21[5]     5418     2058
## prjusedrg_mostthft_av12x21[6]     6425     2648
## prjusedrg_mostthft_av12x21[7]     5814     2744
## prjusedrg_mostthft_av12x21[8]     6745     2908
## prjhack_mostthft_devx21[1]        5963     2094
## prjhack_mostthft_devx21[2]        6397     2443
## prjhack_mostthft_devx21[3]        6883     2806
## prjhack_mostthft_devx21[4]        6775     3012
## prjhack_mostthft_av12x21[1]       6336     2550
## prjhack_mostthft_av12x21[2]       6234     2595
## prjhack_mostthft_av12x21[3]       6787     2733
## prjhack_mostthft_av12x21[4]       6213     2346
## prjhack_mostthft_av12x21[5]       5921     2484
## prjhack_mostthft_av12x21[6]       6638     2715
## prjhack_mostthft_av12x21[7]       6289     2520
## prjhack_mostthft_av12x21[8]       6810     2662
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.2.6.5 Prior summary
out.chg.prjcrime.stthft.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                          prjhack
##                   normal(0, 0.125)         b  mostthft_av12x2         prjhack
##                    normal(0, 0.25)         b   mostthft_devx2         prjhack
##                             (flat)         b                          prjharm
##                   normal(0, 0.125)         b  mostthft_av12x2         prjharm
##                    normal(0, 0.25)         b   mostthft_devx2         prjharm
##                             (flat)         b                        prjthfgt5
##                   normal(0, 0.125)         b  mostthft_av12x2       prjthfgt5
##                    normal(0, 0.25)         b   mostthft_devx2       prjthfgt5
##                             (flat)         b                        prjthflt5
##                   normal(0, 0.125)         b  mostthft_av12x2       prjthflt5
##                    normal(0, 0.25)         b   mostthft_devx2       prjthflt5
##                             (flat)         b                        prjthreat
##                   normal(0, 0.125)         b  mostthft_av12x2       prjthreat
##                    normal(0, 0.25)         b   mostthft_devx2       prjthreat
##                             (flat)         b                        prjusedrg
##                   normal(0, 0.125)         b  mostthft_av12x2       prjusedrg
##                    normal(0, 0.25)         b   mostthft_devx2       prjusedrg
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                          prjhack
##                       normal(0, 2) Intercept                          prjharm
##                       normal(0, 2) Intercept                        prjthfgt5
##                       normal(0, 2) Intercept                        prjthflt5
##                       normal(0, 2) Intercept                        prjthreat
##                       normal(0, 2) Intercept                        prjusedrg
##               student_t(3, 0, 2.5)        sd                          prjhack
##               student_t(3, 0, 2.5)        sd                          prjharm
##               student_t(3, 0, 2.5)        sd                        prjthfgt5
##               student_t(3, 0, 2.5)        sd                        prjthflt5
##               student_t(3, 0, 2.5)        sd                        prjthreat
##               student_t(3, 0, 2.5)        sd                        prjusedrg
##               student_t(3, 0, 2.5)        sd                     id   prjhack
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjhack
##               student_t(3, 0, 2.5)        sd                     id   prjharm
##               student_t(3, 0, 2.5)        sd        Intercept    id   prjharm
##               student_t(3, 0, 2.5)        sd                     id prjthfgt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthfgt5
##               student_t(3, 0, 2.5)        sd                     id prjthflt5
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthflt5
##               student_t(3, 0, 2.5)        sd                     id prjthreat
##               student_t(3, 0, 2.5)        sd        Intercept    id prjthreat
##               student_t(3, 0, 2.5)        sd                     id prjusedrg
##               student_t(3, 0, 2.5)        sd        Intercept    id prjusedrg
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21         prjhack
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21         prjhack
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21         prjharm
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21         prjharm
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       prjthfgt5
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       prjthfgt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       prjthflt5
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       prjthflt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       prjthreat
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       prjthreat
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       prjusedrg
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.2.7 B/W Change Corr: stmug/crim intent

#Bivariate Change: criminal intent items ~ mo(stmug)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmug_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostmug_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmug_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostmug_av12x21', 
                  resp = prjdv_names)
  )

chg.prjcrime.stmug.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/chg_prjcrime_stmug_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stmug.fit <- ppchecks(chg.prjcrime.stmug.fit)
6.2.2.7.1 Coefficient plot (intervals)
out.chg.prjcrime.stmug.fit[[10]]

6.2.2.7.2 Coefficient plot (distributions)
out.chg.prjcrime.stmug.fit[[9]]

6.2.2.7.3 PPcheck (density)
p1 <- out.chg.prjcrime.stmug.fit[[3]] + labs(title = "Theft <5BAM Intent (T1)") 
p2 <- out.chg.prjcrime.stmug.fit[[4]] + labs(title = "Theft >5BAM Intent (T1)")
p3 <- out.chg.prjcrime.stmug.fit[[5]] + labs(title = "Threat Intent (T1)")
p4 <- out.chg.prjcrime.stmug.fit[[6]] + labs(title = "Harm Intent (T1)")
p5 <- out.chg.prjcrime.stmug.fit[[7]] + labs(title = "Use Drugs Intent (T1)")
p6 <- out.chg.prjcrime.stmug.fit[[8]] + labs(title = "Hack Intent (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

6.2.2.7.4 Fit summary
out.chg.prjcrime.stmug.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          prjthreat ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          prjharm ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          prjusedrg ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          prjhack ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     4.54      0.66     3.40     6.00 1.00     1115
## sd(prjthfgt5_Intercept)     3.80      0.56     2.82     4.99 1.01      898
## sd(prjthreat_Intercept)     3.55      0.57     2.55     4.72 1.00     1348
## sd(prjharm_Intercept)       2.96      0.52     2.02     4.07 1.00     1316
## sd(prjusedrg_Intercept)     3.15      0.55     2.15     4.34 1.00     1152
## sd(prjhack_Intercept)       0.85      0.54     0.04     2.00 1.00      557
##                         Tail_ESS
## sd(prjthflt5_Intercept)     1901
## sd(prjthfgt5_Intercept)     1726
## sd(prjthreat_Intercept)     2303
## sd(prjharm_Intercept)       2261
## sd(prjusedrg_Intercept)     1594
## sd(prjhack_Intercept)       1309
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_Intercept         -5.47      0.81    -7.20    -3.94 1.00     1239
## prjthfgt5_Intercept         -5.18      0.73    -6.67    -3.79 1.00     1283
## prjthreat_Intercept         -5.96      0.89    -7.79    -4.25 1.01     1515
## prjharm_Intercept           -5.81      0.86    -7.60    -4.27 1.00     1600
## prjusedrg_Intercept         -6.27      0.91    -8.14    -4.57 1.00     1333
## prjhack_Intercept           -4.14      0.64    -5.49    -2.94 1.00     1079
## prjthflt5_mostmug_devx2     -0.06      0.19    -0.44     0.32 1.00     3060
## prjthflt5_mostmug_av12x2    -0.02      0.10    -0.22     0.17 1.00     2312
## prjthfgt5_mostmug_devx2      0.03      0.18    -0.33     0.38 1.00     3155
## prjthfgt5_mostmug_av12x2    -0.01      0.09    -0.19     0.18 1.00     2146
## prjthreat_mostmug_devx2     -0.21      0.20    -0.62     0.18 1.00     3449
## prjthreat_mostmug_av12x2    -0.01      0.10    -0.20     0.19 1.00     2944
## prjharm_mostmug_devx2       -0.08      0.20    -0.50     0.32 1.00     3217
## prjharm_mostmug_av12x2       0.01      0.09    -0.17     0.19 1.00     3322
## prjusedrg_mostmug_devx2      0.02      0.22    -0.45     0.44 1.00     2501
## prjusedrg_mostmug_av12x2     0.01      0.09    -0.18     0.19 1.00     2853
## prjhack_mostmug_devx2       -0.02      0.21    -0.42     0.37 1.00     2068
## prjhack_mostmug_av12x2       0.02      0.08    -0.14     0.18 1.00     3201
##                          Tail_ESS
## prjthflt5_Intercept          1618
## prjthfgt5_Intercept          2190
## prjthreat_Intercept          2532
## prjharm_Intercept            2055
## prjusedrg_Intercept          1553
## prjhack_Intercept            1406
## prjthflt5_mostmug_devx2      2534
## prjthflt5_mostmug_av12x2     2312
## prjthfgt5_mostmug_devx2      3017
## prjthfgt5_mostmug_av12x2     2787
## prjthreat_mostmug_devx2      2730
## prjthreat_mostmug_av12x2     2619
## prjharm_mostmug_devx2        2776
## prjharm_mostmug_av12x2       3251
## prjusedrg_mostmug_devx2      2762
## prjusedrg_mostmug_av12x2     2873
## prjhack_mostmug_devx2        2315
## prjhack_mostmug_av12x2       2600
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## prjthflt5_mostmug_devx21[1]      0.26      0.15     0.04     0.60 1.00     4071
## prjthflt5_mostmug_devx21[2]      0.25      0.14     0.04     0.57 1.00     4602
## prjthflt5_mostmug_devx21[3]      0.23      0.14     0.03     0.57 1.00     3158
## prjthflt5_mostmug_devx21[4]      0.26      0.15     0.04     0.60 1.00     4207
## prjthflt5_mostmug_av12x21[1]     0.12      0.08     0.02     0.32 1.00     4314
## prjthflt5_mostmug_av12x21[2]     0.12      0.08     0.02     0.31 1.00     4129
## prjthflt5_mostmug_av12x21[3]     0.12      0.08     0.02     0.32 1.00     4106
## prjthflt5_mostmug_av12x21[4]     0.13      0.08     0.02     0.33 1.00     4995
## prjthflt5_mostmug_av12x21[5]     0.13      0.08     0.01     0.32 1.00     3806
## prjthflt5_mostmug_av12x21[6]     0.13      0.08     0.02     0.31 1.00     5002
## prjthflt5_mostmug_av12x21[7]     0.13      0.08     0.02     0.33 1.00     4353
## prjthflt5_mostmug_av12x21[8]     0.13      0.08     0.02     0.32 1.00     4647
## prjthfgt5_mostmug_devx21[1]      0.25      0.15     0.03     0.60 1.00     4226
## prjthfgt5_mostmug_devx21[2]      0.23      0.14     0.03     0.57 1.00     4844
## prjthfgt5_mostmug_devx21[3]      0.26      0.15     0.04     0.60 1.00     3582
## prjthfgt5_mostmug_devx21[4]      0.26      0.14     0.04     0.57 1.00     4255
## prjthfgt5_mostmug_av12x21[1]     0.12      0.08     0.02     0.32 1.00     3860
## prjthfgt5_mostmug_av12x21[2]     0.12      0.08     0.02     0.31 1.00     4383
## prjthfgt5_mostmug_av12x21[3]     0.12      0.08     0.02     0.31 1.00     3691
## prjthfgt5_mostmug_av12x21[4]     0.12      0.08     0.02     0.32 1.00     4746
## prjthfgt5_mostmug_av12x21[5]     0.13      0.08     0.02     0.32 1.00     4460
## prjthfgt5_mostmug_av12x21[6]     0.13      0.08     0.02     0.33 1.00     3847
## prjthfgt5_mostmug_av12x21[7]     0.13      0.08     0.02     0.32 1.00     5091
## prjthfgt5_mostmug_av12x21[8]     0.13      0.08     0.02     0.32 1.00     4124
## prjthreat_mostmug_devx21[1]      0.29      0.16     0.05     0.62 1.00     3732
## prjthreat_mostmug_devx21[2]      0.26      0.14     0.04     0.57 1.00     4746
## prjthreat_mostmug_devx21[3]      0.21      0.13     0.03     0.52 1.00     3416
## prjthreat_mostmug_devx21[4]      0.25      0.14     0.03     0.58 1.00     5217
## prjthreat_mostmug_av12x21[1]     0.12      0.08     0.02     0.31 1.00     4253
## prjthreat_mostmug_av12x21[2]     0.12      0.08     0.02     0.32 1.00     4295
## prjthreat_mostmug_av12x21[3]     0.12      0.08     0.01     0.32 1.00     5206
## prjthreat_mostmug_av12x21[4]     0.12      0.08     0.02     0.32 1.00     4671
## prjthreat_mostmug_av12x21[5]     0.13      0.08     0.02     0.32 1.00     4681
## prjthreat_mostmug_av12x21[6]     0.13      0.08     0.02     0.32 1.00     3825
## prjthreat_mostmug_av12x21[7]     0.13      0.08     0.02     0.32 1.00     4181
## prjthreat_mostmug_av12x21[8]     0.13      0.08     0.02     0.32 1.00     3691
## prjharm_mostmug_devx21[1]        0.27      0.15     0.04     0.62 1.00     3616
## prjharm_mostmug_devx21[2]        0.25      0.14     0.04     0.56 1.00     3831
## prjharm_mostmug_devx21[3]        0.23      0.14     0.03     0.56 1.00     3708
## prjharm_mostmug_devx21[4]        0.25      0.15     0.03     0.60 1.00     3617
## prjharm_mostmug_av12x21[1]       0.12      0.08     0.02     0.31 1.00     3854
## prjharm_mostmug_av12x21[2]       0.13      0.08     0.02     0.32 1.00     4282
## prjharm_mostmug_av12x21[3]       0.13      0.08     0.02     0.32 1.00     4342
## prjharm_mostmug_av12x21[4]       0.12      0.08     0.02     0.31 1.00     4047
## prjharm_mostmug_av12x21[5]       0.12      0.08     0.02     0.32 1.00     5068
## prjharm_mostmug_av12x21[6]       0.12      0.08     0.02     0.32 1.00     4147
## prjharm_mostmug_av12x21[7]       0.13      0.08     0.02     0.33 1.00     4480
## prjharm_mostmug_av12x21[8]       0.13      0.08     0.02     0.32 1.00     4591
## prjusedrg_mostmug_devx21[1]      0.25      0.16     0.03     0.62 1.00     2919
## prjusedrg_mostmug_devx21[2]      0.23      0.14     0.03     0.57 1.00     3545
## prjusedrg_mostmug_devx21[3]      0.27      0.16     0.03     0.63 1.00     2886
## prjusedrg_mostmug_devx21[4]      0.25      0.15     0.04     0.58 1.00     5175
## prjusedrg_mostmug_av12x21[1]     0.12      0.08     0.02     0.32 1.00     4631
## prjusedrg_mostmug_av12x21[2]     0.12      0.08     0.02     0.31 1.00     4506
## prjusedrg_mostmug_av12x21[3]     0.13      0.08     0.02     0.32 1.00     3722
## prjusedrg_mostmug_av12x21[4]     0.12      0.08     0.02     0.31 1.00     4601
## prjusedrg_mostmug_av12x21[5]     0.13      0.08     0.02     0.32 1.00     3654
## prjusedrg_mostmug_av12x21[6]     0.13      0.08     0.02     0.32 1.00     4634
## prjusedrg_mostmug_av12x21[7]     0.13      0.08     0.02     0.32 1.00     4037
## prjusedrg_mostmug_av12x21[8]     0.13      0.08     0.02     0.33 1.00     5404
## prjhack_mostmug_devx21[1]        0.26      0.15     0.04     0.61 1.00     3638
## prjhack_mostmug_devx21[2]        0.24      0.14     0.03     0.57 1.00     4506
## prjhack_mostmug_devx21[3]        0.24      0.14     0.03     0.57 1.00     3655
## prjhack_mostmug_devx21[4]        0.26      0.14     0.04     0.58 1.00     3793
## prjhack_mostmug_av12x21[1]       0.12      0.08     0.02     0.31 1.00     4584
## prjhack_mostmug_av12x21[2]       0.12      0.08     0.02     0.30 1.00     4278
## prjhack_mostmug_av12x21[3]       0.12      0.08     0.02     0.31 1.00     4097
## prjhack_mostmug_av12x21[4]       0.12      0.08     0.02     0.31 1.00     4308
## prjhack_mostmug_av12x21[5]       0.13      0.08     0.02     0.31 1.00     4002
## prjhack_mostmug_av12x21[6]       0.13      0.08     0.02     0.32 1.00     4025
## prjhack_mostmug_av12x21[7]       0.13      0.08     0.02     0.33 1.00     3389
## prjhack_mostmug_av12x21[8]       0.13      0.08     0.02     0.33 1.00     5108
##                              Tail_ESS
## prjthflt5_mostmug_devx21[1]      2319
## prjthflt5_mostmug_devx21[2]      3062
## prjthflt5_mostmug_devx21[3]      2141
## prjthflt5_mostmug_devx21[4]      2348
## prjthflt5_mostmug_av12x21[1]     1969
## prjthflt5_mostmug_av12x21[2]     2566
## prjthflt5_mostmug_av12x21[3]     2120
## prjthflt5_mostmug_av12x21[4]     2504
## prjthflt5_mostmug_av12x21[5]     1800
## prjthflt5_mostmug_av12x21[6]     2811
## prjthflt5_mostmug_av12x21[7]     2736
## prjthflt5_mostmug_av12x21[8]     2737
## prjthfgt5_mostmug_devx21[1]      2235
## prjthfgt5_mostmug_devx21[2]      2766
## prjthfgt5_mostmug_devx21[3]      3011
## prjthfgt5_mostmug_devx21[4]      2972
## prjthfgt5_mostmug_av12x21[1]     1876
## prjthfgt5_mostmug_av12x21[2]     1619
## prjthfgt5_mostmug_av12x21[3]     1574
## prjthfgt5_mostmug_av12x21[4]     2213
## prjthfgt5_mostmug_av12x21[5]     2492
## prjthfgt5_mostmug_av12x21[6]     2257
## prjthfgt5_mostmug_av12x21[7]     2370
## prjthfgt5_mostmug_av12x21[8]     2682
## prjthreat_mostmug_devx21[1]      2689
## prjthreat_mostmug_devx21[2]      2629
## prjthreat_mostmug_devx21[3]      2585
## prjthreat_mostmug_devx21[4]      2486
## prjthreat_mostmug_av12x21[1]     2343
## prjthreat_mostmug_av12x21[2]     2180
## prjthreat_mostmug_av12x21[3]     2339
## prjthreat_mostmug_av12x21[4]     1875
## prjthreat_mostmug_av12x21[5]     2713
## prjthreat_mostmug_av12x21[6]     2112
## prjthreat_mostmug_av12x21[7]     3070
## prjthreat_mostmug_av12x21[8]     2393
## prjharm_mostmug_devx21[1]        2295
## prjharm_mostmug_devx21[2]        2430
## prjharm_mostmug_devx21[3]        2483
## prjharm_mostmug_devx21[4]        2402
## prjharm_mostmug_av12x21[1]       2049
## prjharm_mostmug_av12x21[2]       2360
## prjharm_mostmug_av12x21[3]       2130
## prjharm_mostmug_av12x21[4]       2241
## prjharm_mostmug_av12x21[5]       2771
## prjharm_mostmug_av12x21[6]       2637
## prjharm_mostmug_av12x21[7]       3080
## prjharm_mostmug_av12x21[8]       2869
## prjusedrg_mostmug_devx21[1]      2342
## prjusedrg_mostmug_devx21[2]      2608
## prjusedrg_mostmug_devx21[3]      2796
## prjusedrg_mostmug_devx21[4]      2524
## prjusedrg_mostmug_av12x21[1]     2162
## prjusedrg_mostmug_av12x21[2]     2450
## prjusedrg_mostmug_av12x21[3]     2167
## prjusedrg_mostmug_av12x21[4]     2385
## prjusedrg_mostmug_av12x21[5]     2170
## prjusedrg_mostmug_av12x21[6]     2447
## prjusedrg_mostmug_av12x21[7]     2698
## prjusedrg_mostmug_av12x21[8]     2820
## prjhack_mostmug_devx21[1]        2676
## prjhack_mostmug_devx21[2]        2757
## prjhack_mostmug_devx21[3]        2621
## prjhack_mostmug_devx21[4]        2330
## prjhack_mostmug_av12x21[1]       2616
## prjhack_mostmug_av12x21[2]       2296
## prjhack_mostmug_av12x21[3]       1637
## prjhack_mostmug_av12x21[4]       2181
## prjhack_mostmug_av12x21[5]       2062
## prjhack_mostmug_av12x21[6]       2601
## prjhack_mostmug_av12x21[7]       2415
## prjhack_mostmug_av12x21[8]       2935
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.2.7.5 Prior summary
out.chg.prjcrime.stmug.fit[[2]]
##                              prior     class            coef group      resp
##                             (flat)         b                                
##                             (flat)         b                         prjhack
##                   normal(0, 0.125)         b  mostmug_av12x2         prjhack
##                    normal(0, 0.25)         b   mostmug_devx2         prjhack
##                             (flat)         b                         prjharm
##                   normal(0, 0.125)         b  mostmug_av12x2         prjharm
##                    normal(0, 0.25)         b   mostmug_devx2         prjharm
##                             (flat)         b                       prjthfgt5
##                   normal(0, 0.125)         b  mostmug_av12x2       prjthfgt5
##                    normal(0, 0.25)         b   mostmug_devx2       prjthfgt5
##                             (flat)         b                       prjthflt5
##                   normal(0, 0.125)         b  mostmug_av12x2       prjthflt5
##                    normal(0, 0.25)         b   mostmug_devx2       prjthflt5
##                             (flat)         b                       prjthreat
##                   normal(0, 0.125)         b  mostmug_av12x2       prjthreat
##                    normal(0, 0.25)         b   mostmug_devx2       prjthreat
##                             (flat)         b                       prjusedrg
##                   normal(0, 0.125)         b  mostmug_av12x2       prjusedrg
##                    normal(0, 0.25)         b   mostmug_devx2       prjusedrg
##                             (flat) Intercept                                
##                       normal(0, 2) Intercept                         prjhack
##                       normal(0, 2) Intercept                         prjharm
##                       normal(0, 2) Intercept                       prjthfgt5
##                       normal(0, 2) Intercept                       prjthflt5
##                       normal(0, 2) Intercept                       prjthreat
##                       normal(0, 2) Intercept                       prjusedrg
##               student_t(3, 0, 2.5)        sd                         prjhack
##               student_t(3, 0, 2.5)        sd                         prjharm
##               student_t(3, 0, 2.5)        sd                       prjthfgt5
##               student_t(3, 0, 2.5)        sd                       prjthflt5
##               student_t(3, 0, 2.5)        sd                       prjthreat
##               student_t(3, 0, 2.5)        sd                       prjusedrg
##               student_t(3, 0, 2.5)        sd                    id   prjhack
##               student_t(3, 0, 2.5)        sd       Intercept    id   prjhack
##               student_t(3, 0, 2.5)        sd                    id   prjharm
##               student_t(3, 0, 2.5)        sd       Intercept    id   prjharm
##               student_t(3, 0, 2.5)        sd                    id prjthfgt5
##               student_t(3, 0, 2.5)        sd       Intercept    id prjthfgt5
##               student_t(3, 0, 2.5)        sd                    id prjthflt5
##               student_t(3, 0, 2.5)        sd       Intercept    id prjthflt5
##               student_t(3, 0, 2.5)        sd                    id prjthreat
##               student_t(3, 0, 2.5)        sd       Intercept    id prjthreat
##               student_t(3, 0, 2.5)        sd                    id prjusedrg
##               student_t(3, 0, 2.5)        sd       Intercept    id prjusedrg
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21         prjhack
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21         prjhack
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21         prjharm
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21         prjharm
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       prjthfgt5
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       prjthfgt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       prjthflt5
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       prjthflt5
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       prjthreat
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       prjthreat
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       prjusedrg
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.2.8 B/W Change Corr: stress & “any” crim intent

#Bivariate Change: "any" criminal intent ~ mo(stress)
 

#Create function for repetitive prior settings
setmyprior <- function(mochgcoefname, moavcoefname, 
                       simochgcoefname, simoavcoefname) {
  c(
  set_prior('normal(0, 2)', class = 'Intercept'),
  set_prior('normal(0, 0.25)', class = 'b', coef = mochgcoefname), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = moavcoefname), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = simochgcoefname),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = simoavcoefname))
  }

#Update function to call all ppchecks for bivar any crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit)
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95)
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95)  
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, plotcoefs, plotcoefs2)
  return(allchecks)
}

myprior <- setmyprior('mostmony_devx2', 'mostmony_av12x2', 
                      'mostmony_devx21', 'mostmony_av12x21')
chg.anyprjcrime.stmony.fit <- brm(prjany ~ 1 +
    mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id),
    data = stress.long, family = "bernoulli", prior = myprior, 
    cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
    file = "Models/chg_anyprjcrime_stmony_fit", file_refit = "on_change"
)
out.chg.anyprjcrime.stmony.fit <- ppchecks(chg.anyprjcrime.stmony.fit)

myprior <- setmyprior('mosttran_devx2', 'mosttran_av12x2', 
                      'mosttran_devx21', 'mosttran_av12x21')
chg.anyprjcrime.sttran.fit <- brm(prjany ~ 1 +
    mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id),
    data = stress.long, family = "bernoulli", prior = myprior, 
    cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
    file = "Models/chg_anyprjcrime_sttran_fit", file_refit = "on_change"
    )
out.chg.anyprjcrime.sttran.fit <- ppchecks(chg.anyprjcrime.sttran.fit)

myprior <- setmyprior('mostresp_devx2', 'mostresp_av12x2', 
                      'mostresp_devx21', 'mostresp_av12x21')
chg.anyprjcrime.stresp.fit <- brm(prjany ~ 1 +
    mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id),
    data = stress.long, family = "bernoulli", prior = myprior, 
    cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309,
    file = "Models/chg_anyprjcrime_stresp_fit", file_refit = "on_change"
    )
out.chg.anyprjcrime.stresp.fit <- ppchecks(chg.anyprjcrime.stresp.fit)

myprior <- setmyprior('mostfair_devx2', 'mostfair_av12x2', 
                      'mostfair_devx21', 'mostfair_av12x21')
chg.anyprjcrime.stfair.fit <- brm(prjany ~ 1 +
    mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id),
    data = stress.long, family = "bernoulli", prior = myprior, 
    cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
    file = "Models/chg_anyprjcrime_stfair_fit", file_refit = "on_change"
    )
out.chg.anyprjcrime.stfair.fit <- ppchecks(chg.anyprjcrime.stfair.fit)

myprior <- setmyprior('mostjob_devx2', 'mostjob_av12x2', 
                      'mostjob_devx21', 'mostjob_av12x21')
chg.anyprjcrime.stjob.fit <- brm(prjany ~ 1 +
    mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id),
    data = stress.long, family = "bernoulli", prior = myprior, 
    cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
    file = "Models/chg_anyprjcrime_stjob_fit", file_refit = "on_change"
    )
out.chg.anyprjcrime.stjob.fit <- ppchecks(chg.anyprjcrime.stjob.fit)

myprior <- setmyprior('mostthft_devx2', 'mostthft_av12x2', 
                      'mostthft_devx21', 'mostthft_av12x21')
chg.anyprjcrime.stthft.fit <- brm(prjany ~ 1 +
    mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id),
    data = stress.long, family = "bernoulli", prior = myprior, 
    cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309,
    file = "Models/chg_anyprjcrime_stthft_fit", file_refit = "on_change"
    )
out.chg.anyprjcrime.stthft.fit <- ppchecks(chg.anyprjcrime.stthft.fit)

myprior <- setmyprior('mostmug_devx2', 'mostmug_av12x2', 
                      'mostmug_devx21', 'mostmug_av12x21')
chg.anyprjcrime.stmug.fit <- brm(prjany ~ 1 +
    mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id),
    data = stress.long, family = "bernoulli", prior = myprior, 
    cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
    file = "Models/chg_anyprjcrime_stmug_fit", file_refit = "on_change"
    )
out.chg.anyprjcrime.stmug.fit <- ppchecks(chg.anyprjcrime.stmug.fit)
6.2.2.8.1 Coefficient plot (intervals)
p1 <- out.chg.anyprjcrime.stmony.fit[[5]]
p2 <- out.chg.anyprjcrime.sttran.fit[[5]]
p3 <- out.chg.anyprjcrime.stresp.fit[[5]]
p4 <- out.chg.anyprjcrime.stfair.fit[[5]]
p5 <- out.chg.anyprjcrime.stjob.fit[[5]]
p6 <- out.chg.anyprjcrime.stthft.fit[[5]]
p7 <- out.chg.anyprjcrime.stmug.fit[[5]]

playout <- '
AB
CD
E#
FG
'
p1 + p2 + p3 + p4 + p5 + p6 + p7 +
  plot_layout(design = playout) +
  plot_annotation(
  title = 'Coefficient plot',
  subtitle = 'Posterior intervals for monotonic ordinal within-person ("devx2") and between-person ("av12x2") stress\ncoefficients predicting "any criminal intent" with medians, 80% (thick line), and 95% (thin line) intervals')

6.2.2.8.2 Coefficient plot (distributions)
p1 <- out.chg.anyprjcrime.stmony.fit[[4]]
p2 <- out.chg.anyprjcrime.sttran.fit[[4]]
p3 <- out.chg.anyprjcrime.stresp.fit[[4]]
p4 <- out.chg.anyprjcrime.stfair.fit[[4]]
p5 <- out.chg.anyprjcrime.stjob.fit[[4]]
p6 <- out.chg.anyprjcrime.stthft.fit[[4]]
p7 <- out.chg.anyprjcrime.stmug.fit[[4]]

playout <- '
AB
CD
E#
FG
'
p1 + p2 + p3 + p4 + p5 + p6 + p7 +
  plot_layout(design = playout) +
  plot_annotation(
  title = 'Coefficient plot',
  subtitle = 'Posterior distributions for monotonic ordinal within-person ("devx2") and between-person ("av12x2") stress\ncoefficients predicting "any criminal intent" with medians, 80% (thick line), and 95% (thin line) intervals')

6.2.2.8.3 PPcheck (density)
p1 <- out.chg.anyprjcrime.stmony.fit[[3]] + labs(title = "Any crime intent/stmony (T1)") 
p2 <- out.chg.anyprjcrime.sttran.fit[[3]] + labs(title = "Any crime intent/sttran (T1)")
p3 <- out.chg.anyprjcrime.stresp.fit[[3]] + labs(title = "Any crime intent/stresp (T1)")
p4 <- out.chg.anyprjcrime.stfair.fit[[3]] + labs(title = "Any crime intent/stfair (T1)")
p5 <- out.chg.anyprjcrime.stjob.fit[[3]] + labs(title = "Any crime intent/stjob (T1)")
p6 <- out.chg.anyprjcrime.stthft.fit[[3]] + labs(title = "Any crime intent/stthft (T1)")
p7 <- out.chg.anyprjcrime.stmug.fit[[3]] + labs(title = "Any crime intent/stmug (T1)")

(p1 + p2) / (p3 + p4) / (p5 + plot_spacer()) / (p6 + p7)

6.2.2.9 Fit + prior summaries (T1 Any past crime/all stress)

6.2.2.9.1 stmony
out.chg.anyprjcrime.stmony.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.62      0.46     2.81     4.60 1.00     1230     1798
## 
## Regression Coefficients:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept          -3.91      0.64    -5.23    -2.69 1.00     1931     2510
## mostmony_devx2      0.25      0.15    -0.04     0.54 1.00     5262     3052
## mostmony_av12x2    -0.04      0.08    -0.21     0.12 1.00     2404     3060
## 
## Monotonic Simplex Parameters:
##                     Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostmony_devx21[1]      0.22      0.13     0.03     0.53 1.00     6062     2461
## mostmony_devx21[2]      0.25      0.14     0.04     0.57 1.00     6032     2982
## mostmony_devx21[3]      0.29      0.15     0.05     0.60 1.00     4894     2551
## mostmony_devx21[4]      0.23      0.13     0.04     0.52 1.00     6290     2626
## mostmony_av12x21[1]     0.13      0.08     0.02     0.33 1.00     9162     3011
## mostmony_av12x21[2]     0.13      0.08     0.02     0.33 1.00     5332     2426
## mostmony_av12x21[3]     0.13      0.08     0.02     0.34 1.00     7006     2783
## mostmony_av12x21[4]     0.13      0.08     0.02     0.33 1.00     6077     2662
## mostmony_av12x21[5]     0.12      0.08     0.02     0.31 1.00     7429     2911
## mostmony_av12x21[6]     0.12      0.07     0.02     0.30 1.00     6271     2350
## mostmony_av12x21[7]     0.12      0.08     0.02     0.31 1.00     6668     2775
## mostmony_av12x21[8]     0.12      0.08     0.02     0.32 1.00     6828     2533
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stmony.fit[[2]]
##                              prior     class             coef group resp dpar
##                             (flat)         b                                 
##                   normal(0, 0.125)         b  mostmony_av12x2                
##                    normal(0, 0.25)         b   mostmony_devx2                
##                       normal(0, 2) Intercept                                 
##               student_t(3, 0, 2.5)        sd                                 
##               student_t(3, 0, 2.5)        sd                     id          
##               student_t(3, 0, 2.5)        sd        Intercept    id          
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21                
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21                
##  nlpar lb ub       source
##                   default
##                      user
##                      user
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)
##                      user
##                      user
6.2.2.9.2 sttran
out.chg.anyprjcrime.sttran.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.61      0.47     2.79     4.66 1.00     1280     2162
## 
## Regression Coefficients:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept          -3.38      0.63    -4.67    -2.20 1.00     2083     2711
## mosttran_devx2      0.06      0.15    -0.25     0.34 1.00     5009     2880
## mosttran_av12x2    -0.07      0.09    -0.24     0.09 1.00     2119     2980
## 
## Monotonic Simplex Parameters:
##                     Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mosttran_devx21[1]      0.25      0.15     0.04     0.57 1.00     6171     2362
## mosttran_devx21[2]      0.23      0.14     0.03     0.56 1.00     6690     2888
## mosttran_devx21[3]      0.24      0.14     0.03     0.56 1.00     5804     2771
## mosttran_devx21[4]      0.27      0.15     0.04     0.61 1.00     6831     3029
## mosttran_av12x21[1]     0.13      0.08     0.02     0.32 1.00     6438     2775
## mosttran_av12x21[2]     0.13      0.09     0.02     0.34 1.00     6587     2224
## mosttran_av12x21[3]     0.13      0.08     0.02     0.33 1.00     6766     2502
## mosttran_av12x21[4]     0.14      0.09     0.02     0.35 1.00     6507     2969
## mosttran_av12x21[5]     0.12      0.08     0.02     0.32 1.00     6963     2725
## mosttran_av12x21[6]     0.11      0.08     0.02     0.30 1.00     6634     2738
## mosttran_av12x21[7]     0.11      0.08     0.02     0.30 1.00     5505     2723
## mosttran_av12x21[8]     0.12      0.08     0.02     0.31 1.00     5915     2834
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.sttran.fit[[2]]
##                              prior     class             coef group resp dpar
##                             (flat)         b                                 
##                   normal(0, 0.125)         b  mosttran_av12x2                
##                    normal(0, 0.25)         b   mosttran_devx2                
##                       normal(0, 2) Intercept                                 
##               student_t(3, 0, 2.5)        sd                                 
##               student_t(3, 0, 2.5)        sd                     id          
##               student_t(3, 0, 2.5)        sd        Intercept    id          
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21                
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21                
##  nlpar lb ub       source
##                   default
##                      user
##                      user
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)
##                      user
##                      user
6.2.2.9.3 stresp
out.chg.anyprjcrime.stresp.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.38      0.44     2.59     4.30 1.00     1122     1614
## 
## Regression Coefficients:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept          -4.08      0.59    -5.24    -2.97 1.00     2325     2180
## mostresp_devx2     -0.18      0.15    -0.50     0.10 1.00     5429     3083
## mostresp_av12x2     0.20      0.07     0.06     0.34 1.00     2646     2991
## 
## Monotonic Simplex Parameters:
##                     Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostresp_devx21[1]      0.27      0.15     0.04     0.59 1.00     6606     3102
## mostresp_devx21[2]      0.23      0.13     0.04     0.55 1.00     6482     2639
## mostresp_devx21[3]      0.23      0.14     0.03     0.54 1.00     5957     2797
## mostresp_devx21[4]      0.27      0.15     0.04     0.60 1.00     5863     2570
## mostresp_av12x21[1]     0.12      0.08     0.02     0.31 1.00     7180     2583
## mostresp_av12x21[2]     0.11      0.07     0.02     0.28 1.00     6408     2687
## mostresp_av12x21[3]     0.12      0.08     0.01     0.31 1.00     5387     2141
## mostresp_av12x21[4]     0.13      0.08     0.02     0.32 1.00     6496     2799
## mostresp_av12x21[5]     0.12      0.08     0.02     0.30 1.00     6742     2956
## mostresp_av12x21[6]     0.14      0.09     0.02     0.35 1.00     5401     2322
## mostresp_av12x21[7]     0.13      0.08     0.02     0.33 1.00     6269     3041
## mostresp_av12x21[8]     0.12      0.08     0.02     0.30 1.00     6730     2850
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stresp.fit[[2]]
##                              prior     class             coef group resp dpar
##                             (flat)         b                                 
##                   normal(0, 0.125)         b  mostresp_av12x2                
##                    normal(0, 0.25)         b   mostresp_devx2                
##                       normal(0, 2) Intercept                                 
##               student_t(3, 0, 2.5)        sd                                 
##               student_t(3, 0, 2.5)        sd                     id          
##               student_t(3, 0, 2.5)        sd        Intercept    id          
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21                
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21                
##  nlpar lb ub       source
##                   default
##                      user
##                      user
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)
##                      user
##                      user
6.2.2.9.4 stfair
out.chg.anyprjcrime.stfair.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.31      0.43     2.56     4.23 1.00     1499     2499
## 
## Regression Coefficients:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept          -4.49      0.58    -5.68    -3.39 1.00     2452     2728
## mostfair_devx2      0.05      0.15    -0.25     0.35 1.00     4017     3082
## mostfair_av12x2     0.20      0.07     0.07     0.33 1.00     2374     3310
## 
## Monotonic Simplex Parameters:
##                     Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostfair_devx21[1]      0.26      0.15     0.04     0.59 1.00     6686     2114
## mostfair_devx21[2]      0.23      0.14     0.03     0.54 1.00     7239     2809
## mostfair_devx21[3]      0.25      0.14     0.04     0.58 1.00     6041     2338
## mostfair_devx21[4]      0.26      0.15     0.04     0.59 1.00     6829     2914
## mostfair_av12x21[1]     0.12      0.08     0.01     0.31 1.00     5428     2000
## mostfair_av12x21[2]     0.11      0.07     0.02     0.28 1.00     6006     2476
## mostfair_av12x21[3]     0.14      0.09     0.02     0.35 1.00     6149     2179
## mostfair_av12x21[4]     0.12      0.08     0.02     0.30 1.00     6815     3052
## mostfair_av12x21[5]     0.11      0.07     0.01     0.28 1.00     5981     2408
## mostfair_av12x21[6]     0.12      0.08     0.02     0.32 1.00     6755     2923
## mostfair_av12x21[7]     0.15      0.09     0.02     0.37 1.00     5995     2298
## mostfair_av12x21[8]     0.14      0.08     0.02     0.33 1.00     5131     2765
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stfair.fit[[2]]
##                              prior     class             coef group resp dpar
##                             (flat)         b                                 
##                   normal(0, 0.125)         b  mostfair_av12x2                
##                    normal(0, 0.25)         b   mostfair_devx2                
##                       normal(0, 2) Intercept                                 
##               student_t(3, 0, 2.5)        sd                                 
##               student_t(3, 0, 2.5)        sd                     id          
##               student_t(3, 0, 2.5)        sd        Intercept    id          
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21                
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21                
##  nlpar lb ub       source
##                   default
##                      user
##                      user
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)
##                      user
##                      user
6.2.2.9.5 stjob
out.chg.anyprjcrime.stjob.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.27      0.42     2.54     4.17 1.00     1317     2359
## 
## Regression Coefficients:
##                Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept         -4.56      0.58    -5.74    -3.48 1.00     2348     2826
## mostjob_devx2      0.09      0.15    -0.22     0.38 1.00     4901     2915
## mostjob_av12x2     0.22      0.07     0.09     0.35 1.00     2514     3053
## 
## Monotonic Simplex Parameters:
##                    Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostjob_devx21[1]      0.25      0.15     0.03     0.61 1.00     8130     2378
## mostjob_devx21[2]      0.26      0.15     0.04     0.60 1.00     6390     3118
## mostjob_devx21[3]      0.23      0.13     0.04     0.54 1.00     6188     3004
## mostjob_devx21[4]      0.26      0.15     0.04     0.58 1.00     7428     2668
## mostjob_av12x21[1]     0.09      0.06     0.01     0.24 1.00     6083     2484
## mostjob_av12x21[2]     0.10      0.06     0.01     0.25 1.00     5698     2557
## mostjob_av12x21[3]     0.10      0.07     0.01     0.26 1.00     5039     2129
## mostjob_av12x21[4]     0.11      0.07     0.01     0.28 1.00     6467     2550
## mostjob_av12x21[5]     0.12      0.08     0.02     0.32 1.00     7108     2817
## mostjob_av12x21[6]     0.18      0.10     0.03     0.41 1.00     5164     2797
## mostjob_av12x21[7]     0.17      0.10     0.02     0.40 1.00     5569     3029
## mostjob_av12x21[8]     0.14      0.09     0.02     0.34 1.00     6219     3433
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stjob.fit[[2]]
##                              prior     class            coef group resp dpar
##                             (flat)         b                                
##                   normal(0, 0.125)         b  mostjob_av12x2                
##                    normal(0, 0.25)         b   mostjob_devx2                
##                       normal(0, 2) Intercept                                
##               student_t(3, 0, 2.5)        sd                                
##               student_t(3, 0, 2.5)        sd                    id          
##               student_t(3, 0, 2.5)        sd       Intercept    id          
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21                
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21                
##  nlpar lb ub       source
##                   default
##                      user
##                      user
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)
##                      user
##                      user
6.2.2.9.6 stthft
out.chg.anyprjcrime.stthft.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.53      0.45     2.72     4.49 1.00     1248     2362
## 
## Regression Coefficients:
##                 Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept          -3.57      0.56    -4.70    -2.50 1.00     1976     2699
## mostthft_devx2     -0.12      0.16    -0.43     0.20 1.00     4146     2603
## mostthft_av12x2     0.11      0.08    -0.05     0.26 1.00     2636     2970
## 
## Monotonic Simplex Parameters:
##                     Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostthft_devx21[1]      0.27      0.15     0.04     0.61 1.00     5943     2444
## mostthft_devx21[2]      0.26      0.15     0.04     0.60 1.00     6152     2966
## mostthft_devx21[3]      0.22      0.14     0.03     0.54 1.00     6099     3020
## mostthft_devx21[4]      0.25      0.14     0.04     0.58 1.00     6237     3137
## mostthft_av12x21[1]     0.12      0.08     0.02     0.30 1.00     6027     2551
## mostthft_av12x21[2]     0.11      0.07     0.02     0.30 1.00     6806     2223
## mostthft_av12x21[3]     0.12      0.08     0.01     0.31 1.00     7291     2118
## mostthft_av12x21[4]     0.12      0.08     0.02     0.31 1.00     6822     3121
## mostthft_av12x21[5]     0.15      0.09     0.02     0.36 1.00     5315     2852
## mostthft_av12x21[6]     0.14      0.09     0.02     0.36 1.00     6619     2891
## mostthft_av12x21[7]     0.12      0.08     0.02     0.31 1.00     6267     2879
## mostthft_av12x21[8]     0.12      0.08     0.02     0.30 1.00     6758     2848
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stthft.fit[[2]]
##                              prior     class             coef group resp dpar
##                             (flat)         b                                 
##                   normal(0, 0.125)         b  mostthft_av12x2                
##                    normal(0, 0.25)         b   mostthft_devx2                
##                       normal(0, 2) Intercept                                 
##               student_t(3, 0, 2.5)        sd                                 
##               student_t(3, 0, 2.5)        sd                     id          
##               student_t(3, 0, 2.5)        sd        Intercept    id          
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21                
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21                
##  nlpar lb ub       source
##                   default
##                      user
##                      user
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)
##                      user
##                      user
6.2.2.9.7 stmug
out.chg.anyprjcrime.stmug.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.60      0.48     2.74     4.62 1.00     1433     2116
## 
## Regression Coefficients:
##                Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept         -3.60      0.56    -4.75    -2.56 1.00     2520     2786
## mostmug_devx2      0.01      0.17    -0.32     0.34 1.00     4899     3347
## mostmug_av12x2    -0.01      0.09    -0.18     0.15 1.00     3712     3327
## 
## Monotonic Simplex Parameters:
##                    Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## mostmug_devx21[1]      0.26      0.15     0.04     0.60 1.00     6920     2513
## mostmug_devx21[2]      0.24      0.14     0.03     0.58 1.00     6063     3018
## mostmug_devx21[3]      0.24      0.15     0.03     0.59 1.00     6151     2570
## mostmug_devx21[4]      0.26      0.15     0.04     0.59 1.00     5249     2911
## mostmug_av12x21[1]     0.12      0.08     0.02     0.30 1.00     6402     2308
## mostmug_av12x21[2]     0.12      0.08     0.02     0.32 1.00     6170     2446
## mostmug_av12x21[3]     0.12      0.08     0.02     0.32 1.00     8512     2433
## mostmug_av12x21[4]     0.12      0.08     0.02     0.32 1.00     5462     2351
## mostmug_av12x21[5]     0.13      0.08     0.02     0.33 1.00     7304     2386
## mostmug_av12x21[6]     0.13      0.08     0.02     0.32 1.00     7675     2600
## mostmug_av12x21[7]     0.13      0.08     0.02     0.32 1.00     6434     2780
## mostmug_av12x21[8]     0.13      0.08     0.02     0.31 1.00     6620     2630
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stmug.fit[[2]]
##                              prior     class            coef group resp dpar
##                             (flat)         b                                
##                   normal(0, 0.125)         b  mostmug_av12x2                
##                    normal(0, 0.25)         b   mostmug_devx2                
##                       normal(0, 2) Intercept                                
##               student_t(3, 0, 2.5)        sd                                
##               student_t(3, 0, 2.5)        sd                    id          
##               student_t(3, 0, 2.5)        sd       Intercept    id          
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21                
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21                
##  nlpar lb ub       source
##                   default
##                      user
##                      user
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)
##                      user
##                      user

6.2.3 Negative Emotions: Bivariate Change models

Let’s turn to multilevel models predicting negative emotions outcome probabilities.

6.2.3.1 B/W Change Corr: stmony/neg emotions

#Bivariate Change: negative emotions items ~ mo(stmony)
 
#Vectorize priors:

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmony_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostmony_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmony_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostmony_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stmony.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt, 
          depbetray) ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stmony_fit",
      file_refit = "on_change"
  )

##Update function to call all ppchecks for bivar depressive symptom chg models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="depcantgo")
  ppcheckdv2 <-pp_check(modelfit, resp="depeffort")
  ppcheckdv3 <-pp_check(modelfit, resp="deplonely")
  ppcheckdv4 <-pp_check(modelfit, resp="depblues")
  ppcheckdv5 <-pp_check(modelfit, resp="depunfair")
  ppcheckdv6 <-pp_check(modelfit, resp="depmistrt")
  ppcheckdv7 <-pp_check(modelfit, resp="depbetray")
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95) +
    labs(title = "Coefficient plot",
         subtitle = "Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, ppcheckdv3, 
                    ppcheckdv4, ppcheckdv5, ppcheckdv6, ppcheckdv7, 
                    plotcoefs, plotcoefs2)
  return(allchecks)
}

out.chg.alldepress.stmony.fit <- ppchecks(chg.alldepress.stmony.fit)
6.2.3.1.1 Coefficient plot (intervals)
out.chg.alldepress.stmony.fit[[11]]

6.2.3.1.2 Coefficient plot (distributions)
out.chg.alldepress.stmony.fit[[10]]

6.2.3.1.3 PPcheck (density)
p1 <- out.chg.alldepress.stmony.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.chg.alldepress.stmony.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.chg.alldepress.stmony.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.chg.alldepress.stmony.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.chg.alldepress.stmony.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.chg.alldepress.stmony.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.chg.alldepress.stmony.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

6.2.3.1.4 Fit summary
out.chg.alldepress.stmony.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          depeffort ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          deplonely ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          depblues ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          depunfair ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          depmistrt ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##          depbetray ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.30      0.19     0.01     0.70 1.01      642
## sd(depeffort_Intercept)     0.45      0.27     0.02     0.99 1.01      621
## sd(deplonely_Intercept)     0.43      0.24     0.03     0.89 1.01      584
## sd(depblues_Intercept)      0.67      0.31     0.06     1.24 1.02      368
## sd(depunfair_Intercept)     0.24      0.17     0.01     0.62 1.00      835
## sd(depmistrt_Intercept)     0.31      0.21     0.01     0.76 1.01      805
## sd(depbetray_Intercept)     0.43      0.26     0.02     0.96 1.01      528
##                         Tail_ESS
## sd(depcantgo_Intercept)     1458
## sd(depeffort_Intercept)     1281
## sd(deplonely_Intercept)     1186
## sd(depblues_Intercept)       616
## sd(depunfair_Intercept)     2150
## sd(depmistrt_Intercept)     1899
## sd(depbetray_Intercept)     1169
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_Intercept          -1.02      0.29    -1.67    -0.50 1.00     4177
## depeffort_Intercept          -2.03      0.36    -2.77    -1.36 1.00     2920
## deplonely_Intercept          -1.26      0.31    -1.91    -0.67 1.00     2988
## depblues_Intercept           -1.99      0.40    -2.78    -1.17 1.00     2672
## depunfair_Intercept          -1.92      0.29    -2.57    -1.41 1.00     4280
## depmistrt_Intercept          -2.30      0.33    -3.00    -1.70 1.00     3202
## depbetray_Intercept          -2.40      0.37    -3.18    -1.75 1.00     2819
## depcantgo_mostmony_devx2      0.22      0.11     0.03     0.46 1.00     4028
## depcantgo_mostmony_av12x2     0.05      0.03    -0.01     0.11 1.00     5901
## depeffort_mostmony_devx2      0.13      0.12    -0.11     0.37 1.00     3896
## depeffort_mostmony_av12x2     0.01      0.04    -0.07     0.09 1.00     4811
## deplonely_mostmony_devx2      0.13      0.11    -0.09     0.33 1.00     3136
## deplonely_mostmony_av12x2    -0.01      0.03    -0.08     0.05 1.00     6082
## depblues_mostmony_devx2      -0.12      0.13    -0.40     0.12 1.00     4534
## depblues_mostmony_av12x2      0.07      0.05    -0.02     0.16 1.00     5218
## depunfair_mostmony_devx2      0.28      0.09     0.11     0.46 1.00     5010
## depunfair_mostmony_av12x2     0.09      0.04     0.02     0.17 1.00     5391
## depmistrt_mostmony_devx2      0.14      0.12    -0.08     0.38 1.00     4107
## depmistrt_mostmony_av12x2     0.11      0.04     0.03     0.20 1.00     4979
## depbetray_mostmony_devx2      0.04      0.12    -0.19     0.29 1.00     4377
## depbetray_mostmony_av12x2     0.16      0.05     0.07     0.25 1.00     5089
##                           Tail_ESS
## depcantgo_Intercept           2990
## depeffort_Intercept           2710
## deplonely_Intercept           2777
## depblues_Intercept            2717
## depunfair_Intercept           3063
## depmistrt_Intercept           2743
## depbetray_Intercept           2147
## depcantgo_mostmony_devx2      3022
## depcantgo_mostmony_av12x2     3357
## depeffort_mostmony_devx2      2578
## depeffort_mostmony_av12x2     2923
## deplonely_mostmony_devx2      2583
## deplonely_mostmony_av12x2     2495
## depblues_mostmony_devx2       2939
## depblues_mostmony_av12x2      3024
## depunfair_mostmony_devx2      2699
## depunfair_mostmony_av12x2     3121
## depmistrt_mostmony_devx2      2897
## depmistrt_mostmony_av12x2     3365
## depbetray_mostmony_devx2      2807
## depbetray_mostmony_av12x2     2730
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## depcantgo_mostmony_devx21[1]      0.24      0.13     0.04     0.54 1.00
## depcantgo_mostmony_devx21[2]      0.27      0.14     0.05     0.57 1.00
## depcantgo_mostmony_devx21[3]      0.20      0.12     0.03     0.47 1.00
## depcantgo_mostmony_devx21[4]      0.29      0.15     0.04     0.61 1.00
## depcantgo_mostmony_av12x21[1]     0.13      0.08     0.02     0.32 1.00
## depcantgo_mostmony_av12x21[2]     0.13      0.08     0.02     0.32 1.00
## depcantgo_mostmony_av12x21[3]     0.13      0.08     0.02     0.31 1.00
## depcantgo_mostmony_av12x21[4]     0.14      0.09     0.02     0.35 1.00
## depcantgo_mostmony_av12x21[5]     0.12      0.08     0.02     0.30 1.00
## depcantgo_mostmony_av12x21[6]     0.12      0.08     0.02     0.30 1.00
## depcantgo_mostmony_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## depcantgo_mostmony_av12x21[8]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostmony_devx21[1]      0.25      0.15     0.03     0.58 1.00
## depeffort_mostmony_devx21[2]      0.27      0.14     0.05     0.59 1.00
## depeffort_mostmony_devx21[3]      0.22      0.13     0.03     0.53 1.00
## depeffort_mostmony_devx21[4]      0.26      0.15     0.04     0.59 1.00
## depeffort_mostmony_av12x21[1]     0.13      0.08     0.02     0.32 1.00
## depeffort_mostmony_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostmony_av12x21[3]     0.12      0.08     0.01     0.33 1.00
## depeffort_mostmony_av12x21[4]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostmony_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostmony_av12x21[6]     0.13      0.08     0.02     0.30 1.00
## depeffort_mostmony_av12x21[7]     0.13      0.08     0.02     0.32 1.00
## depeffort_mostmony_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## deplonely_mostmony_devx21[1]      0.24      0.14     0.03     0.54 1.00
## deplonely_mostmony_devx21[2]      0.34      0.16     0.06     0.66 1.00
## deplonely_mostmony_devx21[3]      0.20      0.12     0.03     0.49 1.00
## deplonely_mostmony_devx21[4]      0.23      0.14     0.03     0.54 1.00
## deplonely_mostmony_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## deplonely_mostmony_av12x21[2]     0.13      0.08     0.02     0.33 1.00
## deplonely_mostmony_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## deplonely_mostmony_av12x21[4]     0.12      0.08     0.02     0.30 1.00
## deplonely_mostmony_av12x21[5]     0.12      0.08     0.02     0.30 1.00
## deplonely_mostmony_av12x21[6]     0.12      0.08     0.02     0.32 1.00
## deplonely_mostmony_av12x21[7]     0.12      0.08     0.02     0.32 1.00
## deplonely_mostmony_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## depblues_mostmony_devx21[1]       0.28      0.16     0.04     0.62 1.00
## depblues_mostmony_devx21[2]       0.24      0.14     0.04     0.55 1.00
## depblues_mostmony_devx21[3]       0.22      0.13     0.03     0.52 1.00
## depblues_mostmony_devx21[4]       0.26      0.15     0.04     0.60 1.00
## depblues_mostmony_av12x21[1]      0.13      0.08     0.02     0.32 1.00
## depblues_mostmony_av12x21[2]      0.13      0.08     0.02     0.32 1.00
## depblues_mostmony_av12x21[3]      0.12      0.07     0.02     0.30 1.00
## depblues_mostmony_av12x21[4]      0.13      0.08     0.02     0.32 1.00
## depblues_mostmony_av12x21[5]      0.12      0.08     0.02     0.31 1.00
## depblues_mostmony_av12x21[6]      0.11      0.07     0.02     0.29 1.00
## depblues_mostmony_av12x21[7]      0.13      0.08     0.02     0.32 1.00
## depblues_mostmony_av12x21[8]      0.13      0.08     0.02     0.32 1.00
## depunfair_mostmony_devx21[1]      0.19      0.11     0.03     0.45 1.00
## depunfair_mostmony_devx21[2]      0.25      0.12     0.06     0.51 1.00
## depunfair_mostmony_devx21[3]      0.36      0.13     0.11     0.63 1.00
## depunfair_mostmony_devx21[4]      0.20      0.12     0.03     0.46 1.00
## depunfair_mostmony_av12x21[1]     0.13      0.08     0.02     0.32 1.00
## depunfair_mostmony_av12x21[2]     0.12      0.08     0.02     0.30 1.00
## depunfair_mostmony_av12x21[3]     0.10      0.07     0.01     0.26 1.00
## depunfair_mostmony_av12x21[4]     0.10      0.06     0.01     0.25 1.00
## depunfair_mostmony_av12x21[5]     0.13      0.08     0.01     0.32 1.00
## depunfair_mostmony_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## depunfair_mostmony_av12x21[7]     0.15      0.09     0.02     0.36 1.00
## depunfair_mostmony_av12x21[8]     0.16      0.09     0.02     0.37 1.00
## depmistrt_mostmony_devx21[1]      0.24      0.14     0.04     0.56 1.00
## depmistrt_mostmony_devx21[2]      0.20      0.12     0.03     0.49 1.00
## depmistrt_mostmony_devx21[3]      0.29      0.15     0.05     0.63 1.00
## depmistrt_mostmony_devx21[4]      0.26      0.15     0.04     0.58 1.00
## depmistrt_mostmony_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## depmistrt_mostmony_av12x21[2]     0.14      0.08     0.02     0.33 1.00
## depmistrt_mostmony_av12x21[3]     0.13      0.08     0.02     0.31 1.00
## depmistrt_mostmony_av12x21[4]     0.12      0.07     0.01     0.30 1.00
## depmistrt_mostmony_av12x21[5]     0.10      0.06     0.01     0.25 1.00
## depmistrt_mostmony_av12x21[6]     0.10      0.06     0.01     0.26 1.00
## depmistrt_mostmony_av12x21[7]     0.17      0.10     0.03     0.39 1.00
## depmistrt_mostmony_av12x21[8]     0.13      0.08     0.02     0.32 1.00
## depbetray_mostmony_devx21[1]      0.27      0.15     0.04     0.61 1.00
## depbetray_mostmony_devx21[2]      0.23      0.14     0.03     0.55 1.00
## depbetray_mostmony_devx21[3]      0.23      0.14     0.04     0.55 1.00
## depbetray_mostmony_devx21[4]      0.26      0.15     0.04     0.60 1.00
## depbetray_mostmony_av12x21[1]     0.12      0.08     0.02     0.31 1.00
## depbetray_mostmony_av12x21[2]     0.12      0.08     0.02     0.30 1.00
## depbetray_mostmony_av12x21[3]     0.11      0.07     0.02     0.27 1.00
## depbetray_mostmony_av12x21[4]     0.11      0.07     0.01     0.29 1.00
## depbetray_mostmony_av12x21[5]     0.11      0.07     0.01     0.28 1.00
## depbetray_mostmony_av12x21[6]     0.10      0.07     0.01     0.26 1.00
## depbetray_mostmony_av12x21[7]     0.17      0.09     0.03     0.37 1.00
## depbetray_mostmony_av12x21[8]     0.16      0.09     0.03     0.37 1.00
##                               Bulk_ESS Tail_ESS
## depcantgo_mostmony_devx21[1]      5830     2612
## depcantgo_mostmony_devx21[2]      5283     2276
## depcantgo_mostmony_devx21[3]      5743     3306
## depcantgo_mostmony_devx21[4]      5850     2822
## depcantgo_mostmony_av12x21[1]     6929     2558
## depcantgo_mostmony_av12x21[2]     7472     2694
## depcantgo_mostmony_av12x21[3]     6001     2638
## depcantgo_mostmony_av12x21[4]     7741     2425
## depcantgo_mostmony_av12x21[5]     7583     3047
## depcantgo_mostmony_av12x21[6]     7040     2754
## depcantgo_mostmony_av12x21[7]     7030     3053
## depcantgo_mostmony_av12x21[8]     6631     3167
## depeffort_mostmony_devx21[1]      6080     2365
## depeffort_mostmony_devx21[2]      5955     2903
## depeffort_mostmony_devx21[3]      6420     2608
## depeffort_mostmony_devx21[4]      7106     2659
## depeffort_mostmony_av12x21[1]     6800     2431
## depeffort_mostmony_av12x21[2]     6946     2690
## depeffort_mostmony_av12x21[3]     6067     2311
## depeffort_mostmony_av12x21[4]     7033     2497
## depeffort_mostmony_av12x21[5]     6778     2539
## depeffort_mostmony_av12x21[6]     7429     2742
## depeffort_mostmony_av12x21[7]     6090     2157
## depeffort_mostmony_av12x21[8]     6977     2537
## deplonely_mostmony_devx21[1]      6612     2811
## deplonely_mostmony_devx21[2]      4565     2365
## deplonely_mostmony_devx21[3]      5460     2897
## deplonely_mostmony_devx21[4]      5331     2540
## deplonely_mostmony_av12x21[1]     6945     2365
## deplonely_mostmony_av12x21[2]     6762     2401
## deplonely_mostmony_av12x21[3]     6349     2479
## deplonely_mostmony_av12x21[4]     7597     2694
## deplonely_mostmony_av12x21[5]     6035     2647
## deplonely_mostmony_av12x21[6]     5591     2637
## deplonely_mostmony_av12x21[7]     6822     2831
## deplonely_mostmony_av12x21[8]     7535     3132
## depblues_mostmony_devx21[1]       6245     3058
## depblues_mostmony_devx21[2]       6675     2873
## depblues_mostmony_devx21[3]       5461     2935
## depblues_mostmony_devx21[4]       7682     2837
## depblues_mostmony_av12x21[1]      6414     2255
## depblues_mostmony_av12x21[2]      7286     2249
## depblues_mostmony_av12x21[3]      7327     2643
## depblues_mostmony_av12x21[4]      8549     2522
## depblues_mostmony_av12x21[5]      6529     2361
## depblues_mostmony_av12x21[6]      6593     2659
## depblues_mostmony_av12x21[7]      6101     3154
## depblues_mostmony_av12x21[8]      5970     2309
## depunfair_mostmony_devx21[1]      6142     2666
## depunfair_mostmony_devx21[2]      5541     2222
## depunfair_mostmony_devx21[3]      5475     2423
## depunfair_mostmony_devx21[4]      6360     2689
## depunfair_mostmony_av12x21[1]     6089     2620
## depunfair_mostmony_av12x21[2]     7101     2523
## depunfair_mostmony_av12x21[3]     7539     2513
## depunfair_mostmony_av12x21[4]     6079     2500
## depunfair_mostmony_av12x21[5]     6381     2353
## depunfair_mostmony_av12x21[6]     7112     3049
## depunfair_mostmony_av12x21[7]     6364     2542
## depunfair_mostmony_av12x21[8]     5791     3248
## depmistrt_mostmony_devx21[1]      7349     2144
## depmistrt_mostmony_devx21[2]      6300     2590
## depmistrt_mostmony_devx21[3]      4910     2547
## depmistrt_mostmony_devx21[4]      6132     2672
## depmistrt_mostmony_av12x21[1]     6172     2443
## depmistrt_mostmony_av12x21[2]     6735     2443
## depmistrt_mostmony_av12x21[3]     6338     1979
## depmistrt_mostmony_av12x21[4]     8145     2608
## depmistrt_mostmony_av12x21[5]     6264     2857
## depmistrt_mostmony_av12x21[6]     6815     2858
## depmistrt_mostmony_av12x21[7]     6205     2589
## depmistrt_mostmony_av12x21[8]     6271     2980
## depbetray_mostmony_devx21[1]      5223     2382
## depbetray_mostmony_devx21[2]      7367     2948
## depbetray_mostmony_devx21[3]      7172     3109
## depbetray_mostmony_devx21[4]      6335     2795
## depbetray_mostmony_av12x21[1]     6276     2580
## depbetray_mostmony_av12x21[2]     6770     2468
## depbetray_mostmony_av12x21[3]     6337     2135
## depbetray_mostmony_av12x21[4]     6553     2566
## depbetray_mostmony_av12x21[5]     6043     2328
## depbetray_mostmony_av12x21[6]     7063     2583
## depbetray_mostmony_av12x21[7]     5995     2727
## depbetray_mostmony_av12x21[8]     6400     2703
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.3.1.5 Prior summary
out.chg.alldepress.stmony.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                        depbetray
##                   normal(0, 0.125)         b  mostmony_av12x2       depbetray
##                    normal(0, 0.25)         b   mostmony_devx2       depbetray
##                             (flat)         b                         depblues
##                   normal(0, 0.125)         b  mostmony_av12x2        depblues
##                    normal(0, 0.25)         b   mostmony_devx2        depblues
##                             (flat)         b                        depcantgo
##                   normal(0, 0.125)         b  mostmony_av12x2       depcantgo
##                    normal(0, 0.25)         b   mostmony_devx2       depcantgo
##                             (flat)         b                        depeffort
##                   normal(0, 0.125)         b  mostmony_av12x2       depeffort
##                    normal(0, 0.25)         b   mostmony_devx2       depeffort
##                             (flat)         b                        deplonely
##                   normal(0, 0.125)         b  mostmony_av12x2       deplonely
##                    normal(0, 0.25)         b   mostmony_devx2       deplonely
##                             (flat)         b                        depmistrt
##                   normal(0, 0.125)         b  mostmony_av12x2       depmistrt
##                    normal(0, 0.25)         b   mostmony_devx2       depmistrt
##                             (flat)         b                        depunfair
##                   normal(0, 0.125)         b  mostmony_av12x2       depunfair
##                    normal(0, 0.25)         b   mostmony_devx2       depunfair
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                        depbetray
##                       normal(0, 2) Intercept                         depblues
##                       normal(0, 2) Intercept                        depcantgo
##                       normal(0, 2) Intercept                        depeffort
##                       normal(0, 2) Intercept                        deplonely
##                       normal(0, 2) Intercept                        depmistrt
##                       normal(0, 2) Intercept                        depunfair
##               student_t(3, 0, 2.5)        sd                        depbetray
##               student_t(3, 0, 2.5)        sd                         depblues
##               student_t(3, 0, 2.5)        sd                        depcantgo
##               student_t(3, 0, 2.5)        sd                        depeffort
##               student_t(3, 0, 2.5)        sd                        deplonely
##               student_t(3, 0, 2.5)        sd                        depmistrt
##               student_t(3, 0, 2.5)        sd                        depunfair
##               student_t(3, 0, 2.5)        sd                     id depbetray
##               student_t(3, 0, 2.5)        sd        Intercept    id depbetray
##               student_t(3, 0, 2.5)        sd                     id  depblues
##               student_t(3, 0, 2.5)        sd        Intercept    id  depblues
##               student_t(3, 0, 2.5)        sd                     id depcantgo
##               student_t(3, 0, 2.5)        sd        Intercept    id depcantgo
##               student_t(3, 0, 2.5)        sd                     id depeffort
##               student_t(3, 0, 2.5)        sd        Intercept    id depeffort
##               student_t(3, 0, 2.5)        sd                     id deplonely
##               student_t(3, 0, 2.5)        sd        Intercept    id deplonely
##               student_t(3, 0, 2.5)        sd                     id depmistrt
##               student_t(3, 0, 2.5)        sd        Intercept    id depmistrt
##               student_t(3, 0, 2.5)        sd                     id depunfair
##               student_t(3, 0, 2.5)        sd        Intercept    id depunfair
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       depbetray
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       depbetray
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21        depblues
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21        depblues
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       depcantgo
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       depcantgo
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       depeffort
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       depeffort
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       deplonely
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       deplonely
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       depmistrt
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       depmistrt
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmony_av12x21       depunfair
##              dirichlet(2, 2, 2, 2)      simo  mostmony_devx21       depunfair
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.3.2 B/W Change Corr: sttran/neg emotions

#Bivariate Change: negative emotions items ~ mo(sttran)
 
#Vectorize priors:

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mosttran_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mosttran_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mosttran_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mosttran_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.sttran.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt, 
          depbetray) ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_sttran_fit",
      file_refit = "on_change"
  )

out.chg.alldepress.sttran.fit <- ppchecks(chg.alldepress.sttran.fit)
6.2.3.2.1 Coefficient plot (intervals)
out.chg.alldepress.sttran.fit[[11]]

6.2.3.2.2 Coefficient plot (distributions)
out.chg.alldepress.sttran.fit[[10]]

6.2.3.2.3 PPcheck (density)
p1 <- out.chg.alldepress.sttran.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.chg.alldepress.sttran.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.chg.alldepress.sttran.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.chg.alldepress.sttran.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.chg.alldepress.sttran.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.chg.alldepress.sttran.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.chg.alldepress.sttran.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

6.2.3.2.4 Fit summary
out.chg.alldepress.sttran.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          depeffort ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          deplonely ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          depblues ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          depunfair ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          depmistrt ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##          depbetray ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.30      0.19     0.02     0.69 1.00      527
## sd(depeffort_Intercept)     0.43      0.27     0.02     0.99 1.00      489
## sd(deplonely_Intercept)     0.41      0.24     0.03     0.89 1.00      457
## sd(depblues_Intercept)      0.65      0.31     0.07     1.24 1.01      482
## sd(depunfair_Intercept)     0.26      0.18     0.01     0.66 1.00      725
## sd(depmistrt_Intercept)     0.33      0.22     0.02     0.80 1.01      750
## sd(depbetray_Intercept)     0.51      0.28     0.03     1.06 1.01      447
##                         Tail_ESS
## sd(depcantgo_Intercept)     1010
## sd(depeffort_Intercept)      877
## sd(deplonely_Intercept)     1026
## sd(depblues_Intercept)      1230
## sd(depunfair_Intercept)     1385
## sd(depmistrt_Intercept)     1676
## sd(depbetray_Intercept)      593
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_Intercept          -0.95      0.27    -1.53    -0.44 1.00     2907
## depeffort_Intercept          -1.71      0.34    -2.39    -1.02 1.00     2760
## deplonely_Intercept          -1.17      0.27    -1.72    -0.64 1.00     3090
## depblues_Intercept           -2.01      0.38    -2.76    -1.28 1.00     2421
## depunfair_Intercept          -2.07      0.30    -2.71    -1.54 1.00     4069
## depmistrt_Intercept          -2.02      0.37    -2.76    -1.26 1.00     2503
## depbetray_Intercept          -2.08      0.35    -2.83    -1.40 1.00     3043
## depcantgo_mosttran_devx2      0.19      0.09     0.03     0.38 1.00     3802
## depcantgo_mosttran_av12x2     0.04      0.03    -0.02     0.11 1.00     4077
## depeffort_mosttran_devx2      0.03      0.12    -0.22     0.28 1.00     4203
## depeffort_mosttran_av12x2    -0.01      0.04    -0.10     0.07 1.00     4821
## deplonely_mosttran_devx2      0.13      0.10    -0.06     0.34 1.00     3260
## deplonely_mosttran_av12x2    -0.01      0.04    -0.09     0.06 1.00     5107
## depblues_mosttran_devx2      -0.12      0.13    -0.37     0.14 1.00     3871
## depblues_mosttran_av12x2      0.06      0.05    -0.03     0.16 1.00     4606
## depunfair_mosttran_devx2      0.32      0.09     0.16     0.50 1.00     5352
## depunfair_mosttran_av12x2     0.10      0.04     0.03     0.18 1.00     5161
## depmistrt_mosttran_devx2      0.06      0.13    -0.24     0.28 1.00     3065
## depmistrt_mosttran_av12x2     0.08      0.05    -0.01     0.19 1.00     3323
## depbetray_mosttran_devx2     -0.01      0.12    -0.25     0.23 1.00     4082
## depbetray_mosttran_av12x2     0.11      0.05     0.02     0.20 1.00     4865
##                           Tail_ESS
## depcantgo_Intercept           2709
## depeffort_Intercept           2706
## deplonely_Intercept           2308
## depblues_Intercept            2561
## depunfair_Intercept           2526
## depmistrt_Intercept           2140
## depbetray_Intercept           2647
## depcantgo_mosttran_devx2      2492
## depcantgo_mosttran_av12x2     3142
## depeffort_mosttran_devx2      2918
## depeffort_mosttran_av12x2     3097
## deplonely_mosttran_devx2      2408
## deplonely_mosttran_av12x2     2782
## depblues_mosttran_devx2       2696
## depblues_mosttran_av12x2      3061
## depunfair_mosttran_devx2      2749
## depunfair_mosttran_av12x2     3338
## depmistrt_mosttran_devx2      1906
## depmistrt_mosttran_av12x2     2402
## depbetray_mosttran_devx2      2665
## depbetray_mosttran_av12x2     2888
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## depcantgo_mosttran_devx21[1]      0.23      0.13     0.03     0.53 1.00
## depcantgo_mosttran_devx21[2]      0.30      0.14     0.07     0.59 1.00
## depcantgo_mosttran_devx21[3]      0.24      0.12     0.05     0.52 1.00
## depcantgo_mosttran_devx21[4]      0.23      0.13     0.03     0.51 1.00
## depcantgo_mosttran_av12x21[1]     0.12      0.08     0.02     0.30 1.00
## depcantgo_mosttran_av12x21[2]     0.13      0.08     0.02     0.32 1.00
## depcantgo_mosttran_av12x21[3]     0.11      0.07     0.01     0.29 1.00
## depcantgo_mosttran_av12x21[4]     0.12      0.07     0.02     0.29 1.00
## depcantgo_mosttran_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## depcantgo_mosttran_av12x21[6]     0.12      0.07     0.02     0.30 1.00
## depcantgo_mosttran_av12x21[7]     0.14      0.08     0.02     0.34 1.00
## depcantgo_mosttran_av12x21[8]     0.14      0.09     0.02     0.35 1.00
## depeffort_mosttran_devx21[1]      0.26      0.15     0.04     0.61 1.00
## depeffort_mosttran_devx21[2]      0.24      0.14     0.03     0.56 1.00
## depeffort_mosttran_devx21[3]      0.23      0.13     0.04     0.55 1.00
## depeffort_mosttran_devx21[4]      0.27      0.15     0.04     0.61 1.00
## depeffort_mosttran_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## depeffort_mosttran_av12x21[2]     0.13      0.08     0.02     0.33 1.00
## depeffort_mosttran_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## depeffort_mosttran_av12x21[4]     0.12      0.08     0.02     0.30 1.00
## depeffort_mosttran_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## depeffort_mosttran_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## depeffort_mosttran_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## depeffort_mosttran_av12x21[8]     0.13      0.08     0.02     0.32 1.00
## deplonely_mosttran_devx21[1]      0.22      0.13     0.03     0.52 1.00
## deplonely_mosttran_devx21[2]      0.21      0.12     0.03     0.51 1.00
## deplonely_mosttran_devx21[3]      0.31      0.15     0.06     0.62 1.00
## deplonely_mosttran_devx21[4]      0.26      0.15     0.04     0.59 1.00
## deplonely_mosttran_av12x21[1]     0.13      0.09     0.02     0.34 1.00
## deplonely_mosttran_av12x21[2]     0.13      0.08     0.02     0.33 1.00
## deplonely_mosttran_av12x21[3]     0.13      0.08     0.02     0.33 1.00
## deplonely_mosttran_av12x21[4]     0.12      0.08     0.01     0.32 1.00
## deplonely_mosttran_av12x21[5]     0.11      0.08     0.01     0.30 1.00
## deplonely_mosttran_av12x21[6]     0.12      0.08     0.02     0.30 1.00
## deplonely_mosttran_av12x21[7]     0.12      0.08     0.02     0.32 1.00
## deplonely_mosttran_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## depblues_mosttran_devx21[1]       0.25      0.14     0.04     0.57 1.00
## depblues_mosttran_devx21[2]       0.22      0.13     0.03     0.53 1.00
## depblues_mosttran_devx21[3]       0.27      0.15     0.04     0.59 1.00
## depblues_mosttran_devx21[4]       0.26      0.15     0.04     0.58 1.00
## depblues_mosttran_av12x21[1]      0.12      0.08     0.02     0.33 1.00
## depblues_mosttran_av12x21[2]      0.12      0.08     0.02     0.31 1.00
## depblues_mosttran_av12x21[3]      0.12      0.08     0.02     0.32 1.00
## depblues_mosttran_av12x21[4]      0.14      0.09     0.02     0.35 1.00
## depblues_mosttran_av12x21[5]      0.11      0.07     0.01     0.29 1.00
## depblues_mosttran_av12x21[6]      0.11      0.07     0.02     0.29 1.00
## depblues_mosttran_av12x21[7]      0.14      0.09     0.02     0.35 1.00
## depblues_mosttran_av12x21[8]      0.13      0.08     0.02     0.32 1.00
## depunfair_mosttran_devx21[1]      0.15      0.09     0.02     0.37 1.00
## depunfair_mosttran_devx21[2]      0.33      0.12     0.11     0.59 1.00
## depunfair_mosttran_devx21[3]      0.33      0.12     0.11     0.59 1.00
## depunfair_mosttran_devx21[4]      0.19      0.11     0.03     0.42 1.00
## depunfair_mosttran_av12x21[1]     0.12      0.07     0.02     0.29 1.00
## depunfair_mosttran_av12x21[2]     0.11      0.07     0.01     0.29 1.00
## depunfair_mosttran_av12x21[3]     0.10      0.07     0.01     0.26 1.00
## depunfair_mosttran_av12x21[4]     0.11      0.07     0.02     0.29 1.00
## depunfair_mosttran_av12x21[5]     0.11      0.07     0.01     0.28 1.00
## depunfair_mosttran_av12x21[6]     0.13      0.08     0.02     0.31 1.00
## depunfair_mosttran_av12x21[7]     0.19      0.10     0.03     0.42 1.00
## depunfair_mosttran_av12x21[8]     0.14      0.08     0.02     0.33 1.00
## depmistrt_mosttran_devx21[1]      0.25      0.15     0.04     0.59 1.00
## depmistrt_mosttran_devx21[2]      0.21      0.13     0.03     0.53 1.00
## depmistrt_mosttran_devx21[3]      0.28      0.16     0.03     0.63 1.00
## depmistrt_mosttran_devx21[4]      0.26      0.14     0.04     0.58 1.00
## depmistrt_mosttran_av12x21[1]     0.13      0.09     0.02     0.34 1.00
## depmistrt_mosttran_av12x21[2]     0.14      0.09     0.02     0.35 1.00
## depmistrt_mosttran_av12x21[3]     0.13      0.08     0.02     0.33 1.00
## depmistrt_mosttran_av12x21[4]     0.11      0.07     0.01     0.28 1.00
## depmistrt_mosttran_av12x21[5]     0.09      0.07     0.01     0.26 1.00
## depmistrt_mosttran_av12x21[6]     0.10      0.06     0.01     0.25 1.00
## depmistrt_mosttran_av12x21[7]     0.16      0.09     0.03     0.38 1.00
## depmistrt_mosttran_av12x21[8]     0.14      0.08     0.02     0.34 1.00
## depbetray_mosttran_devx21[1]      0.27      0.15     0.04     0.61 1.00
## depbetray_mosttran_devx21[2]      0.23      0.14     0.03     0.54 1.00
## depbetray_mosttran_devx21[3]      0.23      0.14     0.04     0.55 1.00
## depbetray_mosttran_devx21[4]      0.27      0.15     0.04     0.61 1.00
## depbetray_mosttran_av12x21[1]     0.12      0.08     0.02     0.31 1.00
## depbetray_mosttran_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## depbetray_mosttran_av12x21[3]     0.11      0.07     0.02     0.28 1.00
## depbetray_mosttran_av12x21[4]     0.11      0.07     0.02     0.28 1.00
## depbetray_mosttran_av12x21[5]     0.10      0.06     0.01     0.26 1.00
## depbetray_mosttran_av12x21[6]     0.12      0.08     0.01     0.31 1.00
## depbetray_mosttran_av12x21[7]     0.19      0.10     0.03     0.42 1.00
## depbetray_mosttran_av12x21[8]     0.12      0.08     0.02     0.30 1.00
##                               Bulk_ESS Tail_ESS
## depcantgo_mosttran_devx21[1]      5232     2617
## depcantgo_mosttran_devx21[2]      5435     2844
## depcantgo_mosttran_devx21[3]      5410     2450
## depcantgo_mosttran_devx21[4]      5019     2768
## depcantgo_mosttran_av12x21[1]     5139     2137
## depcantgo_mosttran_av12x21[2]     6179     2793
## depcantgo_mosttran_av12x21[3]     5838     2451
## depcantgo_mosttran_av12x21[4]     4829     2645
## depcantgo_mosttran_av12x21[5]     4588     2082
## depcantgo_mosttran_av12x21[6]     5025     2517
## depcantgo_mosttran_av12x21[7]     4937     2809
## depcantgo_mosttran_av12x21[8]     5957     2870
## depeffort_mosttran_devx21[1]      5698     2456
## depeffort_mosttran_devx21[2]      6194     2434
## depeffort_mosttran_devx21[3]      4834     2432
## depeffort_mosttran_devx21[4]      5496     3019
## depeffort_mosttran_av12x21[1]     5777     2150
## depeffort_mosttran_av12x21[2]     5915     2120
## depeffort_mosttran_av12x21[3]     5630     2455
## depeffort_mosttran_av12x21[4]     7066     2767
## depeffort_mosttran_av12x21[5]     5997     2567
## depeffort_mosttran_av12x21[6]     5753     2635
## depeffort_mosttran_av12x21[7]     4418     3055
## depeffort_mosttran_av12x21[8]     4813     2489
## deplonely_mosttran_devx21[1]      4709     2383
## deplonely_mosttran_devx21[2]      5659     2489
## deplonely_mosttran_devx21[3]      4155     3158
## deplonely_mosttran_devx21[4]      5610     2809
## deplonely_mosttran_av12x21[1]     5971     2342
## deplonely_mosttran_av12x21[2]     6369     2563
## deplonely_mosttran_av12x21[3]     5751     2241
## deplonely_mosttran_av12x21[4]     5909     2263
## deplonely_mosttran_av12x21[5]     6368     2791
## deplonely_mosttran_av12x21[6]     5194     2493
## deplonely_mosttran_av12x21[7]     5802     2587
## deplonely_mosttran_av12x21[8]     5551     2270
## depblues_mosttran_devx21[1]       6159     2869
## depblues_mosttran_devx21[2]       6282     2730
## depblues_mosttran_devx21[3]       5326     3242
## depblues_mosttran_devx21[4]       5801     2917
## depblues_mosttran_av12x21[1]      6239     2774
## depblues_mosttran_av12x21[2]      4920     2156
## depblues_mosttran_av12x21[3]      6817     2695
## depblues_mosttran_av12x21[4]      5458     2218
## depblues_mosttran_av12x21[5]      6492     2775
## depblues_mosttran_av12x21[6]      6696     2869
## depblues_mosttran_av12x21[7]      5975     2609
## depblues_mosttran_av12x21[8]      5342     2885
## depunfair_mosttran_devx21[1]      4707     2529
## depunfair_mosttran_devx21[2]      5635     2810
## depunfair_mosttran_devx21[3]      4498     3000
## depunfair_mosttran_devx21[4]      5773     2775
## depunfair_mosttran_av12x21[1]     6364     2815
## depunfair_mosttran_av12x21[2]     6376     2375
## depunfair_mosttran_av12x21[3]     5778     2006
## depunfair_mosttran_av12x21[4]     4997     2065
## depunfair_mosttran_av12x21[5]     6198     3113
## depunfair_mosttran_av12x21[6]     5917     2470
## depunfair_mosttran_av12x21[7]     4984     3122
## depunfair_mosttran_av12x21[8]     6010     2953
## depmistrt_mosttran_devx21[1]      3926     2557
## depmistrt_mosttran_devx21[2]      5924     3133
## depmistrt_mosttran_devx21[3]      3813     3086
## depmistrt_mosttran_devx21[4]      6593     3141
## depmistrt_mosttran_av12x21[1]     5248     2187
## depmistrt_mosttran_av12x21[2]     4635     2561
## depmistrt_mosttran_av12x21[3]     4725     2342
## depmistrt_mosttran_av12x21[4]     5597     2132
## depmistrt_mosttran_av12x21[5]     5717     2648
## depmistrt_mosttran_av12x21[6]     5037     2537
## depmistrt_mosttran_av12x21[7]     5619     2707
## depmistrt_mosttran_av12x21[8]     5719     3019
## depbetray_mosttran_devx21[1]      4902     2675
## depbetray_mosttran_devx21[2]      5544     2548
## depbetray_mosttran_devx21[3]      5461     2887
## depbetray_mosttran_devx21[4]      5430     2864
## depbetray_mosttran_av12x21[1]     5263     1923
## depbetray_mosttran_av12x21[2]     5292     2624
## depbetray_mosttran_av12x21[3]     5281     2815
## depbetray_mosttran_av12x21[4]     5873     2822
## depbetray_mosttran_av12x21[5]     5550     2539
## depbetray_mosttran_av12x21[6]     6182     2531
## depbetray_mosttran_av12x21[7]     6382     2661
## depbetray_mosttran_av12x21[8]     6448     2831
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.3.2.5 Prior summary
out.chg.alldepress.sttran.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                        depbetray
##                   normal(0, 0.125)         b  mosttran_av12x2       depbetray
##                    normal(0, 0.25)         b   mosttran_devx2       depbetray
##                             (flat)         b                         depblues
##                   normal(0, 0.125)         b  mosttran_av12x2        depblues
##                    normal(0, 0.25)         b   mosttran_devx2        depblues
##                             (flat)         b                        depcantgo
##                   normal(0, 0.125)         b  mosttran_av12x2       depcantgo
##                    normal(0, 0.25)         b   mosttran_devx2       depcantgo
##                             (flat)         b                        depeffort
##                   normal(0, 0.125)         b  mosttran_av12x2       depeffort
##                    normal(0, 0.25)         b   mosttran_devx2       depeffort
##                             (flat)         b                        deplonely
##                   normal(0, 0.125)         b  mosttran_av12x2       deplonely
##                    normal(0, 0.25)         b   mosttran_devx2       deplonely
##                             (flat)         b                        depmistrt
##                   normal(0, 0.125)         b  mosttran_av12x2       depmistrt
##                    normal(0, 0.25)         b   mosttran_devx2       depmistrt
##                             (flat)         b                        depunfair
##                   normal(0, 0.125)         b  mosttran_av12x2       depunfair
##                    normal(0, 0.25)         b   mosttran_devx2       depunfair
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                        depbetray
##                       normal(0, 2) Intercept                         depblues
##                       normal(0, 2) Intercept                        depcantgo
##                       normal(0, 2) Intercept                        depeffort
##                       normal(0, 2) Intercept                        deplonely
##                       normal(0, 2) Intercept                        depmistrt
##                       normal(0, 2) Intercept                        depunfair
##               student_t(3, 0, 2.5)        sd                        depbetray
##               student_t(3, 0, 2.5)        sd                         depblues
##               student_t(3, 0, 2.5)        sd                        depcantgo
##               student_t(3, 0, 2.5)        sd                        depeffort
##               student_t(3, 0, 2.5)        sd                        deplonely
##               student_t(3, 0, 2.5)        sd                        depmistrt
##               student_t(3, 0, 2.5)        sd                        depunfair
##               student_t(3, 0, 2.5)        sd                     id depbetray
##               student_t(3, 0, 2.5)        sd        Intercept    id depbetray
##               student_t(3, 0, 2.5)        sd                     id  depblues
##               student_t(3, 0, 2.5)        sd        Intercept    id  depblues
##               student_t(3, 0, 2.5)        sd                     id depcantgo
##               student_t(3, 0, 2.5)        sd        Intercept    id depcantgo
##               student_t(3, 0, 2.5)        sd                     id depeffort
##               student_t(3, 0, 2.5)        sd        Intercept    id depeffort
##               student_t(3, 0, 2.5)        sd                     id deplonely
##               student_t(3, 0, 2.5)        sd        Intercept    id deplonely
##               student_t(3, 0, 2.5)        sd                     id depmistrt
##               student_t(3, 0, 2.5)        sd        Intercept    id depmistrt
##               student_t(3, 0, 2.5)        sd                     id depunfair
##               student_t(3, 0, 2.5)        sd        Intercept    id depunfair
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       depbetray
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       depbetray
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21        depblues
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21        depblues
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       depcantgo
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       depcantgo
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       depeffort
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       depeffort
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       deplonely
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       deplonely
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       depmistrt
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       depmistrt
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mosttran_av12x21       depunfair
##              dirichlet(2, 2, 2, 2)      simo  mosttran_devx21       depunfair
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.3.3 B/W Change Corr: stresp/neg emotions

#Bivariate Change: negative emotions items ~ mo(stresp)
 
#Vectorize priors:

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostresp_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostresp_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostresp_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostresp_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stresp.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt, 
          depbetray) ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stresp_fit",
      file_refit = "on_change"
  )

out.chg.alldepress.stresp.fit <- ppchecks(chg.alldepress.stresp.fit)
6.2.3.3.1 Coefficient plot (intervals)
out.chg.alldepress.stresp.fit[[11]]

6.2.3.3.2 Coefficient plot (distributions)
out.chg.alldepress.stresp.fit[[10]]

6.2.3.3.3 PPcheck (density)
p1 <- out.chg.alldepress.stresp.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.chg.alldepress.stresp.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.chg.alldepress.stresp.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.chg.alldepress.stresp.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.chg.alldepress.stresp.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.chg.alldepress.stresp.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.chg.alldepress.stresp.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

6.2.3.3.4 Fit summary
out.chg.alldepress.stresp.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          depeffort ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          deplonely ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          depblues ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          depunfair ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          depmistrt ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##          depbetray ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.29      0.19     0.01     0.69 1.00      692
## sd(depeffort_Intercept)     0.44      0.26     0.03     0.98 1.01      642
## sd(deplonely_Intercept)     0.44      0.24     0.03     0.90 1.01      712
## sd(depblues_Intercept)      0.64      0.32     0.04     1.24 1.01      551
## sd(depunfair_Intercept)     0.25      0.17     0.01     0.65 1.00     1059
## sd(depmistrt_Intercept)     0.29      0.20     0.01     0.75 1.00      997
## sd(depbetray_Intercept)     0.48      0.27     0.03     1.01 1.00      692
##                         Tail_ESS
## sd(depcantgo_Intercept)     1541
## sd(depeffort_Intercept)     1226
## sd(deplonely_Intercept)     1247
## sd(depblues_Intercept)      1245
## sd(depunfair_Intercept)     1718
## sd(depmistrt_Intercept)     1612
## sd(depbetray_Intercept)     1585
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_Intercept          -0.39      0.24    -0.88     0.06 1.00     4518
## depeffort_Intercept          -2.23      0.34    -2.95    -1.63 1.00     3668
## deplonely_Intercept          -1.27      0.26    -1.80    -0.78 1.00     3703
## depblues_Intercept           -1.93      0.33    -2.56    -1.27 1.00     3054
## depunfair_Intercept          -1.80      0.25    -2.34    -1.35 1.00     5345
## depmistrt_Intercept          -2.36      0.31    -2.99    -1.76 1.00     4159
## depbetray_Intercept          -2.36      0.32    -3.01    -1.78 1.00     2997
## depcantgo_mostresp_devx2      0.09      0.09    -0.09     0.28 1.00     5519
## depcantgo_mostresp_av12x2    -0.03      0.03    -0.08     0.02 1.00     7236
## depeffort_mostresp_devx2      0.14      0.12    -0.08     0.39 1.00     5737
## depeffort_mostresp_av12x2     0.05      0.03    -0.01     0.12 1.00     7387
## deplonely_mostresp_devx2      0.08      0.10    -0.10     0.28 1.00     4922
## deplonely_mostresp_av12x2     0.02      0.03    -0.04     0.08 1.00     6063
## depblues_mostresp_devx2      -0.07      0.11    -0.29     0.15 1.00     5397
## depblues_mostresp_av12x2      0.03      0.04    -0.05     0.10 1.00     6779
## depunfair_mostresp_devx2      0.26      0.09     0.10     0.45 1.00     5632
## depunfair_mostresp_av12x2     0.06      0.03     0.01     0.12 1.00     7463
## depmistrt_mostresp_devx2      0.08      0.11    -0.14     0.31 1.00     4862
## depmistrt_mostresp_av12x2     0.13      0.03     0.07     0.20 1.00     7845
## depbetray_mostresp_devx2      0.08      0.11    -0.14     0.31 1.00     5818
## depbetray_mostresp_av12x2     0.12      0.03     0.05     0.18 1.00     5226
##                           Tail_ESS
## depcantgo_Intercept           3005
## depeffort_Intercept           2804
## deplonely_Intercept           3012
## depblues_Intercept            3115
## depunfair_Intercept           3063
## depmistrt_Intercept           3034
## depbetray_Intercept           2945
## depcantgo_mostresp_devx2      3195
## depcantgo_mostresp_av12x2     3235
## depeffort_mostresp_devx2      3054
## depeffort_mostresp_av12x2     3537
## deplonely_mostresp_devx2      3013
## deplonely_mostresp_av12x2     3149
## depblues_mostresp_devx2       2984
## depblues_mostresp_av12x2      3237
## depunfair_mostresp_devx2      2973
## depunfair_mostresp_av12x2     2447
## depmistrt_mostresp_devx2      2932
## depmistrt_mostresp_av12x2     3121
## depbetray_mostresp_devx2      2948
## depbetray_mostresp_av12x2     2800
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## depcantgo_mostresp_devx21[1]      0.27      0.15     0.04     0.59 1.00
## depcantgo_mostresp_devx21[2]      0.20      0.13     0.03     0.51 1.00
## depcantgo_mostresp_devx21[3]      0.28      0.15     0.04     0.60 1.00
## depcantgo_mostresp_devx21[4]      0.26      0.14     0.04     0.58 1.00
## depcantgo_mostresp_av12x21[1]     0.13      0.08     0.02     0.34 1.00
## depcantgo_mostresp_av12x21[2]     0.13      0.08     0.02     0.33 1.00
## depcantgo_mostresp_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## depcantgo_mostresp_av12x21[4]     0.12      0.08     0.01     0.30 1.00
## depcantgo_mostresp_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## depcantgo_mostresp_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## depcantgo_mostresp_av12x21[7]     0.12      0.08     0.02     0.31 1.00
## depcantgo_mostresp_av12x21[8]     0.15      0.09     0.02     0.36 1.00
## depeffort_mostresp_devx21[1]      0.27      0.15     0.04     0.58 1.00
## depeffort_mostresp_devx21[2]      0.26      0.15     0.04     0.58 1.00
## depeffort_mostresp_devx21[3]      0.20      0.12     0.03     0.49 1.00
## depeffort_mostresp_devx21[4]      0.27      0.15     0.04     0.59 1.00
## depeffort_mostresp_av12x21[1]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostresp_av12x21[2]     0.13      0.08     0.02     0.34 1.00
## depeffort_mostresp_av12x21[3]     0.12      0.08     0.02     0.30 1.00
## depeffort_mostresp_av12x21[4]     0.11      0.07     0.01     0.29 1.00
## depeffort_mostresp_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostresp_av12x21[6]     0.13      0.08     0.02     0.32 1.00
## depeffort_mostresp_av12x21[7]     0.13      0.08     0.02     0.33 1.00
## depeffort_mostresp_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## deplonely_mostresp_devx21[1]      0.25      0.14     0.04     0.58 1.00
## deplonely_mostresp_devx21[2]      0.23      0.14     0.03     0.55 1.00
## deplonely_mostresp_devx21[3]      0.25      0.14     0.04     0.55 1.00
## deplonely_mostresp_devx21[4]      0.27      0.15     0.04     0.62 1.00
## deplonely_mostresp_av12x21[1]     0.13      0.09     0.02     0.35 1.00
## deplonely_mostresp_av12x21[2]     0.14      0.09     0.02     0.35 1.00
## deplonely_mostresp_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## deplonely_mostresp_av12x21[4]     0.12      0.08     0.02     0.32 1.00
## deplonely_mostresp_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## deplonely_mostresp_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## deplonely_mostresp_av12x21[7]     0.12      0.08     0.02     0.32 1.00
## deplonely_mostresp_av12x21[8]     0.12      0.08     0.02     0.31 1.00
## depblues_mostresp_devx21[1]       0.27      0.15     0.04     0.59 1.00
## depblues_mostresp_devx21[2]       0.24      0.14     0.04     0.56 1.00
## depblues_mostresp_devx21[3]       0.23      0.14     0.03     0.55 1.00
## depblues_mostresp_devx21[4]       0.26      0.15     0.04     0.57 1.00
## depblues_mostresp_av12x21[1]      0.12      0.08     0.02     0.31 1.00
## depblues_mostresp_av12x21[2]      0.12      0.07     0.02     0.30 1.00
## depblues_mostresp_av12x21[3]      0.12      0.08     0.02     0.31 1.00
## depblues_mostresp_av12x21[4]      0.12      0.08     0.02     0.30 1.00
## depblues_mostresp_av12x21[5]      0.12      0.08     0.02     0.32 1.00
## depblues_mostresp_av12x21[6]      0.14      0.09     0.02     0.35 1.00
## depblues_mostresp_av12x21[7]      0.14      0.09     0.02     0.35 1.00
## depblues_mostresp_av12x21[8]      0.12      0.08     0.02     0.31 1.00
## depunfair_mostresp_devx21[1]      0.17      0.10     0.02     0.42 1.00
## depunfair_mostresp_devx21[2]      0.27      0.12     0.07     0.54 1.00
## depunfair_mostresp_devx21[3]      0.31      0.13     0.08     0.59 1.00
## depunfair_mostresp_devx21[4]      0.25      0.13     0.04     0.53 1.00
## depunfair_mostresp_av12x21[1]     0.11      0.07     0.01     0.28 1.00
## depunfair_mostresp_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## depunfair_mostresp_av12x21[3]     0.13      0.08     0.02     0.32 1.00
## depunfair_mostresp_av12x21[4]     0.11      0.07     0.02     0.29 1.00
## depunfair_mostresp_av12x21[5]     0.12      0.08     0.02     0.30 1.00
## depunfair_mostresp_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## depunfair_mostresp_av12x21[7]     0.15      0.09     0.02     0.36 1.00
## depunfair_mostresp_av12x21[8]     0.15      0.09     0.02     0.37 1.00
## depmistrt_mostresp_devx21[1]      0.24      0.15     0.03     0.59 1.00
## depmistrt_mostresp_devx21[2]      0.25      0.14     0.04     0.57 1.00
## depmistrt_mostresp_devx21[3]      0.22      0.13     0.03     0.54 1.00
## depmistrt_mostresp_devx21[4]      0.29      0.16     0.05     0.63 1.00
## depmistrt_mostresp_av12x21[1]     0.09      0.06     0.01     0.23 1.00
## depmistrt_mostresp_av12x21[2]     0.11      0.07     0.02     0.27 1.00
## depmistrt_mostresp_av12x21[3]     0.13      0.08     0.02     0.33 1.00
## depmistrt_mostresp_av12x21[4]     0.14      0.08     0.02     0.33 1.00
## depmistrt_mostresp_av12x21[5]     0.12      0.07     0.02     0.30 1.00
## depmistrt_mostresp_av12x21[6]     0.14      0.08     0.02     0.33 1.00
## depmistrt_mostresp_av12x21[7]     0.13      0.08     0.02     0.32 1.01
## depmistrt_mostresp_av12x21[8]     0.13      0.08     0.02     0.31 1.00
## depbetray_mostresp_devx21[1]      0.25      0.14     0.04     0.58 1.00
## depbetray_mostresp_devx21[2]      0.23      0.13     0.04     0.55 1.00
## depbetray_mostresp_devx21[3]      0.24      0.14     0.04     0.57 1.00
## depbetray_mostresp_devx21[4]      0.27      0.15     0.04     0.59 1.00
## depbetray_mostresp_av12x21[1]     0.10      0.07     0.01     0.27 1.00
## depbetray_mostresp_av12x21[2]     0.12      0.08     0.02     0.30 1.00
## depbetray_mostresp_av12x21[3]     0.13      0.08     0.02     0.31 1.00
## depbetray_mostresp_av12x21[4]     0.13      0.08     0.02     0.33 1.00
## depbetray_mostresp_av12x21[5]     0.13      0.08     0.02     0.33 1.00
## depbetray_mostresp_av12x21[6]     0.15      0.09     0.02     0.36 1.00
## depbetray_mostresp_av12x21[7]     0.13      0.08     0.02     0.33 1.00
## depbetray_mostresp_av12x21[8]     0.11      0.07     0.02     0.26 1.00
##                               Bulk_ESS Tail_ESS
## depcantgo_mostresp_devx21[1]      7244     2643
## depcantgo_mostresp_devx21[2]      5592     2978
## depcantgo_mostresp_devx21[3]      5629     2740
## depcantgo_mostresp_devx21[4]      9155     2984
## depcantgo_mostresp_av12x21[1]     7386     2524
## depcantgo_mostresp_av12x21[2]     8162     2744
## depcantgo_mostresp_av12x21[3]     8931     2320
## depcantgo_mostresp_av12x21[4]     8424     2156
## depcantgo_mostresp_av12x21[5]     6934     2731
## depcantgo_mostresp_av12x21[6]     7535     2657
## depcantgo_mostresp_av12x21[7]     6897     2768
## depcantgo_mostresp_av12x21[8]     6650     2881
## depeffort_mostresp_devx21[1]      8200     3270
## depeffort_mostresp_devx21[2]      7830     2409
## depeffort_mostresp_devx21[3]      6230     3143
## depeffort_mostresp_devx21[4]      7949     2874
## depeffort_mostresp_av12x21[1]     7837     2338
## depeffort_mostresp_av12x21[2]     7429     2944
## depeffort_mostresp_av12x21[3]     7276     2464
## depeffort_mostresp_av12x21[4]     8220     2763
## depeffort_mostresp_av12x21[5]     7848     2198
## depeffort_mostresp_av12x21[6]     8076     2512
## depeffort_mostresp_av12x21[7]     7286     2588
## depeffort_mostresp_av12x21[8]     8570     2493
## deplonely_mostresp_devx21[1]      7492     2622
## deplonely_mostresp_devx21[2]      8151     2692
## deplonely_mostresp_devx21[3]      6436     2842
## deplonely_mostresp_devx21[4]      7924     2680
## deplonely_mostresp_av12x21[1]     8344     2547
## deplonely_mostresp_av12x21[2]     7419     2594
## deplonely_mostresp_av12x21[3]     8285     2746
## deplonely_mostresp_av12x21[4]     6968     2519
## deplonely_mostresp_av12x21[5]     7972     2811
## deplonely_mostresp_av12x21[6]     7909     2795
## deplonely_mostresp_av12x21[7]     7051     2780
## deplonely_mostresp_av12x21[8]     7729     3349
## depblues_mostresp_devx21[1]       8573     2946
## depblues_mostresp_devx21[2]       7187     2340
## depblues_mostresp_devx21[3]       6958     1959
## depblues_mostresp_devx21[4]       8648     2592
## depblues_mostresp_av12x21[1]      7989     2796
## depblues_mostresp_av12x21[2]      6649     2605
## depblues_mostresp_av12x21[3]      8207     2507
## depblues_mostresp_av12x21[4]      6368     2925
## depblues_mostresp_av12x21[5]     10582     2699
## depblues_mostresp_av12x21[6]      6858     2926
## depblues_mostresp_av12x21[7]      6275     2897
## depblues_mostresp_av12x21[8]      7314     2983
## depunfair_mostresp_devx21[1]      7074     3007
## depunfair_mostresp_devx21[2]      7495     2584
## depunfair_mostresp_devx21[3]      5020     2648
## depunfair_mostresp_devx21[4]      8394     2944
## depunfair_mostresp_av12x21[1]     7372     2500
## depunfair_mostresp_av12x21[2]     7693     2351
## depunfair_mostresp_av12x21[3]     8154     2494
## depunfair_mostresp_av12x21[4]     7421     2376
## depunfair_mostresp_av12x21[5]     8076     2521
## depunfair_mostresp_av12x21[6]     8363     2796
## depunfair_mostresp_av12x21[7]     8753     2803
## depunfair_mostresp_av12x21[8]     7990     3020
## depmistrt_mostresp_devx21[1]      7088     2834
## depmistrt_mostresp_devx21[2]      9020     3096
## depmistrt_mostresp_devx21[3]      8419     3182
## depmistrt_mostresp_devx21[4]      7419     3123
## depmistrt_mostresp_av12x21[1]     6271     2672
## depmistrt_mostresp_av12x21[2]     6543     2007
## depmistrt_mostresp_av12x21[3]     7032     2476
## depmistrt_mostresp_av12x21[4]     6772     2758
## depmistrt_mostresp_av12x21[5]     7443     2502
## depmistrt_mostresp_av12x21[6]     8117     2574
## depmistrt_mostresp_av12x21[7]     7909     2709
## depmistrt_mostresp_av12x21[8]     8319     3221
## depbetray_mostresp_devx21[1]      6831     2583
## depbetray_mostresp_devx21[2]      6864     2814
## depbetray_mostresp_devx21[3]      7073     2616
## depbetray_mostresp_devx21[4]      7881     3052
## depbetray_mostresp_av12x21[1]     7162     2694
## depbetray_mostresp_av12x21[2]     8199     2808
## depbetray_mostresp_av12x21[3]     7159     2572
## depbetray_mostresp_av12x21[4]     7518     2802
## depbetray_mostresp_av12x21[5]     7210     2500
## depbetray_mostresp_av12x21[6]     7466     2491
## depbetray_mostresp_av12x21[7]     7510     2769
## depbetray_mostresp_av12x21[8]     7212     3005
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.3.3.5 Prior summary
out.chg.alldepress.stresp.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                        depbetray
##                   normal(0, 0.125)         b  mostresp_av12x2       depbetray
##                    normal(0, 0.25)         b   mostresp_devx2       depbetray
##                             (flat)         b                         depblues
##                   normal(0, 0.125)         b  mostresp_av12x2        depblues
##                    normal(0, 0.25)         b   mostresp_devx2        depblues
##                             (flat)         b                        depcantgo
##                   normal(0, 0.125)         b  mostresp_av12x2       depcantgo
##                    normal(0, 0.25)         b   mostresp_devx2       depcantgo
##                             (flat)         b                        depeffort
##                   normal(0, 0.125)         b  mostresp_av12x2       depeffort
##                    normal(0, 0.25)         b   mostresp_devx2       depeffort
##                             (flat)         b                        deplonely
##                   normal(0, 0.125)         b  mostresp_av12x2       deplonely
##                    normal(0, 0.25)         b   mostresp_devx2       deplonely
##                             (flat)         b                        depmistrt
##                   normal(0, 0.125)         b  mostresp_av12x2       depmistrt
##                    normal(0, 0.25)         b   mostresp_devx2       depmistrt
##                             (flat)         b                        depunfair
##                   normal(0, 0.125)         b  mostresp_av12x2       depunfair
##                    normal(0, 0.25)         b   mostresp_devx2       depunfair
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                        depbetray
##                       normal(0, 2) Intercept                         depblues
##                       normal(0, 2) Intercept                        depcantgo
##                       normal(0, 2) Intercept                        depeffort
##                       normal(0, 2) Intercept                        deplonely
##                       normal(0, 2) Intercept                        depmistrt
##                       normal(0, 2) Intercept                        depunfair
##               student_t(3, 0, 2.5)        sd                        depbetray
##               student_t(3, 0, 2.5)        sd                         depblues
##               student_t(3, 0, 2.5)        sd                        depcantgo
##               student_t(3, 0, 2.5)        sd                        depeffort
##               student_t(3, 0, 2.5)        sd                        deplonely
##               student_t(3, 0, 2.5)        sd                        depmistrt
##               student_t(3, 0, 2.5)        sd                        depunfair
##               student_t(3, 0, 2.5)        sd                     id depbetray
##               student_t(3, 0, 2.5)        sd        Intercept    id depbetray
##               student_t(3, 0, 2.5)        sd                     id  depblues
##               student_t(3, 0, 2.5)        sd        Intercept    id  depblues
##               student_t(3, 0, 2.5)        sd                     id depcantgo
##               student_t(3, 0, 2.5)        sd        Intercept    id depcantgo
##               student_t(3, 0, 2.5)        sd                     id depeffort
##               student_t(3, 0, 2.5)        sd        Intercept    id depeffort
##               student_t(3, 0, 2.5)        sd                     id deplonely
##               student_t(3, 0, 2.5)        sd        Intercept    id deplonely
##               student_t(3, 0, 2.5)        sd                     id depmistrt
##               student_t(3, 0, 2.5)        sd        Intercept    id depmistrt
##               student_t(3, 0, 2.5)        sd                     id depunfair
##               student_t(3, 0, 2.5)        sd        Intercept    id depunfair
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       depbetray
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       depbetray
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21        depblues
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21        depblues
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       depcantgo
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       depcantgo
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       depeffort
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       depeffort
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       deplonely
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       deplonely
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       depmistrt
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       depmistrt
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostresp_av12x21       depunfair
##              dirichlet(2, 2, 2, 2)      simo  mostresp_devx21       depunfair
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.3.4 B/W Change Corr: stfair/neg emotions

#Bivariate Change: negative emotions items ~ mo(stfair)
 
#Vectorize priors:

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostfair_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostfair_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostfair_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostfair_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stfair.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt, 
          depbetray) ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stfair_fit",
      file_refit = "on_change"
  )

out.chg.alldepress.stfair.fit <- ppchecks(chg.alldepress.stfair.fit)
6.2.3.4.1 Coefficient plot (intervals)
out.chg.alldepress.stfair.fit[[11]]

6.2.3.4.2 Coefficient plot (distributions)
out.chg.alldepress.stfair.fit[[10]]

6.2.3.4.3 PPcheck (density)
p1 <- out.chg.alldepress.stfair.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.chg.alldepress.stfair.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.chg.alldepress.stfair.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.chg.alldepress.stfair.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.chg.alldepress.stfair.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.chg.alldepress.stfair.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.chg.alldepress.stfair.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

6.2.3.4.4 Fit summary
out.chg.alldepress.stfair.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          depeffort ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          deplonely ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          depblues ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          depunfair ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          depmistrt ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##          depbetray ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.29      0.18     0.01     0.68 1.00      695
## sd(depeffort_Intercept)     0.45      0.26     0.03     0.98 1.00      721
## sd(deplonely_Intercept)     0.42      0.24     0.02     0.88 1.01      608
## sd(depblues_Intercept)      0.63      0.33     0.04     1.26 1.00      554
## sd(depunfair_Intercept)     0.25      0.17     0.01     0.64 1.01      956
## sd(depmistrt_Intercept)     0.29      0.21     0.01     0.75 1.00     1006
## sd(depbetray_Intercept)     0.45      0.26     0.02     0.99 1.01      534
##                         Tail_ESS
## sd(depcantgo_Intercept)     1732
## sd(depeffort_Intercept)     1726
## sd(deplonely_Intercept)     1695
## sd(depblues_Intercept)      1081
## sd(depunfair_Intercept)     1821
## sd(depmistrt_Intercept)     1627
## sd(depbetray_Intercept)     1081
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_Intercept          -0.65      0.27    -1.23    -0.17 1.00     5275
## depeffort_Intercept          -2.45      0.36    -3.20    -1.79 1.00     3995
## deplonely_Intercept          -1.27      0.30    -1.95    -0.74 1.00     3939
## depblues_Intercept           -2.18      0.36    -2.94    -1.50 1.00     2707
## depunfair_Intercept          -1.80      0.27    -2.38    -1.30 1.00     5264
## depmistrt_Intercept          -2.54      0.33    -3.24    -1.96 1.00     4419
## depbetray_Intercept          -2.68      0.39    -3.53    -1.98 1.00     3318
## depcantgo_mostfair_devx2      0.18      0.11    -0.02     0.42 1.00     5477
## depcantgo_mostfair_av12x2    -0.01      0.02    -0.06     0.03 1.00     9028
## depeffort_mostfair_devx2      0.24      0.12     0.02     0.50 1.00     4958
## depeffort_mostfair_av12x2     0.05      0.03    -0.02     0.11 1.00     8344
## deplonely_mostfair_devx2      0.10      0.11    -0.11     0.35 1.00     4495
## deplonely_mostfair_av12x2     0.01      0.03    -0.04     0.07 1.00     8350
## depblues_mostfair_devx2       0.03      0.13    -0.24     0.28 1.00     5721
## depblues_mostfair_av12x2      0.03      0.04    -0.04     0.11 1.00     6796
## depunfair_mostfair_devx2      0.27      0.10     0.09     0.49 1.00     6317
## depunfair_mostfair_av12x2     0.05      0.03    -0.00     0.10 1.00     8140
## depmistrt_mostfair_devx2      0.15      0.11    -0.08     0.38 1.00     5272
## depmistrt_mostfair_av12x2     0.14      0.03     0.07     0.20 1.00     5338
## depbetray_mostfair_devx2      0.17      0.13    -0.07     0.43 1.00     4654
## depbetray_mostfair_av12x2     0.13      0.03     0.07     0.20 1.00     7185
##                           Tail_ESS
## depcantgo_Intercept           3262
## depeffort_Intercept           2935
## deplonely_Intercept           2637
## depblues_Intercept            2844
## depunfair_Intercept           2959
## depmistrt_Intercept           3005
## depbetray_Intercept           2864
## depcantgo_mostfair_devx2      3327
## depcantgo_mostfair_av12x2     2943
## depeffort_mostfair_devx2      3039
## depeffort_mostfair_av12x2     3042
## deplonely_mostfair_devx2      2999
## deplonely_mostfair_av12x2     3207
## depblues_mostfair_devx2       3059
## depblues_mostfair_av12x2      3012
## depunfair_mostfair_devx2      3018
## depunfair_mostfair_av12x2     3048
## depmistrt_mostfair_devx2      2807
## depmistrt_mostfair_av12x2     2816
## depbetray_mostfair_devx2      3231
## depbetray_mostfair_av12x2     3518
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## depcantgo_mostfair_devx21[1]      0.27      0.15     0.04     0.59 1.00
## depcantgo_mostfair_devx21[2]      0.26      0.14     0.05     0.56 1.00
## depcantgo_mostfair_devx21[3]      0.19      0.12     0.03     0.49 1.00
## depcantgo_mostfair_devx21[4]      0.28      0.15     0.04     0.62 1.00
## depcantgo_mostfair_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## depcantgo_mostfair_av12x21[2]     0.13      0.08     0.02     0.33 1.00
## depcantgo_mostfair_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## depcantgo_mostfair_av12x21[4]     0.12      0.08     0.02     0.32 1.00
## depcantgo_mostfair_av12x21[5]     0.12      0.08     0.02     0.32 1.00
## depcantgo_mostfair_av12x21[6]     0.12      0.08     0.02     0.31 1.00
## depcantgo_mostfair_av12x21[7]     0.13      0.08     0.02     0.31 1.00
## depcantgo_mostfair_av12x21[8]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostfair_devx21[1]      0.22      0.13     0.03     0.52 1.00
## depeffort_mostfair_devx21[2]      0.34      0.14     0.09     0.64 1.00
## depeffort_mostfair_devx21[3]      0.18      0.11     0.02     0.46 1.00
## depeffort_mostfair_devx21[4]      0.26      0.14     0.04     0.56 1.00
## depeffort_mostfair_av12x21[1]     0.13      0.08     0.02     0.32 1.00
## depeffort_mostfair_av12x21[2]     0.13      0.09     0.02     0.34 1.00
## depeffort_mostfair_av12x21[3]     0.13      0.08     0.02     0.32 1.00
## depeffort_mostfair_av12x21[4]     0.12      0.08     0.02     0.32 1.00
## depeffort_mostfair_av12x21[5]     0.11      0.07     0.02     0.30 1.00
## depeffort_mostfair_av12x21[6]     0.12      0.08     0.02     0.30 1.00
## depeffort_mostfair_av12x21[7]     0.12      0.08     0.02     0.32 1.00
## depeffort_mostfair_av12x21[8]     0.14      0.09     0.02     0.35 1.00
## deplonely_mostfair_devx21[1]      0.28      0.15     0.04     0.62 1.00
## deplonely_mostfair_devx21[2]      0.21      0.13     0.03     0.50 1.00
## deplonely_mostfair_devx21[3]      0.24      0.14     0.04     0.56 1.00
## deplonely_mostfair_devx21[4]      0.28      0.15     0.05     0.60 1.00
## deplonely_mostfair_av12x21[1]     0.13      0.08     0.02     0.34 1.00
## deplonely_mostfair_av12x21[2]     0.13      0.08     0.02     0.33 1.00
## deplonely_mostfair_av12x21[3]     0.12      0.08     0.02     0.32 1.00
## deplonely_mostfair_av12x21[4]     0.12      0.08     0.02     0.31 1.00
## deplonely_mostfair_av12x21[5]     0.12      0.08     0.01     0.31 1.00
## deplonely_mostfair_av12x21[6]     0.13      0.08     0.02     0.31 1.00
## deplonely_mostfair_av12x21[7]     0.13      0.08     0.02     0.32 1.00
## deplonely_mostfair_av12x21[8]     0.12      0.08     0.01     0.32 1.00
## depblues_mostfair_devx21[1]       0.26      0.15     0.04     0.59 1.00
## depblues_mostfair_devx21[2]       0.25      0.14     0.03     0.57 1.00
## depblues_mostfair_devx21[3]       0.23      0.13     0.03     0.54 1.00
## depblues_mostfair_devx21[4]       0.26      0.15     0.04     0.59 1.00
## depblues_mostfair_av12x21[1]      0.12      0.08     0.01     0.31 1.00
## depblues_mostfair_av12x21[2]      0.12      0.08     0.02     0.31 1.00
## depblues_mostfair_av12x21[3]      0.12      0.08     0.01     0.30 1.00
## depblues_mostfair_av12x21[4]      0.11      0.08     0.01     0.30 1.00
## depblues_mostfair_av12x21[5]      0.12      0.08     0.02     0.31 1.00
## depblues_mostfair_av12x21[6]      0.13      0.08     0.02     0.33 1.00
## depblues_mostfair_av12x21[7]      0.14      0.09     0.02     0.35 1.00
## depblues_mostfair_av12x21[8]      0.14      0.09     0.02     0.36 1.00
## depunfair_mostfair_devx21[1]      0.18      0.11     0.03     0.44 1.00
## depunfair_mostfair_devx21[2]      0.33      0.13     0.09     0.60 1.00
## depunfair_mostfair_devx21[3]      0.24      0.12     0.05     0.50 1.00
## depunfair_mostfair_devx21[4]      0.24      0.13     0.04     0.54 1.00
## depunfair_mostfair_av12x21[1]     0.11      0.07     0.01     0.28 1.00
## depunfair_mostfair_av12x21[2]     0.12      0.08     0.02     0.30 1.00
## depunfair_mostfair_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## depunfair_mostfair_av12x21[4]     0.12      0.08     0.02     0.30 1.00
## depunfair_mostfair_av12x21[5]     0.11      0.07     0.01     0.30 1.00
## depunfair_mostfair_av12x21[6]     0.13      0.08     0.02     0.31 1.00
## depunfair_mostfair_av12x21[7]     0.15      0.10     0.02     0.38 1.00
## depunfair_mostfair_av12x21[8]     0.14      0.08     0.02     0.34 1.00
## depmistrt_mostfair_devx21[1]      0.25      0.13     0.04     0.55 1.00
## depmistrt_mostfair_devx21[2]      0.23      0.13     0.04     0.54 1.00
## depmistrt_mostfair_devx21[3]      0.28      0.14     0.05     0.58 1.00
## depmistrt_mostfair_devx21[4]      0.24      0.14     0.03     0.55 1.00
## depmistrt_mostfair_av12x21[1]     0.09      0.06     0.01     0.23 1.00
## depmistrt_mostfair_av12x21[2]     0.12      0.07     0.02     0.29 1.00
## depmistrt_mostfair_av12x21[3]     0.12      0.07     0.02     0.29 1.00
## depmistrt_mostfair_av12x21[4]     0.14      0.09     0.02     0.35 1.00
## depmistrt_mostfair_av12x21[5]     0.12      0.08     0.02     0.31 1.00
## depmistrt_mostfair_av12x21[6]     0.12      0.07     0.02     0.29 1.00
## depmistrt_mostfair_av12x21[7]     0.19      0.10     0.03     0.41 1.00
## depmistrt_mostfair_av12x21[8]     0.10      0.07     0.01     0.26 1.00
## depbetray_mostfair_devx21[1]      0.26      0.14     0.04     0.58 1.00
## depbetray_mostfair_devx21[2]      0.29      0.14     0.05     0.60 1.00
## depbetray_mostfair_devx21[3]      0.19      0.12     0.02     0.49 1.00
## depbetray_mostfair_devx21[4]      0.26      0.15     0.03     0.59 1.00
## depbetray_mostfair_av12x21[1]     0.11      0.07     0.02     0.28 1.00
## depbetray_mostfair_av12x21[2]     0.13      0.08     0.02     0.32 1.00
## depbetray_mostfair_av12x21[3]     0.14      0.08     0.02     0.33 1.00
## depbetray_mostfair_av12x21[4]     0.15      0.09     0.02     0.35 1.00
## depbetray_mostfair_av12x21[5]     0.10      0.06     0.01     0.25 1.00
## depbetray_mostfair_av12x21[6]     0.10      0.07     0.01     0.28 1.00
## depbetray_mostfair_av12x21[7]     0.13      0.08     0.02     0.32 1.00
## depbetray_mostfair_av12x21[8]     0.14      0.08     0.02     0.33 1.00
##                               Bulk_ESS Tail_ESS
## depcantgo_mostfair_devx21[1]      7214     2075
## depcantgo_mostfair_devx21[2]      8034     2196
## depcantgo_mostfair_devx21[3]      5477     3222
## depcantgo_mostfair_devx21[4]      9063     3259
## depcantgo_mostfair_av12x21[1]     7801     2357
## depcantgo_mostfair_av12x21[2]     8461     2654
## depcantgo_mostfair_av12x21[3]     8158     2634
## depcantgo_mostfair_av12x21[4]     6754     2558
## depcantgo_mostfair_av12x21[5]     7105     2079
## depcantgo_mostfair_av12x21[6]     8146     2727
## depcantgo_mostfair_av12x21[7]     7946     2963
## depcantgo_mostfair_av12x21[8]     7345     2874
## depeffort_mostfair_devx21[1]      7562     2973
## depeffort_mostfair_devx21[2]      6329     2780
## depeffort_mostfair_devx21[3]      5489     2606
## depeffort_mostfair_devx21[4]      9224     3011
## depeffort_mostfair_av12x21[1]     8330     2351
## depeffort_mostfair_av12x21[2]     9287     2646
## depeffort_mostfair_av12x21[3]     7130     2237
## depeffort_mostfair_av12x21[4]     7572     3082
## depeffort_mostfair_av12x21[5]     7859     2851
## depeffort_mostfair_av12x21[6]     7693     2849
## depeffort_mostfair_av12x21[7]     8948     3150
## depeffort_mostfair_av12x21[8]     8542     2398
## deplonely_mostfair_devx21[1]      7711     3012
## deplonely_mostfair_devx21[2]      6443     2968
## deplonely_mostfair_devx21[3]      7093     2763
## deplonely_mostfair_devx21[4]      7899     2623
## deplonely_mostfair_av12x21[1]     7496     2420
## deplonely_mostfair_av12x21[2]     8649     2429
## deplonely_mostfair_av12x21[3]     8045     2365
## deplonely_mostfair_av12x21[4]     7453     2710
## deplonely_mostfair_av12x21[5]     8268     2127
## deplonely_mostfair_av12x21[6]     8636     2620
## deplonely_mostfair_av12x21[7]     7891     3127
## deplonely_mostfair_av12x21[8]     8155     2382
## depblues_mostfair_devx21[1]       9049     2982
## depblues_mostfair_devx21[2]       7608     2846
## depblues_mostfair_devx21[3]       8016     2766
## depblues_mostfair_devx21[4]       8704     3303
## depblues_mostfair_av12x21[1]      6621     2500
## depblues_mostfair_av12x21[2]     10114     2818
## depblues_mostfair_av12x21[3]      8223     2292
## depblues_mostfair_av12x21[4]      8237     2188
## depblues_mostfair_av12x21[5]      7384     2623
## depblues_mostfair_av12x21[6]      8089     2581
## depblues_mostfair_av12x21[7]      8349     2608
## depblues_mostfair_av12x21[8]      6403     2612
## depunfair_mostfair_devx21[1]      7154     3070
## depunfair_mostfair_devx21[2]      6314     2302
## depunfair_mostfair_devx21[3]      5865     3308
## depunfair_mostfair_devx21[4]      7608     2740
## depunfair_mostfair_av12x21[1]     8039     2412
## depunfair_mostfair_av12x21[2]     8320     2469
## depunfair_mostfair_av12x21[3]     7278     2515
## depunfair_mostfair_av12x21[4]     7348     2677
## depunfair_mostfair_av12x21[5]     7885     2520
## depunfair_mostfair_av12x21[6]     7495     2312
## depunfair_mostfair_av12x21[7]     7139     2583
## depunfair_mostfair_av12x21[8]     7504     2795
## depmistrt_mostfair_devx21[1]      6745     2881
## depmistrt_mostfair_devx21[2]      8660     2703
## depmistrt_mostfair_devx21[3]      6651     2796
## depmistrt_mostfair_devx21[4]      7639     2883
## depmistrt_mostfair_av12x21[1]     8946     2799
## depmistrt_mostfair_av12x21[2]     7194     2176
## depmistrt_mostfair_av12x21[3]     7659     2294
## depmistrt_mostfair_av12x21[4]     9241     2383
## depmistrt_mostfair_av12x21[5]     8777     2430
## depmistrt_mostfair_av12x21[6]     6963     2727
## depmistrt_mostfair_av12x21[7]     7489     2714
## depmistrt_mostfair_av12x21[8]     7354     2617
## depbetray_mostfair_devx21[1]      7891     2705
## depbetray_mostfair_devx21[2]      7871     2824
## depbetray_mostfair_devx21[3]      5890     2673
## depbetray_mostfair_devx21[4]      7721     2278
## depbetray_mostfair_av12x21[1]     7693     2774
## depbetray_mostfair_av12x21[2]     7915     2682
## depbetray_mostfair_av12x21[3]     8015     2920
## depbetray_mostfair_av12x21[4]     9346     2969
## depbetray_mostfair_av12x21[5]     8879     2991
## depbetray_mostfair_av12x21[6]     7312     2443
## depbetray_mostfair_av12x21[7]     7329     2473
## depbetray_mostfair_av12x21[8]     7441     3040
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.3.4.5 Prior summary
out.chg.alldepress.stfair.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                        depbetray
##                   normal(0, 0.125)         b  mostfair_av12x2       depbetray
##                    normal(0, 0.25)         b   mostfair_devx2       depbetray
##                             (flat)         b                         depblues
##                   normal(0, 0.125)         b  mostfair_av12x2        depblues
##                    normal(0, 0.25)         b   mostfair_devx2        depblues
##                             (flat)         b                        depcantgo
##                   normal(0, 0.125)         b  mostfair_av12x2       depcantgo
##                    normal(0, 0.25)         b   mostfair_devx2       depcantgo
##                             (flat)         b                        depeffort
##                   normal(0, 0.125)         b  mostfair_av12x2       depeffort
##                    normal(0, 0.25)         b   mostfair_devx2       depeffort
##                             (flat)         b                        deplonely
##                   normal(0, 0.125)         b  mostfair_av12x2       deplonely
##                    normal(0, 0.25)         b   mostfair_devx2       deplonely
##                             (flat)         b                        depmistrt
##                   normal(0, 0.125)         b  mostfair_av12x2       depmistrt
##                    normal(0, 0.25)         b   mostfair_devx2       depmistrt
##                             (flat)         b                        depunfair
##                   normal(0, 0.125)         b  mostfair_av12x2       depunfair
##                    normal(0, 0.25)         b   mostfair_devx2       depunfair
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                        depbetray
##                       normal(0, 2) Intercept                         depblues
##                       normal(0, 2) Intercept                        depcantgo
##                       normal(0, 2) Intercept                        depeffort
##                       normal(0, 2) Intercept                        deplonely
##                       normal(0, 2) Intercept                        depmistrt
##                       normal(0, 2) Intercept                        depunfair
##               student_t(3, 0, 2.5)        sd                        depbetray
##               student_t(3, 0, 2.5)        sd                         depblues
##               student_t(3, 0, 2.5)        sd                        depcantgo
##               student_t(3, 0, 2.5)        sd                        depeffort
##               student_t(3, 0, 2.5)        sd                        deplonely
##               student_t(3, 0, 2.5)        sd                        depmistrt
##               student_t(3, 0, 2.5)        sd                        depunfair
##               student_t(3, 0, 2.5)        sd                     id depbetray
##               student_t(3, 0, 2.5)        sd        Intercept    id depbetray
##               student_t(3, 0, 2.5)        sd                     id  depblues
##               student_t(3, 0, 2.5)        sd        Intercept    id  depblues
##               student_t(3, 0, 2.5)        sd                     id depcantgo
##               student_t(3, 0, 2.5)        sd        Intercept    id depcantgo
##               student_t(3, 0, 2.5)        sd                     id depeffort
##               student_t(3, 0, 2.5)        sd        Intercept    id depeffort
##               student_t(3, 0, 2.5)        sd                     id deplonely
##               student_t(3, 0, 2.5)        sd        Intercept    id deplonely
##               student_t(3, 0, 2.5)        sd                     id depmistrt
##               student_t(3, 0, 2.5)        sd        Intercept    id depmistrt
##               student_t(3, 0, 2.5)        sd                     id depunfair
##               student_t(3, 0, 2.5)        sd        Intercept    id depunfair
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       depbetray
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       depbetray
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21        depblues
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21        depblues
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       depcantgo
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       depcantgo
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       depeffort
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       depeffort
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       deplonely
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       deplonely
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       depmistrt
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       depmistrt
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostfair_av12x21       depunfair
##              dirichlet(2, 2, 2, 2)      simo  mostfair_devx21       depunfair
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.3.5 B/W Change Corr: stjob/neg emotions

#Bivariate Change: negative emotions items ~ mo(stjob)
 
#Vectorize priors:

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostjob_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostjob_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostjob_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostjob_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stjob.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt, 
          depbetray) ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stjob_fit",
      file_refit = "on_change"
  )

out.chg.alldepress.stjob.fit <- ppchecks(chg.alldepress.stjob.fit)
6.2.3.5.1 Coefficient plot (intervals)
out.chg.alldepress.stjob.fit[[11]]

6.2.3.5.2 Coefficient plot (distributions)
out.chg.alldepress.stjob.fit[[10]]

6.2.3.5.3 PPcheck (density)
p1 <- out.chg.alldepress.stjob.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.chg.alldepress.stjob.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.chg.alldepress.stjob.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.chg.alldepress.stjob.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.chg.alldepress.stjob.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.chg.alldepress.stjob.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.chg.alldepress.stjob.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

6.2.3.5.4 Fit summary
out.chg.alldepress.stjob.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          depeffort ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          deplonely ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          depblues ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          depunfair ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          depmistrt ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##          depbetray ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.27      0.18     0.01     0.66 1.00      846
## sd(depeffort_Intercept)     0.42      0.27     0.02     0.97 1.00      742
## sd(deplonely_Intercept)     0.41      0.24     0.02     0.88 1.01      577
## sd(depblues_Intercept)      0.66      0.31     0.06     1.25 1.00      531
## sd(depunfair_Intercept)     0.23      0.16     0.01     0.59 1.00     1164
## sd(depmistrt_Intercept)     0.34      0.22     0.02     0.83 1.00      862
## sd(depbetray_Intercept)     0.46      0.27     0.03     1.02 1.01      651
##                         Tail_ESS
## sd(depcantgo_Intercept)     1542
## sd(depeffort_Intercept)     1397
## sd(deplonely_Intercept)     1298
## sd(depblues_Intercept)       962
## sd(depunfair_Intercept)     1993
## sd(depmistrt_Intercept)     1868
## sd(depbetray_Intercept)     1424
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_Intercept         -0.39      0.22    -0.85     0.02 1.00     5106
## depeffort_Intercept         -2.14      0.33    -2.82    -1.55 1.00     3948
## deplonely_Intercept         -1.16      0.26    -1.69    -0.64 1.00     3818
## depblues_Intercept          -1.97      0.33    -2.62    -1.32 1.00     2754
## depunfair_Intercept         -1.83      0.27    -2.41    -1.37 1.00     4616
## depmistrt_Intercept         -1.82      0.34    -2.43    -1.02 1.00     3399
## depbetray_Intercept         -2.62      0.33    -3.33    -2.03 1.00     2705
## depcantgo_mostjob_devx2      0.18      0.09    -0.01     0.37 1.00     5054
## depcantgo_mostjob_av12x2    -0.06      0.02    -0.11    -0.01 1.00     7519
## depeffort_mostjob_devx2      0.14      0.12    -0.10     0.38 1.00     4827
## depeffort_mostjob_av12x2     0.04      0.03    -0.03     0.10 1.00     6877
## deplonely_mostjob_devx2      0.07      0.10    -0.13     0.26 1.00     4857
## deplonely_mostjob_av12x2     0.01      0.03    -0.05     0.06 1.00     8324
## depblues_mostjob_devx2      -0.07      0.12    -0.30     0.16 1.00     6426
## depblues_mostjob_av12x2      0.03      0.03    -0.03     0.10 1.00     6709
## depunfair_mostjob_devx2      0.22      0.10     0.04     0.42 1.00     5560
## depunfair_mostjob_av12x2     0.09      0.03     0.04     0.14 1.00     7301
## depmistrt_mostjob_devx2      0.00      0.13    -0.30     0.23 1.00     4063
## depmistrt_mostjob_av12x2     0.06      0.03    -0.00     0.12 1.00     7381
## depbetray_mostjob_devx2      0.21      0.11     0.00     0.42 1.00     4260
## depbetray_mostjob_av12x2     0.13      0.04     0.06     0.20 1.00     6094
##                          Tail_ESS
## depcantgo_Intercept          2673
## depeffort_Intercept          3058
## deplonely_Intercept          2733
## depblues_Intercept           2531
## depunfair_Intercept          2761
## depmistrt_Intercept          2658
## depbetray_Intercept          2202
## depcantgo_mostjob_devx2      2894
## depcantgo_mostjob_av12x2     3178
## depeffort_mostjob_devx2      3077
## depeffort_mostjob_av12x2     2813
## deplonely_mostjob_devx2      2902
## deplonely_mostjob_av12x2     3321
## depblues_mostjob_devx2       3122
## depblues_mostjob_av12x2      2960
## depunfair_mostjob_devx2      2925
## depunfair_mostjob_av12x2     3158
## depmistrt_mostjob_devx2      2421
## depmistrt_mostjob_av12x2     3332
## depbetray_mostjob_devx2      2650
## depbetray_mostjob_av12x2     3043
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_mostjob_devx21[1]      0.21      0.13     0.03     0.50 1.00     6130
## depcantgo_mostjob_devx21[2]      0.19      0.11     0.03     0.46 1.00     7577
## depcantgo_mostjob_devx21[3]      0.35      0.15     0.08     0.66 1.00     5349
## depcantgo_mostjob_devx21[4]      0.25      0.14     0.04     0.54 1.00     7668
## depcantgo_mostjob_av12x21[1]     0.10      0.07     0.01     0.27 1.00     6390
## depcantgo_mostjob_av12x21[2]     0.10      0.07     0.02     0.26 1.00     7469
## depcantgo_mostjob_av12x21[3]     0.11      0.07     0.01     0.27 1.00     8435
## depcantgo_mostjob_av12x21[4]     0.12      0.08     0.02     0.30 1.00     7108
## depcantgo_mostjob_av12x21[5]     0.14      0.09     0.02     0.34 1.00     8620
## depcantgo_mostjob_av12x21[6]     0.16      0.09     0.02     0.37 1.00     6959
## depcantgo_mostjob_av12x21[7]     0.14      0.09     0.02     0.35 1.00     6934
## depcantgo_mostjob_av12x21[8]     0.13      0.08     0.02     0.33 1.00     7734
## depeffort_mostjob_devx21[1]      0.24      0.14     0.04     0.57 1.00     7332
## depeffort_mostjob_devx21[2]      0.28      0.15     0.05     0.60 1.00     7249
## depeffort_mostjob_devx21[3]      0.22      0.13     0.03     0.52 1.00     6986
## depeffort_mostjob_devx21[4]      0.25      0.14     0.04     0.56 1.00     7228
## depeffort_mostjob_av12x21[1]     0.12      0.08     0.02     0.31 1.00     9578
## depeffort_mostjob_av12x21[2]     0.13      0.08     0.02     0.32 1.00     8860
## depeffort_mostjob_av12x21[3]     0.12      0.08     0.01     0.31 1.00     8468
## depeffort_mostjob_av12x21[4]     0.12      0.07     0.02     0.30 1.00     7184
## depeffort_mostjob_av12x21[5]     0.12      0.08     0.01     0.31 1.00     6693
## depeffort_mostjob_av12x21[6]     0.12      0.08     0.02     0.32 1.00     7457
## depeffort_mostjob_av12x21[7]     0.14      0.09     0.02     0.34 1.00     7041
## depeffort_mostjob_av12x21[8]     0.14      0.09     0.02     0.36 1.00     7045
## deplonely_mostjob_devx21[1]      0.25      0.15     0.03     0.59 1.00     6294
## deplonely_mostjob_devx21[2]      0.25      0.14     0.04     0.57 1.00     7929
## deplonely_mostjob_devx21[3]      0.24      0.14     0.04     0.55 1.00     6523
## deplonely_mostjob_devx21[4]      0.27      0.15     0.04     0.60 1.00     8071
## deplonely_mostjob_av12x21[1]     0.13      0.08     0.02     0.32 1.00     7300
## deplonely_mostjob_av12x21[2]     0.13      0.08     0.02     0.31 1.00     7164
## deplonely_mostjob_av12x21[3]     0.12      0.08     0.02     0.32 1.00     7857
## deplonely_mostjob_av12x21[4]     0.12      0.08     0.02     0.31 1.00     6985
## deplonely_mostjob_av12x21[5]     0.13      0.08     0.02     0.32 1.00     8468
## deplonely_mostjob_av12x21[6]     0.12      0.08     0.02     0.32 1.00     7824
## deplonely_mostjob_av12x21[7]     0.12      0.08     0.02     0.32 1.00     7385
## deplonely_mostjob_av12x21[8]     0.13      0.08     0.02     0.32 1.00     7401
## depblues_mostjob_devx21[1]       0.25      0.14     0.04     0.57 1.00     8140
## depblues_mostjob_devx21[2]       0.25      0.14     0.04     0.56 1.00     7537
## depblues_mostjob_devx21[3]       0.24      0.14     0.04     0.57 1.00     7298
## depblues_mostjob_devx21[4]       0.26      0.15     0.04     0.60 1.00     7935
## depblues_mostjob_av12x21[1]      0.12      0.08     0.02     0.31 1.00     8169
## depblues_mostjob_av12x21[2]      0.12      0.07     0.02     0.30 1.00     8547
## depblues_mostjob_av12x21[3]      0.12      0.08     0.02     0.31 1.00     6197
## depblues_mostjob_av12x21[4]      0.13      0.08     0.02     0.32 1.00     6916
## depblues_mostjob_av12x21[5]      0.13      0.08     0.02     0.31 1.00     9005
## depblues_mostjob_av12x21[6]      0.13      0.08     0.02     0.34 1.00     7858
## depblues_mostjob_av12x21[7]      0.13      0.08     0.02     0.34 1.00     8068
## depblues_mostjob_av12x21[8]      0.12      0.08     0.02     0.31 1.00     7465
## depunfair_mostjob_devx21[1]      0.22      0.13     0.04     0.52 1.00     6828
## depunfair_mostjob_devx21[2]      0.22      0.12     0.03     0.51 1.00     7841
## depunfair_mostjob_devx21[3]      0.33      0.14     0.07     0.63 1.00     6097
## depunfair_mostjob_devx21[4]      0.23      0.13     0.03     0.52 1.00     7444
## depunfair_mostjob_av12x21[1]     0.10      0.07     0.01     0.26 1.00     6402
## depunfair_mostjob_av12x21[2]     0.11      0.07     0.01     0.27 1.00     7362
## depunfair_mostjob_av12x21[3]     0.12      0.07     0.02     0.30 1.00     6247
## depunfair_mostjob_av12x21[4]     0.12      0.08     0.02     0.31 1.00     7486
## depunfair_mostjob_av12x21[5]     0.12      0.08     0.01     0.31 1.00     7459
## depunfair_mostjob_av12x21[6]     0.11      0.07     0.01     0.28 1.00     6877
## depunfair_mostjob_av12x21[7]     0.19      0.10     0.03     0.41 1.00     7614
## depunfair_mostjob_av12x21[8]     0.14      0.09     0.02     0.34 1.00     7109
## depmistrt_mostjob_devx21[1]      0.27      0.16     0.04     0.63 1.00     5379
## depmistrt_mostjob_devx21[2]      0.23      0.14     0.03     0.54 1.00     6153
## depmistrt_mostjob_devx21[3]      0.24      0.15     0.03     0.59 1.00     4724
## depmistrt_mostjob_devx21[4]      0.26      0.15     0.04     0.59 1.00     6910
## depmistrt_mostjob_av12x21[1]     0.14      0.08     0.02     0.34 1.00     7078
## depmistrt_mostjob_av12x21[2]     0.13      0.08     0.02     0.33 1.00     6949
## depmistrt_mostjob_av12x21[3]     0.12      0.08     0.02     0.33 1.00     7299
## depmistrt_mostjob_av12x21[4]     0.12      0.08     0.02     0.33 1.00     8183
## depmistrt_mostjob_av12x21[5]     0.12      0.08     0.01     0.30 1.00     7833
## depmistrt_mostjob_av12x21[6]     0.11      0.07     0.02     0.29 1.00     8332
## depmistrt_mostjob_av12x21[7]     0.12      0.08     0.02     0.32 1.00     7583
## depmistrt_mostjob_av12x21[8]     0.13      0.08     0.02     0.31 1.00     7467
## depbetray_mostjob_devx21[1]      0.21      0.12     0.03     0.50 1.00     8422
## depbetray_mostjob_devx21[2]      0.28      0.14     0.05     0.57 1.00     8102
## depbetray_mostjob_devx21[3]      0.28      0.14     0.05     0.59 1.00     6257
## depbetray_mostjob_devx21[4]      0.23      0.13     0.03     0.53 1.00     7343
## depbetray_mostjob_av12x21[1]     0.13      0.08     0.02     0.33 1.00     7978
## depbetray_mostjob_av12x21[2]     0.11      0.08     0.01     0.30 1.00     6621
## depbetray_mostjob_av12x21[3]     0.11      0.07     0.01     0.27 1.00     7170
## depbetray_mostjob_av12x21[4]     0.10      0.07     0.01     0.26 1.00     8239
## depbetray_mostjob_av12x21[5]     0.10      0.07     0.01     0.26 1.00     7347
## depbetray_mostjob_av12x21[6]     0.10      0.07     0.01     0.27 1.00     7680
## depbetray_mostjob_av12x21[7]     0.14      0.08     0.02     0.34 1.00     7266
## depbetray_mostjob_av12x21[8]     0.20      0.11     0.03     0.44 1.00     7156
##                              Tail_ESS
## depcantgo_mostjob_devx21[1]      2763
## depcantgo_mostjob_devx21[2]      2664
## depcantgo_mostjob_devx21[3]      2734
## depcantgo_mostjob_devx21[4]      2791
## depcantgo_mostjob_av12x21[1]     2387
## depcantgo_mostjob_av12x21[2]     2494
## depcantgo_mostjob_av12x21[3]     2625
## depcantgo_mostjob_av12x21[4]     2320
## depcantgo_mostjob_av12x21[5]     2305
## depcantgo_mostjob_av12x21[6]     2375
## depcantgo_mostjob_av12x21[7]     3062
## depcantgo_mostjob_av12x21[8]     2625
## depeffort_mostjob_devx21[1]      2336
## depeffort_mostjob_devx21[2]      2872
## depeffort_mostjob_devx21[3]      2785
## depeffort_mostjob_devx21[4]      2964
## depeffort_mostjob_av12x21[1]     2426
## depeffort_mostjob_av12x21[2]     3037
## depeffort_mostjob_av12x21[3]     2730
## depeffort_mostjob_av12x21[4]     2411
## depeffort_mostjob_av12x21[5]     2398
## depeffort_mostjob_av12x21[6]     2460
## depeffort_mostjob_av12x21[7]     2548
## depeffort_mostjob_av12x21[8]     2524
## deplonely_mostjob_devx21[1]      2389
## deplonely_mostjob_devx21[2]      2596
## deplonely_mostjob_devx21[3]      3089
## deplonely_mostjob_devx21[4]      2568
## deplonely_mostjob_av12x21[1]     2623
## deplonely_mostjob_av12x21[2]     2340
## deplonely_mostjob_av12x21[3]     2774
## deplonely_mostjob_av12x21[4]     2171
## deplonely_mostjob_av12x21[5]     2874
## deplonely_mostjob_av12x21[6]     2707
## deplonely_mostjob_av12x21[7]     3058
## deplonely_mostjob_av12x21[8]     2736
## depblues_mostjob_devx21[1]       2751
## depblues_mostjob_devx21[2]       2882
## depblues_mostjob_devx21[3]       2756
## depblues_mostjob_devx21[4]       2593
## depblues_mostjob_av12x21[1]      2991
## depblues_mostjob_av12x21[2]      2942
## depblues_mostjob_av12x21[3]      1517
## depblues_mostjob_av12x21[4]      2709
## depblues_mostjob_av12x21[5]      2832
## depblues_mostjob_av12x21[6]      2702
## depblues_mostjob_av12x21[7]      2676
## depblues_mostjob_av12x21[8]      2573
## depunfair_mostjob_devx21[1]      2707
## depunfair_mostjob_devx21[2]      2610
## depunfair_mostjob_devx21[3]      2787
## depunfair_mostjob_devx21[4]      2953
## depunfair_mostjob_av12x21[1]     2264
## depunfair_mostjob_av12x21[2]     2355
## depunfair_mostjob_av12x21[3]     2783
## depunfair_mostjob_av12x21[4]     2481
## depunfair_mostjob_av12x21[5]     2573
## depunfair_mostjob_av12x21[6]     2674
## depunfair_mostjob_av12x21[7]     2687
## depunfair_mostjob_av12x21[8]     2507
## depmistrt_mostjob_devx21[1]      2994
## depmistrt_mostjob_devx21[2]      2331
## depmistrt_mostjob_devx21[3]      2907
## depmistrt_mostjob_devx21[4]      2818
## depmistrt_mostjob_av12x21[1]     2805
## depmistrt_mostjob_av12x21[2]     2383
## depmistrt_mostjob_av12x21[3]     1955
## depmistrt_mostjob_av12x21[4]     2663
## depmistrt_mostjob_av12x21[5]     2424
## depmistrt_mostjob_av12x21[6]     2602
## depmistrt_mostjob_av12x21[7]     2943
## depmistrt_mostjob_av12x21[8]     2734
## depbetray_mostjob_devx21[1]      2895
## depbetray_mostjob_devx21[2]      2914
## depbetray_mostjob_devx21[3]      2859
## depbetray_mostjob_devx21[4]      2738
## depbetray_mostjob_av12x21[1]     2689
## depbetray_mostjob_av12x21[2]     1962
## depbetray_mostjob_av12x21[3]     2257
## depbetray_mostjob_av12x21[4]     2648
## depbetray_mostjob_av12x21[5]     2668
## depbetray_mostjob_av12x21[6]     2437
## depbetray_mostjob_av12x21[7]     3110
## depbetray_mostjob_av12x21[8]     2918
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.3.5.5 Prior summary
out.chg.alldepress.stjob.fit[[2]]
##                              prior     class            coef group      resp
##                             (flat)         b                                
##                             (flat)         b                       depbetray
##                   normal(0, 0.125)         b  mostjob_av12x2       depbetray
##                    normal(0, 0.25)         b   mostjob_devx2       depbetray
##                             (flat)         b                        depblues
##                   normal(0, 0.125)         b  mostjob_av12x2        depblues
##                    normal(0, 0.25)         b   mostjob_devx2        depblues
##                             (flat)         b                       depcantgo
##                   normal(0, 0.125)         b  mostjob_av12x2       depcantgo
##                    normal(0, 0.25)         b   mostjob_devx2       depcantgo
##                             (flat)         b                       depeffort
##                   normal(0, 0.125)         b  mostjob_av12x2       depeffort
##                    normal(0, 0.25)         b   mostjob_devx2       depeffort
##                             (flat)         b                       deplonely
##                   normal(0, 0.125)         b  mostjob_av12x2       deplonely
##                    normal(0, 0.25)         b   mostjob_devx2       deplonely
##                             (flat)         b                       depmistrt
##                   normal(0, 0.125)         b  mostjob_av12x2       depmistrt
##                    normal(0, 0.25)         b   mostjob_devx2       depmistrt
##                             (flat)         b                       depunfair
##                   normal(0, 0.125)         b  mostjob_av12x2       depunfair
##                    normal(0, 0.25)         b   mostjob_devx2       depunfair
##                             (flat) Intercept                                
##                       normal(0, 2) Intercept                       depbetray
##                       normal(0, 2) Intercept                        depblues
##                       normal(0, 2) Intercept                       depcantgo
##                       normal(0, 2) Intercept                       depeffort
##                       normal(0, 2) Intercept                       deplonely
##                       normal(0, 2) Intercept                       depmistrt
##                       normal(0, 2) Intercept                       depunfair
##               student_t(3, 0, 2.5)        sd                       depbetray
##               student_t(3, 0, 2.5)        sd                        depblues
##               student_t(3, 0, 2.5)        sd                       depcantgo
##               student_t(3, 0, 2.5)        sd                       depeffort
##               student_t(3, 0, 2.5)        sd                       deplonely
##               student_t(3, 0, 2.5)        sd                       depmistrt
##               student_t(3, 0, 2.5)        sd                       depunfair
##               student_t(3, 0, 2.5)        sd                    id depbetray
##               student_t(3, 0, 2.5)        sd       Intercept    id depbetray
##               student_t(3, 0, 2.5)        sd                    id  depblues
##               student_t(3, 0, 2.5)        sd       Intercept    id  depblues
##               student_t(3, 0, 2.5)        sd                    id depcantgo
##               student_t(3, 0, 2.5)        sd       Intercept    id depcantgo
##               student_t(3, 0, 2.5)        sd                    id depeffort
##               student_t(3, 0, 2.5)        sd       Intercept    id depeffort
##               student_t(3, 0, 2.5)        sd                    id deplonely
##               student_t(3, 0, 2.5)        sd       Intercept    id deplonely
##               student_t(3, 0, 2.5)        sd                    id depmistrt
##               student_t(3, 0, 2.5)        sd       Intercept    id depmistrt
##               student_t(3, 0, 2.5)        sd                    id depunfair
##               student_t(3, 0, 2.5)        sd       Intercept    id depunfair
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       depbetray
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       depbetray
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21        depblues
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21        depblues
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       depcantgo
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       depcantgo
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       depeffort
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       depeffort
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       deplonely
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       deplonely
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       depmistrt
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       depmistrt
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostjob_av12x21       depunfair
##              dirichlet(2, 2, 2, 2)      simo  mostjob_devx21       depunfair
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.3.6 B/W Change Corr: stthft/neg emotions

#Bivariate Change: negative emotions items ~ mo(stthft)
 
#Vectorize priors:

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostthft_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostthft_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostthft_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostthft_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stthft.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt, 
          depbetray) ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stthft_fit",
      file_refit = "on_change"
  )


out.chg.alldepress.stthft.fit <- ppchecks(chg.alldepress.stthft.fit)
6.2.3.6.1 Coefficient plot (intervals)
out.chg.alldepress.stthft.fit[[11]]

6.2.3.6.2 Coefficient plot (distributions)
out.chg.alldepress.stthft.fit[[10]]

6.2.3.6.3 PPcheck (density)
p1 <- out.chg.alldepress.stthft.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.chg.alldepress.stthft.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.chg.alldepress.stthft.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.chg.alldepress.stthft.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.chg.alldepress.stthft.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.chg.alldepress.stthft.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.chg.alldepress.stthft.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

6.2.3.6.4 Fit summary
out.chg.alldepress.stthft.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          depeffort ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          deplonely ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          depblues ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          depunfair ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          depmistrt ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##          depbetray ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.28      0.19     0.01     0.69 1.00      673
## sd(depeffort_Intercept)     0.43      0.27     0.02     0.98 1.00      706
## sd(deplonely_Intercept)     0.42      0.24     0.02     0.90 1.01      392
## sd(depblues_Intercept)      0.63      0.32     0.05     1.24 1.01      544
## sd(depunfair_Intercept)     0.25      0.18     0.01     0.64 1.00      968
## sd(depmistrt_Intercept)     0.33      0.22     0.01     0.80 1.01      716
## sd(depbetray_Intercept)     0.53      0.29     0.04     1.10 1.00      497
##                         Tail_ESS
## sd(depcantgo_Intercept)     1747
## sd(depeffort_Intercept)     1419
## sd(deplonely_Intercept)      973
## sd(depblues_Intercept)      1208
## sd(depunfair_Intercept)     1814
## sd(depmistrt_Intercept)     1605
## sd(depbetray_Intercept)     1422
## 
## Regression Coefficients:
##                           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_Intercept          -0.79      0.24    -1.31    -0.37 1.00     3812
## depeffort_Intercept          -1.87      0.30    -2.53    -1.30 1.00     2661
## deplonely_Intercept          -1.53      0.27    -2.08    -1.04 1.00     3445
## depblues_Intercept           -2.24      0.37    -3.02    -1.58 1.00     2434
## depunfair_Intercept          -1.66      0.28    -2.28    -1.16 1.00     3776
## depmistrt_Intercept          -1.92      0.27    -2.45    -1.37 1.00     3514
## depbetray_Intercept          -2.40      0.32    -3.07    -1.86 1.00     2468
## depcantgo_mostthft_devx2      0.15      0.10    -0.03     0.35 1.00     4134
## depcantgo_mostthft_av12x2     0.05      0.03    -0.01     0.11 1.00     7857
## depeffort_mostthft_devx2      0.10      0.12    -0.14     0.36 1.00     4917
## depeffort_mostthft_av12x2    -0.00      0.04    -0.08     0.07 1.00     6509
## deplonely_mostthft_devx2      0.23      0.11     0.02     0.45 1.00     4177
## deplonely_mostthft_av12x2     0.03      0.03    -0.03     0.09 1.00     6699
## depblues_mostthft_devx2       0.20      0.14    -0.06     0.51 1.00     4846
## depblues_mostthft_av12x2     -0.04      0.04    -0.13     0.05 1.00     6297
## depunfair_mostthft_devx2      0.25      0.11     0.05     0.47 1.00     5000
## depunfair_mostthft_av12x2     0.04      0.03    -0.02     0.11 1.00     6426
## depmistrt_mostthft_devx2      0.13      0.12    -0.12     0.34 1.00     4026
## depmistrt_mostthft_av12x2     0.06      0.04    -0.02     0.13 1.00     6798
## depbetray_mostthft_devx2      0.26      0.11     0.05     0.49 1.00     5065
## depbetray_mostthft_av12x2     0.09      0.04     0.01     0.18 1.00     6078
##                           Tail_ESS
## depcantgo_Intercept           2608
## depeffort_Intercept           2679
## deplonely_Intercept           2768
## depblues_Intercept            2505
## depunfair_Intercept           2662
## depmistrt_Intercept           2425
## depbetray_Intercept           2703
## depcantgo_mostthft_devx2      2938
## depcantgo_mostthft_av12x2     3052
## depeffort_mostthft_devx2      3143
## depeffort_mostthft_av12x2     2992
## deplonely_mostthft_devx2      3097
## deplonely_mostthft_av12x2     3094
## depblues_mostthft_devx2       2994
## depblues_mostthft_av12x2      2986
## depunfair_mostthft_devx2      2972
## depunfair_mostthft_av12x2     3372
## depmistrt_mostthft_devx2      2379
## depmistrt_mostthft_av12x2     2827
## depbetray_mostthft_devx2      3169
## depbetray_mostthft_av12x2     3266
## 
## Monotonic Simplex Parameters:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## depcantgo_mostthft_devx21[1]      0.23      0.13     0.03     0.52 1.00
## depcantgo_mostthft_devx21[2]      0.28      0.14     0.05     0.59 1.00
## depcantgo_mostthft_devx21[3]      0.24      0.13     0.04     0.54 1.00
## depcantgo_mostthft_devx21[4]      0.25      0.14     0.04     0.56 1.00
## depcantgo_mostthft_av12x21[1]     0.13      0.08     0.02     0.31 1.00
## depcantgo_mostthft_av12x21[2]     0.12      0.07     0.02     0.30 1.00
## depcantgo_mostthft_av12x21[3]     0.12      0.07     0.02     0.30 1.00
## depcantgo_mostthft_av12x21[4]     0.14      0.09     0.02     0.34 1.00
## depcantgo_mostthft_av12x21[5]     0.13      0.08     0.02     0.33 1.00
## depcantgo_mostthft_av12x21[6]     0.13      0.08     0.02     0.34 1.00
## depcantgo_mostthft_av12x21[7]     0.12      0.08     0.02     0.30 1.00
## depcantgo_mostthft_av12x21[8]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostthft_devx21[1]      0.26      0.15     0.03     0.59 1.00
## depeffort_mostthft_devx21[2]      0.23      0.14     0.04     0.56 1.00
## depeffort_mostthft_devx21[3]      0.23      0.14     0.03     0.54 1.00
## depeffort_mostthft_devx21[4]      0.27      0.15     0.04     0.61 1.00
## depeffort_mostthft_av12x21[1]     0.13      0.08     0.02     0.33 1.00
## depeffort_mostthft_av12x21[2]     0.12      0.08     0.02     0.32 1.00
## depeffort_mostthft_av12x21[3]     0.12      0.08     0.02     0.30 1.00
## depeffort_mostthft_av12x21[4]     0.12      0.08     0.02     0.31 1.00
## depeffort_mostthft_av12x21[5]     0.12      0.08     0.01     0.31 1.00
## depeffort_mostthft_av12x21[6]     0.13      0.08     0.02     0.32 1.00
## depeffort_mostthft_av12x21[7]     0.13      0.08     0.02     0.33 1.00
## depeffort_mostthft_av12x21[8]     0.13      0.08     0.02     0.31 1.00
## deplonely_mostthft_devx21[1]      0.17      0.11     0.02     0.45 1.00
## deplonely_mostthft_devx21[2]      0.35      0.15     0.09     0.65 1.00
## deplonely_mostthft_devx21[3]      0.21      0.12     0.04     0.49 1.00
## deplonely_mostthft_devx21[4]      0.26      0.14     0.04     0.57 1.00
## deplonely_mostthft_av12x21[1]     0.11      0.08     0.02     0.30 1.00
## deplonely_mostthft_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## deplonely_mostthft_av12x21[3]     0.13      0.08     0.01     0.32 1.00
## deplonely_mostthft_av12x21[4]     0.13      0.08     0.02     0.33 1.00
## deplonely_mostthft_av12x21[5]     0.13      0.08     0.02     0.31 1.00
## deplonely_mostthft_av12x21[6]     0.13      0.08     0.02     0.33 1.00
## deplonely_mostthft_av12x21[7]     0.13      0.08     0.02     0.34 1.00
## deplonely_mostthft_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## depblues_mostthft_devx21[1]       0.25      0.14     0.04     0.57 1.00
## depblues_mostthft_devx21[2]       0.25      0.14     0.04     0.56 1.00
## depblues_mostthft_devx21[3]       0.21      0.12     0.03     0.50 1.00
## depblues_mostthft_devx21[4]       0.29      0.16     0.04     0.62 1.00
## depblues_mostthft_av12x21[1]      0.14      0.09     0.02     0.34 1.00
## depblues_mostthft_av12x21[2]      0.13      0.09     0.02     0.34 1.00
## depblues_mostthft_av12x21[3]      0.13      0.08     0.02     0.33 1.00
## depblues_mostthft_av12x21[4]      0.12      0.08     0.02     0.31 1.00
## depblues_mostthft_av12x21[5]      0.11      0.08     0.01     0.30 1.00
## depblues_mostthft_av12x21[6]      0.12      0.08     0.02     0.31 1.00
## depblues_mostthft_av12x21[7]      0.12      0.08     0.01     0.32 1.00
## depblues_mostthft_av12x21[8]      0.13      0.08     0.02     0.33 1.00
## depunfair_mostthft_devx21[1]      0.22      0.13     0.03     0.50 1.00
## depunfair_mostthft_devx21[2]      0.34      0.14     0.09     0.64 1.00
## depunfair_mostthft_devx21[3]      0.20      0.11     0.03     0.47 1.00
## depunfair_mostthft_devx21[4]      0.23      0.13     0.03     0.53 1.00
## depunfair_mostthft_av12x21[1]     0.11      0.08     0.02     0.30 1.00
## depunfair_mostthft_av12x21[2]     0.11      0.07     0.01     0.28 1.00
## depunfair_mostthft_av12x21[3]     0.11      0.07     0.01     0.28 1.00
## depunfair_mostthft_av12x21[4]     0.12      0.08     0.02     0.30 1.00
## depunfair_mostthft_av12x21[5]     0.13      0.08     0.02     0.33 1.00
## depunfair_mostthft_av12x21[6]     0.14      0.09     0.02     0.35 1.00
## depunfair_mostthft_av12x21[7]     0.14      0.09     0.02     0.36 1.00
## depunfair_mostthft_av12x21[8]     0.14      0.09     0.02     0.36 1.00
## depmistrt_mostthft_devx21[1]      0.23      0.14     0.04     0.55 1.00
## depmistrt_mostthft_devx21[2]      0.21      0.12     0.03     0.50 1.00
## depmistrt_mostthft_devx21[3]      0.33      0.16     0.05     0.65 1.00
## depmistrt_mostthft_devx21[4]      0.24      0.14     0.03     0.56 1.00
## depmistrt_mostthft_av12x21[1]     0.12      0.08     0.02     0.31 1.00
## depmistrt_mostthft_av12x21[2]     0.12      0.08     0.02     0.31 1.00
## depmistrt_mostthft_av12x21[3]     0.12      0.08     0.02     0.31 1.00
## depmistrt_mostthft_av12x21[4]     0.11      0.07     0.01     0.29 1.00
## depmistrt_mostthft_av12x21[5]     0.13      0.08     0.02     0.32 1.00
## depmistrt_mostthft_av12x21[6]     0.13      0.08     0.02     0.32 1.00
## depmistrt_mostthft_av12x21[7]     0.14      0.09     0.02     0.35 1.00
## depmistrt_mostthft_av12x21[8]     0.13      0.08     0.02     0.33 1.00
## depbetray_mostthft_devx21[1]      0.18      0.11     0.02     0.44 1.00
## depbetray_mostthft_devx21[2]      0.32      0.14     0.08     0.60 1.00
## depbetray_mostthft_devx21[3]      0.29      0.13     0.06     0.59 1.00
## depbetray_mostthft_devx21[4]      0.21      0.12     0.03     0.49 1.00
## depbetray_mostthft_av12x21[1]     0.10      0.07     0.01     0.27 1.00
## depbetray_mostthft_av12x21[2]     0.11      0.07     0.01     0.28 1.00
## depbetray_mostthft_av12x21[3]     0.10      0.07     0.01     0.27 1.00
## depbetray_mostthft_av12x21[4]     0.11      0.07     0.01     0.28 1.00
## depbetray_mostthft_av12x21[5]     0.13      0.09     0.02     0.34 1.00
## depbetray_mostthft_av12x21[6]     0.14      0.09     0.02     0.36 1.00
## depbetray_mostthft_av12x21[7]     0.17      0.10     0.02     0.39 1.00
## depbetray_mostthft_av12x21[8]     0.13      0.08     0.02     0.32 1.00
##                               Bulk_ESS Tail_ESS
## depcantgo_mostthft_devx21[1]      7135     2859
## depcantgo_mostthft_devx21[2]      7977     2529
## depcantgo_mostthft_devx21[3]      6079     2523
## depcantgo_mostthft_devx21[4]      6180     2983
## depcantgo_mostthft_av12x21[1]     7832     2593
## depcantgo_mostthft_av12x21[2]     6625     2525
## depcantgo_mostthft_av12x21[3]     7434     2744
## depcantgo_mostthft_av12x21[4]     8300     2557
## depcantgo_mostthft_av12x21[5]     7426     2915
## depcantgo_mostthft_av12x21[6]     6845     2553
## depcantgo_mostthft_av12x21[7]     5906     2623
## depcantgo_mostthft_av12x21[8]     6675     2704
## depeffort_mostthft_devx21[1]      6423     2655
## depeffort_mostthft_devx21[2]      7495     2216
## depeffort_mostthft_devx21[3]      6693     2372
## depeffort_mostthft_devx21[4]      6885     2597
## depeffort_mostthft_av12x21[1]     7017     2556
## depeffort_mostthft_av12x21[2]     6795     2170
## depeffort_mostthft_av12x21[3]     5738     2250
## depeffort_mostthft_av12x21[4]     7267     1928
## depeffort_mostthft_av12x21[5]     6276     2063
## depeffort_mostthft_av12x21[6]     6548     2836
## depeffort_mostthft_av12x21[7]     8262     2922
## depeffort_mostthft_av12x21[8]     5880     2987
## deplonely_mostthft_devx21[1]      6756     2995
## deplonely_mostthft_devx21[2]      5979     2744
## deplonely_mostthft_devx21[3]      5625     2926
## deplonely_mostthft_devx21[4]      6089     2505
## deplonely_mostthft_av12x21[1]     7355     2422
## deplonely_mostthft_av12x21[2]     6827     2514
## deplonely_mostthft_av12x21[3]     6466     2763
## deplonely_mostthft_av12x21[4]     7754     2687
## deplonely_mostthft_av12x21[5]     7768     2654
## deplonely_mostthft_av12x21[6]     7475     2454
## deplonely_mostthft_av12x21[7]     6728     2808
## deplonely_mostthft_av12x21[8]     5914     3100
## depblues_mostthft_devx21[1]       6251     3005
## depblues_mostthft_devx21[2]       7258     2561
## depblues_mostthft_devx21[3]       6747     3100
## depblues_mostthft_devx21[4]       7643     2778
## depblues_mostthft_av12x21[1]      7236     2467
## depblues_mostthft_av12x21[2]      6220     2671
## depblues_mostthft_av12x21[3]      6838     2657
## depblues_mostthft_av12x21[4]      7240     2798
## depblues_mostthft_av12x21[5]      6807     2844
## depblues_mostthft_av12x21[6]      6795     2751
## depblues_mostthft_av12x21[7]      7444     2769
## depblues_mostthft_av12x21[8]      6840     3039
## depunfair_mostthft_devx21[1]      7231     3273
## depunfair_mostthft_devx21[2]      6845     2403
## depunfair_mostthft_devx21[3]      5718     3076
## depunfair_mostthft_devx21[4]      7338     3052
## depunfair_mostthft_av12x21[1]     8993     2392
## depunfair_mostthft_av12x21[2]     6920     2858
## depunfair_mostthft_av12x21[3]     6594     2521
## depunfair_mostthft_av12x21[4]     7336     2829
## depunfair_mostthft_av12x21[5]     8340     2386
## depunfair_mostthft_av12x21[6]     6424     2385
## depunfair_mostthft_av12x21[7]     6245     2728
## depunfair_mostthft_av12x21[8]     6511     3096
## depmistrt_mostthft_devx21[1]      6200     2820
## depmistrt_mostthft_devx21[2]      7954     2808
## depmistrt_mostthft_devx21[3]      4723     2943
## depmistrt_mostthft_devx21[4]      7403     2914
## depmistrt_mostthft_av12x21[1]     7377     2469
## depmistrt_mostthft_av12x21[2]     7330     2798
## depmistrt_mostthft_av12x21[3]     6761     2516
## depmistrt_mostthft_av12x21[4]     7071     2993
## depmistrt_mostthft_av12x21[5]     7099     2618
## depmistrt_mostthft_av12x21[6]     7720     2372
## depmistrt_mostthft_av12x21[7]     6920     2987
## depmistrt_mostthft_av12x21[8]     6627     2454
## depbetray_mostthft_devx21[1]      6282     2483
## depbetray_mostthft_devx21[2]      6989     2383
## depbetray_mostthft_devx21[3]      5914     2617
## depbetray_mostthft_devx21[4]      7233     2756
## depbetray_mostthft_av12x21[1]     5683     1982
## depbetray_mostthft_av12x21[2]     6370     2308
## depbetray_mostthft_av12x21[3]     7248     2569
## depbetray_mostthft_av12x21[4]     6328     2620
## depbetray_mostthft_av12x21[5]     9901     2560
## depbetray_mostthft_av12x21[6]     7822     2767
## depbetray_mostthft_av12x21[7]     5497     3001
## depbetray_mostthft_av12x21[8]     7671     2450
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.3.6.5 Prior summary
out.chg.alldepress.stthft.fit[[2]]
##                              prior     class             coef group      resp
##                             (flat)         b                                 
##                             (flat)         b                        depbetray
##                   normal(0, 0.125)         b  mostthft_av12x2       depbetray
##                    normal(0, 0.25)         b   mostthft_devx2       depbetray
##                             (flat)         b                         depblues
##                   normal(0, 0.125)         b  mostthft_av12x2        depblues
##                    normal(0, 0.25)         b   mostthft_devx2        depblues
##                             (flat)         b                        depcantgo
##                   normal(0, 0.125)         b  mostthft_av12x2       depcantgo
##                    normal(0, 0.25)         b   mostthft_devx2       depcantgo
##                             (flat)         b                        depeffort
##                   normal(0, 0.125)         b  mostthft_av12x2       depeffort
##                    normal(0, 0.25)         b   mostthft_devx2       depeffort
##                             (flat)         b                        deplonely
##                   normal(0, 0.125)         b  mostthft_av12x2       deplonely
##                    normal(0, 0.25)         b   mostthft_devx2       deplonely
##                             (flat)         b                        depmistrt
##                   normal(0, 0.125)         b  mostthft_av12x2       depmistrt
##                    normal(0, 0.25)         b   mostthft_devx2       depmistrt
##                             (flat)         b                        depunfair
##                   normal(0, 0.125)         b  mostthft_av12x2       depunfair
##                    normal(0, 0.25)         b   mostthft_devx2       depunfair
##                             (flat) Intercept                                 
##                       normal(0, 2) Intercept                        depbetray
##                       normal(0, 2) Intercept                         depblues
##                       normal(0, 2) Intercept                        depcantgo
##                       normal(0, 2) Intercept                        depeffort
##                       normal(0, 2) Intercept                        deplonely
##                       normal(0, 2) Intercept                        depmistrt
##                       normal(0, 2) Intercept                        depunfair
##               student_t(3, 0, 2.5)        sd                        depbetray
##               student_t(3, 0, 2.5)        sd                         depblues
##               student_t(3, 0, 2.5)        sd                        depcantgo
##               student_t(3, 0, 2.5)        sd                        depeffort
##               student_t(3, 0, 2.5)        sd                        deplonely
##               student_t(3, 0, 2.5)        sd                        depmistrt
##               student_t(3, 0, 2.5)        sd                        depunfair
##               student_t(3, 0, 2.5)        sd                     id depbetray
##               student_t(3, 0, 2.5)        sd        Intercept    id depbetray
##               student_t(3, 0, 2.5)        sd                     id  depblues
##               student_t(3, 0, 2.5)        sd        Intercept    id  depblues
##               student_t(3, 0, 2.5)        sd                     id depcantgo
##               student_t(3, 0, 2.5)        sd        Intercept    id depcantgo
##               student_t(3, 0, 2.5)        sd                     id depeffort
##               student_t(3, 0, 2.5)        sd        Intercept    id depeffort
##               student_t(3, 0, 2.5)        sd                     id deplonely
##               student_t(3, 0, 2.5)        sd        Intercept    id deplonely
##               student_t(3, 0, 2.5)        sd                     id depmistrt
##               student_t(3, 0, 2.5)        sd        Intercept    id depmistrt
##               student_t(3, 0, 2.5)        sd                     id depunfair
##               student_t(3, 0, 2.5)        sd        Intercept    id depunfair
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       depbetray
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       depbetray
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21        depblues
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21        depblues
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       depcantgo
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       depcantgo
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       depeffort
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       depeffort
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       deplonely
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       deplonely
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       depmistrt
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       depmistrt
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostthft_av12x21       depunfair
##              dirichlet(2, 2, 2, 2)      simo  mostthft_devx21       depunfair
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

6.2.3.7 B/W Change Corr: stmug/neg emotions

#Bivariate Change: negative emotions items ~ mo(stmug)
 
#Vectorize priors:

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  # set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmug_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostmug_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmug_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostmug_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stmug.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt, 
          depbetray) ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stmug_fit",
      file_refit = "on_change"
  )

out.chg.alldepress.stmug.fit <- ppchecks(chg.alldepress.stmug.fit)
6.2.3.7.1 Coefficient plot (intervals)
out.chg.alldepress.stmug.fit[[11]]

6.2.3.7.2 Coefficient plot (distributions)
out.chg.alldepress.stmug.fit[[10]]

6.2.3.7.3 PPcheck (density)
p1 <- out.chg.alldepress.stmug.fit[[3]] + labs(title = "Can't Get Going (T1)") 
p2 <- out.chg.alldepress.stmug.fit[[4]] + labs(title = "Everything Effort (T1)")
p3 <- out.chg.alldepress.stmug.fit[[5]] + labs(title = "Lonely (T1)")
p4 <- out.chg.alldepress.stmug.fit[[6]] + labs(title = "Can't Shake Blues (T1)")
p5 <- out.chg.alldepress.stmug.fit[[7]] + labs(title = "Felt Life Unfair (T1)")
p6 <- out.chg.alldepress.stmug.fit[[8]] + labs(title = "Felt Mistreated (T1)")
p7 <- out.chg.alldepress.stmug.fit[[9]] + labs(title = "Felt Betrayed (T1)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

6.2.3.7.4 Fit summary
out.chg.alldepress.stmug.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          depeffort ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          deplonely ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          depblues ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          depunfair ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          depmistrt ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##          depbetray ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.28      0.18     0.01     0.67 1.00      567
## sd(depeffort_Intercept)     0.43      0.25     0.02     0.94 1.01      620
## sd(deplonely_Intercept)     0.42      0.23     0.03     0.85 1.01      599
## sd(depblues_Intercept)      0.67      0.32     0.05     1.24 1.01      350
## sd(depunfair_Intercept)     0.23      0.16     0.01     0.60 1.00      754
## sd(depmistrt_Intercept)     0.32      0.21     0.02     0.80 1.01      580
## sd(depbetray_Intercept)     0.47      0.27     0.03     1.01 1.01      439
##                         Tail_ESS
## sd(depcantgo_Intercept)     1683
## sd(depeffort_Intercept)     1336
## sd(deplonely_Intercept)     1259
## sd(depblues_Intercept)       880
## sd(depunfair_Intercept)     1414
## sd(depmistrt_Intercept)     1589
## sd(depbetray_Intercept)     1205
## 
## Regression Coefficients:
##                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_Intercept         -0.68      0.26    -1.23    -0.21 1.00     2764
## depeffort_Intercept         -1.81      0.30    -2.41    -1.21 1.00     2820
## deplonely_Intercept         -1.53      0.25    -2.09    -1.10 1.00     2378
## depblues_Intercept          -1.79      0.33    -2.45    -1.12 1.00     1541
## depunfair_Intercept         -1.22      0.26    -1.76    -0.70 1.00     3126
## depmistrt_Intercept         -1.77      0.31    -2.35    -1.11 1.00     2555
## depbetray_Intercept         -2.25      0.32    -2.92    -1.68 1.00     2457
## depcantgo_mostmug_devx2      0.13      0.10    -0.08     0.33 1.00     3011
## depcantgo_mostmug_av12x2     0.02      0.03    -0.04     0.09 1.00     5625
## depeffort_mostmug_devx2      0.05      0.13    -0.22     0.30 1.00     3780
## depeffort_mostmug_av12x2     0.01      0.04    -0.07     0.10 1.00     4886
## deplonely_mostmug_devx2      0.21      0.12    -0.01     0.46 1.00     3006
## deplonely_mostmug_av12x2     0.08      0.04     0.01     0.16 1.00     4375
## depblues_mostmug_devx2      -0.10      0.14    -0.39     0.16 1.00     3285
## depblues_mostmug_av12x2      0.02      0.05    -0.08     0.11 1.00     4869
## depunfair_mostmug_devx2      0.03      0.12    -0.19     0.27 1.00     3533
## depunfair_mostmug_av12x2     0.08      0.04     0.00     0.16 1.00     4944
## depmistrt_mostmug_devx2     -0.02      0.13    -0.28     0.22 1.00     3472
## depmistrt_mostmug_av12x2     0.13      0.04     0.05     0.22 1.00     4648
## depbetray_mostmug_devx2      0.17      0.12    -0.08     0.40 1.00     3978
## depbetray_mostmug_av12x2     0.15      0.05     0.07     0.25 1.00     6104
##                          Tail_ESS
## depcantgo_Intercept          2715
## depeffort_Intercept          2062
## deplonely_Intercept          1941
## depblues_Intercept           2165
## depunfair_Intercept          2529
## depmistrt_Intercept          2195
## depbetray_Intercept          2616
## depcantgo_mostmug_devx2      2487
## depcantgo_mostmug_av12x2     3040
## depeffort_mostmug_devx2      2308
## depeffort_mostmug_av12x2     2345
## deplonely_mostmug_devx2      2374
## deplonely_mostmug_av12x2     2921
## depblues_mostmug_devx2       2630
## depblues_mostmug_av12x2      3208
## depunfair_mostmug_devx2      2474
## depunfair_mostmug_av12x2     2958
## depmistrt_mostmug_devx2      2335
## depmistrt_mostmug_av12x2     2512
## depbetray_mostmug_devx2      2533
## depbetray_mostmug_av12x2     3380
## 
## Monotonic Simplex Parameters:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## depcantgo_mostmug_devx21[1]      0.25      0.14     0.03     0.57 1.00     4885
## depcantgo_mostmug_devx21[2]      0.30      0.15     0.05     0.61 1.00     5426
## depcantgo_mostmug_devx21[3]      0.22      0.13     0.03     0.52 1.00     5739
## depcantgo_mostmug_devx21[4]      0.23      0.14     0.03     0.56 1.00     5725
## depcantgo_mostmug_av12x21[1]     0.12      0.07     0.01     0.30 1.00     5919
## depcantgo_mostmug_av12x21[2]     0.12      0.08     0.02     0.32 1.00     5692
## depcantgo_mostmug_av12x21[3]     0.13      0.08     0.01     0.33 1.00     4788
## depcantgo_mostmug_av12x21[4]     0.12      0.08     0.02     0.31 1.00     6696
## depcantgo_mostmug_av12x21[5]     0.12      0.08     0.02     0.30 1.00     6154
## depcantgo_mostmug_av12x21[6]     0.13      0.08     0.02     0.32 1.00     6040
## depcantgo_mostmug_av12x21[7]     0.13      0.08     0.02     0.33 1.00     5738
## depcantgo_mostmug_av12x21[8]     0.13      0.08     0.02     0.33 1.00     6062
## depeffort_mostmug_devx21[1]      0.25      0.14     0.04     0.57 1.00     6070
## depeffort_mostmug_devx21[2]      0.23      0.14     0.03     0.55 1.00     6161
## depeffort_mostmug_devx21[3]      0.25      0.14     0.03     0.58 1.00     4779
## depeffort_mostmug_devx21[4]      0.26      0.14     0.04     0.58 1.00     5461
## depeffort_mostmug_av12x21[1]     0.12      0.08     0.02     0.32 1.00     5316
## depeffort_mostmug_av12x21[2]     0.12      0.08     0.02     0.32 1.00     6958
## depeffort_mostmug_av12x21[3]     0.12      0.08     0.02     0.31 1.00     6932
## depeffort_mostmug_av12x21[4]     0.12      0.08     0.01     0.31 1.00     6013
## depeffort_mostmug_av12x21[5]     0.13      0.08     0.02     0.33 1.00     6292
## depeffort_mostmug_av12x21[6]     0.13      0.08     0.02     0.32 1.00     6208
## depeffort_mostmug_av12x21[7]     0.13      0.08     0.02     0.34 1.00     6513
## depeffort_mostmug_av12x21[8]     0.13      0.08     0.02     0.34 1.00     5841
## deplonely_mostmug_devx21[1]      0.21      0.12     0.03     0.50 1.00     4530
## deplonely_mostmug_devx21[2]      0.21      0.12     0.03     0.49 1.00     6057
## deplonely_mostmug_devx21[3]      0.30      0.15     0.06     0.61 1.00     4779
## deplonely_mostmug_devx21[4]      0.28      0.15     0.05     0.61 1.00     5953
## deplonely_mostmug_av12x21[1]     0.12      0.07     0.02     0.30 1.00     4269
## deplonely_mostmug_av12x21[2]     0.12      0.08     0.02     0.31 1.00     5951
## deplonely_mostmug_av12x21[3]     0.13      0.08     0.02     0.31 1.00     5662
## deplonely_mostmug_av12x21[4]     0.12      0.08     0.01     0.31 1.00     6018
## deplonely_mostmug_av12x21[5]     0.13      0.08     0.02     0.32 1.00     6060
## deplonely_mostmug_av12x21[6]     0.14      0.09     0.02     0.34 1.00     5463
## deplonely_mostmug_av12x21[7]     0.13      0.08     0.02     0.32 1.00     6205
## deplonely_mostmug_av12x21[8]     0.11      0.07     0.02     0.30 1.00     6006
## depblues_mostmug_devx21[1]       0.25      0.15     0.04     0.58 1.00     6010
## depblues_mostmug_devx21[2]       0.23      0.13     0.03     0.54 1.00     5842
## depblues_mostmug_devx21[3]       0.24      0.14     0.04     0.56 1.00     6247
## depblues_mostmug_devx21[4]       0.28      0.15     0.04     0.61 1.00     5857
## depblues_mostmug_av12x21[1]      0.12      0.08     0.02     0.31 1.00     7401
## depblues_mostmug_av12x21[2]      0.12      0.08     0.02     0.30 1.00     5923
## depblues_mostmug_av12x21[3]      0.12      0.08     0.01     0.31 1.00     5345
## depblues_mostmug_av12x21[4]      0.12      0.08     0.02     0.31 1.00     6252
## depblues_mostmug_av12x21[5]      0.13      0.08     0.02     0.33 1.00     6283
## depblues_mostmug_av12x21[6]      0.13      0.08     0.02     0.33 1.00     6226
## depblues_mostmug_av12x21[7]      0.13      0.08     0.02     0.33 1.00     6227
## depblues_mostmug_av12x21[8]      0.13      0.08     0.02     0.33 1.00     5392
## depunfair_mostmug_devx21[1]      0.27      0.15     0.04     0.59 1.00     5659
## depunfair_mostmug_devx21[2]      0.23      0.13     0.03     0.53 1.00     5316
## depunfair_mostmug_devx21[3]      0.24      0.13     0.04     0.54 1.00     5061
## depunfair_mostmug_devx21[4]      0.27      0.15     0.04     0.60 1.00     5389
## depunfair_mostmug_av12x21[1]     0.10      0.07     0.01     0.27 1.00     6521
## depunfair_mostmug_av12x21[2]     0.09      0.06     0.01     0.25 1.00     6101
## depunfair_mostmug_av12x21[3]     0.12      0.08     0.02     0.30 1.00     5176
## depunfair_mostmug_av12x21[4]     0.13      0.08     0.02     0.33 1.00     5241
## depunfair_mostmug_av12x21[5]     0.14      0.09     0.02     0.34 1.00     5380
## depunfair_mostmug_av12x21[6]     0.14      0.09     0.02     0.37 1.00     5556
## depunfair_mostmug_av12x21[7]     0.15      0.09     0.02     0.36 1.00     5471
## depunfair_mostmug_av12x21[8]     0.13      0.08     0.02     0.33 1.00     6180
## depmistrt_mostmug_devx21[1]      0.27      0.15     0.04     0.62 1.00     4573
## depmistrt_mostmug_devx21[2]      0.24      0.14     0.03     0.56 1.00     6308
## depmistrt_mostmug_devx21[3]      0.23      0.14     0.03     0.55 1.00     4789
## depmistrt_mostmug_devx21[4]      0.26      0.15     0.03     0.60 1.00     6377
## depmistrt_mostmug_av12x21[1]     0.15      0.08     0.02     0.34 1.00     6613
## depmistrt_mostmug_av12x21[2]     0.12      0.08     0.02     0.30 1.00     5336
## depmistrt_mostmug_av12x21[3]     0.10      0.07     0.01     0.26 1.00     4712
## depmistrt_mostmug_av12x21[4]     0.11      0.08     0.02     0.29 1.00     6706
## depmistrt_mostmug_av12x21[5]     0.12      0.07     0.02     0.29 1.00     7896
## depmistrt_mostmug_av12x21[6]     0.13      0.08     0.02     0.31 1.00     6301
## depmistrt_mostmug_av12x21[7]     0.15      0.09     0.02     0.36 1.00     5224
## depmistrt_mostmug_av12x21[8]     0.12      0.08     0.02     0.31 1.00     5871
## depbetray_mostmug_devx21[1]      0.22      0.13     0.03     0.53 1.00     5908
## depbetray_mostmug_devx21[2]      0.29      0.15     0.05     0.60 1.00     5027
## depbetray_mostmug_devx21[3]      0.25      0.14     0.04     0.56 1.00     6013
## depbetray_mostmug_devx21[4]      0.23      0.13     0.03     0.53 1.00     5826
## depbetray_mostmug_av12x21[1]     0.10      0.06     0.01     0.25 1.00     6159
## depbetray_mostmug_av12x21[2]     0.10      0.06     0.01     0.25 1.00     6368
## depbetray_mostmug_av12x21[3]     0.08      0.06     0.01     0.22 1.00     4808
## depbetray_mostmug_av12x21[4]     0.11      0.07     0.01     0.28 1.00     4591
## depbetray_mostmug_av12x21[5]     0.17      0.10     0.02     0.39 1.00     6198
## depbetray_mostmug_av12x21[6]     0.19      0.11     0.03     0.43 1.00     5175
## depbetray_mostmug_av12x21[7]     0.15      0.09     0.02     0.35 1.00     5115
## depbetray_mostmug_av12x21[8]     0.12      0.07     0.01     0.30 1.00     6885
##                              Tail_ESS
## depcantgo_mostmug_devx21[1]      2154
## depcantgo_mostmug_devx21[2]      2582
## depcantgo_mostmug_devx21[3]      2735
## depcantgo_mostmug_devx21[4]      2708
## depcantgo_mostmug_av12x21[1]     2529
## depcantgo_mostmug_av12x21[2]     2394
## depcantgo_mostmug_av12x21[3]     2314
## depcantgo_mostmug_av12x21[4]     2540
## depcantgo_mostmug_av12x21[5]     2615
## depcantgo_mostmug_av12x21[6]     2289
## depcantgo_mostmug_av12x21[7]     2645
## depcantgo_mostmug_av12x21[8]     2708
## depeffort_mostmug_devx21[1]      2972
## depeffort_mostmug_devx21[2]      2680
## depeffort_mostmug_devx21[3]      3029
## depeffort_mostmug_devx21[4]      2836
## depeffort_mostmug_av12x21[1]     2188
## depeffort_mostmug_av12x21[2]     2373
## depeffort_mostmug_av12x21[3]     2296
## depeffort_mostmug_av12x21[4]     2390
## depeffort_mostmug_av12x21[5]     2675
## depeffort_mostmug_av12x21[6]     2738
## depeffort_mostmug_av12x21[7]     2527
## depeffort_mostmug_av12x21[8]     2771
## deplonely_mostmug_devx21[1]      2708
## deplonely_mostmug_devx21[2]      2653
## deplonely_mostmug_devx21[3]      2791
## deplonely_mostmug_devx21[4]      2988
## deplonely_mostmug_av12x21[1]     2134
## deplonely_mostmug_av12x21[2]     2228
## deplonely_mostmug_av12x21[3]     2805
## deplonely_mostmug_av12x21[4]     2613
## deplonely_mostmug_av12x21[5]     2433
## deplonely_mostmug_av12x21[6]     2682
## deplonely_mostmug_av12x21[7]     2728
## deplonely_mostmug_av12x21[8]     2870
## depblues_mostmug_devx21[1]       2406
## depblues_mostmug_devx21[2]       2947
## depblues_mostmug_devx21[3]       2703
## depblues_mostmug_devx21[4]       2710
## depblues_mostmug_av12x21[1]      2189
## depblues_mostmug_av12x21[2]      2477
## depblues_mostmug_av12x21[3]      2259
## depblues_mostmug_av12x21[4]      2716
## depblues_mostmug_av12x21[5]      2380
## depblues_mostmug_av12x21[6]      2575
## depblues_mostmug_av12x21[7]      2883
## depblues_mostmug_av12x21[8]      2734
## depunfair_mostmug_devx21[1]      2444
## depunfair_mostmug_devx21[2]      3033
## depunfair_mostmug_devx21[3]      2565
## depunfair_mostmug_devx21[4]      3024
## depunfair_mostmug_av12x21[1]     2218
## depunfair_mostmug_av12x21[2]     2127
## depunfair_mostmug_av12x21[3]     2324
## depunfair_mostmug_av12x21[4]     2042
## depunfair_mostmug_av12x21[5]     2442
## depunfair_mostmug_av12x21[6]     2713
## depunfair_mostmug_av12x21[7]     2851
## depunfair_mostmug_av12x21[8]     2948
## depmistrt_mostmug_devx21[1]      2401
## depmistrt_mostmug_devx21[2]      2244
## depmistrt_mostmug_devx21[3]      2938
## depmistrt_mostmug_devx21[4]      2476
## depmistrt_mostmug_av12x21[1]     2899
## depmistrt_mostmug_av12x21[2]     2070
## depmistrt_mostmug_av12x21[3]     1833
## depmistrt_mostmug_av12x21[4]     2726
## depmistrt_mostmug_av12x21[5]     3347
## depmistrt_mostmug_av12x21[6]     2166
## depmistrt_mostmug_av12x21[7]     2938
## depmistrt_mostmug_av12x21[8]     3003
## depbetray_mostmug_devx21[1]      2225
## depbetray_mostmug_devx21[2]      2842
## depbetray_mostmug_devx21[3]      3092
## depbetray_mostmug_devx21[4]      2707
## depbetray_mostmug_av12x21[1]     2217
## depbetray_mostmug_av12x21[2]     2294
## depbetray_mostmug_av12x21[3]     2169
## depbetray_mostmug_av12x21[4]     2399
## depbetray_mostmug_av12x21[5]     2313
## depbetray_mostmug_av12x21[6]     2673
## depbetray_mostmug_av12x21[7]     2429
## depbetray_mostmug_av12x21[8]     2775
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
6.2.3.7.5 Prior summary
out.chg.alldepress.stmug.fit[[2]]
##                              prior     class            coef group      resp
##                             (flat)         b                                
##                             (flat)         b                       depbetray
##                   normal(0, 0.125)         b  mostmug_av12x2       depbetray
##                    normal(0, 0.25)         b   mostmug_devx2       depbetray
##                             (flat)         b                        depblues
##                   normal(0, 0.125)         b  mostmug_av12x2        depblues
##                    normal(0, 0.25)         b   mostmug_devx2        depblues
##                             (flat)         b                       depcantgo
##                   normal(0, 0.125)         b  mostmug_av12x2       depcantgo
##                    normal(0, 0.25)         b   mostmug_devx2       depcantgo
##                             (flat)         b                       depeffort
##                   normal(0, 0.125)         b  mostmug_av12x2       depeffort
##                    normal(0, 0.25)         b   mostmug_devx2       depeffort
##                             (flat)         b                       deplonely
##                   normal(0, 0.125)         b  mostmug_av12x2       deplonely
##                    normal(0, 0.25)         b   mostmug_devx2       deplonely
##                             (flat)         b                       depmistrt
##                   normal(0, 0.125)         b  mostmug_av12x2       depmistrt
##                    normal(0, 0.25)         b   mostmug_devx2       depmistrt
##                             (flat)         b                       depunfair
##                   normal(0, 0.125)         b  mostmug_av12x2       depunfair
##                    normal(0, 0.25)         b   mostmug_devx2       depunfair
##                             (flat) Intercept                                
##                       normal(0, 2) Intercept                       depbetray
##                       normal(0, 2) Intercept                        depblues
##                       normal(0, 2) Intercept                       depcantgo
##                       normal(0, 2) Intercept                       depeffort
##                       normal(0, 2) Intercept                       deplonely
##                       normal(0, 2) Intercept                       depmistrt
##                       normal(0, 2) Intercept                       depunfair
##               student_t(3, 0, 2.5)        sd                       depbetray
##               student_t(3, 0, 2.5)        sd                        depblues
##               student_t(3, 0, 2.5)        sd                       depcantgo
##               student_t(3, 0, 2.5)        sd                       depeffort
##               student_t(3, 0, 2.5)        sd                       deplonely
##               student_t(3, 0, 2.5)        sd                       depmistrt
##               student_t(3, 0, 2.5)        sd                       depunfair
##               student_t(3, 0, 2.5)        sd                    id depbetray
##               student_t(3, 0, 2.5)        sd       Intercept    id depbetray
##               student_t(3, 0, 2.5)        sd                    id  depblues
##               student_t(3, 0, 2.5)        sd       Intercept    id  depblues
##               student_t(3, 0, 2.5)        sd                    id depcantgo
##               student_t(3, 0, 2.5)        sd       Intercept    id depcantgo
##               student_t(3, 0, 2.5)        sd                    id depeffort
##               student_t(3, 0, 2.5)        sd       Intercept    id depeffort
##               student_t(3, 0, 2.5)        sd                    id deplonely
##               student_t(3, 0, 2.5)        sd       Intercept    id deplonely
##               student_t(3, 0, 2.5)        sd                    id depmistrt
##               student_t(3, 0, 2.5)        sd       Intercept    id depmistrt
##               student_t(3, 0, 2.5)        sd                    id depunfair
##               student_t(3, 0, 2.5)        sd       Intercept    id depunfair
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       depbetray
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       depbetray
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21        depblues
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21        depblues
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       depcantgo
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       depcantgo
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       depeffort
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       depeffort
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       deplonely
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       deplonely
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       depmistrt
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       depmistrt
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo mostmug_av12x21       depunfair
##              dirichlet(2, 2, 2, 2)      simo  mostmug_devx21       depunfair
##  dpar nlpar lb ub       source
##                        default
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user

Now that we have model fits for criminal intent and negative emotions change models, let’s generate PLME contrasts and visualize them.

save(stress.wide4, file = here("1_Data_Files/Datasets/stress_wide4.Rdata"))
save(stress.long, file = here("1_Data_Files/Datasets/stress_long.Rdata"))

7 Figure 3: T1 vs Change (T2-T1) Correlations

(RMD FILE: BDK_2023_Stress_6_Chgcorr_viz)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

7.1 Visualizing “bivariate” change associations

7.1.1 Predictive Marginal Contrasts (Crim Intent)

#load stress.wide (from Fig1 Rmd) 
load(here("1_Data_Files/Datasets/stress_wide.Rdata"))

stress.wide <- zap_labels(stress.wide)
stress.wide <- zap_label(stress.wide)

load(here("1_Data_Files/Datasets/stress_wide2.Rdata"))
load(here("1_Data_Files/Datasets/stress_wide3.Rdata"))
load(here("1_Data_Files/Datasets/stress_wide4.Rdata"))
load(here("1_Data_Files/Datasets/stress_long.Rdata"))

#load change brms model fits 
# criminal intent
chg.prjcrime.stmony.fit <- readRDS(here("Models/chg_prjcrime_stmony_fit.rds"))
chg.prjcrime.sttran.fit <- readRDS(here("Models/chg_prjcrime_sttran_fit.rds"))
chg.prjcrime.stresp.fit <- readRDS(here("Models/chg_prjcrime_stresp_fit.rds"))
chg.prjcrime.stfair.fit <- readRDS(here("Models/chg_prjcrime_stfair_fit.rds"))
chg.prjcrime.stjob.fit <- readRDS(here("Models/chg_prjcrime_stjob_fit.rds"))
chg.prjcrime.stthft.fit <- readRDS(here("Models/chg_prjcrime_stthft_fit.rds"))
chg.prjcrime.stmug.fit <- readRDS(here("Models/chg_prjcrime_stmug_fit.rds"))
chg.anyprjcrime.stmony.fit <- readRDS(here("Models/chg_anyprjcrime_stmony_fit.rds"))
chg.anyprjcrime.sttran.fit <- readRDS(here("Models/chg_anyprjcrime_sttran_fit.rds"))
chg.anyprjcrime.stresp.fit <- readRDS(here("Models/chg_anyprjcrime_stresp_fit.rds"))
chg.anyprjcrime.stfair.fit <- readRDS(here("Models/chg_anyprjcrime_stfair_fit.rds"))
chg.anyprjcrime.stjob.fit <- readRDS(here("Models/chg_anyprjcrime_stjob_fit.rds"))
chg.anyprjcrime.stthft.fit <- readRDS(here("Models/chg_anyprjcrime_stthft_fit.rds"))
chg.anyprjcrime.stmug.fit <- readRDS(here("Models/chg_anyprjcrime_stmug_fit.rds"))
# negative emotions
chg.alldepress.stmony.fit <- readRDS(here("Models/chg_alldepress_stmony_fit.rds"))
chg.alldepress.sttran.fit <- readRDS(here("Models/chg_alldepress_sttran_fit.rds"))
chg.alldepress.stresp.fit <- readRDS(here("Models/chg_alldepress_stresp_fit.rds"))
chg.alldepress.stfair.fit <- readRDS(here("Models/chg_alldepress_stfair_fit.rds"))
chg.alldepress.stjob.fit <- readRDS(here("Models/chg_alldepress_stjob_fit.rds"))
chg.alldepress.stthft.fit <- readRDS(here("Models/chg_alldepress_stthft_fit.rds"))
chg.alldepress.stmug.fit <- readRDS(here("Models/chg_alldepress_stmug_fit.rds"))

#T1 posterior PLME contrasts
load(here("1_Data_Files/Datasets/twodif_combineddvs3.Rdata"))
load(here("1_Data_Files/Datasets/twodif_combinedprj3.Rdata"))
load(here("1_Data_Files/Datasets/twodif_combineddep3.Rdata"))
# mfx <- marginaleffects(chg.prjcrime.stmony.fit)
# summary(mfx)
  # https://vincentarelbundock.github.io/marginaleffects/articles/brms.html
  # ordinal models not (yet) supported. see: 
  # https://stackoverflow.com/questions/71333702/calculate-marginal-effects-for-ordinalclmm


# emfx.prjstmony <- chg.prjcrime.stmony.fit %>%
#   emmeans(~ stmony_devx2 | rep.meas,
#           at = list(stmony_av12x2 = c(2,3,4,5,6,7,8,9,10)),
#           epred = TRUE) %>% 
#   contrast(method = "pairwise")
# emfx.prjstmony.draws <- emfx.prjstmony %>% gather_emmeans_draws()
  # emmeans also does not appear to be working as desired w/ or w/out contrasts


# Solution from combining following two sources: 
# https://htmlpreview.github.io/?https://github.com/mjskay/uncertainty-examples/blob/master/marginal-effects_categorical-predictor.html#differences-in-ames
# https://www.andrewheiss.com/blog/2021/11/10/ame-bayes-re-guide/#average-marginal-effects

#Manually generate predictive margins data w/following generic structure:

# create new data grid for epred values
# newdata <- mylongdata %>%
#   data_grid(xdev, xbar, year) 
# 
# # generate epred draws (assuming two waves here)
# predmarg_data = epred_draws(mymodelfit,
#                 newdata = newdata,
#                 re_formula = NA) %>%
#   filter(xdev == -2 & year == 1 | 
#            xdev == 2 & year == 2) %>% 
#   group_by(.category, xdev, .draw) %>%      
#   summarise(`E[y|xdev]` = mean(`.epred`)) 

  # generating ave marginal effects ignoring person-level REs (global grand mean)  
  # see: https://www.andrewheiss.com/blog/2021/11/10/ame-bayes-re-guide/


# # calculate marginal effect contrasts
# margeff_contrast = predmarg_data %>% 
#   compare_levels(`E[y|xdev]`, by = xdev) %>%  # pairwise diffs in `E[y|x]`, by levels of x
#   rename(`difference in E[y|change in x (T2-T1)]` = `E[y|xdev]`) # more accurate column name

# create function to generate new data grid for epred values
gen_newdata <- function(mylongdata, xdev, xave){
  mylongdata %>%
  data_grid({{xdev}}, {{xave}}, year) 
}

# create function to generate epred draws 
  # keeping only 2-unit increases from year 1 to year 2 (contrast 2_t2 - -2_t1)
gen_predmarg_data <- function(mymodelfit, xdev){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  filter({{xdev}} == -2 & year == 1 | 
           {{xdev}} == 2 & year == 2) %>%
  group_by(.category, {{xdev}}, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`))
}

# generate epred draws 
newdata <- gen_newdata(stress.long, stmony_devx2, stmony_av12x2)
predmarg_stmony_prjcrim_chg = gen_predmarg_data(chg.prjcrime.stmony.fit, stmony_devx2)

newdata <- gen_newdata(stress.long, sttran_devx2, sttran_av12x2)
predmarg_sttran_prjcrim_chg = gen_predmarg_data(chg.prjcrime.sttran.fit, sttran_devx2)

newdata <- gen_newdata(stress.long, stresp_devx2, stresp_av12x2)
predmarg_stresp_prjcrim_chg = gen_predmarg_data(chg.prjcrime.stresp.fit, stresp_devx2)

newdata <- gen_newdata(stress.long, stfair_devx2, stfair_av12x2)
predmarg_stfair_prjcrim_chg = gen_predmarg_data(chg.prjcrime.stfair.fit, stfair_devx2)

newdata <- gen_newdata(stress.long, stjob_devx2, stjob_av12x2)
predmarg_stjob_prjcrim_chg = gen_predmarg_data(chg.prjcrime.stjob.fit, stjob_devx2)

newdata <- gen_newdata(stress.long, stthft_devx2, stthft_av12x2)
predmarg_stthft_prjcrim_chg = gen_predmarg_data(chg.prjcrime.stthft.fit, stthft_devx2)

newdata <- gen_newdata(stress.long, stmug_devx2, stmug_av12x2)
predmarg_stmug_prjcrim_chg = gen_predmarg_data(chg.prjcrime.stmug.fit, stmug_devx2)


# create function to generate epred draws from "any crim intent" models 
  # keeping only 2-unit increases from year 1 to year 2 (contrast 2_t2 - -2_t1)
gen_predmarg_data <- function(mymodelfit, xdev){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  filter({{xdev}} == -2 & year == 1 | 
           {{xdev}} == 2 & year == 2) %>%
  group_by({{xdev}}, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`)) %>%
  ungroup() %>%
  mutate(.category="prjany")
}
# generate "any" epred data & merge with individual outcome item epred data
newdata <- gen_newdata(stress.long, stmony_devx2, stmony_av12x2) 
predmarg_stmony_anyprjcrim_chg = gen_predmarg_data(chg.anyprjcrime.stmony.fit, stmony_devx2) 
predmarg_stmony_prjcrim_chg <- bind_rows(predmarg_stmony_prjcrim_chg, 
                                        predmarg_stmony_anyprjcrim_chg)
rm(predmarg_stmony_anyprjcrim_chg) #clean environment

newdata <- gen_newdata(stress.long, sttran_devx2, sttran_av12x2) 
predmarg_sttran_anyprjcrim_chg = gen_predmarg_data(chg.anyprjcrime.sttran.fit, sttran_devx2) 
predmarg_sttran_prjcrim_chg <- bind_rows(predmarg_sttran_prjcrim_chg, 
                                        predmarg_sttran_anyprjcrim_chg)
rm(predmarg_sttran_anyprjcrim_chg) #clean environment

newdata <- gen_newdata(stress.long, stresp_devx2, stresp_av12x2) 
predmarg_stresp_anyprjcrim_chg = gen_predmarg_data(chg.anyprjcrime.stresp.fit, stresp_devx2) 
predmarg_stresp_prjcrim_chg <- bind_rows(predmarg_stresp_prjcrim_chg, 
                                        predmarg_stresp_anyprjcrim_chg)
rm(predmarg_stresp_anyprjcrim_chg) #clean environment

newdata <- gen_newdata(stress.long, stfair_devx2, stfair_av12x2) 
predmarg_stfair_anyprjcrim_chg = gen_predmarg_data(chg.anyprjcrime.stfair.fit, stfair_devx2) 
predmarg_stfair_prjcrim_chg <- bind_rows(predmarg_stfair_prjcrim_chg, 
                                        predmarg_stfair_anyprjcrim_chg)
rm(predmarg_stfair_anyprjcrim_chg) #clean environment

newdata <- gen_newdata(stress.long, stjob_devx2, stjob_av12x2) 
predmarg_stjob_anyprjcrim_chg = gen_predmarg_data(chg.anyprjcrime.stjob.fit, stjob_devx2) 
predmarg_stjob_prjcrim_chg <- bind_rows(predmarg_stjob_prjcrim_chg, 
                                        predmarg_stjob_anyprjcrim_chg)
rm(predmarg_stjob_anyprjcrim_chg) #clean environment

newdata <- gen_newdata(stress.long, stthft_devx2, stthft_av12x2) 
predmarg_stthft_anyprjcrim_chg = gen_predmarg_data(chg.anyprjcrime.stthft.fit, stthft_devx2) 
predmarg_stthft_prjcrim_chg <- bind_rows(predmarg_stthft_prjcrim_chg, 
                                        predmarg_stthft_anyprjcrim_chg)
rm(predmarg_stthft_anyprjcrim_chg) #clean environment

newdata <- gen_newdata(stress.long, stmug_devx2, stmug_av12x2) 
predmarg_stmug_anyprjcrim_chg = gen_predmarg_data(chg.anyprjcrime.stmug.fit, stmug_devx2) 
predmarg_stmug_prjcrim_chg <- bind_rows(predmarg_stmug_prjcrim_chg, 
                                        predmarg_stmug_anyprjcrim_chg)
rm(predmarg_stmug_anyprjcrim_chg) #clean environment


  
#function to calculate mean difference contrasts (marginal effect contrast) 
calc_ME_chg <- function(predmarg_data, xdev) {
  predmarg_data %>%
    compare_levels(`E[y|xdev]`, by = xdev) %>%  # pairwise diffs in `E[y|x]`, by levels of x
    rename(`PLME2chg` = `E[y|xdev]`) # easy colname reflecting ME 2-unit chg contrast 
}

#outputs predicted difference in E[y] associated with 2-Likert category increase in stress (T2-T1) 
  #marg effect contrasts are marginalized over all person-level avg values of stress (AME)

#generate ME contrasts
PLME2_stmony_prjcrim_chg = xfun::cache_rds({calc_ME_chg(predmarg_stmony_prjcrim_chg, "stmony_devx2") %>%
      mutate(stress_var = "Stress:\nMoney",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stmony_devx2)}, file="cache_6_1")
PLME2_sttran_prjcrim_chg = xfun::cache_rds({calc_ME_chg(predmarg_sttran_prjcrim_chg, "sttran_devx2") %>%
      mutate(stress_var = "Stress:\nTransport",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = sttran_devx2)}, file="cache_6_2")
PLME2_stresp_prjcrim_chg = xfun::cache_rds({calc_ME_chg(predmarg_stresp_prjcrim_chg, "stresp_devx2") %>%
      mutate(stress_var = "Stress:\nRespect",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stresp_devx2)}, file="cache_6_3")
PLME2_stfair_prjcrim_chg = xfun::cache_rds({calc_ME_chg(predmarg_stfair_prjcrim_chg, "stfair_devx2") %>%
      mutate(stress_var = "Stress:\nFair Trtmt",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stfair_devx2)}, file="cache_6_4")
PLME2_stjob_prjcrim_chg = xfun::cache_rds({calc_ME_chg(predmarg_stjob_prjcrim_chg, "stjob_devx2") %>%
      mutate(stress_var = "Stress:\nJob",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stjob_devx2)}, file="cache_6_5")
PLME2_stthft_prjcrim_chg = xfun::cache_rds({calc_ME_chg(predmarg_stthft_prjcrim_chg, "stthft_devx2") %>%
      mutate(stress_var = "Stress:\nTheft Vctm",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stthft_devx2)}, file="cache_6_6")
PLME2_stmug_prjcrim_chg = xfun::cache_rds({calc_ME_chg(predmarg_stmug_prjcrim_chg, "stmug_devx2") %>%
      mutate(stress_var = "Stress:\nAssault Vctm",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stmug_devx2)}, file="cache_6_7")

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
PLME2_combinedprjchg <- bind_rows(
  PLME2_stmony_prjcrim_chg,
  PLME2_sttran_prjcrim_chg,
  PLME2_stresp_prjcrim_chg,
  PLME2_stfair_prjcrim_chg,
  PLME2_stjob_prjcrim_chg,
  PLME2_stthft_prjcrim_chg,
  PLME2_stmug_prjcrim_chg) %>% 
  mutate (stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nAssault Vctm",
                                    "Stress:\nTheft Vctm", 
                                    "Stress:\nJob",
                                    "Stress:\nFair Trtmt",
                                    "Stress:\nRespect",
                                    "Stress:\nTransport",
                                    "Stress:\nMoney")
                           )
          )

7.2 Supp. Figure 3A: PLME Stress Chg/Prj Crime

#function to find & drop leading zeroes (used for x-axis label)
dropLeadingZero <- function(l){
  str_replace(l, '0(?=.)', '')
}

#calculate row & col averages of P(diff in E[y|stress change]) > 0 

#Rows: P(mean_twodif | Stress item) > 0
  #aka P(PLME>0|stress)

# View marginal probabilities
# PLME2_combinedprjchg %>%
#   group_by(stress_varf) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(`PLME2chg`>0),
#             p_gt0 = n_gt0 / n_ests) 

  # Stress:\nMoney  0.62
  # Stress:\nTransport  0.30    
  # Stress:\nRespect    0.09
  # Stress:\nFair Trtmt 0.34    
  # Stress:\nJob    0.49
  # Stress:\nTheft Vctm 0.20    
  # Stress:\nAssault Vctm   0.42

#Cols: P(mean_twodif | Crime item) > 0
  #aka P(PLME>0|crime)

#View marginal probabilities
# PLME2_combinedprjchg %>%
#   group_by(.category) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(`PLME2chg`>0),
#             p_gt0 = n_gt0 / n_ests) 

    # prjthflt5 0.45    
    # prjthfgt5 0.57    
    # prjthreat 0.18
    # prjharm   0.19
    # prjusedrg 0.24    
    # prjhack   0.30
    # prjany 0.55

#Add these posterior probabilities into variable name

prjcrimelabsPchg <- c(
  "prjthflt5"="Theft <5BAM\nP(ME>0|col)\n=.45", 
  "prjthfgt5"="Theft >5BAM\nP(ME>0|col)\n=.57", 
  "prjthreat"="Threaten\nP(ME>0|col)\n=.18", 
  "prjharm"="Phys. harm\nP(ME>0|col)\n=.19",
  "prjusedrg"="Use drugs\nP(ME>0|col)\n=.24",
  "prjhack"="Hack info.\nP(ME>0|col)\n=.30", 
  "prjany"="Any crime\nP(ME>0|col)\n=.55")
stress_varlabsPchg <- c(
  "Stress:\nMoney" = "Stress: Money\nP(ME>0|row)\n=.62",
  "Stress:\nTransport" = "Stress: Transport\nP(ME>0|row)\n=.30",
  "Stress:\nRespect" = "Stress: Respect\nP(ME>0|row)=.09",
  "Stress:\nFair Trtmt" = "Stress: Fair Trtmt\nP(ME>0|row)\n=.34",
  "Stress:\nJob" = "Stress: Job\nP(ME>0|row)\n=0.49",
  "Stress:\nTheft Vctm" = "Stress: Theft\nP(ME>0|row)\n=0.20",
  "Stress:\nAssault Vctm"   = "Stress: Assault\nP(ME>0|row)\n=0.43")


#First, add p_gt0 variable used above to each stress/item combo in data (i.e. to each plot)
#Create alpha_scale variable =1 if p_gt0 < 0 (i.e., to be fully opaque) & =p_gt0 if p_gt0 > 1
PLME2_combinedprjchg <- PLME2_combinedprjchg %>%
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(`PLME2chg`>0),
         p_gt0 = n_gt0 / n_ests,
         gt0 = ifelse(`PLME2chg`>0, 1, 0),
         alpha_scale = ifelse(`PLME2chg` <=0, 1, p_gt0), 
         rural.ses.med = as.factor("0")) %>% #add to combine figures 3 & 4 later
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5", "prjthfgt5", "prjthreat",
                                "prjharm", "prjusedrg", "prjhack", 
                                "prjany"))
  )
  

#Using sequential color palette (scio = lajolla)
#Also using ggnewscale to add multiple fill palettes
SuppFigure3A <- ggplot(data = PLME2_combinedprjchg, mapping = aes(x = `PLME2chg`, y = stress_varf)) + 
  facet_wrap(~.category, nrow=1, 
             labeller = labeller(.category= as_labeller(prjcrimelabsPchg))) +
  stat_slab(mapping = aes(fill = p_gt0), .width = .95) +
 scale_fill_scico(palette = "lajolla", begin = .8, end = .3, #tells it where to start and end palette
                   name = "P(PLME > 0)", breaks = c(.1, .5, .9), labels = dropLeadingZero) + 
   new_scale_fill() + #from ggnewscale
  stat_halfeye(mapping = aes(fill = stat(x > 0)), .width = .95, show.legend=FALSE) + 
  scale_fill_manual(values = c("grey80", "NA")) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  # xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.03,.03)) +
  scale_x_continuous(breaks=c(-.02,0,.02), labels = dropLeadingZero) +
  xlab("Posterior Predicted Difference in E[y|stress increase]") + 
  scale_y_discrete(labels=stress_varlabsPchg) + 
  labs(
    title = 'SUPPLEMENTAL FIGURE 3A\nMarginal Effect of 2-Category Increase in Stress on Criminal Intent from T1 to T2, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves. "PLME" refers to "Practically Large Marginal Effect" of 2-category increase in stress on outcome. Darker shaded regions indicate larger\nproportion of posterior effect estimates are greater than zero (positive effect is more probable); grey shading indicates portion of posterior distribution of effect estimates equal to or less than zero.') + 
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        strip.background = element_blank(),
        axis.text.y = element_text(size=10),
        strip.text.x = element_text(size=10),
        plot.title = element_text(size=12, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        plot.title.position = "plot", 
        plot.caption.position =  "plot") 
SuppFigure3A

#Export to image
ggsave("SuppFigure3A.jpeg", width=9, height=6.5, path=here("Output"))

Compared to the T1 marginal contrasts for criminal intent, which were quite small themselves, the marginal contrasts comparing estimated changes in predicted outcome probabilities associated with a two-unit increase in stress from T1 to T2 are extremely small, with most point estimates to the left of zero. Let’s turn to computing and visualizing the negative emotions change contrasts.

7.2.1 Predictive Marginal Contrasts (Negative Emotions)

# create function to generate new data grid for epred values
gen_newdata <- function(mylongdata, xdev, xave){
  mylongdata %>%
  data_grid({{xdev}}, {{xave}}, year) 
}

# create function to generate epred draws 
  # keeping only 2-unit increases from year 1 to year 2 (contrast 2_t2 - -2_t1)
gen_predmarg_data <- function(mymodelfit, xdev){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  filter({{xdev}} == -2 & year == 1 | 
           {{xdev}} == 2 & year == 2) %>%
  group_by(.category, {{xdev}}, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`))
}

# generate epred draws using gen_newdata & gen_predmarg_data function
newdata <- gen_newdata(stress.long, stmony_devx2, stmony_av12x2)
predmarg_stmony_dep_chg = gen_predmarg_data(chg.alldepress.stmony.fit, stmony_devx2)

newdata <- gen_newdata(stress.long, sttran_devx2, sttran_av12x2)
predmarg_sttran_dep_chg = gen_predmarg_data(chg.alldepress.sttran.fit, sttran_devx2)

newdata <- gen_newdata(stress.long, stresp_devx2, stresp_av12x2)
predmarg_stresp_dep_chg = gen_predmarg_data(chg.alldepress.stresp.fit, stresp_devx2)

newdata <- gen_newdata(stress.long, stfair_devx2, stfair_av12x2)
predmarg_stfair_dep_chg = gen_predmarg_data(chg.alldepress.stfair.fit, stfair_devx2)

newdata <- gen_newdata(stress.long, stjob_devx2, stjob_av12x2)
predmarg_stjob_dep_chg = gen_predmarg_data(chg.alldepress.stjob.fit, stjob_devx2)

newdata <- gen_newdata(stress.long, stthft_devx2, stthft_av12x2)
predmarg_stthft_dep_chg = gen_predmarg_data(chg.alldepress.stthft.fit, stthft_devx2)

newdata <- gen_newdata(stress.long, stmug_devx2, stmug_av12x2)
predmarg_stmug_dep_chg = gen_predmarg_data(chg.alldepress.stmug.fit, stmug_devx2)

#outputs predicted difference in E[y] associated with 2-Likert category increase in stress (T2-T1) 
  #marg effect contrasts are marginalized over all person-level avg values of stress (AME)

#generate ME contrasts using calc_ME_chg function
PLME2_stmony_dep_chg = xfun::cache_rds({calc_ME_chg(predmarg_stmony_dep_chg, "stmony_devx2") %>%
      mutate(stress_var = "Stress:\nMoney",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stmony_devx2)}, file="cache_6_8")
PLME2_sttran_dep_chg = xfun::cache_rds({calc_ME_chg(predmarg_sttran_dep_chg, "sttran_devx2") %>%
      mutate(stress_var = "Stress:\nTransport",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = sttran_devx2)}, file="cache_6_9")
PLME2_stresp_dep_chg = xfun::cache_rds({calc_ME_chg(predmarg_stresp_dep_chg, "stresp_devx2") %>%
      mutate(stress_var = "Stress:\nRespect",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stresp_devx2)}, file="cache_6_10")
PLME2_stfair_dep_chg = xfun::cache_rds({calc_ME_chg(predmarg_stfair_dep_chg, "stfair_devx2") %>%
      mutate(stress_var = "Stress:\nFair Trtmt",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stfair_devx2)}, file="cache_6_11")
PLME2_stjob_dep_chg = xfun::cache_rds({calc_ME_chg(predmarg_stjob_dep_chg, "stjob_devx2") %>%
      mutate(stress_var = "Stress:\nJob",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stjob_devx2)}, file="cache_6_12")
PLME2_stthft_dep_chg = xfun::cache_rds({calc_ME_chg(predmarg_stthft_dep_chg, "stthft_devx2") %>%
      mutate(stress_var = "Stress:\nTheft Vctm",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stthft_devx2)}, file="cache_6_13")
PLME2_stmug_dep_chg = xfun::cache_rds({calc_ME_chg(predmarg_stmug_dep_chg, "stmug_devx2") %>%
      mutate(stress_var = "Stress:\nAssault Vctm",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stmug_devx2)}, file="cache_6_14")

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
PLME2_combineddepchg <- bind_rows(
  PLME2_stmony_dep_chg,
  PLME2_sttran_dep_chg,
  PLME2_stresp_dep_chg,
  PLME2_stfair_dep_chg,
  PLME2_stjob_dep_chg,
  PLME2_stthft_dep_chg,
  PLME2_stmug_dep_chg) %>% 
  mutate (stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nAssault Vctm",
                                    "Stress:\nTheft Vctm", 
                                    "Stress:\nJob",
                                    "Stress:\nFair Trtmt",
                                    "Stress:\nRespect",
                                    "Stress:\nTransport",
                                    "Stress:\nMoney")
                           )
          )

7.3 Supp. Figure 3B: PLME Stress Chg/Neg Emotions

#calculate row & col averages of P(diff in E[y|stress change]) > 0 

#Rows: P(mean_twodif | Stress item) > 0
  #aka P(PLME>0|stress)

#View marginal probabilities
# PLME2_combineddepchg %>%
#   group_by(stress_varf) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(`PLME2chg`>0),
#             p_gt0 = n_gt0 / n_ests) 

  # Stress:\nMoney  0.78
  # Stress:\nTransport  0.69    
  # Stress:\nRespect    0.76
  # Stress:\nFair Trtmt 0.89    
  # Stress:\nJob    0.77
  # Stress:\nTheft Vctm 0.93    
  # Stress:\nAssault Vctm   0.68

#Cols: P(mean_twodif | Crime item) > 0
  #aka P(PLME>0|crime)

#View marginal probabilities
# PLME2_combineddepchg %>%
#   group_by(.category) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(`PLME2chg`>0),
#             p_gt0 = n_gt0 / n_ests) 

# depcantgo     0.94    
# depeffort     0.81    
# deplonely     0.88    
# depblues      0.37    
# depunfair     0.94    
# depmistrt     0.74    
# depbetray     0.81    

#Add these posterior probabilities into variable name

depresslabsPchg <- c(
  "depcantgo"="Can't go\nP(ME>0|col)\n=.94", 
  "depeffort"="Effort\nP(ME>0|col)\n=.81", 
  "deplonely"="Lonely\nP(ME>0|col)\n=.88", 
  "depblues"="Blues\nP(ME>0|col)\n=.37",
  "depunfair"="Unfair\nP(ME>0|col)\n=.94",
  "depmistrt"="Mistreated\nP(ME>0|col)\n=.74",
  "depbetray"="Betrayed\nP(ME>0|col)\n=.81")
stress_varlabsPchg <- c(
  "Stress:\nMoney" = "Stress: Money\nP(ME>0|row)\n=.78",
  "Stress:\nTransport" = "Stress: Transport\nP(ME>0|row)\n=.69",
  "Stress:\nRespect" = "Stress: Respect\nP(ME>0|row)=.76",
  "Stress:\nFair Trtmt" = "Stress: Fair Trtmt\nP(ME>0|row)\n=.89",
  "Stress:\nJob" = "Stress: Job\nP(ME>0|row)\n=0.77",
  "Stress:\nTheft Vctm" = "Stress: Theft\nP(ME>0|row)\n=0.93",
  "Stress:\nAssault Vctm"   = "Stress: Assault\nP(ME>0|row)\n=0.68")


#First, add p_gt0 variable used above to each stress/item combo in data (i.e. to each plot)
#Create alpha_scale variable =1 if p_gt0 < 0 (i.e., to be fully opaque) & =p_gt0 if p_gt0 > 1
PLME2_combineddepchg <- PLME2_combineddepchg %>%
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(`PLME2chg`>0),
         p_gt0 = n_gt0 / n_ests,
         gt0 = ifelse(`PLME2chg`>0, 1, 0),
         alpha_scale = ifelse(`PLME2chg` <=0, 1, p_gt0), 
         rural.ses.med = as.factor("0")) #add to combine figures 3 & 4 later

#Using sequential color palette (scio = lajolla)
#Also using ggnewscale to add multiple fill palettes
SuppFigure3B <- ggplot(data = PLME2_combineddepchg, mapping = aes(x = `PLME2chg`, y = stress_varf)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category= as_labeller(depresslabsPchg))) +
  stat_slab(mapping = aes(fill = p_gt0), .width = .95) +
 scale_fill_scico(palette = "lajolla", begin = .8, end = .3, #tells it where to start and end palette
                   name = "P(PLME > 0)", breaks = c(.1, .5, .9), labels = dropLeadingZero) + 
  new_scale_fill() + #from ggnewscale
  stat_halfeye(mapping = aes(fill = stat(x > 0)), .width = .95, show.legend=FALSE) + 
  scale_fill_manual(values = c("grey80", "NA")) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  # xlim(-.5, .5) +
  coord_cartesian(xlim=c(-.4,.4)) + 
  scale_x_continuous(breaks=c(-.3,0,.3)) +
  xlab("Posterior Predicted Difference in E[y|stress increase]") + 
  scale_y_discrete(labels=stress_varlabsPchg) +
  labs(
    title = 'SUPPLEMENTAL FIGURE 3B\nMarginal Effect of 2-Category Increase in Stress on Negative Emotions from T1 to T2, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves. "PLME" refers to "Practically Large Marginal Effect" of 2-category increase in stress on outcome. Darker shaded regions indicate larger\nproportion of posterior effect estimates are greater than zero (positive effect is more probable); grey shading indicates portion of posterior distribution of effect estimates equal to or less than zero.') + 
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        axis.text.y = element_text(size=10),
        strip.text.x = element_text(size=10),
        strip.background = element_blank(),
        plot.title = element_text(size=12, face="bold"),
        plot.caption = element_text(size=8, hjust = 0),
        plot.title.position = "plot", 
        plot.caption.position =  "plot") 
SuppFigure3B

  # Note - had to widen x-axis scale relative to T1 (larger magnitudes, wider dists) 

#Export to image
ggsave("SuppFigure3B.jpeg", width=9, height=6.5, path=here("Output"))

7.4 Supp. Figure 3X: “Stacked” PLME Stress/Outcomes T2-T1

#collapse outcomes & stress_vars
tempdata <- PLME2_combinedprjchg %>% 
  dplyr::filter(.category != "prjany")
twodif_combineddvs_chg <- 
  rbind(tempdata, PLME2_combineddepchg) %>%
  mutate(
    .category = forcats::fct_collapse(.category,
      "prjtheft" = c("prjthflt5", "prjthfgt5"),
      "prjviol" = c("prjthreat", "prjharm"),
      "prjusedrg" = "prjusedrg",
      "prjhack" = "prjhack",
      "depsym" = c("depcantgo", "depeffort", "deplonely", "depblues"),
      "negemo" = c("depunfair", "depmistrt", "depbetray")), 
    stress_var = if_else(stress_var %in% c("Stress:\nMoney", "Stress:\nTransport"), 
                         "Stress:\nFinancial", stress_var), 
    stress_var = if_else(stress_var %in% c("Stress:\nRespect", "Stress:\nFair Trtmt"), 
                         "Stress:\nRelational", stress_var),
    stress_var = if_else(stress_var %in% c("Stress:\nTheft Vctm", "Stress:\nAssault Vctm"), 
                         "Stress:\nCrime Vctm", stress_var), 
    stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nCrime Vctm",
                                    "Stress:\nJob",
                                    "Stress:\nRelational",
                                    "Stress:\nFinancial"))
    )  %>%
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME2chg>0),
         p_gt0 = n_gt0 / n_ests,
         gt0 = ifelse(PLME2chg>0, 1, 0),
         alpha_scale = ifelse(PLME2chg <=0, 1, p_gt0), 
         rural.ses.med = as.factor("0"))


#calculate row & col averages of P(mean_twodif) > 0 

#Rows: P(mean_twodif | Stress item) > 0
  #aka P(PLME>0|stress)

#View marginal probabilities
# twodif_combineddvs_chg %>%
#   group_by(stress_varf) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(PLME2chg>0),
#             p_gt0 = n_gt0 / n_ests) 

# Stress:\nCrime Vctm   0.57    
# Stress:\nJob  24000   0.62    
# Stress:\nRelational   0.53    
# Stress:\nFinancial    0.58    

#Cols: P(mean_twodif | Crime item) > 0
  #aka P(PLME>0|crime)

#View marginal probabilities
# twodif_combineddvs_chg %>%
#   group_by(.category) %>%
#   summarise(n_ests = n(),
#             n_gt0 = sum(PLME2chg>0),
#             p_gt0 = n_gt0 / n_ests) 

# prjtheft  0.51    
# prjviol       0.18    
# prjusedrg 0.24    
# prjhack   0.30    
# depsym    0.75    
# negemo    0.83    

#Add these posterior probabilities into variable name

outcomelabsPchg <- c(
  "prjtheft"="Theft\nIntent\nP(ME>0|col)\n=.51", 
  "prjviol"="Violence\nIntent\nP(ME>0|col)\n=.18", 
  "prjusedrg"="Use drugs\nIntent\nP(ME>0|col)\n=.24", 
  "prjhack"="Hack info.\nIntent\nP(ME>0|col)\n=.30",
  "depsym"="Depressive\nSymptoms\nP(ME>0|col)\n=.75",
  "negemo"="Criminogenic\nEmotions\nP(ME>0|col)\n=.83")
stress_varlabsPchg <- c(
  "Stress:\nFinancial" = "Stress: Financial\nP(ME>0|row)\n=.58",
  "Stress:\nRelational" = "Stress: Personal\nP(ME>0|row)\n=.53",
  "Stress:\nJob" = "Stress: Job\nP(ME>0|row)\n=0.62",
  "Stress:\nCrime Vctm" = "Stress: Crime Vctm\nP(ME>0|row)\n=0.57")


SuppFigure3X <- ggplot(data = twodif_combineddvs_chg, mapping = aes(x = PLME2chg, y = stress_varf)) + 
  facet_wrap(~.category, nrow=1, scales="free_x", 
             labeller = labeller(.category= as_labeller(outcomelabsPchg))) +
  stat_slab(color = "#883E3A", fill = NA, normalize="panels", height=.5) + 
  stat_slab(fill = "#883E3A", alpha=.1, normalize="panels", height=.5) +
  stat_pointinterval(width = .95, color = "#883E3A", 
                     position=position_dodge(width=.2, preserve = "single")) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlab("Posterior Predicted Difference in E[y|stress increase]") + 
  scale_y_discrete(labels=stress_varlabsPchg) +
  facetted_pos_scales(
    x = list(
      .category %in% c("prjtheft", "prjviol", "prjusedrg") ~
        scale_x_continuous(breaks=c(-.01,0,.01), 
                           limits=c(-.02,.011), labels = dropLeadingZero),
      .category == "prjhack" ~
        scale_x_continuous(breaks=c(-.04,0,.04), 
                           limits=c(-.06,.041), labels = dropLeadingZero),
      .category %in% c("depsym", "negemo") ~
        scale_x_continuous(breaks=c(-.3,0,.3), 
                           limits=c(-.5,.5), labels = dropLeadingZero)
    ) ) +
  labs(
    title = 'SUPPLEMENTAL FIGURE 3X\n"Stacked" Marginal Effects of 2-Category Stress Increase on Change in Outcome Probabilities from T1 to T2, Full Sample',
    #subtitle = 'Subtitle here',
    caption = 'Note: N=489 respondents participating at both survey waves. Estimates derived from 14 multivariate Bayesian logistic regression models, with each of seven \ncombined criminal intent outcomes (using `brms::mvbind()`) and each of seven combined negative emotion outcomes separately specifying a single T1 stress \ntypes as a predictor. Stress items were separated into a cross-time average (Xbar_i) between-person L2 predictor and a within-person change (X_it - Xbar_i) \n"fixed effects" estimator. Both stress predictors were specified as monotonic ordinal predictors with a cumulative probit link function. Models were estimated \nin brms with 4 chains and 4000 total post-warmup posterior draws. Practically Large Marginal Effect (PLME) parameter distributions were first estimated \nfrom the expectation of the posterior predictive distribution for each model as predicted probability difference distributions for 2-category stress increase \ncontrasts from T1 to T2 for each bivariate item pair. The final displayed PLME posterior parameter estimate distributions were then generated by "stacking" \n(with equal model weights) to generate average posterior PLME estimates across models with conceptually similar outcome (e.g., Depressive Symptoms) and \nstress (e.g., Financial) item groupings') + 
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        strip.background = element_blank(),
        axis.text.y = element_text(size=10),
        strip.text.x = element_text(size=10),
        plot.title = element_text(size=12, face="bold"),
        plot.caption = element_text(size=8, hjust = 0),
        plot.title.position = "plot", 
        plot.caption.position =  "plot") 
SuppFigure3X 

#Export to image
# ggsave("SuppFigure3X.jpeg", width=9, height=6.5, path=here("Output"))

7.5 Supp. Figure 3XX: “Stacked” PLME Combined Stress/Outcomes T1 vs Change

#wrangle PLME T2-T1 change estimates
PLME2chg <- twodif_combineddvs_chg %>% 
  rename(PLME = PLME2chg) %>%
  mutate(
    method=as.factor("chg"), 
    dif_label='diff in E[y|2-cat stress diff/increase]'
  ) %>% 
  dplyr::select(-c(n_ests,gt0,n_gt0,p_gt0,alpha_scale, contrast))

#wrangle PLME T1 difference estimates
PLME2T1 <- twodif_combineddvs3 %>% 
  rename(PLME = mean_twodif) %>%
  mutate(
    method=as.factor("T1"), 
    dif_label='diff in E[y|2-cat stress diff/increase]', 
    .category = forcats::fct_recode(.category, 
                                    "prjtheft" = "prjtheftw1",
                                    "prjviol" = "prjviolw1",
                                    "prjusedrg" = "prjusedrgw1f",
                                    "prjhack" = "prjhackw1f",
                                    "depsym" = "depsymw1",
                                    "negemo" = "negemow1"
                                    ) 
    ) %>%
  dplyr::select(-c(.chain,.iteration,n_ests,gt0,n_gt0,p_gt0,alpha_scale))


#merge change & T1 estimates (method var indicates which data group)
twodif_compare <- bind_rows(PLME2chg, PLME2T1)
  
outcomelabs <- c(
  "prjtheft"="Theft\nIntent", 
  "prjviol"="Violence\nIntent", 
  "prjusedrg"="Use drugs\nIntent", 
  "prjhack"="Hack info.\nIntent",
  "depsym"="Depressive\nSymptoms",
  "negemo"="Criminogenic\nEmotions")
stress_varlabs <- c(
  "Stress:\nFinancial" = "Stress:\nFinancial",
  "Stress:\nRelational" = "Stress:\nPersonal",
  "Stress:\nJob" = "Stress:\nJob",
  "Stress:\nCrime Vctm" = "Stress:\nCrime Vctm")


SuppFigure3XX <- ggplot(data = PLME2chg, mapping = aes(x = PLME, y = stress_varf)) + 
  facet_wrap(~.category, nrow=1, scales="free_x", 
             labeller = labeller(.category= as_labeller(outcomelabs))) +
  # stat_slab(data=PLME2chg, aes(x=PLME, y=stress_varf), color="#883E3A", 
  #           fill = NA, normalize="panels", height=.5) + 
  # stat_slab(data=PLME2chg, aes(x=PLME, y=stress_varf), color=NA, 
  #           fill = "#883E3A", alpha=.1, normalize="panels", height=.5) + 
  # stat_slab(data=PLME2T1, aes(x=PLME, y=stress_varf), color="#E99D53", 
  #           fill = NA, normalize="panels", height=.5) + 
  # stat_slab(data=PLME2T1, aes(x=PLME, y=stress_varf), color=NA, 
  #           fill = "#E99D53", alpha=.1, normalize="panels", height=.5) + 
  stat_pointinterval(data=PLME2chg, aes(x=PLME, y=stress_varf), color="#883E3A",
                     width = .95, position = position_nudge(y = -.1)) + 
  stat_pointinterval(data=PLME2T1, aes(x=PLME, y=stress_varf), color="#E99D53",
                     width = .95, position = position_nudge(y = .1)) + 
  geom_vline(xintercept = 0, linetype = "dashed") +
  xlab("Posterior Predicted Difference in E[y|stress increase]") + 
  scale_y_discrete(labels=stress_varlabs) +
  # facetted_pos_scales(
  #   x = list(
  #     .category %in% c("prjtheft", "prjviol", "prjusedrg") ~
  #       scale_x_continuous(breaks=c(-.01,0,.01), 
  #                          limits=c(-.02,.011), labels = dropLeadingZero),
  #     .category == "prjhack" ~
  #       scale_x_continuous(breaks=c(-.04,0,.04), 
  #                          limits=c(-.06,.041), labels = dropLeadingZero),
  #     .category %in% c("depsym", "negemo") ~
  #       scale_x_continuous(breaks=c(-.3,0,.3), 
  #                          limits=c(-.5,.5), labels = dropLeadingZero)
  #   ) ) +
  labs(
    title = 'SUPPLEMENTAL FIGURE 3XX\n"Stacked" Marginal Effects of 2-Category Stress Increase on Change in Outcome Probabilities from T1 to T2, Full Sample') + 
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        strip.background = element_blank(),
        axis.text.y = element_text(size=10),
        strip.text.x = element_text(size=10),
        plot.title = element_text(size=12, face="bold"),
        plot.caption = element_text(size=8, hjust = 0),
        plot.title.position = "plot", 
        plot.caption.position =  "plot") 
SuppFigure3XX 

#Export to image
# ggsave("SuppFigure3XX.jpeg", width=9, height=6.5, path=here("Output"))

Let’s move on from these exploratory stacked posterior plots and return to item-specific estimates. Rather than collapsing categories for the sake of plots that are easier to read, we will opt for more densely packed plots that contain far more information and that present more precise estimates of stress-outcome correlations in these data.

7.6 FIGURE 3: PLME Stress/Outcomes T1 vs Change

#wrangle PLME prj crime T1 difference estimates
PLMEprjT1 <- twodif_combinedprj3 %>% 
  rename(PLME = mean_twodif) %>% 
  mutate(
    method=as.factor("T1"), 
    dif_label='diff in E[y|2-cat stress diff/increase]', 
    .category = forcats::fct_recode(.category, 
                                    "prjthflt5" = "prjthflt5w1f",
                                    "prjthfgt5" = "prjthfgt5w1f",
                                    "prjthreat" = "prjthreatw1f",
                                    "prjharm" = "prjharmw1f",
                                    "prjusedrg" = "prjusedrgw1f",
                                    "prjhack" = "prjhackw1f", 
                                    "prjany" = "prjanyw1f"
                                    ),
    p80_gt0 = as.factor(if_else(p_gt0 >= .80, 1, 0))
    ) %>%
  dplyr::select(-c(.chain,.iteration))


#wrangle PLME neg emo T1 difference estimates
PLMEdepT1 <- twodif_combineddep3 %>% 
  rename(PLME = mean_twodif) %>% 
  mutate(
    method=as.factor("T1"), 
    dif_label='diff in E[y|2-cat stress diff/increase]', 
    .category = forcats::fct_recode(.category, 
                                    "depcantgo"="depcantgow1f",
                                    "depeffort"="depeffortw1f",
                                    "deplonely"="deplonelyw1f",
                                    "depblues"="depbluesw1f",
                                    "depunfair"="depunfairw1f",
                                    "depmistrt"="depmistrtw1f",
                                    "depbetray"="depbetrayw1f"
                                    ),
    p80_gt0 = as.factor(if_else(p_gt0 >= .80, 1, 0))
    ) %>%
  dplyr::select(-c(.chain,.iteration))


#wrangle PLME prj crime T2-T1 change estimates
PLMEprjchg <- PLME2_combinedprjchg %>% 
  rename(PLME = PLME2chg) %>%
  mutate(
    method=as.factor("chg"), 
    dif_label='diff in E[y|2-cat stress diff/increase]',
    p80_gt0 = as.factor(if_else(p_gt0 >= .80, 1, 0))
  ) %>% 
  dplyr::select(-c(contrast))

#wrangle PLME neg emo T2-T1 change estimates
PLMEdepchg <- PLME2_combineddepchg %>% 
  rename(PLME = PLME2chg) %>%
  mutate(
    method=as.factor("chg"), 
    dif_label='diff in E[y|2-cat stress diff/increase]', 
    p80_gt0 = as.factor(if_else(p_gt0 >= .80, 1, 0))
  ) %>% 
  dplyr::select(-c(contrast))



prjlabs <- c(
  "prjthflt5"="Theft <5BAM", 
  "prjthfgt5"="Theft >5BAM", 
  "prjthreat"="Threaten", 
  "prjharm"="Phys. harm",
  "prjusedrg"="Use drugs",
  "prjhack"="Hack info", 
  "prjany"="Any crime")
deplabs <- c(
  "depcantgo"="Can't go", 
  "depeffort"="Effort", 
  "deplonely"="Lonely", 
  "depblues"="Blues",
  "depunfair"="Unfair",
  "depmistrt"="Mistreated",
  "depbetray"="Betrayed")

methodlabs <- c(
  "T1"="Between-Person Difference (T1) Estimator", 
  "chg"="Within-Person Change (T2-T1)  \"Fixed Effects\" Estimator")

stress_varlabsalt <- c(
  "Stress:\nMoney" = "Money",
  "Stress:\nTransport" = "Transport",
  "Stress:\nRespect" = "Respect",
  "Stress:\nFair Trtmt" = "Fair Trtmt",
  "Stress:\nJob" = "Job",
  "Stress:\nTheft Vctm" = "Theft",
  "Stress:\nAssault Vctm"   = "Assault")
  
prjplotalt <- ggplot(data = PLMEprjT1, 
                       mapping = aes(x = PLME, 
                                     y = stress_varf,
                                     color = method)) + 
  facet_wrap(~.category, nrow=1, scales="free_x", 
             labeller = labeller(.category= as_labeller(prjlabs))) +
    geom_vline(xintercept = 0, linetype = "dashed", linewidth=.5, alpha=.4) +
  stat_pointinterval(data=PLMEprjT1, aes(x=PLME, y=stress_varf, 
                                alpha=p80_gt0),
                     # color="#E99D53", 
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  stat_pointinterval(data=PLMEprjchg, aes(x=PLME, y=stress_varf,
                                alpha=p80_gt0),
                     # color="#883E3A", 
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  scale_color_manual(values=c("#883E3A","#E99D53"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  # coord_cartesian(xlim=c(-.03,.11)) + 
  # scale_x_continuous(breaks=c(0,.05,.10), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  ylab("Stress Item:\n ") +
  # labs(subtitle=~underline("Criminal Intent")) +
  labs(subtitle="Criminal Intent") +
  scale_y_discrete(labels=stress_varlabsalt) +
  facetted_pos_scales(               # different x-axis scale for "any crime"
    x = list(
      .category == "prjany" ~ 
        scale_x_continuous(breaks=c(-.05,0,.05,.10,.15),  
                           limits = c(-.08,.16), labels = dropLeadingZero),
      .category != "prjany" ~
        scale_x_continuous(breaks=c(0,.05,.10),
                           limits = c(-.03,.11), labels = dropLeadingZero)
    ) ) +
  theme(axis.title.y = element_text(size=10, face="italic"), 
        legend.position = "bottom",
        strip.background = element_blank(),
        strip.text.x = element_text(size=10), 
        axis.text.y = element_text(size=10),
        plot.subtitle=element_text(size=10, hjust=0.5, face="italic"),
        legend.text = element_text(size = 10)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)),
               color = guide_legend(nrow=1, reverse = TRUE))



depplotalt <- ggplot(data = PLMEdepT1, 
                       mapping = aes(x = PLME, 
                                     y = stress_varf,
                                     color = method)) + 
  facet_wrap(~.category, nrow=1, scales="free_x", 
             labeller = labeller(.category= as_labeller(deplabs))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLMEdepT1, aes(x=PLME, y=stress_varf, 
                                         alpha=p80_gt0),
                     # color="#E99D53", 
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  stat_pointinterval(data=PLMEdepchg, aes(x=PLME, y=stress_varf, 
                                          alpha=p80_gt0),
                     # color="#883E3A", .
                     width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  scale_color_manual(values=c("#883E3A","#E99D53"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.16,.36)) + 
  scale_x_continuous(breaks=c(0,.1,.2,.3), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  ylab("Stress Item:\n ") +
  # labs(subtitle=~underline("Negative Emotions")) +
  labs(subtitle="Negative Emotions") +
  scale_y_discrete(labels=stress_varlabsalt) +
  theme(axis.title.y = element_text(size=10, face="italic"), 
        legend.position = "bottom",
        strip.background = element_blank(),
        strip.text.x = element_text(size=10), 
        axis.text.y = element_text(size=10),
        plot.subtitle=element_text(size=12, hjust=0.5, face="italic"),
        legend.text = element_text(size = 10)) +
        guides(shape = guide_legend(override.aes = list(size = 0.5)),
               color = guide_legend(nrow=1, reverse = TRUE))

design <- "
111
222
333
"    
Figure3 <- prjplotalt + depplotalt + guide_area() +
    plot_layout(design=design, guides = 'collect', heights = c(20,20,1)) + 
    plot_annotation(
    title = 'FIGURE 3\nMarginal Effects of 2-Category Increase in Stress Item on Outcome Probabilities, by Estimator (T1; Fixed Effects)',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Each of the 196 intervals displayed represents the estimated marginal effect of a "practically large" 2-category increase in stress on an outcome probability derived from 196 distinct Bayesian logistic regression models. Of these, 182 estimates are from multivariate models simultaneously regressing (using `brms:: mvbind()`) the six specific criminal intent outcomes or the seven negative emotions outcomes on each of the seven stress types (T1: 13*7=91 models; multilevel "between/within" or B/W: 13*7=91 models). The other 14 estimates are from seven T1 or seven B/W models separately regressing "any criminal intent" on each stress item. In B/W models, stress items were separated into a L2 cross-time average (Xbar_i) between-person predictor and a L1 within-person change (X_it - Xbar_i) "fixed effects" estimator. In all models, stress predictors (L1 & L2) were specified as monotonic ordinal predictors with a cumulative probit link function. Models were estimated in brms with 4 chains and 4000 total post-warmup posterior draws per outcome. Marginal effect contrast distributions were estimated from the expectation of the posterior predictive distribution for each model as predicted probability difference distributions, either averaged over all 2-category stress differences (T1), or for 2-category stress increases (T1 to T2 change) averaged over all between-person stress levels. Median posterior density estimates with 95% intervals displayed. Bold point-intervals indicate at least 80% of posterior contrast estimates are greater than zero.', width=195)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'bottom', 
        legend.key.height = unit(.5, 'cm'), 
        legend.margin = margin(0,0,0,0), 
        legend.spacing.y = unit(0, "mm"), 
        plot.title.position = "plot", 
        plot.caption.position =  "plot") 

Figure3

ggsave("Figure3.jpeg", width=9, height=6.5, path=here("Output"))

Figure highlights (with bold point-intervals) all marginal effect contrasts that have at least an 80% posterior probability of being greater than zero (i.e., at least 80% of the posterior estimates for a contrast are greater than zero). These “plausibly positive” estimates are in line with theoretical predictions.

Comparison of between-person and within-person marginal contrasts in Figure 3 reveals that all 17 (out of 42) of the stress-crime correlations observed as plausibly positive (i.e., 80% posterior probability of being greater than zero) at T1 were estimated as null associations by the within-person fixed effects estimator. In fact, of the 42 possible associations examined, the fixed effects estimator shows only two stress-crime change correlations that were positive with at least 80% plausibility. Specifically, a two-unit response category increase in stress about money from T1 to T2 is associated with a very small increase in the predicted probability of reporting any future intent to engage in theft (less than and greater than 5BAM). The other 40 marginal contrasts plotted in Figure 3 suggest that increases in stress from T1 to T2 are likely unrelated to changes in the probability of criminal intent across waves.

Recall that the fixed effects estimator differences out all time-stable effects of (measured or unmeasured) between-person differences. Overall, these patterns suggest that between-person (T1) estimators of stress-criminal intent associations are likely biased by various sources of unmeasured confounding. For example, crime-involved individuals may have more difficulties in interpersonal and work relationships, and their lifestyles or activity routines might expose them to greater victimization risks. In such cases, spurious between-person estimates of stress “effects” on crime may emerge as artifacts of selection or reporting biases.

With respect to negative emotions, 29 out of 49 marginal effect contrasts at T1 were positive with 80% plausibility, whereas the within-person fixed effects estimator generated 32 (of 49) plausibly positive stress-emotions change correlations. Moreover, in most cases, the fixed effects estimator generated larger marginal effect contrasts. Taken together, these results are consistent with theoretical arguments that stress causes depression and other negative emotions.

Let’s pull all these plotted estimates into tables.

7.6.1 Estimates plotted in Fig3

We will specifically report some of the bold or “plausibly positive” (i.e., >=80% posterior probability of PLME > 0) in the text. To make those easier to find, we can filter to keep only those bold estimates. We also provide all estimates plotted in Fig 3 in separate tables.

7.6.1.1 Bold crim intent (T1, >=80% ppd positive)

PLMEprjT1 %>% 
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests) %>% 
  dplyr::filter(p_gt0 >= .80) %>% 
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (T1) Unadj. PLME Estimates**"), 
    subtitle = md("Plausibly positive bold only, Plotted in FIG3 (FIG4 in paper)")
  )
Criminal Intent (T1) Unadj. PLME Estimates
Plausibly positive bold only, Plotted in FIG3 (FIG4 in paper)
stress_var m s ll ul
prjthflt5
Stress: Fair Trtmt 0.040 0.0147 0.0105 0.070
Stress: Job 0.056 0.0185 0.0202 0.092
Stress: Respect 0.029 0.0168 -0.0038 0.062
Stress: Theft Vctm 0.039 0.0264 -0.0067 0.097
prjthfgt5
Stress: Fair Trtmt 0.028 0.0148 -0.0011 0.057
Stress: Job 0.052 0.0163 0.0203 0.084
Stress: Respect 0.018 0.0160 -0.0146 0.049
Stress: Theft Vctm 0.055 0.0282 0.0086 0.117
prjthreat
Stress: Fair Trtmt 0.026 0.0110 0.0050 0.049
Stress: Job 0.035 0.0125 0.0120 0.061
Stress: Respect 0.021 0.0120 -0.0034 0.044
Stress: Theft Vctm 0.019 0.0183 -0.0115 0.062
prjusedrg
Stress: Assault Vctm 0.012 0.0168 -0.0112 0.055
Stress: Job 0.017 0.0100 -0.0023 0.038
Stress: Respect 0.010 0.0099 -0.0090 0.030
prjhack
Stress: Fair Trtmt 0.010 0.0086 -0.0063 0.028
Stress: Job 0.024 0.0087 0.0094 0.044
prjany
Stress: Fair Trtmt 0.056 0.0193 0.0182 0.095
Stress: Job 0.084 0.0223 0.0401 0.129
Stress: Respect 0.051 0.0202 0.0097 0.090
Stress: Theft Vctm 0.033 0.0318 -0.0205 0.103

7.6.1.2 Bold neg emotions (T1, >=80% ppd positive)

PLMEdepT1 %>% 
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests) %>% 
  dplyr::filter(p_gt0 >= .80) %>% 
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (T1) Unadj. PLME Estimates**"), 
    subtitle = md("Plausibly positive bold only, Plotted in FIG3 (FIG4 in paper)")
  )
Negative Emotions (T1) Unadj. PLME Estimates
Plausibly positive bold only, Plotted in FIG3 (FIG4 in paper)
stress_var m s ll ul
depcantgo
Stress: Fair Trtmt 0.028 0.029 -0.02735 0.084
Stress: Money 0.102 0.036 0.03052 0.169
Stress: Theft Vctm 0.036 0.037 -0.03363 0.111
Stress: Transport 0.087 0.037 0.01435 0.161
depeffort
Stress: Assault Vctm 0.044 0.034 -0.01057 0.126
Stress: Fair Trtmt 0.036 0.020 -0.00317 0.075
Stress: Job 0.025 0.020 -0.01589 0.063
Stress: Money 0.021 0.025 -0.02957 0.069
Stress: Respect 0.038 0.018 0.00360 0.072
deplonely
Stress: Assault Vctm 0.130 0.048 0.04687 0.232
Stress: Fair Trtmt 0.066 0.024 0.01909 0.113
Stress: Respect 0.065 0.023 0.01881 0.110
Stress: Theft Vctm 0.117 0.039 0.04421 0.197
depblues
Stress: Fair Trtmt 0.025 0.022 -0.02186 0.067
Stress: Money 0.054 0.028 -0.00211 0.104
Stress: Transport 0.064 0.029 0.00634 0.120
depunfair
Stress: Money 0.107 0.028 0.05388 0.162
Stress: Transport 0.102 0.028 0.04733 0.156
depmistrt
Stress: Assault Vctm 0.159 0.040 0.08860 0.245
Stress: Fair Trtmt 0.094 0.019 0.05711 0.131
Stress: Money 0.055 0.026 0.00212 0.103
Stress: Respect 0.094 0.020 0.05626 0.135
Stress: Theft Vctm 0.051 0.028 0.00011 0.110
depbetray
Stress: Assault Vctm 0.140 0.039 0.07243 0.225
Stress: Fair Trtmt 0.090 0.019 0.05118 0.129
Stress: Job 0.033 0.020 -0.00825 0.072
Stress: Money 0.059 0.024 0.01175 0.106
Stress: Respect 0.078 0.020 0.03865 0.117
Stress: Theft Vctm 0.075 0.029 0.02189 0.138

7.6.1.3 Bold crim intent (chg, >=80% ppd positive)

PLMEprjchg %>% 
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests) %>% 
  dplyr::filter(p_gt0 >= .80) %>% 
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (Chg) Unadj. PLME Estimates**"), 
    subtitle = md("Plausibly positive bold only, Plotted in FIG3 (FIG4 in paper)")
  )
Criminal Intent (Chg) Unadj. PLME Estimates
Plausibly positive bold only, Plotted in FIG3 (FIG4 in paper)
stress_var m s ll ul
prjthflt5
Stress: Money 0.0028 0.0052 -0.0027 0.018
prjthfgt5
Stress: Money 0.0060 0.0072 -0.0017 0.026
prjany
Stress: Money 0.0260 0.0240 -0.0039 0.089

7.6.1.4 Bold neg emotions (chg, >=80% ppd positive)

PLMEdepchg %>% 
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests) %>% 
  dplyr::filter(p_gt0 >= .80) %>% 
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (Chg) Unadj. PLME Estimates**"), 
    subtitle = md("Plausibly positive bold only, Plotted in FIG3 (FIG4 in paper)")
  )
Negative Emotions (Chg) Unadj. PLME Estimates
Plausibly positive bold only, Plotted in FIG3 (FIG4 in paper)
stress_var m s ll ul
depcantgo
Stress: Assault Vctm 0.122 0.096 -0.07470 0.31
Stress: Fair Trtmt 0.163 0.101 -0.01468 0.39
Stress: Job 0.168 0.087 -0.00614 0.35
Stress: Money 0.195 0.100 0.02534 0.42
Stress: Respect 0.085 0.089 -0.08764 0.26
Stress: Theft Vctm 0.146 0.090 -0.02714 0.33
Stress: Transport 0.177 0.081 0.02942 0.35
depeffort
Stress: Fair Trtmt 0.117 0.064 0.00869 0.27
Stress: Job 0.068 0.062 -0.04879 0.20
Stress: Money 0.067 0.064 -0.05622 0.20
Stress: Respect 0.066 0.060 -0.03916 0.20
deplonely
Stress: Assault Vctm 0.171 0.098 -0.00690 0.39
Stress: Fair Trtmt 0.073 0.089 -0.08836 0.27
Stress: Money 0.104 0.079 -0.06594 0.25
Stress: Respect 0.062 0.075 -0.07676 0.22
Stress: Theft Vctm 0.176 0.087 0.01633 0.37
Stress: Transport 0.106 0.083 -0.04889 0.28
depblues
Stress: Theft Vctm 0.083 0.068 -0.02288 0.24
depunfair
Stress: Fair Trtmt 0.197 0.077 0.06834 0.37
Stress: Job 0.161 0.073 0.03007 0.31
Stress: Money 0.206 0.068 0.08339 0.36
Stress: Respect 0.194 0.070 0.07269 0.35
Stress: Theft Vctm 0.186 0.081 0.04006 0.36
Stress: Transport 0.230 0.065 0.12253 0.37
depmistrt
Stress: Fair Trtmt 0.078 0.061 -0.03941 0.20
Stress: Money 0.080 0.069 -0.04490 0.23
Stress: Theft Vctm 0.084 0.075 -0.07812 0.22
depbetray
Stress: Assault Vctm 0.112 0.080 -0.05336 0.27
Stress: Fair Trtmt 0.083 0.064 -0.03771 0.22
Stress: Job 0.106 0.057 0.00044 0.23
Stress: Theft Vctm 0.150 0.066 0.03186 0.29

7.6.1.5 All crim intent (T1)

PLMEprjT1 %>% 
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (T1) Unadj. PLME Estimates**"), 
    subtitle = md("Plotted in FIG3 (FIG4 in paper)")
  )
Criminal Intent (T1) Unadj. PLME Estimates
Plotted in FIG3 (FIG4 in paper)
stress_var m s ll ul
prjthflt5
Stress: Assault Vctm 0.00830 0.0252 -0.0383 0.0613
Stress: Fair Trtmt 0.03996 0.0147 0.0105 0.0696
Stress: Job 0.05612 0.0185 0.0202 0.0919
Stress: Money 0.00192 0.0223 -0.0427 0.0452
Stress: Respect 0.02920 0.0168 -0.0038 0.0619
Stress: Theft Vctm 0.03876 0.0264 -0.0067 0.0966
Stress: Transport -0.01207 0.0232 -0.0595 0.0311
prjthfgt5
Stress: Assault Vctm 0.01656 0.0240 -0.0259 0.0700
Stress: Fair Trtmt 0.02795 0.0148 -0.0011 0.0572
Stress: Job 0.05194 0.0163 0.0203 0.0842
Stress: Money 0.00486 0.0206 -0.0336 0.0466
Stress: Respect 0.01774 0.0160 -0.0146 0.0486
Stress: Theft Vctm 0.05515 0.0282 0.0086 0.1175
Stress: Transport 0.00951 0.0210 -0.0327 0.0484
prjthreat
Stress: Assault Vctm 0.00565 0.0184 -0.0232 0.0472
Stress: Fair Trtmt 0.02637 0.0110 0.0050 0.0486
Stress: Job 0.03487 0.0125 0.0120 0.0614
Stress: Money -0.01476 0.0173 -0.0512 0.0159
Stress: Respect 0.02068 0.0120 -0.0034 0.0440
Stress: Theft Vctm 0.01905 0.0183 -0.0115 0.0617
Stress: Transport -0.00483 0.0164 -0.0391 0.0258
prjharm
Stress: Assault Vctm -0.00033 0.0150 -0.0233 0.0346
Stress: Fair Trtmt 0.00562 0.0107 -0.0162 0.0261
Stress: Job 0.00924 0.0112 -0.0127 0.0318
Stress: Money -0.01821 0.0148 -0.0499 0.0084
Stress: Respect 0.00590 0.0110 -0.0172 0.0270
Stress: Theft Vctm 0.00595 0.0146 -0.0176 0.0397
Stress: Transport -0.01948 0.0162 -0.0563 0.0080
prjusedrg
Stress: Assault Vctm 0.01247 0.0168 -0.0112 0.0552
Stress: Fair Trtmt 0.00644 0.0098 -0.0127 0.0259
Stress: Job 0.01679 0.0100 -0.0023 0.0376
Stress: Money -0.01395 0.0145 -0.0460 0.0123
Stress: Respect 0.01041 0.0099 -0.0090 0.0304
Stress: Theft Vctm -0.00126 0.0123 -0.0205 0.0282
Stress: Transport -0.00489 0.0131 -0.0339 0.0188
prjhack
Stress: Assault Vctm 0.00146 0.0127 -0.0162 0.0342
Stress: Fair Trtmt 0.01023 0.0086 -0.0063 0.0280
Stress: Job 0.02423 0.0087 0.0094 0.0437
Stress: Money -0.00586 0.0123 -0.0327 0.0154
Stress: Respect 0.00493 0.0087 -0.0119 0.0230
Stress: Theft Vctm -0.00092 0.0107 -0.0170 0.0256
Stress: Transport -0.00229 0.0122 -0.0292 0.0200
prjany
Stress: Assault Vctm 0.01521 0.0316 -0.0371 0.0860
Stress: Fair Trtmt 0.05650 0.0193 0.0182 0.0949
Stress: Job 0.08447 0.0223 0.0401 0.1288
Stress: Money -0.03412 0.0310 -0.0967 0.0240
Stress: Respect 0.05082 0.0202 0.0097 0.0898
Stress: Theft Vctm 0.03313 0.0318 -0.0205 0.1032
Stress: Transport -0.01737 0.0361 -0.0866 0.0525

7.6.1.6 All neg emotions (T1)

PLMEdepT1 %>% 
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (T1) Unadj. PLME Estimates**"), 
    subtitle = md("Plotted in FIG3 (FIG4 in paper)")
  )
Negative Emotions (T1) Unadj. PLME Estimates
Plotted in FIG3 (FIG4 in paper)
stress_var m s ll ul
depcantgo
Stress: Assault Vctm 0.02967 0.041 -0.05466 0.1110
Stress: Fair Trtmt 0.02752 0.029 -0.02735 0.0840
Stress: Job -0.06216 0.034 -0.12992 0.0045
Stress: Money 0.10163 0.036 0.03052 0.1693
Stress: Respect 0.01254 0.030 -0.04723 0.0735
Stress: Theft Vctm 0.03552 0.037 -0.03363 0.1109
Stress: Transport 0.08736 0.037 0.01435 0.1614
depeffort
Stress: Assault Vctm 0.04431 0.034 -0.01057 0.1260
Stress: Fair Trtmt 0.03621 0.020 -0.00317 0.0752
Stress: Job 0.02515 0.020 -0.01589 0.0630
Stress: Money 0.02089 0.025 -0.02957 0.0690
Stress: Respect 0.03805 0.018 0.00360 0.0719
Stress: Theft Vctm 0.01631 0.027 -0.02936 0.0745
Stress: Transport 0.00850 0.025 -0.04171 0.0553
deplonely
Stress: Assault Vctm 0.12963 0.048 0.04687 0.2317
Stress: Fair Trtmt 0.06591 0.024 0.01909 0.1129
Stress: Job -0.00550 0.026 -0.06013 0.0432
Stress: Money 0.02308 0.031 -0.03896 0.0829
Stress: Respect 0.06471 0.023 0.01881 0.1103
Stress: Theft Vctm 0.11670 0.039 0.04421 0.1966
Stress: Transport -0.00078 0.032 -0.06678 0.0616
depblues
Stress: Assault Vctm 0.01265 0.037 -0.04418 0.1002
Stress: Fair Trtmt 0.02517 0.022 -0.02186 0.0667
Stress: Job 0.01215 0.023 -0.03392 0.0565
Stress: Money 0.05365 0.028 -0.00211 0.1045
Stress: Respect 0.01128 0.025 -0.03722 0.0569
Stress: Theft Vctm 0.01357 0.034 -0.04296 0.0900
Stress: Transport 0.06421 0.029 0.00634 0.1205
depunfair
Stress: Assault Vctm 0.02649 0.040 -0.03454 0.1189
Stress: Fair Trtmt 0.01702 0.023 -0.03090 0.0613
Stress: Job 0.01543 0.024 -0.03234 0.0592
Stress: Money 0.10670 0.028 0.05388 0.1617
Stress: Respect 0.01403 0.027 -0.04097 0.0624
Stress: Theft Vctm 0.01216 0.033 -0.04261 0.0869
Stress: Transport 0.10163 0.028 0.04733 0.1562
depmistrt
Stress: Assault Vctm 0.15927 0.040 0.08860 0.2451
Stress: Fair Trtmt 0.09353 0.019 0.05711 0.1310
Stress: Job 0.00953 0.022 -0.03649 0.0488
Stress: Money 0.05495 0.026 0.00212 0.1033
Stress: Respect 0.09414 0.020 0.05626 0.1348
Stress: Theft Vctm 0.05145 0.028 0.00011 0.1096
Stress: Transport 0.00332 0.029 -0.05603 0.0580
depbetray
Stress: Assault Vctm 0.13990 0.039 0.07243 0.2254
Stress: Fair Trtmt 0.08968 0.019 0.05118 0.1285
Stress: Job 0.03302 0.020 -0.00825 0.0715
Stress: Money 0.05943 0.024 0.01175 0.1059
Stress: Respect 0.07793 0.020 0.03865 0.1167
Stress: Theft Vctm 0.07543 0.029 0.02189 0.1383
Stress: Transport 0.01202 0.027 -0.04361 0.0656

7.6.1.7 All crim intent (chg)

PLMEprjchg %>% 
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (Chg) Unadj. PLME Estimates**"), 
    subtitle = md("Plotted in FIG3 (FIG4 in paper)")
  )
Criminal Intent (Chg) Unadj. PLME Estimates
Plotted in FIG3 (FIG4 in paper)
stress_var m s ll ul
prjthflt5
Stress: Assault Vctm -0.000672 0.0050 -0.0122 0.007312
Stress: Fair Trtmt 0.000649 0.0053 -0.0090 0.012876
Stress: Job -0.000460 0.0050 -0.0112 0.009539
Stress: Money 0.002795 0.0052 -0.0027 0.017624
Stress: Respect -0.003280 0.0059 -0.0199 0.002158
Stress: Theft Vctm -0.001878 0.0066 -0.0190 0.006708
Stress: Transport 0.000086 0.0044 -0.0079 0.009795
prjthfgt5
Stress: Assault Vctm 0.000745 0.0070 -0.0126 0.016305
Stress: Fair Trtmt 0.002285 0.0065 -0.0082 0.018537
Stress: Job 0.001492 0.0072 -0.0107 0.018537
Stress: Money 0.006011 0.0072 -0.0017 0.026363
Stress: Respect -0.003715 0.0072 -0.0242 0.003775
Stress: Theft Vctm -0.001825 0.0116 -0.0286 0.018030
Stress: Transport 0.000462 0.0062 -0.0110 0.014733
prjthreat
Stress: Assault Vctm -0.001266 0.0038 -0.0112 0.001903
Stress: Fair Trtmt -0.001889 0.0036 -0.0122 0.000985
Stress: Job -0.000499 0.0037 -0.0088 0.005971
Stress: Money -0.000375 0.0026 -0.0065 0.003946
Stress: Respect -0.002778 0.0048 -0.0162 0.000543
Stress: Theft Vctm -0.002601 0.0059 -0.0209 0.001632
Stress: Transport -0.001257 0.0032 -0.0093 0.001331
prjharm
Stress: Assault Vctm -0.000661 0.0044 -0.0109 0.006305
Stress: Fair Trtmt -0.002054 0.0042 -0.0141 0.001528
Stress: Job -0.000764 0.0041 -0.0103 0.005779
Stress: Money -0.000570 0.0038 -0.0098 0.005814
Stress: Respect -0.002447 0.0045 -0.0149 0.001728
Stress: Theft Vctm -0.004166 0.0072 -0.0258 0.000117
Stress: Transport -0.003450 0.0057 -0.0199 0.000430
prjusedrg
Stress: Assault Vctm 0.000177 0.0043 -0.0071 0.008470
Stress: Fair Trtmt -0.001541 0.0035 -0.0111 0.001933
Stress: Job -0.000501 0.0041 -0.0099 0.006461
Stress: Money -0.000867 0.0029 -0.0083 0.002727
Stress: Respect -0.002950 0.0041 -0.0150 0.000015
Stress: Theft Vctm -0.000695 0.0030 -0.0082 0.003177
Stress: Transport -0.001557 0.0036 -0.0111 0.001376
prjhack
Stress: Assault Vctm -0.000819 0.0187 -0.0375 0.037038
Stress: Fair Trtmt -0.012488 0.0157 -0.0534 0.009395
Stress: Job -0.000017 0.0145 -0.0299 0.030009
Stress: Money 0.003731 0.0154 -0.0247 0.038322
Stress: Respect -0.014460 0.0186 -0.0646 0.008575
Stress: Theft Vctm -0.011463 0.0203 -0.0666 0.015074
Stress: Transport -0.014022 0.0187 -0.0663 0.008119
prjany
Stress: Assault Vctm 0.000793 0.0216 -0.0421 0.045480
Stress: Fair Trtmt 0.005569 0.0205 -0.0323 0.051726
Stress: Job 0.010845 0.0219 -0.0291 0.060448
Stress: Money 0.025973 0.0240 -0.0039 0.088965
Stress: Respect -0.018389 0.0217 -0.0742 0.012077
Stress: Theft Vctm -0.014331 0.0271 -0.0816 0.028117
Stress: Transport 0.006167 0.0204 -0.0292 0.051096

7.6.1.8 All neg emotions (chg)

PLMEdepchg %>% 
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (Chg) Unadj. PLME Estimates**"), 
    subtitle = md("Plotted in FIG3 (FIG4 in paper)")
  )
Negative Emotions (Chg) Unadj. PLME Estimates
Plotted in FIG3 (FIG4 in paper)
stress_var m s ll ul
depcantgo
Stress: Assault Vctm 0.1224 0.096 -0.07470 0.306
Stress: Fair Trtmt 0.1628 0.101 -0.01468 0.387
Stress: Job 0.1682 0.087 -0.00614 0.346
Stress: Money 0.1945 0.100 0.02534 0.416
Stress: Respect 0.0848 0.089 -0.08764 0.263
Stress: Theft Vctm 0.1463 0.090 -0.02714 0.327
Stress: Transport 0.1771 0.081 0.02942 0.349
depeffort
Stress: Assault Vctm 0.0300 0.072 -0.11694 0.168
Stress: Fair Trtmt 0.1173 0.064 0.00869 0.272
Stress: Job 0.0678 0.062 -0.04879 0.200
Stress: Money 0.0667 0.064 -0.05622 0.199
Stress: Respect 0.0664 0.060 -0.03916 0.199
Stress: Theft Vctm 0.0497 0.067 -0.07495 0.197
Stress: Transport 0.0164 0.065 -0.11370 0.150
deplonely
Stress: Assault Vctm 0.1710 0.098 -0.00690 0.389
Stress: Fair Trtmt 0.0729 0.089 -0.08836 0.275
Stress: Job 0.0533 0.079 -0.09742 0.211
Stress: Money 0.1040 0.079 -0.06594 0.246
Stress: Respect 0.0620 0.075 -0.07676 0.224
Stress: Theft Vctm 0.1765 0.087 0.01633 0.367
Stress: Transport 0.1056 0.083 -0.04889 0.280
depblues
Stress: Assault Vctm -0.0434 0.062 -0.17499 0.071
Stress: Fair Trtmt 0.0145 0.056 -0.10285 0.122
Stress: Job -0.0320 0.051 -0.13296 0.070
Stress: Money -0.0500 0.061 -0.19278 0.051
Stress: Respect -0.0293 0.049 -0.13479 0.064
Stress: Theft Vctm 0.0826 0.068 -0.02288 0.245
Stress: Transport -0.0500 0.056 -0.16196 0.061
depunfair
Stress: Assault Vctm 0.0263 0.095 -0.15321 0.222
Stress: Fair Trtmt 0.1971 0.077 0.06834 0.374
Stress: Job 0.1611 0.073 0.03007 0.314
Stress: Money 0.2060 0.068 0.08339 0.355
Stress: Respect 0.1936 0.070 0.07269 0.349
Stress: Theft Vctm 0.1856 0.081 0.04006 0.362
Stress: Transport 0.2299 0.065 0.12253 0.372
depmistrt
Stress: Assault Vctm -0.0133 0.086 -0.19494 0.151
Stress: Fair Trtmt 0.0777 0.061 -0.03941 0.202
Stress: Job 0.0091 0.077 -0.18283 0.132
Stress: Money 0.0798 0.069 -0.04490 0.231
Stress: Respect 0.0426 0.063 -0.07361 0.174
Stress: Theft Vctm 0.0839 0.075 -0.07812 0.219
Stress: Transport 0.0370 0.077 -0.14106 0.170
depbetray
Stress: Assault Vctm 0.1122 0.080 -0.05336 0.266
Stress: Fair Trtmt 0.0826 0.064 -0.03771 0.217
Stress: Job 0.1063 0.057 0.00044 0.227
Stress: Money 0.0228 0.062 -0.09990 0.151
Stress: Respect 0.0402 0.059 -0.06941 0.168
Stress: Theft Vctm 0.1499 0.066 0.03186 0.292
Stress: Transport -0.0071 0.066 -0.13997 0.123

7.6.2 Median unweighted (meta-analytic avg) estimates from Fig 4

We can also summarize the median unweighted PLME estimates and 80% posterior interval ranges for these model estimates.

7.6.2.1 Crim intent (T1)

PLMEprjT1 %>% 
  ungroup() %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .10),
            ul = quantile(PLME, probs = .90)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (T1) Median Unadj. PLME Estimate**")
  )
Criminal Intent (T1) Median Unadj. PLME Estimate
m s ll ul
0.011 0.03 -0.019 0.053

7.6.2.2 Neg emotions (T1)

PLMEdepT1 %>% 
 # summarize PLME estimates across the MCMC draws
  ungroup() %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .10),
            ul = quantile(PLME, probs = .90)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (T1) Median Unadj. PLME Estimate**"), 
  )
Negative Emotions (T1) Median Unadj. PLME Estimate
m s ll ul
0.04 0.052 -0.013 0.11

7.6.2.3 Crim intent (chg)

PLMEprjchg %>% 
  ungroup() %>%
 # summarize PLME estimates across the MCMC draws
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .10),
            ul = quantile(PLME, probs = .90)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (Chg) Median Unadj. PLME Estimate**"), 
  )
Criminal Intent (Chg) Median Unadj. PLME Estimate
m s ll ul
-0.0011 0.014 -0.014 0.0088

7.6.2.4 Neg emotions (chg)

PLMEdepchg %>% 
  ungroup() %>%
 # summarize PLME estimates across the MCMC draws
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .10),
            ul = quantile(PLME, probs = .90)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (Chg) Median Unadj. PLME Estimate**"), 
  )
Negative Emotions (Chg) Median Unadj. PLME Estimate
m s ll ul
0.08 0.11 -0.046 0.23

Let’s now turn to examining community variations.

8 Modeling change correlations by community

(RMD FILE: BDK_2023_Stress_7_Chgcorr_comm_mods)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

8.1 RQ3. Stress/Past Crime (T2-T1) x Community Bivariate Correlations

RQ3 (Stress amplification): Are within-person change (fixed effects) correlations between subjective stress and posited outcomes - self-reported criminal intent and negative emotions - positive and strongest in low-SES urban communities?

Recall that the overall (full sample) change associations displayed in Figure 3 may mask important and theoretically expected community variations in the stress-crime relationship. In particular, stress process theories imply that such associations should be strongest where stress is most chronic - that is, in urban areas and particularly low-SES urban communities.

So, let’s model these potential community variations in item pair associations and then see if we can add them to the plot without overloading it.

8.1.1 Criminal Intent & Stress x Community Correlation Models

8.1.1.1 Corr X Community: stmony & prj crime

load(here("1_Data_Files/Datasets/stress_long.Rdata"))
#Community Change: criminal intent items ~ mo(stmony)
 
#Vectorize priors:

#list of colnames for projected crime DVs  
prjdv_names <- noquote(c("prjthflt5", "prjthfgt5", "prjthreat", "prjharm", 
                         "prjusedrg", "prjhack"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmony_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostmony_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmony_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostmony_av12x21', 
                  resp = prjdv_names)
  )

# drop year from model to avoid inappropriately partially out systematic stress change differences.  
  # also, with two waves, can only add random int OR random slope for year
chg.prjcrime.stmony.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stmony_devx2) + mo(stmony_av12x2) + 
    rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stmony_comm_fit",
      file_refit = "on_change"
  )

#Update function to call all ppchecks for bivar projected crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="prjthflt5")
  ppcheckdv2 <-pp_check(modelfit, resp="prjthfgt5")
  ppcheckdv3 <-pp_check(modelfit, resp="prjthreat")
  ppcheckdv4 <-pp_check(modelfit, resp="prjharm")
  ppcheckdv5 <-pp_check(modelfit, resp="prjusedrg")
  ppcheckdv6 <-pp_check(modelfit, resp="prjhack")
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95) +
    labs(title = "Coefficient plot",
         subtitle = "Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, 
                    ppcheckdv3, ppcheckdv4, ppcheckdv5, ppcheckdv6, 
                    plotcoefs, plotcoefs2)
  return(allchecks)
}

out.chg.prjcrime.stmony.comm.fit <- ppchecks(chg.prjcrime.stmony.comm.fit)
8.1.1.1.1 Coefficient plot (intervals)
out.chg.prjcrime.stmony.comm.fit[[10]]

8.1.1.1.2 PPcheck (density)
p1 <- out.chg.prjcrime.stmony.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stmony.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stmony.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stmony.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stmony.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stmony.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

8.1.1.1.3 Fit summary
out.chg.prjcrime.stmony.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          prjharm ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          prjhack ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     4.15      0.60     3.10     5.43 1.00     1430
## sd(prjthfgt5_Intercept)     3.50      0.51     2.58     4.57 1.00     1225
## sd(prjthreat_Intercept)     3.27      0.57     2.21     4.48 1.00     1676
## sd(prjharm_Intercept)       3.02      0.56     2.04     4.21 1.00     1747
## sd(prjusedrg_Intercept)     2.94      0.54     1.96     4.10 1.00     1760
## sd(prjhack_Intercept)       0.87      0.56     0.05     2.04 1.00      847
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2572
## sd(prjthfgt5_Intercept)     1779
## sd(prjthreat_Intercept)     2830
## sd(prjharm_Intercept)       2564
## sd(prjusedrg_Intercept)     2593
## sd(prjhack_Intercept)       1710
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_Intercept                        -6.15      0.91    -8.04    -4.38
## prjthfgt5_Intercept                        -5.86      0.85    -7.60    -4.25
## prjthreat_Intercept                        -6.09      0.98    -8.11    -4.26
## prjharm_Intercept                          -5.72      0.97    -7.69    -3.93
## prjusedrg_Intercept                        -5.80      0.96    -7.74    -3.99
## prjhack_Intercept                          -4.31      0.78    -5.91    -2.87
## prjthflt5_rural.ses.med2                   -0.23      0.87    -1.89     1.49
## prjthflt5_rural.ses.med3                    0.64      0.82    -1.02     2.17
## prjthflt5_rural.ses.med4                    1.03      0.88    -0.75     2.66
## prjthfgt5_rural.ses.med2                   -0.40      0.88    -2.13     1.38
## prjthfgt5_rural.ses.med3                    0.61      0.79    -1.01     2.07
## prjthfgt5_rural.ses.med4                    0.80      0.85    -0.87     2.40
## prjthreat_rural.ses.med2                   -0.25      0.90    -2.04     1.56
## prjthreat_rural.ses.med3                    0.52      0.83    -1.10     2.12
## prjthreat_rural.ses.med4                    1.21      0.88    -0.65     2.82
## prjharm_rural.ses.med2                     -0.10      0.81    -1.63     1.54
## prjharm_rural.ses.med3                      0.39      0.80    -1.26     1.96
## prjharm_rural.ses.med4                      0.73      0.77    -0.84     2.21
## prjusedrg_rural.ses.med2                   -0.39      0.87    -2.08     1.39
## prjusedrg_rural.ses.med3                   -0.12      0.87    -1.84     1.59
## prjusedrg_rural.ses.med4                    1.34      0.85    -0.44     2.87
## prjhack_rural.ses.med2                     -0.50      0.88    -2.20     1.23
## prjhack_rural.ses.med3                      0.33      0.79    -1.31     1.84
## prjhack_rural.ses.med4                      0.57      0.76    -1.01     1.99
## prjthflt5_mostmony_devx2                    0.01      0.22    -0.43     0.41
## prjthflt5_mostmony_av12x2                  -0.05      0.09    -0.24     0.13
## prjthflt5_mostmony_devx2:rural.ses.med2    -0.95      0.59    -2.21     0.10
## prjthflt5_mostmony_devx2:rural.ses.med3     0.59      0.38    -0.13     1.40
## prjthflt5_mostmony_devx2:rural.ses.med4     0.78      0.40     0.07     1.67
## prjthfgt5_mostmony_devx2                    0.06      0.21    -0.38     0.44
## prjthfgt5_mostmony_av12x2                  -0.03      0.09    -0.21     0.14
## prjthfgt5_mostmony_devx2:rural.ses.med2    -0.85      0.60    -2.13     0.23
## prjthfgt5_mostmony_devx2:rural.ses.med3     0.52      0.36    -0.19     1.25
## prjthfgt5_mostmony_devx2:rural.ses.med4     0.75      0.38     0.03     1.57
## prjthreat_mostmony_devx2                   -0.11      0.21    -0.52     0.28
## prjthreat_mostmony_av12x2                  -0.10      0.09    -0.29     0.09
## prjthreat_mostmony_devx2:rural.ses.med2    -0.72      0.63    -2.07     0.42
## prjthreat_mostmony_devx2:rural.ses.med3     0.09      0.47    -0.89     0.97
## prjthreat_mostmony_devx2:rural.ses.med4     0.37      0.49    -0.59     1.39
## prjharm_mostmony_devx2                     -0.09      0.21    -0.50     0.32
## prjharm_mostmony_av12x2                    -0.12      0.09    -0.30     0.06
## prjharm_mostmony_devx2:rural.ses.med2      -0.33      0.50    -1.40     0.61
## prjharm_mostmony_devx2:rural.ses.med3      -0.06      0.51    -1.17     0.88
## prjharm_mostmony_devx2:rural.ses.med4       0.24      0.43    -0.62     1.10
## prjusedrg_mostmony_devx2                   -0.16      0.21    -0.56     0.25
## prjusedrg_mostmony_av12x2                  -0.05      0.09    -0.24     0.12
## prjusedrg_mostmony_devx2:rural.ses.med2    -0.22      0.56    -1.39     0.81
## prjusedrg_mostmony_devx2:rural.ses.med3    -0.37      0.55    -1.51     0.63
## prjusedrg_mostmony_devx2:rural.ses.med4     0.26      0.47    -0.63     1.22
## prjhack_mostmony_devx2                      0.04      0.21    -0.36     0.45
## prjhack_mostmony_av12x2                    -0.05      0.08    -0.20     0.11
## prjhack_mostmony_devx2:rural.ses.med2      -0.39      0.56    -1.54     0.67
## prjhack_mostmony_devx2:rural.ses.med3      -0.19      0.56    -1.44     0.81
## prjhack_mostmony_devx2:rural.ses.med4       0.20      0.38    -0.59     0.94
##                                         Rhat Bulk_ESS Tail_ESS
## prjthflt5_Intercept                     1.00     2819     2903
## prjthfgt5_Intercept                     1.00     2419     2950
## prjthreat_Intercept                     1.00     2543     2994
## prjharm_Intercept                       1.00     2349     3037
## prjusedrg_Intercept                     1.00     3041     3268
## prjhack_Intercept                       1.00     2012     2940
## prjthflt5_rural.ses.med2                1.00     5780     3353
## prjthflt5_rural.ses.med3                1.00     5107     3428
## prjthflt5_rural.ses.med4                1.00     4430     2845
## prjthfgt5_rural.ses.med2                1.00     5804     3213
## prjthfgt5_rural.ses.med3                1.00     4017     2968
## prjthfgt5_rural.ses.med4                1.00     4606     3304
## prjthreat_rural.ses.med2                1.00     5347     2731
## prjthreat_rural.ses.med3                1.00     6110     3617
## prjthreat_rural.ses.med4                1.00     4274     3103
## prjharm_rural.ses.med2                  1.00     5393     3192
## prjharm_rural.ses.med3                  1.00     5272     3625
## prjharm_rural.ses.med4                  1.00     5002     3353
## prjusedrg_rural.ses.med2                1.00     5771     3296
## prjusedrg_rural.ses.med3                1.00     5105     2946
## prjusedrg_rural.ses.med4                1.00     4400     3613
## prjhack_rural.ses.med2                  1.00     5272     3184
## prjhack_rural.ses.med3                  1.00     4350     2981
## prjhack_rural.ses.med4                  1.00     4338     3057
## prjthflt5_mostmony_devx2                1.00     5188     3418
## prjthflt5_mostmony_av12x2               1.00     3282     3145
## prjthflt5_mostmony_devx2:rural.ses.med2 1.00     4480     3255
## prjthflt5_mostmony_devx2:rural.ses.med3 1.00     4073     3158
## prjthflt5_mostmony_devx2:rural.ses.med4 1.00     3405     2824
## prjthfgt5_mostmony_devx2                1.00     3792     3195
## prjthfgt5_mostmony_av12x2               1.00     3720     3380
## prjthfgt5_mostmony_devx2:rural.ses.med2 1.00     4422     2665
## prjthfgt5_mostmony_devx2:rural.ses.med3 1.00     3210     2714
## prjthfgt5_mostmony_devx2:rural.ses.med4 1.00     3216     3029
## prjthreat_mostmony_devx2                1.00     5205     3136
## prjthreat_mostmony_av12x2               1.00     4003     3326
## prjthreat_mostmony_devx2:rural.ses.med2 1.00     4136     2684
## prjthreat_mostmony_devx2:rural.ses.med3 1.00     3381     2773
## prjthreat_mostmony_devx2:rural.ses.med4 1.00     2708     3156
## prjharm_mostmony_devx2                  1.00     5320     3161
## prjharm_mostmony_av12x2                 1.00     4964     3388
## prjharm_mostmony_devx2:rural.ses.med2   1.00     4288     3289
## prjharm_mostmony_devx2:rural.ses.med3   1.00     4082     3111
## prjharm_mostmony_devx2:rural.ses.med4   1.00     4031     2961
## prjusedrg_mostmony_devx2                1.00     5988     3160
## prjusedrg_mostmony_av12x2               1.00     3939     2827
## prjusedrg_mostmony_devx2:rural.ses.med2 1.00     4180     3204
## prjusedrg_mostmony_devx2:rural.ses.med3 1.00     3979     2888
## prjusedrg_mostmony_devx2:rural.ses.med4 1.00     3061     3140
## prjhack_mostmony_devx2                  1.00     5650     3223
## prjhack_mostmony_av12x2                 1.00     6767     3411
## prjhack_mostmony_devx2:rural.ses.med2   1.00     4256     3423
## prjhack_mostmony_devx2:rural.ses.med3   1.00     3623     3578
## prjhack_mostmony_devx2:rural.ses.med4   1.00     3593     2671
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## prjthflt5_mostmony_devx21[1]                    0.25      0.15     0.03
## prjthflt5_mostmony_devx21[2]                    0.24      0.14     0.03
## prjthflt5_mostmony_devx21[3]                    0.24      0.14     0.03
## prjthflt5_mostmony_devx21[4]                    0.26      0.15     0.04
## prjthflt5_mostmony_av12x21[1]                   0.13      0.08     0.02
## prjthflt5_mostmony_av12x21[2]                   0.13      0.08     0.02
## prjthflt5_mostmony_av12x21[3]                   0.13      0.08     0.02
## prjthflt5_mostmony_av12x21[4]                   0.13      0.08     0.01
## prjthflt5_mostmony_av12x21[5]                   0.12      0.08     0.02
## prjthflt5_mostmony_av12x21[6]                   0.12      0.08     0.02
## prjthflt5_mostmony_av12x21[7]                   0.12      0.08     0.02
## prjthflt5_mostmony_av12x21[8]                   0.12      0.08     0.02
## prjthflt5_mostmony_devx2:rural.ses.med21[1]     0.27      0.18     0.01
## prjthflt5_mostmony_devx2:rural.ses.med21[2]     0.21      0.17     0.01
## prjthflt5_mostmony_devx2:rural.ses.med21[3]     0.29      0.20     0.02
## prjthflt5_mostmony_devx2:rural.ses.med21[4]     0.23      0.18     0.01
## prjthflt5_mostmony_devx2:rural.ses.med31[1]     0.25      0.18     0.01
## prjthflt5_mostmony_devx2:rural.ses.med31[2]     0.31      0.20     0.02
## prjthflt5_mostmony_devx2:rural.ses.med31[3]     0.20      0.16     0.01
## prjthflt5_mostmony_devx2:rural.ses.med31[4]     0.24      0.18     0.01
## prjthflt5_mostmony_devx2:rural.ses.med41[1]     0.33      0.20     0.02
## prjthflt5_mostmony_devx2:rural.ses.med41[2]     0.23      0.18     0.01
## prjthflt5_mostmony_devx2:rural.ses.med41[3]     0.21      0.16     0.01
## prjthflt5_mostmony_devx2:rural.ses.med41[4]     0.23      0.17     0.01
## prjthfgt5_mostmony_devx21[1]                    0.25      0.14     0.04
## prjthfgt5_mostmony_devx21[2]                    0.25      0.15     0.04
## prjthfgt5_mostmony_devx21[3]                    0.24      0.14     0.03
## prjthfgt5_mostmony_devx21[4]                    0.25      0.15     0.04
## prjthfgt5_mostmony_av12x21[1]                   0.13      0.08     0.02
## prjthfgt5_mostmony_av12x21[2]                   0.13      0.08     0.02
## prjthfgt5_mostmony_av12x21[3]                   0.12      0.08     0.02
## prjthfgt5_mostmony_av12x21[4]                   0.12      0.08     0.02
## prjthfgt5_mostmony_av12x21[5]                   0.12      0.08     0.02
## prjthfgt5_mostmony_av12x21[6]                   0.12      0.08     0.02
## prjthfgt5_mostmony_av12x21[7]                   0.13      0.08     0.02
## prjthfgt5_mostmony_av12x21[8]                   0.13      0.08     0.02
## prjthfgt5_mostmony_devx2:rural.ses.med21[1]     0.30      0.20     0.02
## prjthfgt5_mostmony_devx2:rural.ses.med21[2]     0.19      0.16     0.01
## prjthfgt5_mostmony_devx2:rural.ses.med21[3]     0.27      0.19     0.01
## prjthfgt5_mostmony_devx2:rural.ses.med21[4]     0.24      0.18     0.01
## prjthfgt5_mostmony_devx2:rural.ses.med31[1]     0.25      0.19     0.01
## prjthfgt5_mostmony_devx2:rural.ses.med31[2]     0.32      0.21     0.02
## prjthfgt5_mostmony_devx2:rural.ses.med31[3]     0.19      0.16     0.01
## prjthfgt5_mostmony_devx2:rural.ses.med31[4]     0.24      0.19     0.01
## prjthfgt5_mostmony_devx2:rural.ses.med41[1]     0.29      0.19     0.01
## prjthfgt5_mostmony_devx2:rural.ses.med41[2]     0.31      0.20     0.02
## prjthfgt5_mostmony_devx2:rural.ses.med41[3]     0.17      0.14     0.01
## prjthfgt5_mostmony_devx2:rural.ses.med41[4]     0.23      0.17     0.01
## prjthreat_mostmony_devx21[1]                    0.26      0.15     0.04
## prjthreat_mostmony_devx21[2]                    0.24      0.15     0.03
## prjthreat_mostmony_devx21[3]                    0.26      0.15     0.04
## prjthreat_mostmony_devx21[4]                    0.24      0.15     0.03
## prjthreat_mostmony_av12x21[1]                   0.13      0.08     0.02
## prjthreat_mostmony_av12x21[2]                   0.12      0.08     0.01
## prjthreat_mostmony_av12x21[3]                   0.13      0.08     0.02
## prjthreat_mostmony_av12x21[4]                   0.13      0.08     0.02
## prjthreat_mostmony_av12x21[5]                   0.14      0.09     0.02
## prjthreat_mostmony_av12x21[6]                   0.13      0.08     0.01
## prjthreat_mostmony_av12x21[7]                   0.12      0.08     0.02
## prjthreat_mostmony_av12x21[8]                   0.12      0.08     0.01
## prjthreat_mostmony_devx2:rural.ses.med21[1]     0.28      0.20     0.01
## prjthreat_mostmony_devx2:rural.ses.med21[2]     0.20      0.17     0.01
## prjthreat_mostmony_devx2:rural.ses.med21[3]     0.26      0.20     0.01
## prjthreat_mostmony_devx2:rural.ses.med21[4]     0.25      0.19     0.01
## prjthreat_mostmony_devx2:rural.ses.med31[1]     0.24      0.19     0.01
## prjthreat_mostmony_devx2:rural.ses.med31[2]     0.23      0.18     0.01
## prjthreat_mostmony_devx2:rural.ses.med31[3]     0.23      0.18     0.01
## prjthreat_mostmony_devx2:rural.ses.med31[4]     0.30      0.21     0.01
## prjthreat_mostmony_devx2:rural.ses.med41[1]     0.30      0.21     0.01
## prjthreat_mostmony_devx2:rural.ses.med41[2]     0.24      0.18     0.01
## prjthreat_mostmony_devx2:rural.ses.med41[3]     0.18      0.17     0.01
## prjthreat_mostmony_devx2:rural.ses.med41[4]     0.28      0.20     0.01
## prjharm_mostmony_devx21[1]                      0.26      0.15     0.04
## prjharm_mostmony_devx21[2]                      0.24      0.14     0.03
## prjharm_mostmony_devx21[3]                      0.24      0.15     0.03
## prjharm_mostmony_devx21[4]                      0.25      0.15     0.03
## prjharm_mostmony_av12x21[1]                     0.12      0.08     0.01
## prjharm_mostmony_av12x21[2]                     0.12      0.08     0.02
## prjharm_mostmony_av12x21[3]                     0.13      0.08     0.02
## prjharm_mostmony_av12x21[4]                     0.13      0.08     0.02
## prjharm_mostmony_av12x21[5]                     0.13      0.08     0.02
## prjharm_mostmony_av12x21[6]                     0.14      0.09     0.02
## prjharm_mostmony_av12x21[7]                     0.12      0.08     0.02
## prjharm_mostmony_av12x21[8]                     0.12      0.08     0.02
## prjharm_mostmony_devx2:rural.ses.med21[1]       0.26      0.19     0.01
## prjharm_mostmony_devx2:rural.ses.med21[2]       0.23      0.18     0.01
## prjharm_mostmony_devx2:rural.ses.med21[3]       0.23      0.18     0.01
## prjharm_mostmony_devx2:rural.ses.med21[4]       0.28      0.20     0.01
## prjharm_mostmony_devx2:rural.ses.med31[1]       0.23      0.18     0.01
## prjharm_mostmony_devx2:rural.ses.med31[2]       0.22      0.19     0.01
## prjharm_mostmony_devx2:rural.ses.med31[3]       0.25      0.19     0.01
## prjharm_mostmony_devx2:rural.ses.med31[4]       0.29      0.21     0.01
## prjharm_mostmony_devx2:rural.ses.med41[1]       0.26      0.20     0.01
## prjharm_mostmony_devx2:rural.ses.med41[2]       0.23      0.19     0.01
## prjharm_mostmony_devx2:rural.ses.med41[3]       0.22      0.18     0.01
## prjharm_mostmony_devx2:rural.ses.med41[4]       0.28      0.21     0.01
## prjusedrg_mostmony_devx21[1]                    0.27      0.15     0.04
## prjusedrg_mostmony_devx21[2]                    0.25      0.15     0.03
## prjusedrg_mostmony_devx21[3]                    0.23      0.14     0.03
## prjusedrg_mostmony_devx21[4]                    0.25      0.15     0.03
## prjusedrg_mostmony_av12x21[1]                   0.13      0.08     0.02
## prjusedrg_mostmony_av12x21[2]                   0.12      0.08     0.01
## prjusedrg_mostmony_av12x21[3]                   0.13      0.08     0.02
## prjusedrg_mostmony_av12x21[4]                   0.13      0.08     0.02
## prjusedrg_mostmony_av12x21[5]                   0.12      0.08     0.02
## prjusedrg_mostmony_av12x21[6]                   0.12      0.08     0.01
## prjusedrg_mostmony_av12x21[7]                   0.12      0.08     0.02
## prjusedrg_mostmony_av12x21[8]                   0.12      0.08     0.02
## prjusedrg_mostmony_devx2:rural.ses.med21[1]     0.27      0.20     0.01
## prjusedrg_mostmony_devx2:rural.ses.med21[2]     0.21      0.18     0.01
## prjusedrg_mostmony_devx2:rural.ses.med21[3]     0.23      0.18     0.01
## prjusedrg_mostmony_devx2:rural.ses.med21[4]     0.29      0.20     0.01
## prjusedrg_mostmony_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## prjusedrg_mostmony_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## prjusedrg_mostmony_devx2:rural.ses.med31[3]     0.23      0.18     0.01
## prjusedrg_mostmony_devx2:rural.ses.med31[4]     0.28      0.20     0.01
## prjusedrg_mostmony_devx2:rural.ses.med41[1]     0.31      0.22     0.01
## prjusedrg_mostmony_devx2:rural.ses.med41[2]     0.21      0.18     0.01
## prjusedrg_mostmony_devx2:rural.ses.med41[3]     0.20      0.18     0.01
## prjusedrg_mostmony_devx2:rural.ses.med41[4]     0.28      0.21     0.01
## prjhack_mostmony_devx21[1]                      0.25      0.15     0.03
## prjhack_mostmony_devx21[2]                      0.24      0.14     0.04
## prjhack_mostmony_devx21[3]                      0.25      0.14     0.04
## prjhack_mostmony_devx21[4]                      0.25      0.14     0.04
## prjhack_mostmony_av12x21[1]                     0.13      0.08     0.02
## prjhack_mostmony_av12x21[2]                     0.13      0.08     0.02
## prjhack_mostmony_av12x21[3]                     0.12      0.08     0.02
## prjhack_mostmony_av12x21[4]                     0.12      0.08     0.02
## prjhack_mostmony_av12x21[5]                     0.12      0.08     0.01
## prjhack_mostmony_av12x21[6]                     0.12      0.08     0.01
## prjhack_mostmony_av12x21[7]                     0.13      0.08     0.02
## prjhack_mostmony_av12x21[8]                     0.13      0.08     0.02
## prjhack_mostmony_devx2:rural.ses.med21[1]       0.28      0.20     0.01
## prjhack_mostmony_devx2:rural.ses.med21[2]       0.24      0.18     0.01
## prjhack_mostmony_devx2:rural.ses.med21[3]       0.21      0.18     0.01
## prjhack_mostmony_devx2:rural.ses.med21[4]       0.28      0.20     0.01
## prjhack_mostmony_devx2:rural.ses.med31[1]       0.22      0.18     0.01
## prjhack_mostmony_devx2:rural.ses.med31[2]       0.21      0.19     0.01
## prjhack_mostmony_devx2:rural.ses.med31[3]       0.29      0.22     0.01
## prjhack_mostmony_devx2:rural.ses.med31[4]       0.28      0.21     0.01
## prjhack_mostmony_devx2:rural.ses.med41[1]       0.26      0.20     0.01
## prjhack_mostmony_devx2:rural.ses.med41[2]       0.23      0.18     0.01
## prjhack_mostmony_devx2:rural.ses.med41[3]       0.23      0.18     0.01
## prjhack_mostmony_devx2:rural.ses.med41[4]       0.29      0.21     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## prjthflt5_mostmony_devx21[1]                    0.60 1.00     6631     2750
## prjthflt5_mostmony_devx21[2]                    0.56 1.00     7623     2864
## prjthflt5_mostmony_devx21[3]                    0.57 1.00     6822     2546
## prjthflt5_mostmony_devx21[4]                    0.60 1.00     8112     3040
## prjthflt5_mostmony_av12x21[1]                   0.32 1.00     7605     2494
## prjthflt5_mostmony_av12x21[2]                   0.33 1.00     6219     2690
## prjthflt5_mostmony_av12x21[3]                   0.32 1.00     6135     2379
## prjthflt5_mostmony_av12x21[4]                   0.33 1.00     7239     1995
## prjthflt5_mostmony_av12x21[5]                   0.31 1.00     6785     2706
## prjthflt5_mostmony_av12x21[6]                   0.32 1.00     6490     2502
## prjthflt5_mostmony_av12x21[7]                   0.31 1.00     7077     3059
## prjthflt5_mostmony_av12x21[8]                   0.31 1.00     5440     3026
## prjthflt5_mostmony_devx2:rural.ses.med21[1]     0.69 1.00     4736     2438
## prjthflt5_mostmony_devx2:rural.ses.med21[2]     0.64 1.00     5943     2940
## prjthflt5_mostmony_devx2:rural.ses.med21[3]     0.72 1.00     5758     3015
## prjthflt5_mostmony_devx2:rural.ses.med21[4]     0.64 1.00     6069     2295
## prjthflt5_mostmony_devx2:rural.ses.med31[1]     0.67 1.00     5519     2681
## prjthflt5_mostmony_devx2:rural.ses.med31[2]     0.76 1.00     3971     2497
## prjthflt5_mostmony_devx2:rural.ses.med31[3]     0.61 1.00     4733     3050
## prjthflt5_mostmony_devx2:rural.ses.med31[4]     0.67 1.00     5517     2947
## prjthflt5_mostmony_devx2:rural.ses.med41[1]     0.76 1.00     4060     2298
## prjthflt5_mostmony_devx2:rural.ses.med41[2]     0.65 1.00     4223     2851
## prjthflt5_mostmony_devx2:rural.ses.med41[3]     0.60 1.00     5255     3215
## prjthflt5_mostmony_devx2:rural.ses.med41[4]     0.64 1.00     5328     2815
## prjthfgt5_mostmony_devx21[1]                    0.59 1.00     6837     2457
## prjthfgt5_mostmony_devx21[2]                    0.59 1.00     6400     2985
## prjthfgt5_mostmony_devx21[3]                    0.57 1.00     6851     2782
## prjthfgt5_mostmony_devx21[4]                    0.58 1.00     6585     3065
## prjthfgt5_mostmony_av12x21[1]                   0.31 1.00     6564     2285
## prjthfgt5_mostmony_av12x21[2]                   0.32 1.00     7263     2727
## prjthfgt5_mostmony_av12x21[3]                   0.31 1.00     8022     2627
## prjthfgt5_mostmony_av12x21[4]                   0.32 1.00     7335     2583
## prjthfgt5_mostmony_av12x21[5]                   0.32 1.00     5797     2765
## prjthfgt5_mostmony_av12x21[6]                   0.31 1.00     6894     2968
## prjthfgt5_mostmony_av12x21[7]                   0.31 1.00     6682     3016
## prjthfgt5_mostmony_av12x21[8]                   0.32 1.00     7564     3180
## prjthfgt5_mostmony_devx2:rural.ses.med21[1]     0.72 1.00     6014     2966
## prjthfgt5_mostmony_devx2:rural.ses.med21[2]     0.60 1.00     6739     2543
## prjthfgt5_mostmony_devx2:rural.ses.med21[3]     0.70 1.00     6351     3065
## prjthfgt5_mostmony_devx2:rural.ses.med21[4]     0.66 1.00     6547     3003
## prjthfgt5_mostmony_devx2:rural.ses.med31[1]     0.69 1.00     5840     2966
## prjthfgt5_mostmony_devx2:rural.ses.med31[2]     0.76 1.00     4646     2883
## prjthfgt5_mostmony_devx2:rural.ses.med31[3]     0.58 1.00     4262     2982
## prjthfgt5_mostmony_devx2:rural.ses.med31[4]     0.68 1.00     5393     2838
## prjthfgt5_mostmony_devx2:rural.ses.med41[1]     0.70 1.00     6013     2656
## prjthfgt5_mostmony_devx2:rural.ses.med41[2]     0.74 1.00     4794     2090
## prjthfgt5_mostmony_devx2:rural.ses.med41[3]     0.53 1.00     3928     3003
## prjthfgt5_mostmony_devx2:rural.ses.med41[4]     0.62 1.00     5908     2921
## prjthreat_mostmony_devx21[1]                    0.59 1.00     7384     2730
## prjthreat_mostmony_devx21[2]                    0.57 1.00     6565     2339
## prjthreat_mostmony_devx21[3]                    0.60 1.00     6923     2779
## prjthreat_mostmony_devx21[4]                    0.57 1.00     5506     2405
## prjthreat_mostmony_av12x21[1]                   0.32 1.00     6135     2697
## prjthreat_mostmony_av12x21[2]                   0.33 1.00     8581     2596
## prjthreat_mostmony_av12x21[3]                   0.32 1.00     6897     2463
## prjthreat_mostmony_av12x21[4]                   0.34 1.00     6604     2617
## prjthreat_mostmony_av12x21[5]                   0.35 1.00     7445     2532
## prjthreat_mostmony_av12x21[6]                   0.32 1.00     6063     2501
## prjthreat_mostmony_av12x21[7]                   0.31 1.00     6979     2814
## prjthreat_mostmony_av12x21[8]                   0.30 1.00     7052     2333
## prjthreat_mostmony_devx2:rural.ses.med21[1]     0.72 1.00     5652     2350
## prjthreat_mostmony_devx2:rural.ses.med21[2]     0.63 1.00     6066     2512
## prjthreat_mostmony_devx2:rural.ses.med21[3]     0.72 1.00     7074     2877
## prjthreat_mostmony_devx2:rural.ses.med21[4]     0.71 1.00     5831     2568
## prjthreat_mostmony_devx2:rural.ses.med31[1]     0.69 1.00     6345     2330
## prjthreat_mostmony_devx2:rural.ses.med31[2]     0.67 1.00     5207     2581
## prjthreat_mostmony_devx2:rural.ses.med31[3]     0.68 1.00     5976     2696
## prjthreat_mostmony_devx2:rural.ses.med31[4]     0.75 1.00     5729     2774
## prjthreat_mostmony_devx2:rural.ses.med41[1]     0.76 1.00     4440     2637
## prjthreat_mostmony_devx2:rural.ses.med41[2]     0.68 1.00     5461     3137
## prjthreat_mostmony_devx2:rural.ses.med41[3]     0.61 1.00     4150     3073
## prjthreat_mostmony_devx2:rural.ses.med41[4]     0.73 1.00     6589     2621
## prjharm_mostmony_devx21[1]                      0.60 1.00     7494     2609
## prjharm_mostmony_devx21[2]                      0.56 1.00     6707     2881
## prjharm_mostmony_devx21[3]                      0.60 1.01     7965     3020
## prjharm_mostmony_devx21[4]                      0.59 1.00     6320     2988
## prjharm_mostmony_av12x21[1]                     0.31 1.00     7237     2312
## prjharm_mostmony_av12x21[2]                     0.31 1.00     6752     1991
## prjharm_mostmony_av12x21[3]                     0.32 1.00     7789     2146
## prjharm_mostmony_av12x21[4]                     0.31 1.00     6472     2599
## prjharm_mostmony_av12x21[5]                     0.33 1.00     7805     2526
## prjharm_mostmony_av12x21[6]                     0.34 1.00     6883     2728
## prjharm_mostmony_av12x21[7]                     0.31 1.00     5911     2866
## prjharm_mostmony_av12x21[8]                     0.30 1.00     6440     3021
## prjharm_mostmony_devx2:rural.ses.med21[1]       0.70 1.00     6010     2317
## prjharm_mostmony_devx2:rural.ses.med21[2]       0.66 1.00     6124     2848
## prjharm_mostmony_devx2:rural.ses.med21[3]       0.66 1.00     6102     2237
## prjharm_mostmony_devx2:rural.ses.med21[4]       0.74 1.00     5120     3067
## prjharm_mostmony_devx2:rural.ses.med31[1]       0.67 1.00     5738     2481
## prjharm_mostmony_devx2:rural.ses.med31[2]       0.69 1.00     5037     2411
## prjharm_mostmony_devx2:rural.ses.med31[3]       0.72 1.00     5255     2838
## prjharm_mostmony_devx2:rural.ses.med31[4]       0.74 1.00     6830     3086
## prjharm_mostmony_devx2:rural.ses.med41[1]       0.72 1.00     7511     2586
## prjharm_mostmony_devx2:rural.ses.med41[2]       0.68 1.00     5931     2497
## prjharm_mostmony_devx2:rural.ses.med41[3]       0.65 1.00     6309     2909
## prjharm_mostmony_devx2:rural.ses.med41[4]       0.75 1.00     6044     2832
## prjusedrg_mostmony_devx21[1]                    0.60 1.00     8297     2551
## prjusedrg_mostmony_devx21[2]                    0.59 1.00     8930     2341
## prjusedrg_mostmony_devx21[3]                    0.55 1.00     7748     2906
## prjusedrg_mostmony_devx21[4]                    0.59 1.00     7785     2816
## prjusedrg_mostmony_av12x21[1]                   0.32 1.00     6441     2563
## prjusedrg_mostmony_av12x21[2]                   0.32 1.00     5849     2057
## prjusedrg_mostmony_av12x21[3]                   0.31 1.00     6871     2510
## prjusedrg_mostmony_av12x21[4]                   0.32 1.00     6328     3064
## prjusedrg_mostmony_av12x21[5]                   0.32 1.00     7700     2779
## prjusedrg_mostmony_av12x21[6]                   0.33 1.00     6995     2444
## prjusedrg_mostmony_av12x21[7]                   0.30 1.00     7330     3328
## prjusedrg_mostmony_av12x21[8]                   0.31 1.00     6803     2978
## prjusedrg_mostmony_devx2:rural.ses.med21[1]     0.74 1.00     5474     2234
## prjusedrg_mostmony_devx2:rural.ses.med21[2]     0.65 1.00     6157     2521
## prjusedrg_mostmony_devx2:rural.ses.med21[3]     0.67 1.00     5676     2677
## prjusedrg_mostmony_devx2:rural.ses.med21[4]     0.73 1.00     4928     2769
## prjusedrg_mostmony_devx2:rural.ses.med31[1]     0.71 1.00     5342     2427
## prjusedrg_mostmony_devx2:rural.ses.med31[2]     0.66 1.00     6359     2424
## prjusedrg_mostmony_devx2:rural.ses.med31[3]     0.69 1.00     5882     2324
## prjusedrg_mostmony_devx2:rural.ses.med31[4]     0.73 1.00     4886     2800
## prjusedrg_mostmony_devx2:rural.ses.med41[1]     0.78 1.00     4089     2539
## prjusedrg_mostmony_devx2:rural.ses.med41[2]     0.67 1.00     5784     2539
## prjusedrg_mostmony_devx2:rural.ses.med41[3]     0.66 1.00     4281     2965
## prjusedrg_mostmony_devx2:rural.ses.med41[4]     0.75 1.00     5929     3103
## prjhack_mostmony_devx21[1]                      0.59 1.00     8527     2597
## prjhack_mostmony_devx21[2]                      0.56 1.00     6115     2227
## prjhack_mostmony_devx21[3]                      0.58 1.00     6545     3252
## prjhack_mostmony_devx21[4]                      0.57 1.00     6254     2954
## prjhack_mostmony_av12x21[1]                     0.32 1.00     7320     2266
## prjhack_mostmony_av12x21[2]                     0.34 1.00     7132     2650
## prjhack_mostmony_av12x21[3]                     0.32 1.00     5903     2153
## prjhack_mostmony_av12x21[4]                     0.31 1.00     7110     2667
## prjhack_mostmony_av12x21[5]                     0.30 1.00     6136     2413
## prjhack_mostmony_av12x21[6]                     0.31 1.00     8614     2678
## prjhack_mostmony_av12x21[7]                     0.32 1.00     7226     2986
## prjhack_mostmony_av12x21[8]                     0.32 1.00     6712     2919
## prjhack_mostmony_devx2:rural.ses.med21[1]       0.74 1.00     4753     2246
## prjhack_mostmony_devx2:rural.ses.med21[2]       0.68 1.00     6622     2576
## prjhack_mostmony_devx2:rural.ses.med21[3]       0.66 1.00     5539     2637
## prjhack_mostmony_devx2:rural.ses.med21[4]       0.73 1.00     6067     2984
## prjhack_mostmony_devx2:rural.ses.med31[1]       0.66 1.00     5357     2546
## prjhack_mostmony_devx2:rural.ses.med31[2]       0.69 1.00     4550     3215
## prjhack_mostmony_devx2:rural.ses.med31[3]       0.78 1.00     4474     3461
## prjhack_mostmony_devx2:rural.ses.med31[4]       0.74 1.00     5711     2650
## prjhack_mostmony_devx2:rural.ses.med41[1]       0.72 1.00     6390     2576
## prjhack_mostmony_devx2:rural.ses.med41[2]       0.67 1.00     6446     2618
## prjhack_mostmony_devx2:rural.ses.med41[3]       0.65 1.00     5715     2929
## prjhack_mostmony_devx2:rural.ses.med41[4]       0.75 1.00     5735     2495
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.1.1.4 Prior summary
out.chg.prjcrime.stmony.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##          prjhack                          user
##          prjhack                          user
##          prjhack                          user
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjharm                          user
##          prjharm                          user
##          prjharm                          user
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##                                        default
##          prjhack                          user
##          prjharm                          user
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthreat                          user
##        prjusedrg                          user
##          prjhack             0         default
##          prjharm             0         default
##        prjthfgt5             0         default
##        prjthflt5             0         default
##        prjthreat             0         default
##        prjusedrg             0         default
##     id   prjhack             0    (vectorized)
##     id   prjhack             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##          prjhack                          user
##          prjhack                       default
##          prjhack                       default
##          prjhack                       default
##          prjhack                          user
##          prjharm                          user
##          prjharm                       default
##          prjharm                       default
##          prjharm                       default
##          prjharm                          user
##        prjthfgt5                          user
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                          user
##        prjthreat                          user
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                          user
##        prjusedrg                          user
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                          user

8.1.1.2 Corr X Community: sttran & prj crime

#Community Change: criminal intent items ~ mo(sttran)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mosttran_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mosttran_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mosttran_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mosttran_av12x21', 
                  resp = prjdv_names)
  )

# drop year from model to avoid inappropriately partially out systematic stress change differences.  
  # also, with two waves, can only add random int OR random slope for year
chg.prjcrime.sttran.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(sttran_devx2) + mo(sttran_av12x2) + 
    rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_sttran_comm_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.sttran.comm.fit <- ppchecks(chg.prjcrime.sttran.comm.fit)
8.1.1.2.1 Coefficient plot (intervals)
out.chg.prjcrime.sttran.comm.fit[[10]]

8.1.1.2.2 PPcheck (density)
p1 <- out.chg.prjcrime.sttran.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.sttran.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.sttran.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.sttran.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.sttran.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.sttran.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

8.1.1.2.3 Fit summary
out.chg.prjcrime.sttran.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          prjharm ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          prjhack ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.93      0.57     2.87     5.15 1.00     1593
## sd(prjthfgt5_Intercept)     3.36      0.50     2.45     4.42 1.00     1522
## sd(prjthreat_Intercept)     3.31      0.58     2.32     4.57 1.00     1713
## sd(prjharm_Intercept)       3.13      0.59     2.11     4.40 1.00     1763
## sd(prjusedrg_Intercept)     3.01      0.56     2.02     4.20 1.00     1889
## sd(prjhack_Intercept)       0.93      0.58     0.04     2.13 1.00      747
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2409
## sd(prjthfgt5_Intercept)     2437
## sd(prjthreat_Intercept)     2794
## sd(prjharm_Intercept)       2669
## sd(prjusedrg_Intercept)     2376
## sd(prjhack_Intercept)       1667
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_Intercept                        -5.31      0.88    -7.12    -3.67
## prjthfgt5_Intercept                        -5.03      0.82    -6.69    -3.47
## prjthreat_Intercept                        -5.98      0.95    -7.95    -4.17
## prjharm_Intercept                          -5.13      0.97    -7.17    -3.30
## prjusedrg_Intercept                        -5.55      0.95    -7.55    -3.80
## prjhack_Intercept                          -3.84      0.78    -5.49    -2.39
## prjthflt5_rural.ses.med2                   -0.48      0.88    -2.15     1.28
## prjthflt5_rural.ses.med3                    1.14      0.80    -0.53     2.63
## prjthflt5_rural.ses.med4                    1.26      0.85    -0.48     2.81
## prjthfgt5_rural.ses.med2                   -0.51      0.89    -2.21     1.30
## prjthfgt5_rural.ses.med3                    1.18      0.78    -0.45     2.62
## prjthfgt5_rural.ses.med4                    1.11      0.79    -0.49     2.63
## prjthreat_rural.ses.med2                   -0.31      0.91    -2.02     1.48
## prjthreat_rural.ses.med3                    0.54      0.79    -1.09     2.07
## prjthreat_rural.ses.med4                    1.55      0.87    -0.29     3.20
## prjharm_rural.ses.med2                      0.20      0.88    -1.52     1.93
## prjharm_rural.ses.med3                     -0.04      0.80    -1.68     1.47
## prjharm_rural.ses.med4                      1.36      0.76    -0.24     2.75
## prjusedrg_rural.ses.med2                   -0.27      0.85    -1.90     1.44
## prjusedrg_rural.ses.med3                   -0.04      0.83    -1.64     1.58
## prjusedrg_rural.ses.med4                    1.67      0.80    -0.04     3.15
## prjhack_rural.ses.med2                     -0.38      0.84    -2.06     1.33
## prjhack_rural.ses.med3                      0.10      0.74    -1.39     1.60
## prjhack_rural.ses.med4                      1.25      0.68    -0.12     2.58
## prjthflt5_mosttran_devx2                   -0.09      0.19    -0.46     0.29
## prjthflt5_mosttran_av12x2                  -0.12      0.10    -0.31     0.07
## prjthflt5_mosttran_devx2:rural.ses.med2    -0.64      0.54    -1.77     0.36
## prjthflt5_mosttran_devx2:rural.ses.med3     0.23      0.42    -0.55     1.12
## prjthflt5_mosttran_devx2:rural.ses.med4     0.65      0.45    -0.14     1.62
## prjthfgt5_mosttran_devx2                   -0.06      0.20    -0.48     0.32
## prjthfgt5_mosttran_av12x2                  -0.07      0.09    -0.25     0.11
## prjthfgt5_mosttran_devx2:rural.ses.med2    -0.76      0.51    -1.81     0.20
## prjthfgt5_mosttran_devx2:rural.ses.med3     0.06      0.42    -0.77     0.95
## prjthfgt5_mosttran_devx2:rural.ses.med4     0.53      0.36    -0.14     1.29
## prjthreat_mosttran_devx2                   -0.18      0.21    -0.59     0.22
## prjthreat_mosttran_av12x2                  -0.06      0.09    -0.25     0.12
## prjthreat_mosttran_devx2:rural.ses.med2    -0.76      0.63    -2.08     0.39
## prjthreat_mosttran_devx2:rural.ses.med3    -0.03      0.47    -0.97     0.89
## prjthreat_mosttran_devx2:rural.ses.med4     0.08      0.48    -0.83     1.09
## prjharm_mosttran_devx2                     -0.28      0.21    -0.70     0.14
## prjharm_mosttran_av12x2                    -0.17      0.10    -0.35     0.03
## prjharm_mosttran_devx2:rural.ses.med2      -0.79      0.58    -2.06     0.25
## prjharm_mosttran_devx2:rural.ses.med3       0.19      0.48    -0.81     1.08
## prjharm_mosttran_devx2:rural.ses.med4      -0.41      0.54    -1.53     0.64
## prjusedrg_mosttran_devx2                   -0.18      0.21    -0.60     0.23
## prjusedrg_mosttran_av12x2                  -0.07      0.10    -0.27     0.12
## prjusedrg_mosttran_devx2:rural.ses.med2    -0.56      0.60    -1.87     0.51
## prjusedrg_mosttran_devx2:rural.ses.med3    -0.69      0.58    -1.90     0.37
## prjusedrg_mosttran_devx2:rural.ses.med4    -0.08      0.50    -1.10     0.88
## prjhack_mosttran_devx2                     -0.19      0.21    -0.59     0.21
## prjhack_mosttran_av12x2                    -0.03      0.09    -0.20     0.14
## prjhack_mosttran_devx2:rural.ses.med2      -0.69      0.61    -1.96     0.44
## prjhack_mosttran_devx2:rural.ses.med3      -0.03      0.47    -1.05     0.82
## prjhack_mosttran_devx2:rural.ses.med4      -0.31      0.42    -1.27     0.45
##                                         Rhat Bulk_ESS Tail_ESS
## prjthflt5_Intercept                     1.00     2917     3185
## prjthfgt5_Intercept                     1.00     2650     2720
## prjthreat_Intercept                     1.00     3296     3132
## prjharm_Intercept                       1.00     2898     2519
## prjusedrg_Intercept                     1.00     3364     3442
## prjhack_Intercept                       1.00     2231     2351
## prjthflt5_rural.ses.med2                1.00     5716     2906
## prjthflt5_rural.ses.med3                1.00     4594     2902
## prjthflt5_rural.ses.med4                1.00     4894     3034
## prjthfgt5_rural.ses.med2                1.00     5379     3445
## prjthfgt5_rural.ses.med3                1.00     4437     3212
## prjthfgt5_rural.ses.med4                1.00     4526     2910
## prjthreat_rural.ses.med2                1.00     5490     3044
## prjthreat_rural.ses.med3                1.00     5482     2993
## prjthreat_rural.ses.med4                1.00     4426     3092
## prjharm_rural.ses.med2                  1.00     5878     3011
## prjharm_rural.ses.med3                  1.00     5500     3224
## prjharm_rural.ses.med4                  1.00     4373     3006
## prjusedrg_rural.ses.med2                1.00     5636     3208
## prjusedrg_rural.ses.med3                1.00     5614     3378
## prjusedrg_rural.ses.med4                1.00     3972     3287
## prjhack_rural.ses.med2                  1.00     5977     3163
## prjhack_rural.ses.med3                  1.00     4919     3133
## prjhack_rural.ses.med4                  1.00     4583     2899
## prjthflt5_mosttran_devx2                1.00     4943     3307
## prjthflt5_mosttran_av12x2               1.00     3510     3163
## prjthflt5_mosttran_devx2:rural.ses.med2 1.00     3879     2862
## prjthflt5_mosttran_devx2:rural.ses.med3 1.00     3397     2733
## prjthflt5_mosttran_devx2:rural.ses.med4 1.00     2885     2401
## prjthfgt5_mosttran_devx2                1.00     4672     2964
## prjthfgt5_mosttran_av12x2               1.00     4224     2741
## prjthfgt5_mosttran_devx2:rural.ses.med2 1.00     3176     2681
## prjthfgt5_mosttran_devx2:rural.ses.med3 1.00     2624     2716
## prjthfgt5_mosttran_devx2:rural.ses.med4 1.00     3827     3188
## prjthreat_mosttran_devx2                1.00     5729     3202
## prjthreat_mosttran_av12x2               1.00     5051     3057
## prjthreat_mosttran_devx2:rural.ses.med2 1.00     4504     3241
## prjthreat_mosttran_devx2:rural.ses.med3 1.00     3266     2971
## prjthreat_mosttran_devx2:rural.ses.med4 1.00     2975     2809
## prjharm_mosttran_devx2                  1.00     5372     3446
## prjharm_mosttran_av12x2                 1.00     5103     3402
## prjharm_mosttran_devx2:rural.ses.med2   1.00     4361     2946
## prjharm_mosttran_devx2:rural.ses.med3   1.00     3924     2785
## prjharm_mosttran_devx2:rural.ses.med4   1.00     3247     2921
## prjusedrg_mosttran_devx2                1.00     5729     2824
## prjusedrg_mosttran_av12x2               1.00     4798     2857
## prjusedrg_mosttran_devx2:rural.ses.med2 1.00     4579     2943
## prjusedrg_mosttran_devx2:rural.ses.med3 1.00     4508     3037
## prjusedrg_mosttran_devx2:rural.ses.med4 1.00     2440     2934
## prjhack_mosttran_devx2                  1.00     5769     3020
## prjhack_mosttran_av12x2                 1.00     5700     3037
## prjhack_mosttran_devx2:rural.ses.med2   1.00     4518     3211
## prjhack_mosttran_devx2:rural.ses.med3   1.00     4022     3061
## prjhack_mosttran_devx2:rural.ses.med4   1.00     4000     2768
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## prjthflt5_mosttran_devx21[1]                    0.27      0.15     0.04
## prjthflt5_mosttran_devx21[2]                    0.24      0.14     0.03
## prjthflt5_mosttran_devx21[3]                    0.24      0.14     0.04
## prjthflt5_mosttran_devx21[4]                    0.25      0.15     0.04
## prjthflt5_mosttran_av12x21[1]                   0.13      0.08     0.02
## prjthflt5_mosttran_av12x21[2]                   0.14      0.09     0.02
## prjthflt5_mosttran_av12x21[3]                   0.12      0.08     0.01
## prjthflt5_mosttran_av12x21[4]                   0.13      0.08     0.02
## prjthflt5_mosttran_av12x21[5]                   0.12      0.08     0.02
## prjthflt5_mosttran_av12x21[6]                   0.12      0.07     0.02
## prjthflt5_mosttran_av12x21[7]                   0.12      0.08     0.02
## prjthflt5_mosttran_av12x21[8]                   0.12      0.08     0.02
## prjthflt5_mosttran_devx2:rural.ses.med21[1]     0.31      0.21     0.01
## prjthflt5_mosttran_devx2:rural.ses.med21[2]     0.22      0.17     0.01
## prjthflt5_mosttran_devx2:rural.ses.med21[3]     0.21      0.17     0.01
## prjthflt5_mosttran_devx2:rural.ses.med21[4]     0.26      0.20     0.01
## prjthflt5_mosttran_devx2:rural.ses.med31[1]     0.29      0.21     0.01
## prjthflt5_mosttran_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## prjthflt5_mosttran_devx2:rural.ses.med31[3]     0.20      0.17     0.01
## prjthflt5_mosttran_devx2:rural.ses.med31[4]     0.29      0.21     0.01
## prjthflt5_mosttran_devx2:rural.ses.med41[1]     0.36      0.22     0.02
## prjthflt5_mosttran_devx2:rural.ses.med41[2]     0.16      0.15     0.00
## prjthflt5_mosttran_devx2:rural.ses.med41[3]     0.16      0.15     0.00
## prjthflt5_mosttran_devx2:rural.ses.med41[4]     0.32      0.22     0.01
## prjthfgt5_mosttran_devx21[1]                    0.27      0.15     0.03
## prjthfgt5_mosttran_devx21[2]                    0.24      0.14     0.04
## prjthfgt5_mosttran_devx21[3]                    0.23      0.14     0.03
## prjthfgt5_mosttran_devx21[4]                    0.26      0.15     0.04
## prjthfgt5_mosttran_av12x21[1]                   0.13      0.09     0.02
## prjthfgt5_mosttran_av12x21[2]                   0.13      0.09     0.02
## prjthfgt5_mosttran_av12x21[3]                   0.12      0.08     0.02
## prjthfgt5_mosttran_av12x21[4]                   0.13      0.08     0.02
## prjthfgt5_mosttran_av12x21[5]                   0.12      0.08     0.02
## prjthfgt5_mosttran_av12x21[6]                   0.11      0.08     0.02
## prjthfgt5_mosttran_av12x21[7]                   0.12      0.08     0.01
## prjthfgt5_mosttran_av12x21[8]                   0.13      0.08     0.02
## prjthfgt5_mosttran_devx2:rural.ses.med21[1]     0.33      0.21     0.02
## prjthfgt5_mosttran_devx2:rural.ses.med21[2]     0.24      0.18     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med21[3]     0.19      0.16     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med21[4]     0.25      0.19     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med31[2]     0.21      0.18     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med31[3]     0.22      0.18     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med31[4]     0.30      0.22     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med41[1]     0.29      0.20     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med41[2]     0.23      0.18     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med41[3]     0.22      0.17     0.01
## prjthfgt5_mosttran_devx2:rural.ses.med41[4]     0.25      0.19     0.01
## prjthreat_mosttran_devx21[1]                    0.27      0.15     0.04
## prjthreat_mosttran_devx21[2]                    0.25      0.14     0.04
## prjthreat_mosttran_devx21[3]                    0.24      0.14     0.03
## prjthreat_mosttran_devx21[4]                    0.25      0.15     0.03
## prjthreat_mosttran_av12x21[1]                   0.13      0.08     0.02
## prjthreat_mosttran_av12x21[2]                   0.13      0.08     0.02
## prjthreat_mosttran_av12x21[3]                   0.13      0.08     0.02
## prjthreat_mosttran_av12x21[4]                   0.13      0.08     0.02
## prjthreat_mosttran_av12x21[5]                   0.12      0.08     0.02
## prjthreat_mosttran_av12x21[6]                   0.12      0.08     0.02
## prjthreat_mosttran_av12x21[7]                   0.12      0.08     0.01
## prjthreat_mosttran_av12x21[8]                   0.13      0.08     0.02
## prjthreat_mosttran_devx2:rural.ses.med21[1]     0.29      0.20     0.01
## prjthreat_mosttran_devx2:rural.ses.med21[2]     0.21      0.17     0.00
## prjthreat_mosttran_devx2:rural.ses.med21[3]     0.26      0.19     0.01
## prjthreat_mosttran_devx2:rural.ses.med21[4]     0.25      0.19     0.01
## prjthreat_mosttran_devx2:rural.ses.med31[1]     0.25      0.19     0.01
## prjthreat_mosttran_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## prjthreat_mosttran_devx2:rural.ses.med31[3]     0.24      0.19     0.01
## prjthreat_mosttran_devx2:rural.ses.med31[4]     0.30      0.22     0.01
## prjthreat_mosttran_devx2:rural.ses.med41[1]     0.30      0.23     0.01
## prjthreat_mosttran_devx2:rural.ses.med41[2]     0.21      0.18     0.01
## prjthreat_mosttran_devx2:rural.ses.med41[3]     0.21      0.18     0.01
## prjthreat_mosttran_devx2:rural.ses.med41[4]     0.28      0.21     0.01
## prjharm_mosttran_devx21[1]                      0.27      0.15     0.04
## prjharm_mosttran_devx21[2]                      0.24      0.14     0.04
## prjharm_mosttran_devx21[3]                      0.27      0.15     0.05
## prjharm_mosttran_devx21[4]                      0.23      0.14     0.03
## prjharm_mosttran_av12x21[1]                     0.12      0.07     0.02
## prjharm_mosttran_av12x21[2]                     0.12      0.08     0.02
## prjharm_mosttran_av12x21[3]                     0.14      0.09     0.02
## prjharm_mosttran_av12x21[4]                     0.14      0.09     0.02
## prjharm_mosttran_av12x21[5]                     0.14      0.08     0.02
## prjharm_mosttran_av12x21[6]                     0.12      0.07     0.02
## prjharm_mosttran_av12x21[7]                     0.11      0.07     0.02
## prjharm_mosttran_av12x21[8]                     0.11      0.07     0.01
## prjharm_mosttran_devx2:rural.ses.med21[1]       0.29      0.20     0.01
## prjharm_mosttran_devx2:rural.ses.med21[2]       0.19      0.16     0.01
## prjharm_mosttran_devx2:rural.ses.med21[3]       0.27      0.20     0.01
## prjharm_mosttran_devx2:rural.ses.med21[4]       0.25      0.19     0.01
## prjharm_mosttran_devx2:rural.ses.med31[1]       0.23      0.18     0.01
## prjharm_mosttran_devx2:rural.ses.med31[2]       0.26      0.19     0.01
## prjharm_mosttran_devx2:rural.ses.med31[3]       0.23      0.18     0.01
## prjharm_mosttran_devx2:rural.ses.med31[4]       0.29      0.21     0.01
## prjharm_mosttran_devx2:rural.ses.med41[1]       0.19      0.18     0.01
## prjharm_mosttran_devx2:rural.ses.med41[2]       0.21      0.17     0.01
## prjharm_mosttran_devx2:rural.ses.med41[3]       0.32      0.22     0.01
## prjharm_mosttran_devx2:rural.ses.med41[4]       0.28      0.20     0.01
## prjusedrg_mosttran_devx21[1]                    0.26      0.14     0.04
## prjusedrg_mosttran_devx21[2]                    0.24      0.14     0.04
## prjusedrg_mosttran_devx21[3]                    0.25      0.14     0.04
## prjusedrg_mosttran_devx21[4]                    0.25      0.14     0.04
## prjusedrg_mosttran_av12x21[1]                   0.13      0.08     0.02
## prjusedrg_mosttran_av12x21[2]                   0.12      0.08     0.02
## prjusedrg_mosttran_av12x21[3]                   0.13      0.08     0.02
## prjusedrg_mosttran_av12x21[4]                   0.13      0.09     0.02
## prjusedrg_mosttran_av12x21[5]                   0.12      0.08     0.01
## prjusedrg_mosttran_av12x21[6]                   0.12      0.08     0.02
## prjusedrg_mosttran_av12x21[7]                   0.12      0.08     0.01
## prjusedrg_mosttran_av12x21[8]                   0.12      0.08     0.01
## prjusedrg_mosttran_devx2:rural.ses.med21[1]     0.26      0.19     0.01
## prjusedrg_mosttran_devx2:rural.ses.med21[2]     0.20      0.17     0.00
## prjusedrg_mosttran_devx2:rural.ses.med21[3]     0.27      0.20     0.01
## prjusedrg_mosttran_devx2:rural.ses.med21[4]     0.27      0.20     0.01
## prjusedrg_mosttran_devx2:rural.ses.med31[1]     0.25      0.18     0.01
## prjusedrg_mosttran_devx2:rural.ses.med31[2]     0.20      0.17     0.01
## prjusedrg_mosttran_devx2:rural.ses.med31[3]     0.29      0.21     0.01
## prjusedrg_mosttran_devx2:rural.ses.med31[4]     0.26      0.20     0.01
## prjusedrg_mosttran_devx2:rural.ses.med41[1]     0.26      0.22     0.01
## prjusedrg_mosttran_devx2:rural.ses.med41[2]     0.21      0.18     0.01
## prjusedrg_mosttran_devx2:rural.ses.med41[3]     0.24      0.19     0.01
## prjusedrg_mosttran_devx2:rural.ses.med41[4]     0.29      0.21     0.01
## prjhack_mosttran_devx21[1]                      0.27      0.15     0.04
## prjhack_mosttran_devx21[2]                      0.25      0.14     0.04
## prjhack_mosttran_devx21[3]                      0.23      0.14     0.03
## prjhack_mosttran_devx21[4]                      0.25      0.15     0.03
## prjhack_mosttran_av12x21[1]                     0.13      0.08     0.02
## prjhack_mosttran_av12x21[2]                     0.13      0.08     0.02
## prjhack_mosttran_av12x21[3]                     0.13      0.08     0.02
## prjhack_mosttran_av12x21[4]                     0.13      0.08     0.02
## prjhack_mosttran_av12x21[5]                     0.12      0.08     0.02
## prjhack_mosttran_av12x21[6]                     0.12      0.08     0.01
## prjhack_mosttran_av12x21[7]                     0.12      0.08     0.01
## prjhack_mosttran_av12x21[8]                     0.13      0.08     0.02
## prjhack_mosttran_devx2:rural.ses.med21[1]       0.27      0.20     0.01
## prjhack_mosttran_devx2:rural.ses.med21[2]       0.22      0.18     0.01
## prjhack_mosttran_devx2:rural.ses.med21[3]       0.26      0.19     0.01
## prjhack_mosttran_devx2:rural.ses.med21[4]       0.26      0.19     0.01
## prjhack_mosttran_devx2:rural.ses.med31[1]       0.24      0.19     0.01
## prjhack_mosttran_devx2:rural.ses.med31[2]       0.23      0.19     0.01
## prjhack_mosttran_devx2:rural.ses.med31[3]       0.24      0.19     0.01
## prjhack_mosttran_devx2:rural.ses.med31[4]       0.29      0.21     0.01
## prjhack_mosttran_devx2:rural.ses.med41[1]       0.21      0.17     0.01
## prjhack_mosttran_devx2:rural.ses.med41[2]       0.27      0.20     0.01
## prjhack_mosttran_devx2:rural.ses.med41[3]       0.22      0.18     0.01
## prjhack_mosttran_devx2:rural.ses.med41[4]       0.30      0.21     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## prjthflt5_mosttran_devx21[1]                    0.61 1.00     6897     2670
## prjthflt5_mosttran_devx21[2]                    0.57 1.00     6472     2443
## prjthflt5_mosttran_devx21[3]                    0.57 1.00     6513     2754
## prjthflt5_mosttran_devx21[4]                    0.58 1.00     6905     2782
## prjthflt5_mosttran_av12x21[1]                   0.32 1.00     7035     2713
## prjthflt5_mosttran_av12x21[2]                   0.35 1.00     7739     2471
## prjthflt5_mosttran_av12x21[3]                   0.31 1.00     7310     2362
## prjthflt5_mosttran_av12x21[4]                   0.32 1.00     6722     2808
## prjthflt5_mosttran_av12x21[5]                   0.31 1.00     6588     2680
## prjthflt5_mosttran_av12x21[6]                   0.30 1.00     6848     2475
## prjthflt5_mosttran_av12x21[7]                   0.31 1.00     6128     2856
## prjthflt5_mosttran_av12x21[8]                   0.31 1.00     6025     3115
## prjthflt5_mosttran_devx2:rural.ses.med21[1]     0.75 1.00     4670     2912
## prjthflt5_mosttran_devx2:rural.ses.med21[2]     0.64 1.00     5189     2395
## prjthflt5_mosttran_devx2:rural.ses.med21[3]     0.63 1.00     5890     2341
## prjthflt5_mosttran_devx2:rural.ses.med21[4]     0.71 1.00     6132     2212
## prjthflt5_mosttran_devx2:rural.ses.med31[1]     0.74 1.00     4387     2425
## prjthflt5_mosttran_devx2:rural.ses.med31[2]     0.66 1.00     5015     2354
## prjthflt5_mosttran_devx2:rural.ses.med31[3]     0.63 1.00     4394     2770
## prjthflt5_mosttran_devx2:rural.ses.med31[4]     0.76 1.01     6082     2583
## prjthflt5_mosttran_devx2:rural.ses.med41[1]     0.79 1.00     5159     2827
## prjthflt5_mosttran_devx2:rural.ses.med41[2]     0.57 1.00     4732     2723
## prjthflt5_mosttran_devx2:rural.ses.med41[3]     0.55 1.00     4893     2769
## prjthflt5_mosttran_devx2:rural.ses.med41[4]     0.77 1.00     5302     2901
## prjthfgt5_mosttran_devx21[1]                    0.62 1.00     6747     2195
## prjthfgt5_mosttran_devx21[2]                    0.57 1.00     6935     2449
## prjthfgt5_mosttran_devx21[3]                    0.56 1.00     6782     3011
## prjthfgt5_mosttran_devx21[4]                    0.60 1.00     6202     3018
## prjthfgt5_mosttran_av12x21[1]                   0.33 1.00     7789     2689
## prjthfgt5_mosttran_av12x21[2]                   0.35 1.00     6433     2459
## prjthfgt5_mosttran_av12x21[3]                   0.31 1.00     6334     2503
## prjthfgt5_mosttran_av12x21[4]                   0.33 1.00     6623     2388
## prjthfgt5_mosttran_av12x21[5]                   0.30 1.00     6891     3006
## prjthfgt5_mosttran_av12x21[6]                   0.31 1.00     7112     2634
## prjthfgt5_mosttran_av12x21[7]                   0.32 1.00     5407     2528
## prjthfgt5_mosttran_av12x21[8]                   0.32 1.00     6899     2711
## prjthfgt5_mosttran_devx2:rural.ses.med21[1]     0.75 1.00     4795     2649
## prjthfgt5_mosttran_devx2:rural.ses.med21[2]     0.67 1.00     5909     2597
## prjthfgt5_mosttran_devx2:rural.ses.med21[3]     0.59 1.00     5000     2535
## prjthfgt5_mosttran_devx2:rural.ses.med21[4]     0.69 1.00     5503     2293
## prjthfgt5_mosttran_devx2:rural.ses.med31[1]     0.74 1.00     4707     2871
## prjthfgt5_mosttran_devx2:rural.ses.med31[2]     0.66 1.00     6782     2840
## prjthfgt5_mosttran_devx2:rural.ses.med31[3]     0.68 1.00     4432     2391
## prjthfgt5_mosttran_devx2:rural.ses.med31[4]     0.76 1.00     5250     2751
## prjthfgt5_mosttran_devx2:rural.ses.med41[1]     0.72 1.00     5663     2547
## prjthfgt5_mosttran_devx2:rural.ses.med41[2]     0.65 1.00     5037     2720
## prjthfgt5_mosttran_devx2:rural.ses.med41[3]     0.66 1.00     4161     2560
## prjthfgt5_mosttran_devx2:rural.ses.med41[4]     0.67 1.00     5372     2532
## prjthreat_mosttran_devx21[1]                    0.59 1.00     7663     2472
## prjthreat_mosttran_devx21[2]                    0.56 1.00     5778     2594
## prjthreat_mosttran_devx21[3]                    0.55 1.00     6808     2441
## prjthreat_mosttran_devx21[4]                    0.59 1.00     7471     2154
## prjthreat_mosttran_av12x21[1]                   0.33 1.00     7604     2649
## prjthreat_mosttran_av12x21[2]                   0.33 1.00     6432     1989
## prjthreat_mosttran_av12x21[3]                   0.32 1.00     6637     2592
## prjthreat_mosttran_av12x21[4]                   0.32 1.00     6645     2511
## prjthreat_mosttran_av12x21[5]                   0.32 1.00     7518     2719
## prjthreat_mosttran_av12x21[6]                   0.31 1.00     6239     2645
## prjthreat_mosttran_av12x21[7]                   0.32 1.00     7212     2448
## prjthreat_mosttran_av12x21[8]                   0.33 1.00     5961     2915
## prjthreat_mosttran_devx2:rural.ses.med21[1]     0.74 1.00     5881     2767
## prjthreat_mosttran_devx2:rural.ses.med21[2]     0.64 1.00     5992     2390
## prjthreat_mosttran_devx2:rural.ses.med21[3]     0.69 1.00     5297     2289
## prjthreat_mosttran_devx2:rural.ses.med21[4]     0.69 1.00     6384     2840
## prjthreat_mosttran_devx2:rural.ses.med31[1]     0.69 1.00     6092     2377
## prjthreat_mosttran_devx2:rural.ses.med31[2]     0.68 1.00     6500     2693
## prjthreat_mosttran_devx2:rural.ses.med31[3]     0.69 1.00     5403     2276
## prjthreat_mosttran_devx2:rural.ses.med31[4]     0.78 1.00     5126     2216
## prjthreat_mosttran_devx2:rural.ses.med41[1]     0.79 1.00     3532     2724
## prjthreat_mosttran_devx2:rural.ses.med41[2]     0.65 1.00     4701     2962
## prjthreat_mosttran_devx2:rural.ses.med41[3]     0.66 1.00     4553     2649
## prjthreat_mosttran_devx2:rural.ses.med41[4]     0.75 1.00     5348     2676
## prjharm_mosttran_devx21[1]                      0.61 1.00     7092     2186
## prjharm_mosttran_devx21[2]                      0.55 1.00     7624     2668
## prjharm_mosttran_devx21[3]                      0.59 1.00     7145     2841
## prjharm_mosttran_devx21[4]                      0.54 1.00     7331     2554
## prjharm_mosttran_av12x21[1]                     0.30 1.00     6550     2632
## prjharm_mosttran_av12x21[2]                     0.31 1.00     7190     2574
## prjharm_mosttran_av12x21[3]                     0.35 1.00     7829     2197
## prjharm_mosttran_av12x21[4]                     0.36 1.00     7124     2631
## prjharm_mosttran_av12x21[5]                     0.34 1.00     6773     2766
## prjharm_mosttran_av12x21[6]                     0.29 1.00     6492     2186
## prjharm_mosttran_av12x21[7]                     0.29 1.00     6290     2489
## prjharm_mosttran_av12x21[8]                     0.28 1.00     5969     2961
## prjharm_mosttran_devx2:rural.ses.med21[1]       0.73 1.00     5356     2294
## prjharm_mosttran_devx2:rural.ses.med21[2]       0.61 1.00     5633     2349
## prjharm_mosttran_devx2:rural.ses.med21[3]       0.73 1.00     6163     2497
## prjharm_mosttran_devx2:rural.ses.med21[4]       0.69 1.00     5727     2710
## prjharm_mosttran_devx2:rural.ses.med31[1]       0.66 1.00     6146     2476
## prjharm_mosttran_devx2:rural.ses.med31[2]       0.70 1.00     4197     2756
## prjharm_mosttran_devx2:rural.ses.med31[3]       0.67 1.00     6052     3027
## prjharm_mosttran_devx2:rural.ses.med31[4]       0.74 1.00     4924     2559
## prjharm_mosttran_devx2:rural.ses.med41[1]       0.67 1.00     4114     2715
## prjharm_mosttran_devx2:rural.ses.med41[2]       0.65 1.00     4905     2745
## prjharm_mosttran_devx2:rural.ses.med41[3]       0.79 1.00     4652     2657
## prjharm_mosttran_devx2:rural.ses.med41[4]       0.72 1.00     5764     2801
## prjusedrg_mosttran_devx21[1]                    0.58 1.00     6774     2692
## prjusedrg_mosttran_devx21[2]                    0.56 1.00     6140     2533
## prjusedrg_mosttran_devx21[3]                    0.57 1.00     5773     2611
## prjusedrg_mosttran_devx21[4]                    0.57 1.00     6870     2648
## prjusedrg_mosttran_av12x21[1]                   0.31 1.00     6352     2789
## prjusedrg_mosttran_av12x21[2]                   0.31 1.00     7360     1869
## prjusedrg_mosttran_av12x21[3]                   0.33 1.00     6850     2407
## prjusedrg_mosttran_av12x21[4]                   0.34 1.00     5618     2263
## prjusedrg_mosttran_av12x21[5]                   0.32 1.00     6472     2615
## prjusedrg_mosttran_av12x21[6]                   0.31 1.00     7321     2739
## prjusedrg_mosttran_av12x21[7]                   0.32 1.00     6552     2229
## prjusedrg_mosttran_av12x21[8]                   0.32 1.00     6141     3133
## prjusedrg_mosttran_devx2:rural.ses.med21[1]     0.71 1.00     6008     2267
## prjusedrg_mosttran_devx2:rural.ses.med21[2]     0.64 1.00     5851     2368
## prjusedrg_mosttran_devx2:rural.ses.med21[3]     0.74 1.00     5926     2892
## prjusedrg_mosttran_devx2:rural.ses.med21[4]     0.73 1.00     5726     2746
## prjusedrg_mosttran_devx2:rural.ses.med31[1]     0.67 1.00     5690     2269
## prjusedrg_mosttran_devx2:rural.ses.med31[2]     0.62 1.00     5608     2858
## prjusedrg_mosttran_devx2:rural.ses.med31[3]     0.75 1.00     5087     2988
## prjusedrg_mosttran_devx2:rural.ses.med31[4]     0.70 1.00     6741     2743
## prjusedrg_mosttran_devx2:rural.ses.med41[1]     0.77 1.00     3751     2912
## prjusedrg_mosttran_devx2:rural.ses.med41[2]     0.66 1.00     5608     2654
## prjusedrg_mosttran_devx2:rural.ses.med41[3]     0.71 1.00     3979     2653
## prjusedrg_mosttran_devx2:rural.ses.med41[4]     0.76 1.00     5848     2978
## prjhack_mosttran_devx21[1]                      0.61 1.00     7799     2744
## prjhack_mosttran_devx21[2]                      0.57 1.00     7448     2782
## prjhack_mosttran_devx21[3]                      0.55 1.00     6448     2687
## prjhack_mosttran_devx21[4]                      0.59 1.00     8608     2861
## prjhack_mosttran_av12x21[1]                     0.32 1.00     7578     2907
## prjhack_mosttran_av12x21[2]                     0.33 1.00     7823     2425
## prjhack_mosttran_av12x21[3]                     0.33 1.00     8070     2235
## prjhack_mosttran_av12x21[4]                     0.32 1.00     6190     2452
## prjhack_mosttran_av12x21[5]                     0.31 1.00     7537     2678
## prjhack_mosttran_av12x21[6]                     0.31 1.00     6562     2259
## prjhack_mosttran_av12x21[7]                     0.31 1.00     6252     2986
## prjhack_mosttran_av12x21[8]                     0.32 1.00     7039     2502
## prjhack_mosttran_devx2:rural.ses.med21[1]       0.71 1.00     5509     2510
## prjhack_mosttran_devx2:rural.ses.med21[2]       0.66 1.00     5405     2157
## prjhack_mosttran_devx2:rural.ses.med21[3]       0.70 1.00     5505     2372
## prjhack_mosttran_devx2:rural.ses.med21[4]       0.71 1.00     5670     2265
## prjhack_mosttran_devx2:rural.ses.med31[1]       0.68 1.00     6341     2423
## prjhack_mosttran_devx2:rural.ses.med31[2]       0.70 1.00     5643     2733
## prjhack_mosttran_devx2:rural.ses.med31[3]       0.70 1.00     5447     2189
## prjhack_mosttran_devx2:rural.ses.med31[4]       0.76 1.00     5177     3010
## prjhack_mosttran_devx2:rural.ses.med41[1]       0.65 1.00     4783     2406
## prjhack_mosttran_devx2:rural.ses.med41[2]       0.73 1.00     5256     2567
## prjhack_mosttran_devx2:rural.ses.med41[3]       0.65 1.00     5491     2823
## prjhack_mosttran_devx2:rural.ses.med41[4]       0.77 1.00     4651     2256
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.1.2.4 Prior summary
out.chg.prjcrime.sttran.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##          prjhack                          user
##          prjhack                          user
##          prjhack                          user
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjharm                          user
##          prjharm                          user
##          prjharm                          user
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##                                        default
##          prjhack                          user
##          prjharm                          user
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthreat                          user
##        prjusedrg                          user
##          prjhack             0         default
##          prjharm             0         default
##        prjthfgt5             0         default
##        prjthflt5             0         default
##        prjthreat             0         default
##        prjusedrg             0         default
##     id   prjhack             0    (vectorized)
##     id   prjhack             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##          prjhack                          user
##          prjhack                       default
##          prjhack                       default
##          prjhack                       default
##          prjhack                          user
##          prjharm                          user
##          prjharm                       default
##          prjharm                       default
##          prjharm                       default
##          prjharm                          user
##        prjthfgt5                          user
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                          user
##        prjthreat                          user
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                          user
##        prjusedrg                          user
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                          user

8.1.1.3 Corr X Community: stresp & prj crime

#Community Change: criminal intent items ~ mo(stresp)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostresp_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostresp_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostresp_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostresp_av12x21', 
                  resp = prjdv_names)
  )

# drop year from model to avoid inappropriately partially out systematic stress change differences.  
  # also, with two waves, can only add random int OR random slope for year
chg.prjcrime.stresp.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stresp_devx2) + mo(stresp_av12x2) + 
    rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stresp_comm_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stresp.comm.fit <- ppchecks(chg.prjcrime.stresp.comm.fit)
8.1.1.3.1 Coefficient plot (intervals)
out.chg.prjcrime.stresp.comm.fit[[10]]

8.1.1.3.2 PPcheck (density)
p1 <- out.chg.prjcrime.stresp.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stresp.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stresp.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stresp.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stresp.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stresp.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

8.1.1.3.3 Fit summary
out.chg.prjcrime.stresp.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          prjharm ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          prjhack ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.86      0.56     2.86     5.05 1.00     1696
## sd(prjthfgt5_Intercept)     3.30      0.50     2.43     4.36 1.00     1587
## sd(prjthreat_Intercept)     3.04      0.55     2.07     4.24 1.00     1533
## sd(prjharm_Intercept)       3.00      0.55     2.03     4.18 1.01     1375
## sd(prjusedrg_Intercept)     2.80      0.54     1.83     3.96 1.00     1411
## sd(prjhack_Intercept)       0.85      0.55     0.04     2.03 1.00      961
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2646
## sd(prjthfgt5_Intercept)     2256
## sd(prjthreat_Intercept)     2559
## sd(prjharm_Intercept)       2560
## sd(prjusedrg_Intercept)     1799
## sd(prjhack_Intercept)       1791
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_Intercept                        -5.76      0.86    -7.49    -4.11
## prjthfgt5_Intercept                        -5.23      0.82    -6.94    -3.72
## prjthreat_Intercept                        -6.38      0.92    -8.22    -4.66
## prjharm_Intercept                          -6.06      0.95    -7.97    -4.32
## prjusedrg_Intercept                        -6.00      0.93    -7.92    -4.33
## prjhack_Intercept                          -4.31      0.76    -5.93    -2.93
## prjthflt5_rural.ses.med2                   -0.54      0.85    -2.13     1.17
## prjthflt5_rural.ses.med3                    1.27      0.70    -0.14     2.64
## prjthflt5_rural.ses.med4                    1.31      0.84    -0.43     2.86
## prjthfgt5_rural.ses.med2                   -0.70      0.89    -2.39     1.10
## prjthfgt5_rural.ses.med3                    1.20      0.69    -0.11     2.54
## prjthfgt5_rural.ses.med4                    1.27      0.80    -0.39     2.75
## prjthreat_rural.ses.med2                   -0.56      0.87    -2.20     1.16
## prjthreat_rural.ses.med3                    0.73      0.74    -0.71     2.20
## prjthreat_rural.ses.med4                    1.24      0.79    -0.36     2.72
## prjharm_rural.ses.med2                     -0.24      0.81    -1.79     1.35
## prjharm_rural.ses.med3                      0.03      0.76    -1.49     1.49
## prjharm_rural.ses.med4                      1.35      0.76    -0.16     2.85
## prjusedrg_rural.ses.med2                   -0.33      0.83    -1.94     1.30
## prjusedrg_rural.ses.med3                   -0.18      0.80    -1.71     1.42
## prjusedrg_rural.ses.med4                    1.30      0.78    -0.38     2.76
## prjhack_rural.ses.med2                     -0.62      0.86    -2.26     1.12
## prjhack_rural.ses.med3                      0.53      0.70    -0.84     1.90
## prjhack_rural.ses.med4                      0.80      0.69    -0.56     2.17
## prjthflt5_mostresp_devx2                   -0.24      0.21    -0.66     0.16
## prjthflt5_mostresp_av12x2                   0.10      0.08    -0.06     0.26
## prjthflt5_mostresp_devx2:rural.ses.med2    -0.68      0.50    -1.73     0.24
## prjthflt5_mostresp_devx2:rural.ses.med3     0.01      0.37    -0.84     0.67
## prjthflt5_mostresp_devx2:rural.ses.med4     0.41      0.38    -0.33     1.17
## prjthfgt5_mostresp_devx2                   -0.21      0.20    -0.62     0.18
## prjthfgt5_mostresp_av12x2                   0.07      0.08    -0.09     0.22
## prjthfgt5_mostresp_devx2:rural.ses.med2    -0.67      0.53    -1.79     0.32
## prjthfgt5_mostresp_devx2:rural.ses.med3    -0.02      0.39    -0.91     0.60
## prjthfgt5_mostresp_devx2:rural.ses.med4     0.34      0.36    -0.38     1.06
## prjthreat_mostresp_devx2                   -0.33      0.21    -0.75     0.07
## prjthreat_mostresp_av12x2                   0.15      0.08    -0.02     0.30
## prjthreat_mostresp_devx2:rural.ses.med2    -0.32      0.59    -1.53     0.75
## prjthreat_mostresp_devx2:rural.ses.med3    -0.10      0.40    -0.95     0.63
## prjthreat_mostresp_devx2:rural.ses.med4     0.33      0.39    -0.41     1.14
## prjharm_mostresp_devx2                     -0.20      0.22    -0.63     0.22
## prjharm_mostresp_av12x2                     0.05      0.09    -0.13     0.21
## prjharm_mostresp_devx2:rural.ses.med2      -0.30      0.51    -1.41     0.69
## prjharm_mostresp_devx2:rural.ses.med3       0.13      0.42    -0.76     0.91
## prjharm_mostresp_devx2:rural.ses.med4      -0.34      0.44    -1.28     0.47
## prjusedrg_mostresp_devx2                   -0.35      0.21    -0.74     0.06
## prjusedrg_mostresp_av12x2                   0.12      0.09    -0.06     0.29
## prjusedrg_mostresp_devx2:rural.ses.med2    -0.29      0.54    -1.39     0.74
## prjusedrg_mostresp_devx2:rural.ses.med3    -0.41      0.51    -1.50     0.56
## prjusedrg_mostresp_devx2:rural.ses.med4     0.23      0.40    -0.53     1.04
## prjhack_mostresp_devx2                     -0.21      0.21    -0.63     0.20
## prjhack_mostresp_av12x2                     0.09      0.07    -0.05     0.23
## prjhack_mostresp_devx2:rural.ses.med2      -0.38      0.57    -1.56     0.75
## prjhack_mostresp_devx2:rural.ses.med3      -0.35      0.43    -1.29     0.42
## prjhack_mostresp_devx2:rural.ses.med4      -0.04      0.39    -0.93     0.64
##                                         Rhat Bulk_ESS Tail_ESS
## prjthflt5_Intercept                     1.00     4102     3505
## prjthfgt5_Intercept                     1.00     3391     3202
## prjthreat_Intercept                     1.00     3972     2833
## prjharm_Intercept                       1.00     3041     3308
## prjusedrg_Intercept                     1.00     3311     2933
## prjhack_Intercept                       1.00     3019     2777
## prjthflt5_rural.ses.med2                1.00     6762     3191
## prjthflt5_rural.ses.med3                1.00     5289     3651
## prjthflt5_rural.ses.med4                1.00     5803     3138
## prjthfgt5_rural.ses.med2                1.00     6182     3085
## prjthfgt5_rural.ses.med3                1.00     4846     3277
## prjthfgt5_rural.ses.med4                1.00     4665     2962
## prjthreat_rural.ses.med2                1.00     7348     3178
## prjthreat_rural.ses.med3                1.00     5921     3117
## prjthreat_rural.ses.med4                1.00     5281     3018
## prjharm_rural.ses.med2                  1.00     6829     2852
## prjharm_rural.ses.med3                  1.00     6551     3218
## prjharm_rural.ses.med4                  1.00     6081     3172
## prjusedrg_rural.ses.med2                1.00     6440     3359
## prjusedrg_rural.ses.med3                1.00     6861     2997
## prjusedrg_rural.ses.med4                1.00     5189     2991
## prjhack_rural.ses.med2                  1.00     6492     3124
## prjhack_rural.ses.med3                  1.00     6585     3161
## prjhack_rural.ses.med4                  1.00     6793     3321
## prjthflt5_mostresp_devx2                1.00     5075     3604
## prjthflt5_mostresp_av12x2               1.00     3707     3121
## prjthflt5_mostresp_devx2:rural.ses.med2 1.00     4583     2947
## prjthflt5_mostresp_devx2:rural.ses.med3 1.00     3391     2431
## prjthflt5_mostresp_devx2:rural.ses.med4 1.00     3714     3072
## prjthfgt5_mostresp_devx2                1.00     4346     3332
## prjthfgt5_mostresp_av12x2               1.00     4220     2905
## prjthfgt5_mostresp_devx2:rural.ses.med2 1.00     4126     3322
## prjthfgt5_mostresp_devx2:rural.ses.med3 1.00     3296     2240
## prjthfgt5_mostresp_devx2:rural.ses.med4 1.00     3964     3211
## prjthreat_mostresp_devx2                1.00     5506     3376
## prjthreat_mostresp_av12x2               1.00     4326     3381
## prjthreat_mostresp_devx2:rural.ses.med2 1.00     4796     3615
## prjthreat_mostresp_devx2:rural.ses.med3 1.00     4995     2902
## prjthreat_mostresp_devx2:rural.ses.med4 1.00     4969     3107
## prjharm_mostresp_devx2                  1.00     6330     3064
## prjharm_mostresp_av12x2                 1.00     5739     2985
## prjharm_mostresp_devx2:rural.ses.med2   1.00     5170     3230
## prjharm_mostresp_devx2:rural.ses.med3   1.00     4952     2588
## prjharm_mostresp_devx2:rural.ses.med4   1.00     4876     2713
## prjusedrg_mostresp_devx2                1.00     6695     3251
## prjusedrg_mostresp_av12x2               1.00     4841     3191
## prjusedrg_mostresp_devx2:rural.ses.med2 1.00     4576     3025
## prjusedrg_mostresp_devx2:rural.ses.med3 1.00     4965     3337
## prjusedrg_mostresp_devx2:rural.ses.med4 1.00     4387     3363
## prjhack_mostresp_devx2                  1.00     6532     2758
## prjhack_mostresp_av12x2                 1.00     7325     2726
## prjhack_mostresp_devx2:rural.ses.med2   1.00     4916     2981
## prjhack_mostresp_devx2:rural.ses.med3   1.00     5207     2921
## prjhack_mostresp_devx2:rural.ses.med4   1.00     4905     2592
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## prjthflt5_mostresp_devx21[1]                    0.29      0.16     0.04
## prjthflt5_mostresp_devx21[2]                    0.25      0.14     0.04
## prjthflt5_mostresp_devx21[3]                    0.21      0.13     0.03
## prjthflt5_mostresp_devx21[4]                    0.25      0.15     0.04
## prjthflt5_mostresp_av12x21[1]                   0.12      0.08     0.02
## prjthflt5_mostresp_av12x21[2]                   0.12      0.08     0.02
## prjthflt5_mostresp_av12x21[3]                   0.12      0.08     0.02
## prjthflt5_mostresp_av12x21[4]                   0.12      0.08     0.02
## prjthflt5_mostresp_av12x21[5]                   0.12      0.08     0.02
## prjthflt5_mostresp_av12x21[6]                   0.13      0.08     0.02
## prjthflt5_mostresp_av12x21[7]                   0.13      0.08     0.02
## prjthflt5_mostresp_av12x21[8]                   0.12      0.08     0.01
## prjthflt5_mostresp_devx2:rural.ses.med21[1]     0.31      0.20     0.02
## prjthflt5_mostresp_devx2:rural.ses.med21[2]     0.26      0.19     0.01
## prjthflt5_mostresp_devx2:rural.ses.med21[3]     0.17      0.16     0.01
## prjthflt5_mostresp_devx2:rural.ses.med21[4]     0.26      0.19     0.01
## prjthflt5_mostresp_devx2:rural.ses.med31[1]     0.25      0.19     0.01
## prjthflt5_mostresp_devx2:rural.ses.med31[2]     0.23      0.19     0.01
## prjthflt5_mostresp_devx2:rural.ses.med31[3]     0.22      0.18     0.01
## prjthflt5_mostresp_devx2:rural.ses.med31[4]     0.30      0.22     0.01
## prjthflt5_mostresp_devx2:rural.ses.med41[1]     0.34      0.22     0.02
## prjthflt5_mostresp_devx2:rural.ses.med41[2]     0.21      0.17     0.01
## prjthflt5_mostresp_devx2:rural.ses.med41[3]     0.20      0.17     0.01
## prjthflt5_mostresp_devx2:rural.ses.med41[4]     0.25      0.19     0.01
## prjthfgt5_mostresp_devx21[1]                    0.28      0.15     0.04
## prjthfgt5_mostresp_devx21[2]                    0.25      0.14     0.04
## prjthfgt5_mostresp_devx21[3]                    0.22      0.13     0.03
## prjthfgt5_mostresp_devx21[4]                    0.26      0.15     0.04
## prjthfgt5_mostresp_av12x21[1]                   0.13      0.08     0.02
## prjthfgt5_mostresp_av12x21[2]                   0.13      0.08     0.02
## prjthfgt5_mostresp_av12x21[3]                   0.12      0.08     0.02
## prjthfgt5_mostresp_av12x21[4]                   0.12      0.08     0.02
## prjthfgt5_mostresp_av12x21[5]                   0.12      0.08     0.02
## prjthfgt5_mostresp_av12x21[6]                   0.13      0.08     0.01
## prjthfgt5_mostresp_av12x21[7]                   0.13      0.08     0.02
## prjthfgt5_mostresp_av12x21[8]                   0.12      0.08     0.02
## prjthfgt5_mostresp_devx2:rural.ses.med21[1]     0.33      0.21     0.02
## prjthfgt5_mostresp_devx2:rural.ses.med21[2]     0.25      0.19     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med21[3]     0.16      0.15     0.00
## prjthfgt5_mostresp_devx2:rural.ses.med21[4]     0.26      0.19     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med31[1]     0.25      0.19     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med31[2]     0.23      0.18     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med31[3]     0.22      0.18     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med31[4]     0.30      0.22     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med41[1]     0.32      0.22     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med41[2]     0.21      0.17     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med41[3]     0.21      0.17     0.01
## prjthfgt5_mostresp_devx2:rural.ses.med41[4]     0.26      0.19     0.01
## prjthreat_mostresp_devx21[1]                    0.27      0.15     0.04
## prjthreat_mostresp_devx21[2]                    0.31      0.16     0.05
## prjthreat_mostresp_devx21[3]                    0.20      0.13     0.03
## prjthreat_mostresp_devx21[4]                    0.22      0.13     0.03
## prjthreat_mostresp_av12x21[1]                   0.11      0.07     0.01
## prjthreat_mostresp_av12x21[2]                   0.11      0.08     0.01
## prjthreat_mostresp_av12x21[3]                   0.12      0.08     0.02
## prjthreat_mostresp_av12x21[4]                   0.13      0.08     0.02
## prjthreat_mostresp_av12x21[5]                   0.13      0.08     0.02
## prjthreat_mostresp_av12x21[6]                   0.13      0.08     0.02
## prjthreat_mostresp_av12x21[7]                   0.14      0.09     0.02
## prjthreat_mostresp_av12x21[8]                   0.12      0.08     0.02
## prjthreat_mostresp_devx2:rural.ses.med21[1]     0.29      0.21     0.01
## prjthreat_mostresp_devx2:rural.ses.med21[2]     0.21      0.18     0.01
## prjthreat_mostresp_devx2:rural.ses.med21[3]     0.22      0.18     0.01
## prjthreat_mostresp_devx2:rural.ses.med21[4]     0.28      0.21     0.01
## prjthreat_mostresp_devx2:rural.ses.med31[1]     0.25      0.19     0.01
## prjthreat_mostresp_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## prjthreat_mostresp_devx2:rural.ses.med31[3]     0.23      0.18     0.01
## prjthreat_mostresp_devx2:rural.ses.med31[4]     0.29      0.21     0.01
## prjthreat_mostresp_devx2:rural.ses.med41[1]     0.30      0.21     0.01
## prjthreat_mostresp_devx2:rural.ses.med41[2]     0.19      0.17     0.00
## prjthreat_mostresp_devx2:rural.ses.med41[3]     0.24      0.19     0.01
## prjthreat_mostresp_devx2:rural.ses.med41[4]     0.27      0.20     0.01
## prjharm_mostresp_devx21[1]                      0.27      0.15     0.04
## prjharm_mostresp_devx21[2]                      0.27      0.15     0.04
## prjharm_mostresp_devx21[3]                      0.22      0.14     0.03
## prjharm_mostresp_devx21[4]                      0.25      0.14     0.04
## prjharm_mostresp_av12x21[1]                     0.13      0.08     0.02
## prjharm_mostresp_av12x21[2]                     0.12      0.08     0.02
## prjharm_mostresp_av12x21[3]                     0.12      0.08     0.02
## prjharm_mostresp_av12x21[4]                     0.12      0.08     0.01
## prjharm_mostresp_av12x21[5]                     0.13      0.08     0.02
## prjharm_mostresp_av12x21[6]                     0.13      0.08     0.02
## prjharm_mostresp_av12x21[7]                     0.12      0.08     0.02
## prjharm_mostresp_av12x21[8]                     0.12      0.08     0.02
## prjharm_mostresp_devx2:rural.ses.med21[1]       0.26      0.19     0.01
## prjharm_mostresp_devx2:rural.ses.med21[2]       0.22      0.18     0.01
## prjharm_mostresp_devx2:rural.ses.med21[3]       0.23      0.18     0.01
## prjharm_mostresp_devx2:rural.ses.med21[4]       0.29      0.21     0.01
## prjharm_mostresp_devx2:rural.ses.med31[1]       0.24      0.18     0.01
## prjharm_mostresp_devx2:rural.ses.med31[2]       0.23      0.18     0.01
## prjharm_mostresp_devx2:rural.ses.med31[3]       0.26      0.20     0.01
## prjharm_mostresp_devx2:rural.ses.med31[4]       0.28      0.21     0.01
## prjharm_mostresp_devx2:rural.ses.med41[1]       0.21      0.18     0.01
## prjharm_mostresp_devx2:rural.ses.med41[2]       0.26      0.19     0.01
## prjharm_mostresp_devx2:rural.ses.med41[3]       0.24      0.19     0.01
## prjharm_mostresp_devx2:rural.ses.med41[4]       0.30      0.21     0.01
## prjusedrg_mostresp_devx21[1]                    0.24      0.14     0.03
## prjusedrg_mostresp_devx21[2]                    0.30      0.16     0.05
## prjusedrg_mostresp_devx21[3]                    0.25      0.14     0.04
## prjusedrg_mostresp_devx21[4]                    0.21      0.13     0.03
## prjusedrg_mostresp_av12x21[1]                   0.11      0.07     0.02
## prjusedrg_mostresp_av12x21[2]                   0.11      0.07     0.02
## prjusedrg_mostresp_av12x21[3]                   0.12      0.08     0.02
## prjusedrg_mostresp_av12x21[4]                   0.13      0.08     0.02
## prjusedrg_mostresp_av12x21[5]                   0.13      0.08     0.02
## prjusedrg_mostresp_av12x21[6]                   0.13      0.08     0.02
## prjusedrg_mostresp_av12x21[7]                   0.13      0.08     0.02
## prjusedrg_mostresp_av12x21[8]                   0.13      0.08     0.02
## prjusedrg_mostresp_devx2:rural.ses.med21[1]     0.26      0.19     0.01
## prjusedrg_mostresp_devx2:rural.ses.med21[2]     0.22      0.18     0.01
## prjusedrg_mostresp_devx2:rural.ses.med21[3]     0.23      0.19     0.01
## prjusedrg_mostresp_devx2:rural.ses.med21[4]     0.29      0.21     0.01
## prjusedrg_mostresp_devx2:rural.ses.med31[1]     0.26      0.19     0.01
## prjusedrg_mostresp_devx2:rural.ses.med31[2]     0.23      0.18     0.01
## prjusedrg_mostresp_devx2:rural.ses.med31[3]     0.24      0.19     0.01
## prjusedrg_mostresp_devx2:rural.ses.med31[4]     0.27      0.20     0.01
## prjusedrg_mostresp_devx2:rural.ses.med41[1]     0.29      0.21     0.01
## prjusedrg_mostresp_devx2:rural.ses.med41[2]     0.22      0.18     0.01
## prjusedrg_mostresp_devx2:rural.ses.med41[3]     0.21      0.18     0.01
## prjusedrg_mostresp_devx2:rural.ses.med41[4]     0.28      0.20     0.01
## prjhack_mostresp_devx21[1]                      0.28      0.15     0.05
## prjhack_mostresp_devx21[2]                      0.25      0.14     0.04
## prjhack_mostresp_devx21[3]                      0.22      0.13     0.03
## prjhack_mostresp_devx21[4]                      0.25      0.14     0.04
## prjhack_mostresp_av12x21[1]                     0.12      0.08     0.01
## prjhack_mostresp_av12x21[2]                     0.12      0.08     0.02
## prjhack_mostresp_av12x21[3]                     0.13      0.08     0.02
## prjhack_mostresp_av12x21[4]                     0.13      0.08     0.02
## prjhack_mostresp_av12x21[5]                     0.13      0.08     0.02
## prjhack_mostresp_av12x21[6]                     0.13      0.08     0.02
## prjhack_mostresp_av12x21[7]                     0.12      0.08     0.02
## prjhack_mostresp_av12x21[8]                     0.12      0.08     0.02
## prjhack_mostresp_devx2:rural.ses.med21[1]       0.28      0.21     0.01
## prjhack_mostresp_devx2:rural.ses.med21[2]       0.23      0.18     0.01
## prjhack_mostresp_devx2:rural.ses.med21[3]       0.21      0.18     0.01
## prjhack_mostresp_devx2:rural.ses.med21[4]       0.28      0.20     0.01
## prjhack_mostresp_devx2:rural.ses.med31[1]       0.25      0.19     0.01
## prjhack_mostresp_devx2:rural.ses.med31[2]       0.22      0.17     0.01
## prjhack_mostresp_devx2:rural.ses.med31[3]       0.24      0.19     0.01
## prjhack_mostresp_devx2:rural.ses.med31[4]       0.29      0.21     0.01
## prjhack_mostresp_devx2:rural.ses.med41[1]       0.24      0.18     0.01
## prjhack_mostresp_devx2:rural.ses.med41[2]       0.23      0.18     0.01
## prjhack_mostresp_devx2:rural.ses.med41[3]       0.24      0.19     0.01
## prjhack_mostresp_devx2:rural.ses.med41[4]       0.29      0.22     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## prjthflt5_mostresp_devx21[1]                    0.63 1.00     9154     2478
## prjthflt5_mostresp_devx21[2]                    0.57 1.00     7334     2726
## prjthflt5_mostresp_devx21[3]                    0.52 1.00     6066     2701
## prjthflt5_mostresp_devx21[4]                    0.58 1.00     6865     2863
## prjthflt5_mostresp_av12x21[1]                   0.32 1.00     7475     2530
## prjthflt5_mostresp_av12x21[2]                   0.32 1.00     7053     2672
## prjthflt5_mostresp_av12x21[3]                   0.32 1.00     7789     2197
## prjthflt5_mostresp_av12x21[4]                   0.31 1.00     6980     2287
## prjthflt5_mostresp_av12x21[5]                   0.31 1.00     6792     2839
## prjthflt5_mostresp_av12x21[6]                   0.33 1.00     7107     2525
## prjthflt5_mostresp_av12x21[7]                   0.34 1.00     6866     2588
## prjthflt5_mostresp_av12x21[8]                   0.30 1.00     6664     2637
## prjthflt5_mostresp_devx2:rural.ses.med21[1]     0.75 1.00     5198     2686
## prjthflt5_mostresp_devx2:rural.ses.med21[2]     0.70 1.00     5956     3323
## prjthflt5_mostresp_devx2:rural.ses.med21[3]     0.58 1.00     5994     2958
## prjthflt5_mostresp_devx2:rural.ses.med21[4]     0.70 1.00     6580     2919
## prjthflt5_mostresp_devx2:rural.ses.med31[1]     0.71 1.00     7050     2959
## prjthflt5_mostresp_devx2:rural.ses.med31[2]     0.67 1.00     4606     2687
## prjthflt5_mostresp_devx2:rural.ses.med31[3]     0.66 1.00     5466     3039
## prjthflt5_mostresp_devx2:rural.ses.med31[4]     0.79 1.00     5243     3067
## prjthflt5_mostresp_devx2:rural.ses.med41[1]     0.79 1.00     4941     2971
## prjthflt5_mostresp_devx2:rural.ses.med41[2]     0.64 1.00     5178     2566
## prjthflt5_mostresp_devx2:rural.ses.med41[3]     0.64 1.00     5863     3221
## prjthflt5_mostresp_devx2:rural.ses.med41[4]     0.69 1.00     6350     3193
## prjthfgt5_mostresp_devx21[1]                    0.62 1.00     7978     3064
## prjthfgt5_mostresp_devx21[2]                    0.57 1.00     7508     2887
## prjthfgt5_mostresp_devx21[3]                    0.54 1.00     6437     2691
## prjthfgt5_mostresp_devx21[4]                    0.58 1.00     7618     2885
## prjthfgt5_mostresp_av12x21[1]                   0.32 1.00     7136     2544
## prjthfgt5_mostresp_av12x21[2]                   0.32 1.00     7187     2240
## prjthfgt5_mostresp_av12x21[3]                   0.32 1.00     7399     2657
## prjthfgt5_mostresp_av12x21[4]                   0.32 1.00     8048     2155
## prjthfgt5_mostresp_av12x21[5]                   0.31 1.00     6843     2229
## prjthfgt5_mostresp_av12x21[6]                   0.32 1.00     7562     2642
## prjthfgt5_mostresp_av12x21[7]                   0.33 1.00     7990     3154
## prjthfgt5_mostresp_av12x21[8]                   0.31 1.00     8315     3202
## prjthfgt5_mostresp_devx2:rural.ses.med21[1]     0.77 1.00     6171     2031
## prjthfgt5_mostresp_devx2:rural.ses.med21[2]     0.69 1.00     6493     2717
## prjthfgt5_mostresp_devx2:rural.ses.med21[3]     0.58 1.00     5000     3071
## prjthfgt5_mostresp_devx2:rural.ses.med21[4]     0.69 1.00     5744     2610
## prjthfgt5_mostresp_devx2:rural.ses.med31[1]     0.69 1.00     5858     2880
## prjthfgt5_mostresp_devx2:rural.ses.med31[2]     0.66 1.00     5596     3149
## prjthfgt5_mostresp_devx2:rural.ses.med31[3]     0.68 1.00     5517     2941
## prjthfgt5_mostresp_devx2:rural.ses.med31[4]     0.81 1.00     4338     2976
## prjthfgt5_mostresp_devx2:rural.ses.med41[1]     0.78 1.00     4775     2515
## prjthfgt5_mostresp_devx2:rural.ses.med41[2]     0.63 1.00     5194     2657
## prjthfgt5_mostresp_devx2:rural.ses.med41[3]     0.65 1.00     5166     2544
## prjthfgt5_mostresp_devx2:rural.ses.med41[4]     0.70 1.00     6128     2480
## prjthreat_mostresp_devx21[1]                    0.60 1.00     7540     3161
## prjthreat_mostresp_devx21[2]                    0.64 1.00     6386     3092
## prjthreat_mostresp_devx21[3]                    0.51 1.00     6788     2890
## prjthreat_mostresp_devx21[4]                    0.52 1.00     6974     2966
## prjthreat_mostresp_av12x21[1]                   0.29 1.00     6125     2202
## prjthreat_mostresp_av12x21[2]                   0.30 1.00     7083     2620
## prjthreat_mostresp_av12x21[3]                   0.31 1.00     7375     2500
## prjthreat_mostresp_av12x21[4]                   0.31 1.00     8346     2334
## prjthreat_mostresp_av12x21[5]                   0.32 1.00     6351     2406
## prjthreat_mostresp_av12x21[6]                   0.33 1.00     7491     2612
## prjthreat_mostresp_av12x21[7]                   0.35 1.00     8362     3018
## prjthreat_mostresp_av12x21[8]                   0.32 1.00     8222     2946
## prjthreat_mostresp_devx2:rural.ses.med21[1]     0.75 1.00     5809     2858
## prjthreat_mostresp_devx2:rural.ses.med21[2]     0.66 1.00     5739     2640
## prjthreat_mostresp_devx2:rural.ses.med21[3]     0.68 1.00     5887     3014
## prjthreat_mostresp_devx2:rural.ses.med21[4]     0.74 1.00     6841     3177
## prjthreat_mostresp_devx2:rural.ses.med31[1]     0.71 1.00     6779     2257
## prjthreat_mostresp_devx2:rural.ses.med31[2]     0.68 1.00     6508     2729
## prjthreat_mostresp_devx2:rural.ses.med31[3]     0.67 1.00     6086     2826
## prjthreat_mostresp_devx2:rural.ses.med31[4]     0.75 1.00     5862     2814
## prjthreat_mostresp_devx2:rural.ses.med41[1]     0.75 1.00     5608     2892
## prjthreat_mostresp_devx2:rural.ses.med41[2]     0.63 1.00     5244     2601
## prjthreat_mostresp_devx2:rural.ses.med41[3]     0.69 1.00     5915     2789
## prjthreat_mostresp_devx2:rural.ses.med41[4]     0.74 1.00     6154     2721
## prjharm_mostresp_devx21[1]                      0.61 1.00     9660     2911
## prjharm_mostresp_devx21[2]                      0.59 1.00     6998     2850
## prjharm_mostresp_devx21[3]                      0.53 1.00     6081     3074
## prjharm_mostresp_devx21[4]                      0.58 1.00     8571     2594
## prjharm_mostresp_av12x21[1]                     0.33 1.00     6975     2494
## prjharm_mostresp_av12x21[2]                     0.31 1.00     7097     2829
## prjharm_mostresp_av12x21[3]                     0.31 1.00     6280     2605
## prjharm_mostresp_av12x21[4]                     0.32 1.00     6753     2063
## prjharm_mostresp_av12x21[5]                     0.32 1.00     7475     2435
## prjharm_mostresp_av12x21[6]                     0.33 1.00     6764     2299
## prjharm_mostresp_av12x21[7]                     0.32 1.00     6989     2697
## prjharm_mostresp_av12x21[8]                     0.32 1.00     6676     2919
## prjharm_mostresp_devx2:rural.ses.med21[1]       0.70 1.00     6710     2517
## prjharm_mostresp_devx2:rural.ses.med21[2]       0.65 1.00     7791     2842
## prjharm_mostresp_devx2:rural.ses.med21[3]       0.67 1.00     5417     2653
## prjharm_mostresp_devx2:rural.ses.med21[4]       0.74 1.00     6808     2917
## prjharm_mostresp_devx2:rural.ses.med31[1]       0.68 1.00     6020     2032
## prjharm_mostresp_devx2:rural.ses.med31[2]       0.67 1.00     6985     1966
## prjharm_mostresp_devx2:rural.ses.med31[3]       0.73 1.00     5591     2058
## prjharm_mostresp_devx2:rural.ses.med31[4]       0.75 1.00     5183     2573
## prjharm_mostresp_devx2:rural.ses.med41[1]       0.66 1.00     5940     2587
## prjharm_mostresp_devx2:rural.ses.med41[2]       0.69 1.00     5440     3241
## prjharm_mostresp_devx2:rural.ses.med41[3]       0.69 1.00     5900     3299
## prjharm_mostresp_devx2:rural.ses.med41[4]       0.75 1.00     5886     2777
## prjusedrg_mostresp_devx21[1]                    0.56 1.00     8715     2788
## prjusedrg_mostresp_devx21[2]                    0.64 1.00     6918     3073
## prjusedrg_mostresp_devx21[3]                    0.58 1.00     6591     2796
## prjusedrg_mostresp_devx21[4]                    0.50 1.00     5760     3295
## prjusedrg_mostresp_av12x21[1]                   0.29 1.00     6423     2941
## prjusedrg_mostresp_av12x21[2]                   0.30 1.00     7150     2488
## prjusedrg_mostresp_av12x21[3]                   0.33 1.00     7809     2572
## prjusedrg_mostresp_av12x21[4]                   0.32 1.00     7945     2167
## prjusedrg_mostresp_av12x21[5]                   0.33 1.00     8770     2708
## prjusedrg_mostresp_av12x21[6]                   0.33 1.00     7442     2807
## prjusedrg_mostresp_av12x21[7]                   0.33 1.00     6867     2908
## prjusedrg_mostresp_av12x21[8]                   0.33 1.00     6774     2965
## prjusedrg_mostresp_devx2:rural.ses.med21[1]     0.71 1.00     5559     2837
## prjusedrg_mostresp_devx2:rural.ses.med21[2]     0.67 1.00     6754     2625
## prjusedrg_mostresp_devx2:rural.ses.med21[3]     0.68 1.00     5754     2849
## prjusedrg_mostresp_devx2:rural.ses.med21[4]     0.75 1.00     5706     2702
## prjusedrg_mostresp_devx2:rural.ses.med31[1]     0.69 1.00     5958     2306
## prjusedrg_mostresp_devx2:rural.ses.med31[2]     0.67 1.00     6353     2564
## prjusedrg_mostresp_devx2:rural.ses.med31[3]     0.70 1.00     7529     2723
## prjusedrg_mostresp_devx2:rural.ses.med31[4]     0.73 1.00     5067     2423
## prjusedrg_mostresp_devx2:rural.ses.med41[1]     0.75 1.00     5288     3064
## prjusedrg_mostresp_devx2:rural.ses.med41[2]     0.66 1.00     5702     2185
## prjusedrg_mostresp_devx2:rural.ses.med41[3]     0.66 1.00     5463     2930
## prjusedrg_mostresp_devx2:rural.ses.med41[4]     0.74 1.00     7234     2423
## prjhack_mostresp_devx21[1]                      0.61 1.00     7886     2596
## prjhack_mostresp_devx21[2]                      0.58 1.00     8771     2616
## prjhack_mostresp_devx21[3]                      0.53 1.00     6280     2638
## prjhack_mostresp_devx21[4]                      0.57 1.00     9261     2612
## prjhack_mostresp_av12x21[1]                     0.33 1.00     8418     2529
## prjhack_mostresp_av12x21[2]                     0.31 1.00     7856     2613
## prjhack_mostresp_av12x21[3]                     0.32 1.00     7598     2270
## prjhack_mostresp_av12x21[4]                     0.32 1.00     6664     2475
## prjhack_mostresp_av12x21[5]                     0.34 1.00     7253     2916
## prjhack_mostresp_av12x21[6]                     0.32 1.00     8170     3056
## prjhack_mostresp_av12x21[7]                     0.31 1.00     6846     2685
## prjhack_mostresp_av12x21[8]                     0.32 1.00     7851     2850
## prjhack_mostresp_devx2:rural.ses.med21[1]       0.75 1.00     6781     3025
## prjhack_mostresp_devx2:rural.ses.med21[2]       0.67 1.00     6129     2772
## prjhack_mostresp_devx2:rural.ses.med21[3]       0.67 1.00     4784     2526
## prjhack_mostresp_devx2:rural.ses.med21[4]       0.73 1.00     5866     2797
## prjhack_mostresp_devx2:rural.ses.med31[1]       0.69 1.00     5999     2527
## prjhack_mostresp_devx2:rural.ses.med31[2]       0.65 1.00     6514     2874
## prjhack_mostresp_devx2:rural.ses.med31[3]       0.69 1.00     6554     2318
## prjhack_mostresp_devx2:rural.ses.med31[4]       0.76 1.00     6088     2658
## prjhack_mostresp_devx2:rural.ses.med41[1]       0.68 1.00     8089     2794
## prjhack_mostresp_devx2:rural.ses.med41[2]       0.67 1.00     6180     2247
## prjhack_mostresp_devx2:rural.ses.med41[3]       0.68 1.00     6258     2752
## prjhack_mostresp_devx2:rural.ses.med41[4]       0.77 1.00     4775     2725
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.1.3.4 Prior summary
out.chg.prjcrime.stresp.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##          prjhack                          user
##          prjhack                          user
##          prjhack                          user
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjharm                          user
##          prjharm                          user
##          prjharm                          user
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##                                        default
##          prjhack                          user
##          prjharm                          user
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthreat                          user
##        prjusedrg                          user
##          prjhack             0         default
##          prjharm             0         default
##        prjthfgt5             0         default
##        prjthflt5             0         default
##        prjthreat             0         default
##        prjusedrg             0         default
##     id   prjhack             0    (vectorized)
##     id   prjhack             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##          prjhack                          user
##          prjhack                       default
##          prjhack                       default
##          prjhack                       default
##          prjhack                          user
##          prjharm                          user
##          prjharm                       default
##          prjharm                       default
##          prjharm                       default
##          prjharm                          user
##        prjthfgt5                          user
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                          user
##        prjthreat                          user
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                          user
##        prjusedrg                          user
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                          user

8.1.1.4 Corr X Community: stfair & prj crime

#Community Change: criminal intent items ~ mo(stfair)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostfair_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostfair_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostfair_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostfair_av12x21', 
                  resp = prjdv_names)
  )

# drop year from model to avoid inappropriately partially out systematic stress change differences.  
  # also, with two waves, can only add random int OR random slope for year
chg.prjcrime.stfair.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stfair_devx2) + mo(stfair_av12x2) + 
    rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stfair_comm_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stfair.comm.fit <- ppchecks(chg.prjcrime.stfair.comm.fit)
8.1.1.4.1 Coefficient plot (intervals)
out.chg.prjcrime.stfair.comm.fit[[10]]

8.1.1.4.2 PPcheck (density)
p1 <- out.chg.prjcrime.stfair.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stfair.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stfair.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stfair.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stfair.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stfair.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

8.1.1.4.3 Fit summary
out.chg.prjcrime.stfair.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          prjharm ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          prjhack ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.80      0.55     2.83     4.99 1.00     1670
## sd(prjthfgt5_Intercept)     3.33      0.49     2.46     4.39 1.00     1580
## sd(prjthreat_Intercept)     3.15      0.55     2.15     4.31 1.00     1914
## sd(prjharm_Intercept)       3.05      0.57     2.03     4.26 1.00     1727
## sd(prjusedrg_Intercept)     2.90      0.54     1.93     4.05 1.00     2099
## sd(prjhack_Intercept)       0.81      0.53     0.03     1.99 1.00     1016
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2291
## sd(prjthfgt5_Intercept)     2400
## sd(prjthreat_Intercept)     2922
## sd(prjharm_Intercept)       2424
## sd(prjusedrg_Intercept)     2746
## sd(prjhack_Intercept)       2101
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_Intercept                        -6.36      0.87    -8.13    -4.72
## prjthfgt5_Intercept                        -5.83      0.83    -7.58    -4.32
## prjthreat_Intercept                        -6.46      0.96    -8.46    -4.69
## prjharm_Intercept                          -5.91      0.96    -7.82    -4.12
## prjusedrg_Intercept                        -6.04      0.96    -8.04    -4.24
## prjhack_Intercept                          -4.41      0.75    -5.96    -3.02
## prjthflt5_rural.ses.med2                   -0.47      0.89    -2.22     1.31
## prjthflt5_rural.ses.med3                    0.61      0.78    -1.00     2.05
## prjthflt5_rural.ses.med4                    1.51      0.90    -0.37     3.12
## prjthfgt5_rural.ses.med2                   -0.50      0.92    -2.23     1.31
## prjthfgt5_rural.ses.med3                    0.85      0.77    -0.75     2.29
## prjthfgt5_rural.ses.med4                    1.00      0.84    -0.77     2.53
## prjthreat_rural.ses.med2                   -0.29      0.89    -2.01     1.54
## prjthreat_rural.ses.med3                    0.35      0.77    -1.16     1.87
## prjthreat_rural.ses.med4                    1.25      0.84    -0.45     2.81
## prjharm_rural.ses.med2                     -0.20      0.82    -1.81     1.47
## prjharm_rural.ses.med3                      0.02      0.76    -1.48     1.52
## prjharm_rural.ses.med4                      1.21      0.79    -0.44     2.72
## prjusedrg_rural.ses.med2                    0.01      0.85    -1.62     1.69
## prjusedrg_rural.ses.med3                   -0.23      0.81    -1.84     1.40
## prjusedrg_rural.ses.med4                    1.00      0.83    -0.72     2.55
## prjhack_rural.ses.med2                     -0.58      0.87    -2.27     1.17
## prjhack_rural.ses.med3                      0.23      0.73    -1.21     1.70
## prjhack_rural.ses.med4                      0.93      0.72    -0.54     2.29
## prjthflt5_mostfair_devx2                   -0.06      0.20    -0.47     0.33
## prjthflt5_mostfair_av12x2                   0.13      0.08    -0.03     0.29
## prjthflt5_mostfair_devx2:rural.ses.med2    -0.65      0.53    -1.72     0.34
## prjthflt5_mostfair_devx2:rural.ses.med3     0.47      0.34    -0.18     1.16
## prjthflt5_mostfair_devx2:rural.ses.med4     0.29      0.48    -0.66     1.26
## prjthfgt5_mostfair_devx2                   -0.00      0.20    -0.41     0.38
## prjthfgt5_mostfair_av12x2                   0.07      0.08    -0.09     0.22
## prjthfgt5_mostfair_devx2:rural.ses.med2    -0.74      0.53    -1.85     0.26
## prjthfgt5_mostfair_devx2:rural.ses.med3     0.27      0.35    -0.41     0.98
## prjthfgt5_mostfair_devx2:rural.ses.med4     0.52      0.39    -0.21     1.31
## prjthreat_mostfair_devx2                   -0.29      0.21    -0.71     0.12
## prjthreat_mostfair_av12x2                   0.10      0.08    -0.06     0.27
## prjthreat_mostfair_devx2:rural.ses.med2    -0.65      0.63    -1.99     0.52
## prjthreat_mostfair_devx2:rural.ses.med3     0.17      0.42    -0.68     1.00
## prjthreat_mostfair_devx2:rural.ses.med4     0.29      0.45    -0.59     1.21
## prjharm_mostfair_devx2                     -0.24      0.21    -0.65     0.17
## prjharm_mostfair_av12x2                     0.01      0.08    -0.16     0.17
## prjharm_mostfair_devx2:rural.ses.med2      -0.31      0.54    -1.42     0.70
## prjharm_mostfair_devx2:rural.ses.med3       0.18      0.42    -0.67     1.00
## prjharm_mostfair_devx2:rural.ses.med4      -0.34      0.63    -1.71     0.77
## prjusedrg_mostfair_devx2                   -0.26      0.21    -0.67     0.14
## prjusedrg_mostfair_av12x2                   0.06      0.08    -0.11     0.22
## prjusedrg_mostfair_devx2:rural.ses.med2    -0.67      0.59    -1.93     0.42
## prjusedrg_mostfair_devx2:rural.ses.med3    -0.36      0.53    -1.50     0.63
## prjusedrg_mostfair_devx2:rural.ses.med4     0.49      0.41    -0.28     1.30
## prjhack_mostfair_devx2                     -0.19      0.21    -0.60     0.21
## prjhack_mostfair_av12x2                     0.11      0.07    -0.04     0.25
## prjhack_mostfair_devx2:rural.ses.med2      -0.38      0.59    -1.58     0.75
## prjhack_mostfair_devx2:rural.ses.med3      -0.15      0.45    -1.13     0.66
## prjhack_mostfair_devx2:rural.ses.med4      -0.17      0.46    -1.17     0.68
##                                         Rhat Bulk_ESS Tail_ESS
## prjthflt5_Intercept                     1.00     3999     3296
## prjthfgt5_Intercept                     1.00     3179     3054
## prjthreat_Intercept                     1.00     4240     3337
## prjharm_Intercept                       1.00     3620     3303
## prjusedrg_Intercept                     1.00     3637     2958
## prjhack_Intercept                       1.00     3703     3205
## prjthflt5_rural.ses.med2                1.00     6674     3385
## prjthflt5_rural.ses.med3                1.00     5542     3268
## prjthflt5_rural.ses.med4                1.00     4498     3439
## prjthfgt5_rural.ses.med2                1.00     6482     2984
## prjthfgt5_rural.ses.med3                1.00     5460     3016
## prjthfgt5_rural.ses.med4                1.00     5572     3420
## prjthreat_rural.ses.med2                1.00     7523     2432
## prjthreat_rural.ses.med3                1.00     5458     2983
## prjthreat_rural.ses.med4                1.00     5738     3621
## prjharm_rural.ses.med2                  1.00     5872     2851
## prjharm_rural.ses.med3                  1.00     6422     2882
## prjharm_rural.ses.med4                  1.00     6392     3187
## prjusedrg_rural.ses.med2                1.00     6317     2670
## prjusedrg_rural.ses.med3                1.00     6743     3032
## prjusedrg_rural.ses.med4                1.00     5964     3103
## prjhack_rural.ses.med2                  1.00     6020     3564
## prjhack_rural.ses.med3                  1.00     6498     3023
## prjhack_rural.ses.med4                  1.00     5644     3265
## prjthflt5_mostfair_devx2                1.00     5487     3055
## prjthflt5_mostfair_av12x2               1.00     4493     3082
## prjthflt5_mostfair_devx2:rural.ses.med2 1.00     4497     3343
## prjthflt5_mostfair_devx2:rural.ses.med3 1.00     3888     2921
## prjthflt5_mostfair_devx2:rural.ses.med4 1.00     3104     3074
## prjthfgt5_mostfair_devx2                1.00     5593     3450
## prjthfgt5_mostfair_av12x2               1.00     4145     3356
## prjthfgt5_mostfair_devx2:rural.ses.med2 1.00     4338     3163
## prjthfgt5_mostfair_devx2:rural.ses.med3 1.00     4218     2838
## prjthfgt5_mostfair_devx2:rural.ses.med4 1.00     3976     2435
## prjthreat_mostfair_devx2                1.00     7202     3484
## prjthreat_mostfair_av12x2               1.00     3828     2520
## prjthreat_mostfair_devx2:rural.ses.med2 1.00     5170     3050
## prjthreat_mostfair_devx2:rural.ses.med3 1.00     5215     3347
## prjthreat_mostfair_devx2:rural.ses.med4 1.00     4788     3503
## prjharm_mostfair_devx2                  1.00     5806     3134
## prjharm_mostfair_av12x2                 1.00     4734     3657
## prjharm_mostfair_devx2:rural.ses.med2   1.00     4388     2835
## prjharm_mostfair_devx2:rural.ses.med3   1.00     4791     3323
## prjharm_mostfair_devx2:rural.ses.med4   1.00     3691     3618
## prjusedrg_mostfair_devx2                1.00     6133     3450
## prjusedrg_mostfair_av12x2               1.00     5193     3234
## prjusedrg_mostfair_devx2:rural.ses.med2 1.00     5809     3187
## prjusedrg_mostfair_devx2:rural.ses.med3 1.00     4857     3467
## prjusedrg_mostfair_devx2:rural.ses.med4 1.00     4442     2855
## prjhack_mostfair_devx2                  1.00     6864     3319
## prjhack_mostfair_av12x2                 1.00     8366     3238
## prjhack_mostfair_devx2:rural.ses.med2   1.00     4441     3307
## prjhack_mostfair_devx2:rural.ses.med3   1.00     5376     2876
## prjhack_mostfair_devx2:rural.ses.med4   1.00     4785     2908
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## prjthflt5_mostfair_devx21[1]                    0.27      0.15     0.04
## prjthflt5_mostfair_devx21[2]                    0.24      0.14     0.04
## prjthflt5_mostfair_devx21[3]                    0.24      0.14     0.04
## prjthflt5_mostfair_devx21[4]                    0.26      0.14     0.04
## prjthflt5_mostfair_av12x21[1]                   0.12      0.08     0.02
## prjthflt5_mostfair_av12x21[2]                   0.12      0.08     0.02
## prjthflt5_mostfair_av12x21[3]                   0.13      0.08     0.02
## prjthflt5_mostfair_av12x21[4]                   0.12      0.08     0.02
## prjthflt5_mostfair_av12x21[5]                   0.12      0.08     0.02
## prjthflt5_mostfair_av12x21[6]                   0.13      0.08     0.02
## prjthflt5_mostfair_av12x21[7]                   0.13      0.09     0.02
## prjthflt5_mostfair_av12x21[8]                   0.13      0.08     0.02
## prjthflt5_mostfair_devx2:rural.ses.med21[1]     0.32      0.21     0.01
## prjthflt5_mostfair_devx2:rural.ses.med21[2]     0.21      0.17     0.01
## prjthflt5_mostfair_devx2:rural.ses.med21[3]     0.21      0.17     0.01
## prjthflt5_mostfair_devx2:rural.ses.med21[4]     0.26      0.19     0.01
## prjthflt5_mostfair_devx2:rural.ses.med31[1]     0.26      0.19     0.01
## prjthflt5_mostfair_devx2:rural.ses.med31[2]     0.26      0.19     0.01
## prjthflt5_mostfair_devx2:rural.ses.med31[3]     0.24      0.18     0.01
## prjthflt5_mostfair_devx2:rural.ses.med31[4]     0.24      0.18     0.01
## prjthflt5_mostfair_devx2:rural.ses.med41[1]     0.34      0.23     0.01
## prjthflt5_mostfair_devx2:rural.ses.med41[2]     0.20      0.17     0.00
## prjthflt5_mostfair_devx2:rural.ses.med41[3]     0.19      0.17     0.00
## prjthflt5_mostfair_devx2:rural.ses.med41[4]     0.27      0.20     0.01
## prjthfgt5_mostfair_devx21[1]                    0.26      0.15     0.04
## prjthfgt5_mostfair_devx21[2]                    0.24      0.14     0.03
## prjthfgt5_mostfair_devx21[3]                    0.24      0.14     0.03
## prjthfgt5_mostfair_devx21[4]                    0.26      0.15     0.03
## prjthfgt5_mostfair_av12x21[1]                   0.13      0.08     0.02
## prjthfgt5_mostfair_av12x21[2]                   0.12      0.08     0.02
## prjthfgt5_mostfair_av12x21[3]                   0.13      0.08     0.02
## prjthfgt5_mostfair_av12x21[4]                   0.12      0.08     0.02
## prjthfgt5_mostfair_av12x21[5]                   0.12      0.08     0.01
## prjthfgt5_mostfair_av12x21[6]                   0.13      0.08     0.02
## prjthfgt5_mostfair_av12x21[7]                   0.13      0.08     0.02
## prjthfgt5_mostfair_av12x21[8]                   0.12      0.08     0.02
## prjthfgt5_mostfair_devx2:rural.ses.med21[1]     0.32      0.21     0.02
## prjthfgt5_mostfair_devx2:rural.ses.med21[2]     0.23      0.18     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med21[3]     0.19      0.17     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med21[4]     0.25      0.19     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med31[1]     0.29      0.20     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med31[3]     0.23      0.18     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med31[4]     0.27      0.20     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med41[1]     0.32      0.21     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med41[2]     0.25      0.19     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med41[3]     0.19      0.16     0.01
## prjthfgt5_mostfair_devx2:rural.ses.med41[4]     0.24      0.19     0.01
## prjthreat_mostfair_devx21[1]                    0.26      0.14     0.04
## prjthreat_mostfair_devx21[2]                    0.26      0.14     0.04
## prjthreat_mostfair_devx21[3]                    0.26      0.15     0.04
## prjthreat_mostfair_devx21[4]                    0.23      0.14     0.03
## prjthreat_mostfair_av12x21[1]                   0.12      0.08     0.01
## prjthreat_mostfair_av12x21[2]                   0.12      0.08     0.01
## prjthreat_mostfair_av12x21[3]                   0.12      0.08     0.02
## prjthreat_mostfair_av12x21[4]                   0.13      0.08     0.02
## prjthreat_mostfair_av12x21[5]                   0.13      0.08     0.02
## prjthreat_mostfair_av12x21[6]                   0.12      0.08     0.02
## prjthreat_mostfair_av12x21[7]                   0.13      0.08     0.02
## prjthreat_mostfair_av12x21[8]                   0.13      0.08     0.02
## prjthreat_mostfair_devx2:rural.ses.med21[1]     0.28      0.20     0.01
## prjthreat_mostfair_devx2:rural.ses.med21[2]     0.20      0.17     0.01
## prjthreat_mostfair_devx2:rural.ses.med21[3]     0.26      0.19     0.01
## prjthreat_mostfair_devx2:rural.ses.med21[4]     0.26      0.20     0.01
## prjthreat_mostfair_devx2:rural.ses.med31[1]     0.24      0.19     0.01
## prjthreat_mostfair_devx2:rural.ses.med31[2]     0.23      0.18     0.01
## prjthreat_mostfair_devx2:rural.ses.med31[3]     0.24      0.19     0.01
## prjthreat_mostfair_devx2:rural.ses.med31[4]     0.29      0.21     0.01
## prjthreat_mostfair_devx2:rural.ses.med41[1]     0.31      0.21     0.01
## prjthreat_mostfair_devx2:rural.ses.med41[2]     0.21      0.17     0.01
## prjthreat_mostfair_devx2:rural.ses.med41[3]     0.20      0.17     0.01
## prjthreat_mostfair_devx2:rural.ses.med41[4]     0.28      0.21     0.01
## prjharm_mostfair_devx21[1]                      0.26      0.14     0.04
## prjharm_mostfair_devx21[2]                      0.27      0.15     0.04
## prjharm_mostfair_devx21[3]                      0.23      0.14     0.04
## prjharm_mostfair_devx21[4]                      0.24      0.14     0.03
## prjharm_mostfair_av12x21[1]                     0.13      0.08     0.02
## prjharm_mostfair_av12x21[2]                     0.13      0.08     0.02
## prjharm_mostfair_av12x21[3]                     0.13      0.08     0.02
## prjharm_mostfair_av12x21[4]                     0.12      0.08     0.02
## prjharm_mostfair_av12x21[5]                     0.13      0.08     0.02
## prjharm_mostfair_av12x21[6]                     0.12      0.08     0.02
## prjharm_mostfair_av12x21[7]                     0.12      0.08     0.02
## prjharm_mostfair_av12x21[8]                     0.13      0.08     0.02
## prjharm_mostfair_devx2:rural.ses.med21[1]       0.26      0.20     0.01
## prjharm_mostfair_devx2:rural.ses.med21[2]       0.23      0.18     0.01
## prjharm_mostfair_devx2:rural.ses.med21[3]       0.23      0.19     0.01
## prjharm_mostfair_devx2:rural.ses.med21[4]       0.28      0.21     0.01
## prjharm_mostfair_devx2:rural.ses.med31[1]       0.23      0.18     0.01
## prjharm_mostfair_devx2:rural.ses.med31[2]       0.22      0.18     0.01
## prjharm_mostfair_devx2:rural.ses.med31[3]       0.26      0.20     0.01
## prjharm_mostfair_devx2:rural.ses.med31[4]       0.29      0.21     0.01
## prjharm_mostfair_devx2:rural.ses.med41[1]       0.20      0.19     0.01
## prjharm_mostfair_devx2:rural.ses.med41[2]       0.18      0.17     0.01
## prjharm_mostfair_devx2:rural.ses.med41[3]       0.34      0.24     0.01
## prjharm_mostfair_devx2:rural.ses.med41[4]       0.27      0.20     0.01
## prjusedrg_mostfair_devx21[1]                    0.26      0.14     0.04
## prjusedrg_mostfair_devx21[2]                    0.27      0.15     0.05
## prjusedrg_mostfair_devx21[3]                    0.24      0.14     0.04
## prjusedrg_mostfair_devx21[4]                    0.23      0.14     0.04
## prjusedrg_mostfair_av12x21[1]                   0.12      0.08     0.01
## prjusedrg_mostfair_av12x21[2]                   0.12      0.08     0.02
## prjusedrg_mostfair_av12x21[3]                   0.13      0.08     0.02
## prjusedrg_mostfair_av12x21[4]                   0.12      0.08     0.02
## prjusedrg_mostfair_av12x21[5]                   0.12      0.08     0.02
## prjusedrg_mostfair_av12x21[6]                   0.13      0.08     0.02
## prjusedrg_mostfair_av12x21[7]                   0.13      0.08     0.02
## prjusedrg_mostfair_av12x21[8]                   0.13      0.08     0.02
## prjusedrg_mostfair_devx2:rural.ses.med21[1]     0.24      0.18     0.01
## prjusedrg_mostfair_devx2:rural.ses.med21[2]     0.22      0.18     0.01
## prjusedrg_mostfair_devx2:rural.ses.med21[3]     0.28      0.21     0.01
## prjusedrg_mostfair_devx2:rural.ses.med21[4]     0.25      0.20     0.01
## prjusedrg_mostfair_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## prjusedrg_mostfair_devx2:rural.ses.med31[2]     0.21      0.18     0.01
## prjusedrg_mostfair_devx2:rural.ses.med31[3]     0.24      0.18     0.01
## prjusedrg_mostfair_devx2:rural.ses.med31[4]     0.29      0.20     0.01
## prjusedrg_mostfair_devx2:rural.ses.med41[1]     0.31      0.20     0.01
## prjusedrg_mostfair_devx2:rural.ses.med41[2]     0.19      0.16     0.01
## prjusedrg_mostfair_devx2:rural.ses.med41[3]     0.25      0.18     0.01
## prjusedrg_mostfair_devx2:rural.ses.med41[4]     0.25      0.19     0.01
## prjhack_mostfair_devx21[1]                      0.25      0.14     0.04
## prjhack_mostfair_devx21[2]                      0.28      0.15     0.05
## prjhack_mostfair_devx21[3]                      0.23      0.14     0.03
## prjhack_mostfair_devx21[4]                      0.24      0.14     0.04
## prjhack_mostfair_av12x21[1]                     0.12      0.07     0.02
## prjhack_mostfair_av12x21[2]                     0.11      0.08     0.02
## prjhack_mostfair_av12x21[3]                     0.12      0.08     0.02
## prjhack_mostfair_av12x21[4]                     0.13      0.08     0.02
## prjhack_mostfair_av12x21[5]                     0.13      0.08     0.02
## prjhack_mostfair_av12x21[6]                     0.13      0.08     0.02
## prjhack_mostfair_av12x21[7]                     0.14      0.08     0.02
## prjhack_mostfair_av12x21[8]                     0.12      0.08     0.02
## prjhack_mostfair_devx2:rural.ses.med21[1]       0.28      0.21     0.01
## prjhack_mostfair_devx2:rural.ses.med21[2]       0.23      0.18     0.01
## prjhack_mostfair_devx2:rural.ses.med21[3]       0.21      0.18     0.01
## prjhack_mostfair_devx2:rural.ses.med21[4]       0.28      0.21     0.01
## prjhack_mostfair_devx2:rural.ses.med31[1]       0.24      0.19     0.01
## prjhack_mostfair_devx2:rural.ses.med31[2]       0.22      0.18     0.01
## prjhack_mostfair_devx2:rural.ses.med31[3]       0.25      0.19     0.01
## prjhack_mostfair_devx2:rural.ses.med31[4]       0.29      0.21     0.01
## prjhack_mostfair_devx2:rural.ses.med41[1]       0.23      0.19     0.01
## prjhack_mostfair_devx2:rural.ses.med41[2]       0.23      0.18     0.01
## prjhack_mostfair_devx2:rural.ses.med41[3]       0.25      0.19     0.01
## prjhack_mostfair_devx2:rural.ses.med41[4]       0.30      0.21     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## prjthflt5_mostfair_devx21[1]                    0.61 1.00     7172     3012
## prjthflt5_mostfair_devx21[2]                    0.55 1.00     7996     2392
## prjthflt5_mostfair_devx21[3]                    0.55 1.00     5642     3074
## prjthflt5_mostfair_devx21[4]                    0.59 1.00     7561     2662
## prjthflt5_mostfair_av12x21[1]                   0.30 1.00     7528     2418
## prjthflt5_mostfair_av12x21[2]                   0.32 1.00     6980     2608
## prjthflt5_mostfair_av12x21[3]                   0.34 1.00     6756     2689
## prjthflt5_mostfair_av12x21[4]                   0.32 1.00     8018     2608
## prjthflt5_mostfair_av12x21[5]                   0.31 1.00     8666     2408
## prjthflt5_mostfair_av12x21[6]                   0.32 1.00     8205     2710
## prjthflt5_mostfair_av12x21[7]                   0.34 1.00     7521     2315
## prjthflt5_mostfair_av12x21[8]                   0.32 1.00     7822     2799
## prjthflt5_mostfair_devx2:rural.ses.med21[1]     0.77 1.00     5506     2721
## prjthflt5_mostfair_devx2:rural.ses.med21[2]     0.63 1.00     6374     2988
## prjthflt5_mostfair_devx2:rural.ses.med21[3]     0.65 1.00     5709     2665
## prjthflt5_mostfair_devx2:rural.ses.med21[4]     0.70 1.00     5948     2562
## prjthflt5_mostfair_devx2:rural.ses.med31[1]     0.69 1.00     6344     2098
## prjthflt5_mostfair_devx2:rural.ses.med31[2]     0.70 1.00     5772     2904
## prjthflt5_mostfair_devx2:rural.ses.med31[3]     0.67 1.00     5296     3139
## prjthflt5_mostfair_devx2:rural.ses.med31[4]     0.66 1.00     5917     3113
## prjthflt5_mostfair_devx2:rural.ses.med41[1]     0.81 1.00     3988     3139
## prjthflt5_mostfair_devx2:rural.ses.med41[2]     0.64 1.00     6269     2603
## prjthflt5_mostfair_devx2:rural.ses.med41[3]     0.65 1.00     3974     3114
## prjthflt5_mostfair_devx2:rural.ses.med41[4]     0.74 1.00     6863     2789
## prjthfgt5_mostfair_devx21[1]                    0.60 1.00     8350     3135
## prjthfgt5_mostfair_devx21[2]                    0.57 1.00     8041     2507
## prjthfgt5_mostfair_devx21[3]                    0.55 1.00     5874     2993
## prjthfgt5_mostfair_devx21[4]                    0.60 1.00     7180     2885
## prjthfgt5_mostfair_av12x21[1]                   0.32 1.00     7468     2611
## prjthfgt5_mostfair_av12x21[2]                   0.32 1.00     7262     2624
## prjthfgt5_mostfair_av12x21[3]                   0.33 1.00     8718     2472
## prjthfgt5_mostfair_av12x21[4]                   0.31 1.00     9022     2951
## prjthfgt5_mostfair_av12x21[5]                   0.32 1.00     7091     2247
## prjthfgt5_mostfair_av12x21[6]                   0.33 1.00     8352     2507
## prjthfgt5_mostfair_av12x21[7]                   0.33 1.00     7549     2929
## prjthfgt5_mostfair_av12x21[8]                   0.31 1.00     7344     2514
## prjthfgt5_mostfair_devx2:rural.ses.med21[1]     0.76 1.00     5205     2881
## prjthfgt5_mostfair_devx2:rural.ses.med21[2]     0.65 1.00     6197     2681
## prjthfgt5_mostfair_devx2:rural.ses.med21[3]     0.62 1.00     4973     2506
## prjthfgt5_mostfair_devx2:rural.ses.med21[4]     0.69 1.00     6398     3110
## prjthfgt5_mostfair_devx2:rural.ses.med31[1]     0.72 1.00     5339     2238
## prjthfgt5_mostfair_devx2:rural.ses.med31[2]     0.66 1.00     5488     2304
## prjthfgt5_mostfair_devx2:rural.ses.med31[3]     0.66 1.00     4484     2560
## prjthfgt5_mostfair_devx2:rural.ses.med31[4]     0.72 1.00     5946     3265
## prjthfgt5_mostfair_devx2:rural.ses.med41[1]     0.77 1.00     5874     2898
## prjthfgt5_mostfair_devx2:rural.ses.med41[2]     0.70 1.00     5340     2750
## prjthfgt5_mostfair_devx2:rural.ses.med41[3]     0.60 1.00     4572     2863
## prjthfgt5_mostfair_devx2:rural.ses.med41[4]     0.68 1.00     5506     2543
## prjthreat_mostfair_devx21[1]                    0.57 1.00     7690     2722
## prjthreat_mostfair_devx21[2]                    0.59 1.00     7924     2641
## prjthreat_mostfair_devx21[3]                    0.59 1.00     6343     2880
## prjthreat_mostfair_devx21[4]                    0.55 1.00     7360     2792
## prjthreat_mostfair_av12x21[1]                   0.31 1.00     8133     2153
## prjthreat_mostfair_av12x21[2]                   0.31 1.00     7143     2705
## prjthreat_mostfair_av12x21[3]                   0.30 1.00     8027     2775
## prjthreat_mostfair_av12x21[4]                   0.32 1.00     8298     2857
## prjthreat_mostfair_av12x21[5]                   0.32 1.00     7705     2501
## prjthreat_mostfair_av12x21[6]                   0.31 1.00     7974     2392
## prjthreat_mostfair_av12x21[7]                   0.33 1.00     6863     2786
## prjthreat_mostfair_av12x21[8]                   0.33 1.00     7579     2891
## prjthreat_mostfair_devx2:rural.ses.med21[1]     0.72 1.00     6985     2896
## prjthreat_mostfair_devx2:rural.ses.med21[2]     0.63 1.00     5791     2503
## prjthreat_mostfair_devx2:rural.ses.med21[3]     0.72 1.00     5556     2967
## prjthreat_mostfair_devx2:rural.ses.med21[4]     0.72 1.00     7165     2933
## prjthreat_mostfair_devx2:rural.ses.med31[1]     0.70 1.00     7494     2536
## prjthreat_mostfair_devx2:rural.ses.med31[2]     0.66 1.00     6000     2669
## prjthreat_mostfair_devx2:rural.ses.med31[3]     0.68 1.00     6256     2780
## prjthreat_mostfair_devx2:rural.ses.med31[4]     0.75 1.00     5518     2137
## prjthreat_mostfair_devx2:rural.ses.med41[1]     0.76 1.00     5375     3029
## prjthreat_mostfair_devx2:rural.ses.med41[2]     0.64 1.00     7141     2953
## prjthreat_mostfair_devx2:rural.ses.med41[3]     0.64 1.00     5444     2639
## prjthreat_mostfair_devx2:rural.ses.med41[4]     0.75 1.00     6510     3089
## prjharm_mostfair_devx21[1]                      0.58 1.00     8373     2572
## prjharm_mostfair_devx21[2]                      0.60 1.00     7218     3010
## prjharm_mostfair_devx21[3]                      0.55 1.00     7208     2975
## prjharm_mostfair_devx21[4]                      0.56 1.00     7543     2522
## prjharm_mostfair_av12x21[1]                     0.32 1.00     8117     2266
## prjharm_mostfair_av12x21[2]                     0.32 1.00     7382     2454
## prjharm_mostfair_av12x21[3]                     0.32 1.00     7898     2294
## prjharm_mostfair_av12x21[4]                     0.32 1.00     6672     2623
## prjharm_mostfair_av12x21[5]                     0.32 1.00     9053     2197
## prjharm_mostfair_av12x21[6]                     0.32 1.00     7779     2554
## prjharm_mostfair_av12x21[7]                     0.32 1.00     6979     2735
## prjharm_mostfair_av12x21[8]                     0.31 1.00     7635     2743
## prjharm_mostfair_devx2:rural.ses.med21[1]       0.71 1.00     6545     2296
## prjharm_mostfair_devx2:rural.ses.med21[2]       0.67 1.00     6001     2140
## prjharm_mostfair_devx2:rural.ses.med21[3]       0.69 1.00     7221     2556
## prjharm_mostfair_devx2:rural.ses.med21[4]       0.76 1.00     5761     2874
## prjharm_mostfair_devx2:rural.ses.med31[1]       0.67 1.00     5962     2735
## prjharm_mostfair_devx2:rural.ses.med31[2]       0.66 1.00     5505     2730
## prjharm_mostfair_devx2:rural.ses.med31[3]       0.72 1.00     5373     3091
## prjharm_mostfair_devx2:rural.ses.med31[4]       0.75 1.00     6028     2732
## prjharm_mostfair_devx2:rural.ses.med41[1]       0.69 1.00     4291     2855
## prjharm_mostfair_devx2:rural.ses.med41[2]       0.61 1.00     5401     2469
## prjharm_mostfair_devx2:rural.ses.med41[3]       0.82 1.00     4116     3112
## prjharm_mostfair_devx2:rural.ses.med41[4]       0.73 1.00     6247     2474
## prjusedrg_mostfair_devx21[1]                    0.58 1.00     8122     2454
## prjusedrg_mostfair_devx21[2]                    0.60 1.00     6442     2629
## prjusedrg_mostfair_devx21[3]                    0.55 1.00     6832     2964
## prjusedrg_mostfair_devx21[4]                    0.56 1.00     9087     2914
## prjusedrg_mostfair_av12x21[1]                   0.31 1.00     6645     2585
## prjusedrg_mostfair_av12x21[2]                   0.31 1.00     7727     2734
## prjusedrg_mostfair_av12x21[3]                   0.31 1.00     7163     2729
## prjusedrg_mostfair_av12x21[4]                   0.33 1.00     8291     2492
## prjusedrg_mostfair_av12x21[5]                   0.31 1.00     6391     2226
## prjusedrg_mostfair_av12x21[6]                   0.32 1.00     8761     1923
## prjusedrg_mostfair_av12x21[7]                   0.33 1.00     6031     2718
## prjusedrg_mostfair_av12x21[8]                   0.33 1.00     7082     2761
## prjusedrg_mostfair_devx2:rural.ses.med21[1]     0.66 1.00     6192     2684
## prjusedrg_mostfair_devx2:rural.ses.med21[2]     0.66 1.00     5928     2567
## prjusedrg_mostfair_devx2:rural.ses.med21[3]     0.75 1.00     5875     2832
## prjusedrg_mostfair_devx2:rural.ses.med21[4]     0.73 1.00     6310     2444
## prjusedrg_mostfair_devx2:rural.ses.med31[1]     0.73 1.00     5660     2683
## prjusedrg_mostfair_devx2:rural.ses.med31[2]     0.64 1.00     6207     2564
## prjusedrg_mostfair_devx2:rural.ses.med31[3]     0.69 1.00     5770     2951
## prjusedrg_mostfair_devx2:rural.ses.med31[4]     0.74 1.00     5640     2531
## prjusedrg_mostfair_devx2:rural.ses.med41[1]     0.73 1.00     4844     2360
## prjusedrg_mostfair_devx2:rural.ses.med41[2]     0.59 1.00     5941     2926
## prjusedrg_mostfair_devx2:rural.ses.med41[3]     0.67 1.00     5423     2759
## prjusedrg_mostfair_devx2:rural.ses.med41[4]     0.69 1.00     6488     2785
## prjhack_mostfair_devx21[1]                      0.57 1.00     8361     2647
## prjhack_mostfair_devx21[2]                      0.60 1.00     7196     3402
## prjhack_mostfair_devx21[3]                      0.55 1.00     7610     2795
## prjhack_mostfair_devx21[4]                      0.58 1.00     8012     2621
## prjhack_mostfair_av12x21[1]                     0.29 1.00     7715     2559
## prjhack_mostfair_av12x21[2]                     0.30 1.00     7962     2507
## prjhack_mostfair_av12x21[3]                     0.31 1.00     7685     2420
## prjhack_mostfair_av12x21[4]                     0.32 1.00     7285     2252
## prjhack_mostfair_av12x21[5]                     0.33 1.00     7823     2554
## prjhack_mostfair_av12x21[6]                     0.34 1.00     6769     2619
## prjhack_mostfair_av12x21[7]                     0.33 1.00     8073     3088
## prjhack_mostfair_av12x21[8]                     0.31 1.00     7843     2592
## prjhack_mostfair_devx2:rural.ses.med21[1]       0.75 1.00     5748     2982
## prjhack_mostfair_devx2:rural.ses.med21[2]       0.67 1.00     6008     2459
## prjhack_mostfair_devx2:rural.ses.med21[3]       0.65 1.00     5171     2716
## prjhack_mostfair_devx2:rural.ses.med21[4]       0.74 1.00     6470     2834
## prjhack_mostfair_devx2:rural.ses.med31[1]       0.69 1.00     5229     2118
## prjhack_mostfair_devx2:rural.ses.med31[2]       0.65 1.00     6580     2820
## prjhack_mostfair_devx2:rural.ses.med31[3]       0.69 1.00     6846     2994
## prjhack_mostfair_devx2:rural.ses.med31[4]       0.76 1.00     5423     2331
## prjhack_mostfair_devx2:rural.ses.med41[1]       0.69 1.00     5855     2568
## prjhack_mostfair_devx2:rural.ses.med41[2]       0.66 1.00     6786     2762
## prjhack_mostfair_devx2:rural.ses.med41[3]       0.70 1.00     5622     2821
## prjhack_mostfair_devx2:rural.ses.med41[4]       0.77 1.00     5533     3169
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.1.4.4 Prior summary
out.chg.prjcrime.stfair.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##          prjhack                          user
##          prjhack                          user
##          prjhack                          user
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjharm                          user
##          prjharm                          user
##          prjharm                          user
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##                                        default
##          prjhack                          user
##          prjharm                          user
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthreat                          user
##        prjusedrg                          user
##          prjhack             0         default
##          prjharm             0         default
##        prjthfgt5             0         default
##        prjthflt5             0         default
##        prjthreat             0         default
##        prjusedrg             0         default
##     id   prjhack             0    (vectorized)
##     id   prjhack             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##          prjhack                          user
##          prjhack                       default
##          prjhack                       default
##          prjhack                       default
##          prjhack                          user
##          prjharm                          user
##          prjharm                       default
##          prjharm                       default
##          prjharm                       default
##          prjharm                          user
##        prjthfgt5                          user
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                          user
##        prjthreat                          user
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                          user
##        prjusedrg                          user
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                          user

8.1.1.5 Corr X Community: stjob & prj crime

#Community Change: criminal intent items ~ mo(stjob)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostjob_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostjob_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostjob_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostjob_av12x21', 
                  resp = prjdv_names)
  )

# drop year from model to avoid inappropriately partially out systematic stress change differences.  
  # also, with two waves, can only add random int OR random slope for year
chg.prjcrime.stjob.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stjob_devx2) + mo(stjob_av12x2) + 
    rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stjob_comm_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stjob.comm.fit <- ppchecks(chg.prjcrime.stjob.comm.fit)
8.1.1.5.1 Coefficient plot (intervals)
out.chg.prjcrime.stjob.comm.fit[[10]]

8.1.1.5.2 PPcheck (density)
p1 <- out.chg.prjcrime.stjob.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stjob.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stjob.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stjob.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stjob.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stjob.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

8.1.1.5.3 Fit summary
out.chg.prjcrime.stjob.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          prjharm ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          prjhack ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.92      0.58     2.90     5.16 1.00     1589
## sd(prjthfgt5_Intercept)     3.22      0.49     2.33     4.28 1.00     1296
## sd(prjthreat_Intercept)     2.86      0.50     1.97     3.95 1.00     1743
## sd(prjharm_Intercept)       2.90      0.54     1.97     4.03 1.00     1742
## sd(prjusedrg_Intercept)     2.61      0.51     1.69     3.70 1.00     1668
## sd(prjhack_Intercept)       0.60      0.41     0.03     1.50 1.00     1568
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2531
## sd(prjthfgt5_Intercept)     2606
## sd(prjthreat_Intercept)     2538
## sd(prjharm_Intercept)       2841
## sd(prjusedrg_Intercept)     2432
## sd(prjhack_Intercept)       1960
## 
## Regression Coefficients:
##                                        Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_Intercept                       -6.22      0.86    -8.00    -4.62
## prjthfgt5_Intercept                       -5.83      0.81    -7.50    -4.32
## prjthreat_Intercept                       -6.93      0.92    -8.89    -5.17
## prjharm_Intercept                         -6.40      0.92    -8.27    -4.72
## prjusedrg_Intercept                       -6.50      0.91    -8.36    -4.83
## prjhack_Intercept                         -5.44      0.75    -6.98    -4.04
## prjthflt5_rural.ses.med2                  -0.18      0.84    -1.78     1.49
## prjthflt5_rural.ses.med3                   0.50      0.80    -1.12     2.01
## prjthflt5_rural.ses.med4                   1.27      0.91    -0.63     2.97
## prjthfgt5_rural.ses.med2                  -0.48      0.90    -2.25     1.35
## prjthfgt5_rural.ses.med3                   0.33      0.78    -1.29     1.81
## prjthfgt5_rural.ses.med4                   1.24      0.92    -0.62     2.91
## prjthreat_rural.ses.med2                  -0.39      0.85    -2.05     1.30
## prjthreat_rural.ses.med3                   0.41      0.76    -1.06     1.90
## prjthreat_rural.ses.med4                   1.18      0.87    -0.63     2.81
## prjharm_rural.ses.med2                    -0.13      0.83    -1.67     1.55
## prjharm_rural.ses.med3                     0.41      0.75    -1.06     1.87
## prjharm_rural.ses.med4                     1.05      0.79    -0.61     2.56
## prjusedrg_rural.ses.med2                  -0.32      0.84    -1.95     1.34
## prjusedrg_rural.ses.med3                  -0.15      0.81    -1.74     1.50
## prjusedrg_rural.ses.med4                   1.39      0.84    -0.38     2.90
## prjhack_rural.ses.med2                    -0.46      0.87    -2.14     1.32
## prjhack_rural.ses.med3                     0.34      0.70    -1.02     1.68
## prjhack_rural.ses.med4                     0.76      0.74    -0.72     2.17
## prjthflt5_mostjob_devx2                   -0.14      0.20    -0.54     0.26
## prjthflt5_mostjob_av12x2                   0.11      0.08    -0.04     0.26
## prjthflt5_mostjob_devx2:rural.ses.med2    -1.06      0.58    -2.30    -0.02
## prjthflt5_mostjob_devx2:rural.ses.med3     0.58      0.36    -0.07     1.35
## prjthflt5_mostjob_devx2:rural.ses.med4     0.47      0.45    -0.48     1.34
## prjthfgt5_mostjob_devx2                   -0.09      0.21    -0.50     0.32
## prjthfgt5_mostjob_av12x2                   0.12      0.07    -0.03     0.26
## prjthfgt5_mostjob_devx2:rural.ses.med2    -0.80      0.59    -2.06     0.26
## prjthfgt5_mostjob_devx2:rural.ses.med3     0.57      0.33    -0.06     1.27
## prjthfgt5_mostjob_devx2:rural.ses.med4     0.35      0.47    -0.64     1.20
## prjthreat_mostjob_devx2                   -0.10      0.22    -0.55     0.33
## prjthreat_mostjob_av12x2                   0.18      0.08     0.02     0.34
## prjthreat_mostjob_devx2:rural.ses.med2    -0.32      0.56    -1.48     0.70
## prjthreat_mostjob_devx2:rural.ses.med3     0.17      0.40    -0.66     0.93
## prjthreat_mostjob_devx2:rural.ses.med4     0.29      0.48    -0.79     1.13
## prjharm_mostjob_devx2                     -0.02      0.21    -0.45     0.39
## prjharm_mostjob_av12x2                     0.09      0.08    -0.07     0.24
## prjharm_mostjob_devx2:rural.ses.med2      -0.37      0.51    -1.48     0.55
## prjharm_mostjob_devx2:rural.ses.med3      -0.22      0.44    -1.16     0.59
## prjharm_mostjob_devx2:rural.ses.med4      -0.19      0.51    -1.26     0.75
## prjusedrg_mostjob_devx2                   -0.04      0.22    -0.48     0.37
## prjusedrg_mostjob_av12x2                   0.15      0.08    -0.00     0.31
## prjusedrg_mostjob_devx2:rural.ses.med2    -0.23      0.53    -1.37     0.73
## prjusedrg_mostjob_devx2:rural.ses.med3    -0.41      0.50    -1.48     0.46
## prjusedrg_mostjob_devx2:rural.ses.med4     0.13      0.44    -0.77     1.01
## prjhack_mostjob_devx2                      0.06      0.21    -0.36     0.46
## prjhack_mostjob_av12x2                     0.25      0.08     0.11     0.41
## prjhack_mostjob_devx2:rural.ses.med2      -0.42      0.54    -1.54     0.60
## prjhack_mostjob_devx2:rural.ses.med3      -0.29      0.43    -1.23     0.46
## prjhack_mostjob_devx2:rural.ses.med4      -0.24      0.52    -1.40     0.63
##                                        Rhat Bulk_ESS Tail_ESS
## prjthflt5_Intercept                    1.00     3355     3280
## prjthfgt5_Intercept                    1.00     3102     3276
## prjthreat_Intercept                    1.00     3413     2970
## prjharm_Intercept                      1.00     3525     3186
## prjusedrg_Intercept                    1.00     3157     2598
## prjhack_Intercept                      1.00     5651     3380
## prjthflt5_rural.ses.med2               1.00     7986     3376
## prjthflt5_rural.ses.med3               1.00     5928     3653
## prjthflt5_rural.ses.med4               1.00     7190     3581
## prjthfgt5_rural.ses.med2               1.00     7126     3234
## prjthfgt5_rural.ses.med3               1.00     6418     3238
## prjthfgt5_rural.ses.med4               1.00     4431     3283
## prjthreat_rural.ses.med2               1.00     7163     2936
## prjthreat_rural.ses.med3               1.00     5726     3179
## prjthreat_rural.ses.med4               1.00     5891     3365
## prjharm_rural.ses.med2                 1.00     7175     3095
## prjharm_rural.ses.med3                 1.00     7362     3010
## prjharm_rural.ses.med4                 1.00     6451     2840
## prjusedrg_rural.ses.med2               1.00     8150     3263
## prjusedrg_rural.ses.med3               1.00     8809     2849
## prjusedrg_rural.ses.med4               1.00     5306     3275
## prjhack_rural.ses.med2                 1.00     7370     3480
## prjhack_rural.ses.med3                 1.00     6609     3487
## prjhack_rural.ses.med4                 1.00     6965     3568
## prjthflt5_mostjob_devx2                1.00     6505     2872
## prjthflt5_mostjob_av12x2               1.00     3554     3274
## prjthflt5_mostjob_devx2:rural.ses.med2 1.00     5597     3232
## prjthflt5_mostjob_devx2:rural.ses.med3 1.00     4421     3039
## prjthflt5_mostjob_devx2:rural.ses.med4 1.00     3992     3345
## prjthfgt5_mostjob_devx2                1.00     5293     3214
## prjthfgt5_mostjob_av12x2               1.00     4889     3268
## prjthfgt5_mostjob_devx2:rural.ses.med2 1.00     5691     3185
## prjthfgt5_mostjob_devx2:rural.ses.med3 1.00     4415     3051
## prjthfgt5_mostjob_devx2:rural.ses.med4 1.00     2838     3208
## prjthreat_mostjob_devx2                1.00     6347     3266
## prjthreat_mostjob_av12x2               1.00     4538     2869
## prjthreat_mostjob_devx2:rural.ses.med2 1.00     4482     3386
## prjthreat_mostjob_devx2:rural.ses.med3 1.00     4519     2743
## prjthreat_mostjob_devx2:rural.ses.med4 1.00     3678     3203
## prjharm_mostjob_devx2                  1.00     5800     3127
## prjharm_mostjob_av12x2                 1.00     5471     3487
## prjharm_mostjob_devx2:rural.ses.med2   1.00     4334     3047
## prjharm_mostjob_devx2:rural.ses.med3   1.00     4962     2989
## prjharm_mostjob_devx2:rural.ses.med4   1.00     4757     3014
## prjusedrg_mostjob_devx2                1.00     6055     3250
## prjusedrg_mostjob_av12x2               1.00     5431     3513
## prjusedrg_mostjob_devx2:rural.ses.med2 1.00     5104     2930
## prjusedrg_mostjob_devx2:rural.ses.med3 1.00     5230     3003
## prjusedrg_mostjob_devx2:rural.ses.med4 1.00     4123     3195
## prjhack_mostjob_devx2                  1.00     7167     3182
## prjhack_mostjob_av12x2                 1.00     7811     2648
## prjhack_mostjob_devx2:rural.ses.med2   1.00     5452     3191
## prjhack_mostjob_devx2:rural.ses.med3   1.00     5895     3351
## prjhack_mostjob_devx2:rural.ses.med4   1.00     5117     3142
## 
## Monotonic Simplex Parameters:
##                                            Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_mostjob_devx21[1]                    0.26      0.15     0.04     0.59
## prjthflt5_mostjob_devx21[2]                    0.24      0.14     0.04     0.55
## prjthflt5_mostjob_devx21[3]                    0.26      0.14     0.04     0.59
## prjthflt5_mostjob_devx21[4]                    0.24      0.14     0.04     0.55
## prjthflt5_mostjob_av12x21[1]                   0.11      0.07     0.02     0.30
## prjthflt5_mostjob_av12x21[2]                   0.12      0.08     0.02     0.31
## prjthflt5_mostjob_av12x21[3]                   0.12      0.08     0.02     0.30
## prjthflt5_mostjob_av12x21[4]                   0.12      0.08     0.02     0.32
## prjthflt5_mostjob_av12x21[5]                   0.13      0.08     0.02     0.33
## prjthflt5_mostjob_av12x21[6]                   0.14      0.09     0.02     0.35
## prjthflt5_mostjob_av12x21[7]                   0.13      0.08     0.02     0.32
## prjthflt5_mostjob_av12x21[8]                   0.13      0.08     0.02     0.33
## prjthflt5_mostjob_devx2:rural.ses.med21[1]     0.24      0.18     0.01     0.67
## prjthflt5_mostjob_devx2:rural.ses.med21[2]     0.24      0.18     0.01     0.68
## prjthflt5_mostjob_devx2:rural.ses.med21[3]     0.30      0.20     0.02     0.72
## prjthflt5_mostjob_devx2:rural.ses.med21[4]     0.22      0.17     0.01     0.64
## prjthflt5_mostjob_devx2:rural.ses.med31[1]     0.27      0.19     0.01     0.70
## prjthflt5_mostjob_devx2:rural.ses.med31[2]     0.27      0.19     0.01     0.71
## prjthflt5_mostjob_devx2:rural.ses.med31[3]     0.20      0.16     0.01     0.59
## prjthflt5_mostjob_devx2:rural.ses.med31[4]     0.26      0.19     0.01     0.67
## prjthflt5_mostjob_devx2:rural.ses.med41[1]     0.36      0.23     0.02     0.81
## prjthflt5_mostjob_devx2:rural.ses.med41[2]     0.23      0.18     0.01     0.69
## prjthflt5_mostjob_devx2:rural.ses.med41[3]     0.17      0.16     0.01     0.59
## prjthflt5_mostjob_devx2:rural.ses.med41[4]     0.24      0.18     0.01     0.68
## prjthfgt5_mostjob_devx21[1]                    0.26      0.14     0.04     0.57
## prjthfgt5_mostjob_devx21[2]                    0.23      0.14     0.03     0.55
## prjthfgt5_mostjob_devx21[3]                    0.26      0.15     0.04     0.59
## prjthfgt5_mostjob_devx21[4]                    0.25      0.15     0.04     0.59
## prjthfgt5_mostjob_av12x21[1]                   0.12      0.08     0.01     0.31
## prjthfgt5_mostjob_av12x21[2]                   0.12      0.08     0.02     0.31
## prjthfgt5_mostjob_av12x21[3]                   0.12      0.08     0.02     0.29
## prjthfgt5_mostjob_av12x21[4]                   0.12      0.08     0.02     0.31
## prjthfgt5_mostjob_av12x21[5]                   0.13      0.08     0.02     0.32
## prjthfgt5_mostjob_av12x21[6]                   0.14      0.09     0.02     0.34
## prjthfgt5_mostjob_av12x21[7]                   0.12      0.08     0.02     0.31
## prjthfgt5_mostjob_av12x21[8]                   0.13      0.09     0.02     0.34
## prjthfgt5_mostjob_devx2:rural.ses.med21[1]     0.30      0.20     0.01     0.75
## prjthfgt5_mostjob_devx2:rural.ses.med21[2]     0.19      0.16     0.01     0.61
## prjthfgt5_mostjob_devx2:rural.ses.med21[3]     0.27      0.20     0.01     0.72
## prjthfgt5_mostjob_devx2:rural.ses.med21[4]     0.24      0.19     0.01     0.68
## prjthfgt5_mostjob_devx2:rural.ses.med31[1]     0.25      0.18     0.01     0.66
## prjthfgt5_mostjob_devx2:rural.ses.med31[2]     0.30      0.19     0.02     0.73
## prjthfgt5_mostjob_devx2:rural.ses.med31[3]     0.19      0.15     0.01     0.58
## prjthfgt5_mostjob_devx2:rural.ses.med31[4]     0.26      0.18     0.01     0.65
## prjthfgt5_mostjob_devx2:rural.ses.med41[1]     0.31      0.22     0.01     0.78
## prjthfgt5_mostjob_devx2:rural.ses.med41[2]     0.26      0.20     0.01     0.70
## prjthfgt5_mostjob_devx2:rural.ses.med41[3]     0.18      0.17     0.00     0.65
## prjthfgt5_mostjob_devx2:rural.ses.med41[4]     0.25      0.19     0.01     0.69
## prjthreat_mostjob_devx21[1]                    0.27      0.15     0.04     0.60
## prjthreat_mostjob_devx21[2]                    0.24      0.14     0.04     0.56
## prjthreat_mostjob_devx21[3]                    0.24      0.14     0.03     0.57
## prjthreat_mostjob_devx21[4]                    0.26      0.14     0.04     0.58
## prjthreat_mostjob_av12x21[1]                   0.11      0.07     0.01     0.28
## prjthreat_mostjob_av12x21[2]                   0.12      0.07     0.01     0.29
## prjthreat_mostjob_av12x21[3]                   0.12      0.08     0.02     0.30
## prjthreat_mostjob_av12x21[4]                   0.12      0.08     0.02     0.30
## prjthreat_mostjob_av12x21[5]                   0.12      0.08     0.02     0.31
## prjthreat_mostjob_av12x21[6]                   0.13      0.09     0.01     0.34
## prjthreat_mostjob_av12x21[7]                   0.15      0.09     0.02     0.37
## prjthreat_mostjob_av12x21[8]                   0.13      0.08     0.02     0.34
## prjthreat_mostjob_devx2:rural.ses.med21[1]     0.28      0.20     0.01     0.74
## prjthreat_mostjob_devx2:rural.ses.med21[2]     0.21      0.18     0.01     0.67
## prjthreat_mostjob_devx2:rural.ses.med21[3]     0.23      0.19     0.01     0.70
## prjthreat_mostjob_devx2:rural.ses.med21[4]     0.28      0.21     0.01     0.75
## prjthreat_mostjob_devx2:rural.ses.med31[1]     0.24      0.19     0.01     0.69
## prjthreat_mostjob_devx2:rural.ses.med31[2]     0.22      0.18     0.01     0.65
## prjthreat_mostjob_devx2:rural.ses.med31[3]     0.25      0.19     0.01     0.70
## prjthreat_mostjob_devx2:rural.ses.med31[4]     0.28      0.21     0.01     0.75
## prjthreat_mostjob_devx2:rural.ses.med41[1]     0.29      0.21     0.01     0.75
## prjthreat_mostjob_devx2:rural.ses.med41[2]     0.25      0.19     0.01     0.71
## prjthreat_mostjob_devx2:rural.ses.med41[3]     0.20      0.18     0.00     0.69
## prjthreat_mostjob_devx2:rural.ses.med41[4]     0.26      0.19     0.01     0.70
## prjharm_mostjob_devx21[1]                      0.26      0.15     0.04     0.60
## prjharm_mostjob_devx21[2]                      0.24      0.14     0.04     0.56
## prjharm_mostjob_devx21[3]                      0.24      0.14     0.03     0.57
## prjharm_mostjob_devx21[4]                      0.26      0.15     0.04     0.59
## prjharm_mostjob_av12x21[1]                     0.12      0.08     0.02     0.32
## prjharm_mostjob_av12x21[2]                     0.12      0.08     0.02     0.31
## prjharm_mostjob_av12x21[3]                     0.12      0.08     0.02     0.31
## prjharm_mostjob_av12x21[4]                     0.13      0.08     0.02     0.33
## prjharm_mostjob_av12x21[5]                     0.12      0.08     0.02     0.31
## prjharm_mostjob_av12x21[6]                     0.13      0.08     0.02     0.34
## prjharm_mostjob_av12x21[7]                     0.13      0.08     0.02     0.32
## prjharm_mostjob_av12x21[8]                     0.12      0.07     0.02     0.30
## prjharm_mostjob_devx2:rural.ses.med21[1]       0.26      0.19     0.01     0.71
## prjharm_mostjob_devx2:rural.ses.med21[2]       0.23      0.18     0.01     0.67
## prjharm_mostjob_devx2:rural.ses.med21[3]       0.23      0.19     0.01     0.68
## prjharm_mostjob_devx2:rural.ses.med21[4]       0.28      0.20     0.01     0.74
## prjharm_mostjob_devx2:rural.ses.med31[1]       0.24      0.19     0.01     0.68
## prjharm_mostjob_devx2:rural.ses.med31[2]       0.23      0.18     0.01     0.67
## prjharm_mostjob_devx2:rural.ses.med31[3]       0.24      0.18     0.01     0.67
## prjharm_mostjob_devx2:rural.ses.med31[4]       0.29      0.21     0.01     0.75
## prjharm_mostjob_devx2:rural.ses.med41[1]       0.22      0.19     0.01     0.67
## prjharm_mostjob_devx2:rural.ses.med41[2]       0.21      0.18     0.01     0.66
## prjharm_mostjob_devx2:rural.ses.med41[3]       0.28      0.21     0.01     0.76
## prjharm_mostjob_devx2:rural.ses.med41[4]       0.29      0.20     0.01     0.74
## prjusedrg_mostjob_devx21[1]                    0.26      0.15     0.04     0.61
## prjusedrg_mostjob_devx21[2]                    0.24      0.14     0.04     0.56
## prjusedrg_mostjob_devx21[3]                    0.24      0.14     0.03     0.57
## prjusedrg_mostjob_devx21[4]                    0.26      0.14     0.04     0.58
## prjusedrg_mostjob_av12x21[1]                   0.11      0.07     0.02     0.29
## prjusedrg_mostjob_av12x21[2]                   0.12      0.08     0.01     0.31
## prjusedrg_mostjob_av12x21[3]                   0.12      0.07     0.02     0.30
## prjusedrg_mostjob_av12x21[4]                   0.12      0.08     0.02     0.30
## prjusedrg_mostjob_av12x21[5]                   0.13      0.08     0.02     0.33
## prjusedrg_mostjob_av12x21[6]                   0.13      0.08     0.02     0.33
## prjusedrg_mostjob_av12x21[7]                   0.15      0.09     0.02     0.38
## prjusedrg_mostjob_av12x21[8]                   0.12      0.07     0.02     0.29
## prjusedrg_mostjob_devx2:rural.ses.med21[1]     0.26      0.20     0.01     0.71
## prjusedrg_mostjob_devx2:rural.ses.med21[2]     0.22      0.18     0.01     0.67
## prjusedrg_mostjob_devx2:rural.ses.med21[3]     0.24      0.19     0.01     0.68
## prjusedrg_mostjob_devx2:rural.ses.med21[4]     0.29      0.21     0.01     0.75
## prjusedrg_mostjob_devx2:rural.ses.med31[1]     0.26      0.20     0.01     0.72
## prjusedrg_mostjob_devx2:rural.ses.med31[2]     0.22      0.17     0.01     0.65
## prjusedrg_mostjob_devx2:rural.ses.med31[3]     0.24      0.19     0.01     0.68
## prjusedrg_mostjob_devx2:rural.ses.med31[4]     0.28      0.21     0.01     0.74
## prjusedrg_mostjob_devx2:rural.ses.med41[1]     0.29      0.22     0.01     0.78
## prjusedrg_mostjob_devx2:rural.ses.med41[2]     0.21      0.18     0.01     0.64
## prjusedrg_mostjob_devx2:rural.ses.med41[3]     0.22      0.18     0.01     0.65
## prjusedrg_mostjob_devx2:rural.ses.med41[4]     0.28      0.21     0.01     0.75
## prjhack_mostjob_devx21[1]                      0.25      0.14     0.04     0.57
## prjhack_mostjob_devx21[2]                      0.25      0.14     0.04     0.58
## prjhack_mostjob_devx21[3]                      0.26      0.15     0.04     0.59
## prjhack_mostjob_devx21[4]                      0.25      0.15     0.04     0.60
## prjhack_mostjob_av12x21[1]                     0.10      0.07     0.01     0.26
## prjhack_mostjob_av12x21[2]                     0.10      0.07     0.01     0.27
## prjhack_mostjob_av12x21[3]                     0.11      0.07     0.01     0.28
## prjhack_mostjob_av12x21[4]                     0.10      0.07     0.01     0.27
## prjhack_mostjob_av12x21[5]                     0.12      0.08     0.01     0.31
## prjhack_mostjob_av12x21[6]                     0.14      0.09     0.02     0.34
## prjhack_mostjob_av12x21[7]                     0.19      0.10     0.03     0.41
## prjhack_mostjob_av12x21[8]                     0.14      0.08     0.02     0.33
## prjhack_mostjob_devx2:rural.ses.med21[1]       0.28      0.20     0.01     0.74
## prjhack_mostjob_devx2:rural.ses.med21[2]       0.24      0.19     0.01     0.68
## prjhack_mostjob_devx2:rural.ses.med21[3]       0.21      0.18     0.01     0.66
## prjhack_mostjob_devx2:rural.ses.med21[4]       0.28      0.20     0.01     0.73
## prjhack_mostjob_devx2:rural.ses.med31[1]       0.23      0.18     0.01     0.68
## prjhack_mostjob_devx2:rural.ses.med31[2]       0.23      0.18     0.01     0.67
## prjhack_mostjob_devx2:rural.ses.med31[3]       0.25      0.19     0.01     0.69
## prjhack_mostjob_devx2:rural.ses.med31[4]       0.29      0.21     0.01     0.75
## prjhack_mostjob_devx2:rural.ses.med41[1]       0.21      0.18     0.01     0.66
## prjhack_mostjob_devx2:rural.ses.med41[2]       0.20      0.18     0.00     0.67
## prjhack_mostjob_devx2:rural.ses.med41[3]       0.31      0.23     0.01     0.80
## prjhack_mostjob_devx2:rural.ses.med41[4]       0.28      0.21     0.01     0.75
##                                            Rhat Bulk_ESS Tail_ESS
## prjthflt5_mostjob_devx21[1]                1.00     8559     2854
## prjthflt5_mostjob_devx21[2]                1.00     6973     2609
## prjthflt5_mostjob_devx21[3]                1.00     7683     2756
## prjthflt5_mostjob_devx21[4]                1.00     7220     2298
## prjthflt5_mostjob_av12x21[1]               1.00     7731     2923
## prjthflt5_mostjob_av12x21[2]               1.00     8800     2872
## prjthflt5_mostjob_av12x21[3]               1.00     8371     2559
## prjthflt5_mostjob_av12x21[4]               1.00     8226     2963
## prjthflt5_mostjob_av12x21[5]               1.00     8558     2341
## prjthflt5_mostjob_av12x21[6]               1.00     7876     2397
## prjthflt5_mostjob_av12x21[7]               1.00     7008     2522
## prjthflt5_mostjob_av12x21[8]               1.00     7835     2342
## prjthflt5_mostjob_devx2:rural.ses.med21[1] 1.00     7123     2587
## prjthflt5_mostjob_devx2:rural.ses.med21[2] 1.00     6237     2711
## prjthflt5_mostjob_devx2:rural.ses.med21[3] 1.00     5815     3175
## prjthflt5_mostjob_devx2:rural.ses.med21[4] 1.00     6068     2865
## prjthflt5_mostjob_devx2:rural.ses.med31[1] 1.00     7289     2621
## prjthflt5_mostjob_devx2:rural.ses.med31[2] 1.00     7174     2908
## prjthflt5_mostjob_devx2:rural.ses.med31[3] 1.00     5470     2837
## prjthflt5_mostjob_devx2:rural.ses.med31[4] 1.00     6801     3364
## prjthflt5_mostjob_devx2:rural.ses.med41[1] 1.00     5238     3016
## prjthflt5_mostjob_devx2:rural.ses.med41[2] 1.00     6480     2592
## prjthflt5_mostjob_devx2:rural.ses.med41[3] 1.00     4955     2853
## prjthflt5_mostjob_devx2:rural.ses.med41[4] 1.00     6273     2930
## prjthfgt5_mostjob_devx21[1]                1.00     8600     2476
## prjthfgt5_mostjob_devx21[2]                1.00     7617     2858
## prjthfgt5_mostjob_devx21[3]                1.00     7513     2712
## prjthfgt5_mostjob_devx21[4]                1.00     8912     2735
## prjthfgt5_mostjob_av12x21[1]               1.00     7841     2429
## prjthfgt5_mostjob_av12x21[2]               1.00     6940     2628
## prjthfgt5_mostjob_av12x21[3]               1.00     8628     2301
## prjthfgt5_mostjob_av12x21[4]               1.00     7091     2990
## prjthfgt5_mostjob_av12x21[5]               1.00     7248     2623
## prjthfgt5_mostjob_av12x21[6]               1.00     8622     2794
## prjthfgt5_mostjob_av12x21[7]               1.00     6608     2580
## prjthfgt5_mostjob_av12x21[8]               1.00     6773     2401
## prjthfgt5_mostjob_devx2:rural.ses.med21[1] 1.00     6484     2418
## prjthfgt5_mostjob_devx2:rural.ses.med21[2] 1.00     7093     2814
## prjthfgt5_mostjob_devx2:rural.ses.med21[3] 1.00     7376     2806
## prjthfgt5_mostjob_devx2:rural.ses.med21[4] 1.00     6027     3123
## prjthfgt5_mostjob_devx2:rural.ses.med31[1] 1.00     6824     2813
## prjthfgt5_mostjob_devx2:rural.ses.med31[2] 1.00     7635     3048
## prjthfgt5_mostjob_devx2:rural.ses.med31[3] 1.00     5139     3070
## prjthfgt5_mostjob_devx2:rural.ses.med31[4] 1.00     6475     2792
## prjthfgt5_mostjob_devx2:rural.ses.med41[1] 1.00     4985     3192
## prjthfgt5_mostjob_devx2:rural.ses.med41[2] 1.00     4921     2745
## prjthfgt5_mostjob_devx2:rural.ses.med41[3] 1.00     3762     2841
## prjthfgt5_mostjob_devx2:rural.ses.med41[4] 1.00     7078     2606
## prjthreat_mostjob_devx21[1]                1.00     8712     2636
## prjthreat_mostjob_devx21[2]                1.00     8269     2694
## prjthreat_mostjob_devx21[3]                1.00     8161     2728
## prjthreat_mostjob_devx21[4]                1.00     7222     2563
## prjthreat_mostjob_av12x21[1]               1.00     7906     2064
## prjthreat_mostjob_av12x21[2]               1.00     8188     2403
## prjthreat_mostjob_av12x21[3]               1.00     7888     2809
## prjthreat_mostjob_av12x21[4]               1.00     7116     2209
## prjthreat_mostjob_av12x21[5]               1.00     6905     2538
## prjthreat_mostjob_av12x21[6]               1.00     8048     2430
## prjthreat_mostjob_av12x21[7]               1.00     6570     3235
## prjthreat_mostjob_av12x21[8]               1.00     6844     3000
## prjthreat_mostjob_devx2:rural.ses.med21[1] 1.00     6249     2482
## prjthreat_mostjob_devx2:rural.ses.med21[2] 1.00     6578     2706
## prjthreat_mostjob_devx2:rural.ses.med21[3] 1.00     6272     2643
## prjthreat_mostjob_devx2:rural.ses.med21[4] 1.00     5552     2416
## prjthreat_mostjob_devx2:rural.ses.med31[1] 1.00     7186     2658
## prjthreat_mostjob_devx2:rural.ses.med31[2] 1.00     7111     2971
## prjthreat_mostjob_devx2:rural.ses.med31[3] 1.00     5771     2635
## prjthreat_mostjob_devx2:rural.ses.med31[4] 1.00     6052     3163
## prjthreat_mostjob_devx2:rural.ses.med41[1] 1.00     5481     2765
## prjthreat_mostjob_devx2:rural.ses.med41[2] 1.00     5196     3003
## prjthreat_mostjob_devx2:rural.ses.med41[3] 1.00     3947     2626
## prjthreat_mostjob_devx2:rural.ses.med41[4] 1.00     6620     2762
## prjharm_mostjob_devx21[1]                  1.00     8827     2701
## prjharm_mostjob_devx21[2]                  1.00     6828     2306
## prjharm_mostjob_devx21[3]                  1.00     6784     3111
## prjharm_mostjob_devx21[4]                  1.00     8310     2823
## prjharm_mostjob_av12x21[1]                 1.00     7082     2332
## prjharm_mostjob_av12x21[2]                 1.00     7477     2685
## prjharm_mostjob_av12x21[3]                 1.00     8056     2483
## prjharm_mostjob_av12x21[4]                 1.00     7786     2363
## prjharm_mostjob_av12x21[5]                 1.00     8504     2310
## prjharm_mostjob_av12x21[6]                 1.00     7737     2673
## prjharm_mostjob_av12x21[7]                 1.00     8810     3049
## prjharm_mostjob_av12x21[8]                 1.00     6514     2242
## prjharm_mostjob_devx2:rural.ses.med21[1]   1.00     7800     2940
## prjharm_mostjob_devx2:rural.ses.med21[2]   1.00     6508     2640
## prjharm_mostjob_devx2:rural.ses.med21[3]   1.00     6698     2639
## prjharm_mostjob_devx2:rural.ses.med21[4]   1.00     5888     2205
## prjharm_mostjob_devx2:rural.ses.med31[1]   1.00     7902     2764
## prjharm_mostjob_devx2:rural.ses.med31[2]   1.00     6647     2807
## prjharm_mostjob_devx2:rural.ses.med31[3]   1.00     6306     2835
## prjharm_mostjob_devx2:rural.ses.med31[4]   1.00     6214     2582
## prjharm_mostjob_devx2:rural.ses.med41[1]   1.00     6027     2647
## prjharm_mostjob_devx2:rural.ses.med41[2]   1.00     6544     2728
## prjharm_mostjob_devx2:rural.ses.med41[3]   1.00     5673     2900
## prjharm_mostjob_devx2:rural.ses.med41[4]   1.00     5878     2605
## prjusedrg_mostjob_devx21[1]                1.00     8468     2742
## prjusedrg_mostjob_devx21[2]                1.00     7396     2648
## prjusedrg_mostjob_devx21[3]                1.00     6837     3077
## prjusedrg_mostjob_devx21[4]                1.00     7482     2392
## prjusedrg_mostjob_av12x21[1]               1.00     7625     2671
## prjusedrg_mostjob_av12x21[2]               1.00     7089     2167
## prjusedrg_mostjob_av12x21[3]               1.00     7956     2684
## prjusedrg_mostjob_av12x21[4]               1.00     8541     2950
## prjusedrg_mostjob_av12x21[5]               1.00     7843     2520
## prjusedrg_mostjob_av12x21[6]               1.00     8571     2746
## prjusedrg_mostjob_av12x21[7]               1.00     7710     2750
## prjusedrg_mostjob_av12x21[8]               1.00     6909     2593
## prjusedrg_mostjob_devx2:rural.ses.med21[1] 1.00     7302     2281
## prjusedrg_mostjob_devx2:rural.ses.med21[2] 1.00     7715     2630
## prjusedrg_mostjob_devx2:rural.ses.med21[3] 1.00     6498     2469
## prjusedrg_mostjob_devx2:rural.ses.med21[4] 1.00     5910     2863
## prjusedrg_mostjob_devx2:rural.ses.med31[1] 1.00     6144     2614
## prjusedrg_mostjob_devx2:rural.ses.med31[2] 1.00     6061     3074
## prjusedrg_mostjob_devx2:rural.ses.med31[3] 1.00     6970     2524
## prjusedrg_mostjob_devx2:rural.ses.med31[4] 1.00     5184     2800
## prjusedrg_mostjob_devx2:rural.ses.med41[1] 1.00     4945     2763
## prjusedrg_mostjob_devx2:rural.ses.med41[2] 1.00     6291     2593
## prjusedrg_mostjob_devx2:rural.ses.med41[3] 1.00     5086     2765
## prjusedrg_mostjob_devx2:rural.ses.med41[4] 1.00     6534     2940
## prjhack_mostjob_devx21[1]                  1.00     7513     2155
## prjhack_mostjob_devx21[2]                  1.00     9228     1911
## prjhack_mostjob_devx21[3]                  1.00     6327     2781
## prjhack_mostjob_devx21[4]                  1.00     8007     2693
## prjhack_mostjob_av12x21[1]                 1.00     9040     2687
## prjhack_mostjob_av12x21[2]                 1.00     7711     2996
## prjhack_mostjob_av12x21[3]                 1.00     9575     2665
## prjhack_mostjob_av12x21[4]                 1.00     7762     2761
## prjhack_mostjob_av12x21[5]                 1.01     7864     2588
## prjhack_mostjob_av12x21[6]                 1.00     7788     2873
## prjhack_mostjob_av12x21[7]                 1.00     8388     2394
## prjhack_mostjob_av12x21[8]                 1.00     6524     2709
## prjhack_mostjob_devx2:rural.ses.med21[1]   1.00     6021     2471
## prjhack_mostjob_devx2:rural.ses.med21[2]   1.00     5575     2601
## prjhack_mostjob_devx2:rural.ses.med21[3]   1.00     5817     3219
## prjhack_mostjob_devx2:rural.ses.med21[4]   1.00     6985     2882
## prjhack_mostjob_devx2:rural.ses.med31[1]   1.00     7287     2277
## prjhack_mostjob_devx2:rural.ses.med31[2]   1.00     7670     2892
## prjhack_mostjob_devx2:rural.ses.med31[3]   1.00     6133     2589
## prjhack_mostjob_devx2:rural.ses.med31[4]   1.00     6595     2074
## prjhack_mostjob_devx2:rural.ses.med41[1]   1.00     5420     2742
## prjhack_mostjob_devx2:rural.ses.med41[2]   1.00     5518     2920
## prjhack_mostjob_devx2:rural.ses.med41[3]   1.00     5427     2726
## prjhack_mostjob_devx2:rural.ses.med41[4]   1.00     6385     2769
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.1.5.4 Prior summary
out.chg.prjcrime.stjob.comm.fit[[2]]
##                              prior     class                          coef
##                             (flat)         b                              
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                             (flat) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##          prjhack                          user
##          prjhack                          user
##          prjhack                          user
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjharm                          user
##          prjharm                          user
##          prjharm                          user
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##                                        default
##          prjhack                          user
##          prjharm                          user
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthreat                          user
##        prjusedrg                          user
##          prjhack             0         default
##          prjharm             0         default
##        prjthfgt5             0         default
##        prjthflt5             0         default
##        prjthreat             0         default
##        prjusedrg             0         default
##     id   prjhack             0    (vectorized)
##     id   prjhack             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##          prjhack                          user
##          prjhack                       default
##          prjhack                       default
##          prjhack                       default
##          prjhack                          user
##          prjharm                          user
##          prjharm                       default
##          prjharm                       default
##          prjharm                       default
##          prjharm                          user
##        prjthfgt5                          user
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                          user
##        prjthreat                          user
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                          user
##        prjusedrg                          user
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                          user

8.1.1.6 Corr X Community: stthft & prj crime

#Community Change: criminal intent items ~ mo(stthft)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostthft_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostthft_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostthft_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostthft_av12x21', 
                  resp = prjdv_names)
  )

# drop year from model to avoid inappropriately partially out systematic stress change differences.  
  # also, with two waves, can only add random int OR random slope for year
chg.prjcrime.stthft.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stthft_devx2) + mo(stthft_av12x2) + 
    rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stthft_comm_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stthft.comm.fit <- ppchecks(chg.prjcrime.stthft.comm.fit)
8.1.1.6.1 Coefficient plot (intervals)
out.chg.prjcrime.stthft.comm.fit[[10]]

8.1.1.6.2 PPcheck (density)
p1 <- out.chg.prjcrime.stthft.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stthft.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stthft.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stthft.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stthft.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stthft.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

8.1.1.6.3 Fit summary
out.chg.prjcrime.stthft.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          prjharm ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          prjhack ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.96      0.57     2.94     5.21 1.00     1487
## sd(prjthfgt5_Intercept)     3.30      0.49     2.40     4.34 1.00     1609
## sd(prjthreat_Intercept)     3.14      0.55     2.19     4.29 1.00     1515
## sd(prjharm_Intercept)       3.09      0.57     2.07     4.30 1.00     1550
## sd(prjusedrg_Intercept)     2.87      0.53     1.93     3.97 1.00     1483
## sd(prjhack_Intercept)       0.90      0.57     0.05     2.12 1.00      698
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2564
## sd(prjthfgt5_Intercept)     1721
## sd(prjthreat_Intercept)     2166
## sd(prjharm_Intercept)       2378
## sd(prjusedrg_Intercept)     2382
## sd(prjhack_Intercept)       1389
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_Intercept                        -5.60      0.84    -7.34    -4.03
## prjthfgt5_Intercept                        -5.29      0.78    -6.85    -3.77
## prjthreat_Intercept                        -6.12      0.92    -8.00    -4.37
## prjharm_Intercept                          -5.71      0.93    -7.64    -3.99
## prjusedrg_Intercept                        -5.75      0.91    -7.60    -4.09
## prjhack_Intercept                          -3.99      0.74    -5.59    -2.64
## prjthflt5_rural.ses.med2                   -0.34      0.90    -2.08     1.44
## prjthflt5_rural.ses.med3                    0.66      0.80    -1.00     2.15
## prjthflt5_rural.ses.med4                    1.67      0.75     0.15     3.08
## prjthfgt5_rural.ses.med2                   -0.31      0.92    -2.11     1.44
## prjthfgt5_rural.ses.med3                    0.62      0.77    -0.96     2.06
## prjthfgt5_rural.ses.med4                    1.35      0.76    -0.21     2.77
## prjthreat_rural.ses.med2                   -0.53      0.92    -2.27     1.34
## prjthreat_rural.ses.med3                    0.48      0.76    -1.07     1.97
## prjthreat_rural.ses.med4                    1.61      0.77     0.04     3.03
## prjharm_rural.ses.med2                     -0.02      0.87    -1.63     1.76
## prjharm_rural.ses.med3                      0.21      0.77    -1.29     1.75
## prjharm_rural.ses.med4                      0.98      0.75    -0.53     2.43
## prjusedrg_rural.ses.med2                   -0.41      0.86    -2.09     1.32
## prjusedrg_rural.ses.med3                   -0.15      0.82    -1.76     1.48
## prjusedrg_rural.ses.med4                    1.54      0.77    -0.02     3.04
## prjhack_rural.ses.med2                     -0.31      0.87    -2.02     1.44
## prjhack_rural.ses.med3                     -0.06      0.71    -1.48     1.37
## prjhack_rural.ses.med4                      0.96      0.70    -0.38     2.32
## prjthflt5_mostthft_devx2                   -0.20      0.20    -0.60     0.19
## prjthflt5_mostthft_av12x2                   0.06      0.09    -0.12     0.23
## prjthflt5_mostthft_devx2:rural.ses.med2    -0.80      0.53    -1.92     0.19
## prjthflt5_mostthft_devx2:rural.ses.med3     0.45      0.41    -0.27     1.35
## prjthflt5_mostthft_devx2:rural.ses.med4     0.25      0.35    -0.45     0.93
## prjthfgt5_mostthft_devx2                   -0.15      0.21    -0.58     0.26
## prjthfgt5_mostthft_av12x2                   0.10      0.08    -0.05     0.27
## prjthfgt5_mostthft_devx2:rural.ses.med2    -0.91      0.51    -1.96     0.05
## prjthfgt5_mostthft_devx2:rural.ses.med3     0.36      0.39    -0.31     1.18
## prjthfgt5_mostthft_devx2:rural.ses.med4     0.31      0.33    -0.36     0.95
## prjthreat_mostthft_devx2                   -0.25      0.22    -0.69     0.19
## prjthreat_mostthft_av12x2                   0.10      0.09    -0.08     0.28
## prjthreat_mostthft_devx2:rural.ses.med2    -0.38      0.63    -1.62     0.90
## prjthreat_mostthft_devx2:rural.ses.med3    -0.05      0.47    -1.02     0.84
## prjthreat_mostthft_devx2:rural.ses.med4     0.02      0.41    -0.86     0.81
## prjharm_mostthft_devx2                     -0.33      0.21    -0.75     0.10
## prjharm_mostthft_av12x2                     0.05      0.09    -0.14     0.22
## prjharm_mostthft_devx2:rural.ses.med2      -0.50      0.56    -1.72     0.57
## prjharm_mostthft_devx2:rural.ses.med3      -0.08      0.46    -1.06     0.78
## prjharm_mostthft_devx2:rural.ses.med4      -0.07      0.44    -1.03     0.72
## prjusedrg_mostthft_devx2                   -0.13      0.22    -0.57     0.28
## prjusedrg_mostthft_av12x2                  -0.07      0.09    -0.25     0.11
## prjusedrg_mostthft_devx2:rural.ses.med2    -0.24      0.56    -1.41     0.83
## prjusedrg_mostthft_devx2:rural.ses.med3    -0.48      0.60    -1.78     0.59
## prjusedrg_mostthft_devx2:rural.ses.med4     0.14      0.39    -0.71     0.86
## prjhack_mostthft_devx2                     -0.18      0.21    -0.59     0.24
## prjhack_mostthft_av12x2                    -0.01      0.08    -0.16     0.14
## prjhack_mostthft_devx2:rural.ses.med2      -0.68      0.63    -2.04     0.49
## prjhack_mostthft_devx2:rural.ses.med3       0.12      0.40    -0.73     0.87
## prjhack_mostthft_devx2:rural.ses.med4      -0.05      0.38    -0.78     0.74
##                                         Rhat Bulk_ESS Tail_ESS
## prjthflt5_Intercept                     1.00     2512     2921
## prjthfgt5_Intercept                     1.00     2832     2943
## prjthreat_Intercept                     1.00     2723     3045
## prjharm_Intercept                       1.00     2961     2968
## prjusedrg_Intercept                     1.00     2594     2720
## prjhack_Intercept                       1.00     1555     2329
## prjthflt5_rural.ses.med2                1.00     5429     3297
## prjthflt5_rural.ses.med3                1.00     4022     3092
## prjthflt5_rural.ses.med4                1.00     4089     3057
## prjthfgt5_rural.ses.med2                1.00     4844     3099
## prjthfgt5_rural.ses.med3                1.00     4013     3099
## prjthfgt5_rural.ses.med4                1.00     3997     2759
## prjthreat_rural.ses.med2                1.00     4757     3012
## prjthreat_rural.ses.med3                1.00     5472     3331
## prjthreat_rural.ses.med4                1.00     4310     3057
## prjharm_rural.ses.med2                  1.00     5433     3226
## prjharm_rural.ses.med3                  1.00     5457     3001
## prjharm_rural.ses.med4                  1.00     4232     3120
## prjusedrg_rural.ses.med2                1.00     5382     3616
## prjusedrg_rural.ses.med3                1.00     5343     2778
## prjusedrg_rural.ses.med4                1.00     5192     3130
## prjhack_rural.ses.med2                  1.00     5024     3188
## prjhack_rural.ses.med3                  1.00     5076     3005
## prjhack_rural.ses.med4                  1.00     4513     3208
## prjthflt5_mostthft_devx2                1.00     4532     2980
## prjthflt5_mostthft_av12x2               1.00     3066     3105
## prjthflt5_mostthft_devx2:rural.ses.med2 1.00     3224     2909
## prjthflt5_mostthft_devx2:rural.ses.med3 1.00     3288     2681
## prjthflt5_mostthft_devx2:rural.ses.med4 1.00     3357     3126
## prjthfgt5_mostthft_devx2                1.00     4312     3362
## prjthfgt5_mostthft_av12x2               1.00     3455     3280
## prjthfgt5_mostthft_devx2:rural.ses.med2 1.00     3875     2778
## prjthfgt5_mostthft_devx2:rural.ses.med3 1.00     3131     2537
## prjthfgt5_mostthft_devx2:rural.ses.med4 1.00     3545     3034
## prjthreat_mostthft_devx2                1.00     4438     3016
## prjthreat_mostthft_av12x2               1.00     4478     3176
## prjthreat_mostthft_devx2:rural.ses.med2 1.00     2936     2727
## prjthreat_mostthft_devx2:rural.ses.med3 1.00     3806     2561
## prjthreat_mostthft_devx2:rural.ses.med4 1.00     3235     2834
## prjharm_mostthft_devx2                  1.00     5087     2870
## prjharm_mostthft_av12x2                 1.00     4418     3262
## prjharm_mostthft_devx2:rural.ses.med2   1.00     3839     2666
## prjharm_mostthft_devx2:rural.ses.med3   1.00     3526     2479
## prjharm_mostthft_devx2:rural.ses.med4   1.00     3734     2897
## prjusedrg_mostthft_devx2                1.00     5087     3211
## prjusedrg_mostthft_av12x2               1.00     4630     3259
## prjusedrg_mostthft_devx2:rural.ses.med2 1.00     3679     3217
## prjusedrg_mostthft_devx2:rural.ses.med3 1.00     3924     2626
## prjusedrg_mostthft_devx2:rural.ses.med4 1.00     3646     2522
## prjhack_mostthft_devx2                  1.00     4700     3243
## prjhack_mostthft_av12x2                 1.00     6489     3067
## prjhack_mostthft_devx2:rural.ses.med2   1.00     4270     2866
## prjhack_mostthft_devx2:rural.ses.med3   1.00     4078     2661
## prjhack_mostthft_devx2:rural.ses.med4   1.00     3321     2867
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## prjthflt5_mostthft_devx21[1]                    0.28      0.15     0.05
## prjthflt5_mostthft_devx21[2]                    0.26      0.14     0.04
## prjthflt5_mostthft_devx21[3]                    0.23      0.13     0.03
## prjthflt5_mostthft_devx21[4]                    0.24      0.14     0.03
## prjthflt5_mostthft_av12x21[1]                   0.13      0.08     0.02
## prjthflt5_mostthft_av12x21[2]                   0.12      0.08     0.02
## prjthflt5_mostthft_av12x21[3]                   0.12      0.08     0.02
## prjthflt5_mostthft_av12x21[4]                   0.12      0.08     0.02
## prjthflt5_mostthft_av12x21[5]                   0.13      0.08     0.02
## prjthflt5_mostthft_av12x21[6]                   0.13      0.08     0.02
## prjthflt5_mostthft_av12x21[7]                   0.12      0.08     0.01
## prjthflt5_mostthft_av12x21[8]                   0.13      0.08     0.02
## prjthflt5_mostthft_devx2:rural.ses.med21[1]     0.31      0.20     0.02
## prjthflt5_mostthft_devx2:rural.ses.med21[2]     0.26      0.19     0.01
## prjthflt5_mostthft_devx2:rural.ses.med21[3]     0.19      0.16     0.01
## prjthflt5_mostthft_devx2:rural.ses.med21[4]     0.24      0.18     0.01
## prjthflt5_mostthft_devx2:rural.ses.med31[1]     0.29      0.21     0.01
## prjthflt5_mostthft_devx2:rural.ses.med31[2]     0.21      0.17     0.01
## prjthflt5_mostthft_devx2:rural.ses.med31[3]     0.18      0.16     0.00
## prjthflt5_mostthft_devx2:rural.ses.med31[4]     0.31      0.21     0.01
## prjthflt5_mostthft_devx2:rural.ses.med41[1]     0.29      0.20     0.01
## prjthflt5_mostthft_devx2:rural.ses.med41[2]     0.23      0.18     0.01
## prjthflt5_mostthft_devx2:rural.ses.med41[3]     0.22      0.18     0.01
## prjthflt5_mostthft_devx2:rural.ses.med41[4]     0.25      0.20     0.01
## prjthfgt5_mostthft_devx21[1]                    0.27      0.15     0.04
## prjthfgt5_mostthft_devx21[2]                    0.26      0.15     0.04
## prjthfgt5_mostthft_devx21[3]                    0.22      0.13     0.03
## prjthfgt5_mostthft_devx21[4]                    0.25      0.14     0.04
## prjthfgt5_mostthft_av12x21[1]                   0.13      0.08     0.02
## prjthfgt5_mostthft_av12x21[2]                   0.12      0.08     0.02
## prjthfgt5_mostthft_av12x21[3]                   0.12      0.08     0.02
## prjthfgt5_mostthft_av12x21[4]                   0.12      0.08     0.02
## prjthfgt5_mostthft_av12x21[5]                   0.13      0.08     0.02
## prjthfgt5_mostthft_av12x21[6]                   0.13      0.08     0.02
## prjthfgt5_mostthft_av12x21[7]                   0.12      0.07     0.02
## prjthfgt5_mostthft_av12x21[8]                   0.12      0.08     0.02
## prjthfgt5_mostthft_devx2:rural.ses.med21[1]     0.30      0.19     0.02
## prjthfgt5_mostthft_devx2:rural.ses.med21[2]     0.30      0.20     0.02
## prjthfgt5_mostthft_devx2:rural.ses.med21[3]     0.17      0.15     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med21[4]     0.23      0.18     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med31[1]     0.29      0.21     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med31[2]     0.21      0.18     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med31[3]     0.20      0.17     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med31[4]     0.31      0.21     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med41[1]     0.26      0.19     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med41[2]     0.24      0.19     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med41[3]     0.26      0.19     0.01
## prjthfgt5_mostthft_devx2:rural.ses.med41[4]     0.24      0.19     0.01
## prjthreat_mostthft_devx21[1]                    0.27      0.15     0.04
## prjthreat_mostthft_devx21[2]                    0.28      0.15     0.04
## prjthreat_mostthft_devx21[3]                    0.21      0.13     0.03
## prjthreat_mostthft_devx21[4]                    0.24      0.14     0.03
## prjthreat_mostthft_av12x21[1]                   0.13      0.08     0.02
## prjthreat_mostthft_av12x21[2]                   0.13      0.08     0.02
## prjthreat_mostthft_av12x21[3]                   0.12      0.08     0.02
## prjthreat_mostthft_av12x21[4]                   0.13      0.08     0.02
## prjthreat_mostthft_av12x21[5]                   0.13      0.08     0.02
## prjthreat_mostthft_av12x21[6]                   0.13      0.08     0.02
## prjthreat_mostthft_av12x21[7]                   0.13      0.08     0.02
## prjthreat_mostthft_av12x21[8]                   0.12      0.08     0.01
## prjthreat_mostthft_devx2:rural.ses.med21[1]     0.30      0.21     0.01
## prjthreat_mostthft_devx2:rural.ses.med21[2]     0.23      0.18     0.01
## prjthreat_mostthft_devx2:rural.ses.med21[3]     0.20      0.18     0.01
## prjthreat_mostthft_devx2:rural.ses.med21[4]     0.28      0.20     0.01
## prjthreat_mostthft_devx2:rural.ses.med31[1]     0.24      0.19     0.01
## prjthreat_mostthft_devx2:rural.ses.med31[2]     0.22      0.19     0.01
## prjthreat_mostthft_devx2:rural.ses.med31[3]     0.24      0.19     0.01
## prjthreat_mostthft_devx2:rural.ses.med31[4]     0.30      0.21     0.01
## prjthreat_mostthft_devx2:rural.ses.med41[1]     0.26      0.20     0.01
## prjthreat_mostthft_devx2:rural.ses.med41[2]     0.22      0.18     0.01
## prjthreat_mostthft_devx2:rural.ses.med41[3]     0.23      0.18     0.01
## prjthreat_mostthft_devx2:rural.ses.med41[4]     0.28      0.21     0.01
## prjharm_mostthft_devx21[1]                      0.26      0.14     0.04
## prjharm_mostthft_devx21[2]                      0.30      0.15     0.05
## prjharm_mostthft_devx21[3]                      0.22      0.13     0.03
## prjharm_mostthft_devx21[4]                      0.22      0.13     0.03
## prjharm_mostthft_av12x21[1]                     0.13      0.08     0.02
## prjharm_mostthft_av12x21[2]                     0.13      0.08     0.02
## prjharm_mostthft_av12x21[3]                     0.12      0.08     0.01
## prjharm_mostthft_av12x21[4]                     0.12      0.08     0.01
## prjharm_mostthft_av12x21[5]                     0.12      0.08     0.02
## prjharm_mostthft_av12x21[6]                     0.12      0.08     0.02
## prjharm_mostthft_av12x21[7]                     0.13      0.08     0.02
## prjharm_mostthft_av12x21[8]                     0.13      0.08     0.02
## prjharm_mostthft_devx2:rural.ses.med21[1]       0.25      0.19     0.01
## prjharm_mostthft_devx2:rural.ses.med21[2]       0.25      0.19     0.01
## prjharm_mostthft_devx2:rural.ses.med21[3]       0.23      0.18     0.01
## prjharm_mostthft_devx2:rural.ses.med21[4]       0.27      0.20     0.01
## prjharm_mostthft_devx2:rural.ses.med31[1]       0.25      0.19     0.01
## prjharm_mostthft_devx2:rural.ses.med31[2]       0.22      0.18     0.01
## prjharm_mostthft_devx2:rural.ses.med31[3]       0.24      0.19     0.01
## prjharm_mostthft_devx2:rural.ses.med31[4]       0.30      0.21     0.01
## prjharm_mostthft_devx2:rural.ses.med41[1]       0.24      0.19     0.01
## prjharm_mostthft_devx2:rural.ses.med41[2]       0.23      0.18     0.01
## prjharm_mostthft_devx2:rural.ses.med41[3]       0.24      0.19     0.01
## prjharm_mostthft_devx2:rural.ses.med41[4]       0.29      0.22     0.01
## prjusedrg_mostthft_devx21[1]                    0.27      0.15     0.04
## prjusedrg_mostthft_devx21[2]                    0.24      0.14     0.04
## prjusedrg_mostthft_devx21[3]                    0.23      0.14     0.03
## prjusedrg_mostthft_devx21[4]                    0.26      0.14     0.04
## prjusedrg_mostthft_av12x21[1]                   0.13      0.08     0.02
## prjusedrg_mostthft_av12x21[2]                   0.13      0.08     0.02
## prjusedrg_mostthft_av12x21[3]                   0.13      0.08     0.02
## prjusedrg_mostthft_av12x21[4]                   0.13      0.08     0.02
## prjusedrg_mostthft_av12x21[5]                   0.12      0.08     0.02
## prjusedrg_mostthft_av12x21[6]                   0.12      0.08     0.02
## prjusedrg_mostthft_av12x21[7]                   0.12      0.08     0.02
## prjusedrg_mostthft_av12x21[8]                   0.13      0.08     0.02
## prjusedrg_mostthft_devx2:rural.ses.med21[1]     0.26      0.20     0.01
## prjusedrg_mostthft_devx2:rural.ses.med21[2]     0.22      0.18     0.01
## prjusedrg_mostthft_devx2:rural.ses.med21[3]     0.23      0.18     0.01
## prjusedrg_mostthft_devx2:rural.ses.med21[4]     0.29      0.21     0.01
## prjusedrg_mostthft_devx2:rural.ses.med31[1]     0.25      0.19     0.01
## prjusedrg_mostthft_devx2:rural.ses.med31[2]     0.19      0.17     0.01
## prjusedrg_mostthft_devx2:rural.ses.med31[3]     0.29      0.21     0.01
## prjusedrg_mostthft_devx2:rural.ses.med31[4]     0.27      0.20     0.01
## prjusedrg_mostthft_devx2:rural.ses.med41[1]     0.27      0.20     0.01
## prjusedrg_mostthft_devx2:rural.ses.med41[2]     0.21      0.17     0.01
## prjusedrg_mostthft_devx2:rural.ses.med41[3]     0.24      0.19     0.01
## prjusedrg_mostthft_devx2:rural.ses.med41[4]     0.27      0.21     0.01
## prjhack_mostthft_devx21[1]                      0.26      0.14     0.04
## prjhack_mostthft_devx21[2]                      0.26      0.14     0.04
## prjhack_mostthft_devx21[3]                      0.25      0.14     0.04
## prjhack_mostthft_devx21[4]                      0.23      0.14     0.03
## prjhack_mostthft_av12x21[1]                     0.13      0.08     0.02
## prjhack_mostthft_av12x21[2]                     0.12      0.08     0.02
## prjhack_mostthft_av12x21[3]                     0.12      0.08     0.02
## prjhack_mostthft_av12x21[4]                     0.12      0.08     0.02
## prjhack_mostthft_av12x21[5]                     0.12      0.08     0.02
## prjhack_mostthft_av12x21[6]                     0.13      0.08     0.02
## prjhack_mostthft_av12x21[7]                     0.13      0.08     0.02
## prjhack_mostthft_av12x21[8]                     0.13      0.08     0.02
## prjhack_mostthft_devx2:rural.ses.med21[1]       0.27      0.19     0.01
## prjhack_mostthft_devx2:rural.ses.med21[2]       0.21      0.17     0.01
## prjhack_mostthft_devx2:rural.ses.med21[3]       0.26      0.19     0.01
## prjhack_mostthft_devx2:rural.ses.med21[4]       0.26      0.20     0.01
## prjhack_mostthft_devx2:rural.ses.med31[1]       0.24      0.19     0.01
## prjhack_mostthft_devx2:rural.ses.med31[2]       0.23      0.18     0.01
## prjhack_mostthft_devx2:rural.ses.med31[3]       0.25      0.19     0.01
## prjhack_mostthft_devx2:rural.ses.med31[4]       0.28      0.21     0.01
## prjhack_mostthft_devx2:rural.ses.med41[1]       0.24      0.19     0.01
## prjhack_mostthft_devx2:rural.ses.med41[2]       0.23      0.18     0.01
## prjhack_mostthft_devx2:rural.ses.med41[3]       0.25      0.19     0.01
## prjhack_mostthft_devx2:rural.ses.med41[4]       0.28      0.21     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## prjthflt5_mostthft_devx21[1]                    0.62 1.00     7637     3134
## prjthflt5_mostthft_devx21[2]                    0.59 1.00     5855     2883
## prjthflt5_mostthft_devx21[3]                    0.54 1.00     7238     2885
## prjthflt5_mostthft_devx21[4]                    0.55 1.00     7103     2989
## prjthflt5_mostthft_av12x21[1]                   0.33 1.00     8089     2580
## prjthflt5_mostthft_av12x21[2]                   0.32 1.00     6305     2380
## prjthflt5_mostthft_av12x21[3]                   0.31 1.00     7284     2531
## prjthflt5_mostthft_av12x21[4]                   0.31 1.00     6858     2270
## prjthflt5_mostthft_av12x21[5]                   0.33 1.00     6060     2470
## prjthflt5_mostthft_av12x21[6]                   0.32 1.00     6798     2943
## prjthflt5_mostthft_av12x21[7]                   0.32 1.00     6862     2752
## prjthflt5_mostthft_av12x21[8]                   0.32 1.00     6105     2938
## prjthflt5_mostthft_devx2:rural.ses.med21[1]     0.72 1.00     4706     2844
## prjthflt5_mostthft_devx2:rural.ses.med21[2]     0.70 1.00     4539     2220
## prjthflt5_mostthft_devx2:rural.ses.med21[3]     0.60 1.00     5492     2407
## prjthflt5_mostthft_devx2:rural.ses.med21[4]     0.66 1.00     5187     2804
## prjthflt5_mostthft_devx2:rural.ses.med31[1]     0.75 1.00     4908     2236
## prjthflt5_mostthft_devx2:rural.ses.med31[2]     0.64 1.00     5329     2890
## prjthflt5_mostthft_devx2:rural.ses.med31[3]     0.60 1.00     4491     2988
## prjthflt5_mostthft_devx2:rural.ses.med31[4]     0.77 1.00     5207     2919
## prjthflt5_mostthft_devx2:rural.ses.med41[1]     0.75 1.00     5212     2442
## prjthflt5_mostthft_devx2:rural.ses.med41[2]     0.67 1.00     5303     2491
## prjthflt5_mostthft_devx2:rural.ses.med41[3]     0.64 1.00     5115     2823
## prjthflt5_mostthft_devx2:rural.ses.med41[4]     0.74 1.00     5925     2771
## prjthfgt5_mostthft_devx21[1]                    0.60 1.00     6074     2979
## prjthfgt5_mostthft_devx21[2]                    0.59 1.00     6882     2580
## prjthfgt5_mostthft_devx21[3]                    0.54 1.00     5913     2828
## prjthfgt5_mostthft_devx21[4]                    0.56 1.00     7369     2857
## prjthfgt5_mostthft_av12x21[1]                   0.31 1.00     7241     2224
## prjthfgt5_mostthft_av12x21[2]                   0.32 1.00     7054     2078
## prjthfgt5_mostthft_av12x21[3]                   0.31 1.00     7009     2761
## prjthfgt5_mostthft_av12x21[4]                   0.32 1.00     7189     2575
## prjthfgt5_mostthft_av12x21[5]                   0.33 1.00     6169     2485
## prjthfgt5_mostthft_av12x21[6]                   0.33 1.00     6622     2920
## prjthfgt5_mostthft_av12x21[7]                   0.30 1.00     6693     2708
## prjthfgt5_mostthft_av12x21[8]                   0.31 1.00     7518     2903
## prjthfgt5_mostthft_devx2:rural.ses.med21[1]     0.73 1.00     6098     2813
## prjthfgt5_mostthft_devx2:rural.ses.med21[2]     0.74 1.00     6437     2882
## prjthfgt5_mostthft_devx2:rural.ses.med21[3]     0.56 1.00     6140     2749
## prjthfgt5_mostthft_devx2:rural.ses.med21[4]     0.64 1.00     5533     2816
## prjthfgt5_mostthft_devx2:rural.ses.med31[1]     0.75 1.00     4227     2207
## prjthfgt5_mostthft_devx2:rural.ses.med31[2]     0.66 1.00     4814     2747
## prjthfgt5_mostthft_devx2:rural.ses.med31[3]     0.63 1.00     4348     3114
## prjthfgt5_mostthft_devx2:rural.ses.med31[4]     0.77 1.00     4189     3030
## prjthfgt5_mostthft_devx2:rural.ses.med41[1]     0.71 1.00     5918     2759
## prjthfgt5_mostthft_devx2:rural.ses.med41[2]     0.69 1.00     5746     2851
## prjthfgt5_mostthft_devx2:rural.ses.med41[3]     0.70 1.00     4558     2227
## prjthfgt5_mostthft_devx2:rural.ses.med41[4]     0.70 1.00     5402     2656
## prjthreat_mostthft_devx21[1]                    0.61 1.00     6686     2389
## prjthreat_mostthft_devx21[2]                    0.61 1.00     6574     2820
## prjthreat_mostthft_devx21[3]                    0.52 1.00     6143     3187
## prjthreat_mostthft_devx21[4]                    0.56 1.00     7208     3295
## prjthreat_mostthft_av12x21[1]                   0.31 1.00     8205     3081
## prjthreat_mostthft_av12x21[2]                   0.31 1.00     6954     2289
## prjthreat_mostthft_av12x21[3]                   0.31 1.00     7352     2110
## prjthreat_mostthft_av12x21[4]                   0.32 1.00     6863     2538
## prjthreat_mostthft_av12x21[5]                   0.33 1.00     7088     2585
## prjthreat_mostthft_av12x21[6]                   0.32 1.00     6762     2775
## prjthreat_mostthft_av12x21[7]                   0.32 1.00     5911     2589
## prjthreat_mostthft_av12x21[8]                   0.31 1.00     5710     2796
## prjthreat_mostthft_devx2:rural.ses.med21[1]     0.76 1.00     4941     2328
## prjthreat_mostthft_devx2:rural.ses.med21[2]     0.69 1.00     6364     2504
## prjthreat_mostthft_devx2:rural.ses.med21[3]     0.66 1.00     3758     2566
## prjthreat_mostthft_devx2:rural.ses.med21[4]     0.74 1.00     5787     2953
## prjthreat_mostthft_devx2:rural.ses.med31[1]     0.70 1.00     5210     2282
## prjthreat_mostthft_devx2:rural.ses.med31[2]     0.67 1.00     5324     2291
## prjthreat_mostthft_devx2:rural.ses.med31[3]     0.70 1.00     5549     3370
## prjthreat_mostthft_devx2:rural.ses.med31[4]     0.77 1.00     5697     2880
## prjthreat_mostthft_devx2:rural.ses.med41[1]     0.74 1.00     5091     2930
## prjthreat_mostthft_devx2:rural.ses.med41[2]     0.65 1.00     5303     2475
## prjthreat_mostthft_devx2:rural.ses.med41[3]     0.68 1.00     6128     2877
## prjthreat_mostthft_devx2:rural.ses.med41[4]     0.75 1.00     5447     2966
## prjharm_mostthft_devx21[1]                      0.58 1.00     7005     2370
## prjharm_mostthft_devx21[2]                      0.63 1.00     5779     2673
## prjharm_mostthft_devx21[3]                      0.53 1.00     5972     2964
## prjharm_mostthft_devx21[4]                      0.53 1.00     7326     2936
## prjharm_mostthft_av12x21[1]                     0.31 1.00     7420     2335
## prjharm_mostthft_av12x21[2]                     0.33 1.00     6955     2460
## prjharm_mostthft_av12x21[3]                     0.31 1.00     8367     2322
## prjharm_mostthft_av12x21[4]                     0.32 1.00     7620     2378
## prjharm_mostthft_av12x21[5]                     0.32 1.00     6557     2668
## prjharm_mostthft_av12x21[6]                     0.32 1.00     6346     2455
## prjharm_mostthft_av12x21[7]                     0.33 1.00     6161     2703
## prjharm_mostthft_av12x21[8]                     0.32 1.00     6243     2539
## prjharm_mostthft_devx2:rural.ses.med21[1]       0.70 1.00     4873     2022
## prjharm_mostthft_devx2:rural.ses.med21[2]       0.70 1.00     5631     2738
## prjharm_mostthft_devx2:rural.ses.med21[3]       0.66 1.00     5387     2504
## prjharm_mostthft_devx2:rural.ses.med21[4]       0.74 1.00     5552     2605
## prjharm_mostthft_devx2:rural.ses.med31[1]       0.70 1.00     7447     2541
## prjharm_mostthft_devx2:rural.ses.med31[2]       0.66 1.00     6366     2493
## prjharm_mostthft_devx2:rural.ses.med31[3]       0.68 1.00     5467     2652
## prjharm_mostthft_devx2:rural.ses.med31[4]       0.77 1.00     4822     3187
## prjharm_mostthft_devx2:rural.ses.med41[1]       0.68 1.00     6246     2497
## prjharm_mostthft_devx2:rural.ses.med41[2]       0.66 1.00     6196     2447
## prjharm_mostthft_devx2:rural.ses.med41[3]       0.70 1.00     5585     2685
## prjharm_mostthft_devx2:rural.ses.med41[4]       0.78 1.00     4829     2706
## prjusedrg_mostthft_devx21[1]                    0.60 1.00     6245     2542
## prjusedrg_mostthft_devx21[2]                    0.57 1.00     8421     2855
## prjusedrg_mostthft_devx21[3]                    0.56 1.00     6018     2594
## prjusedrg_mostthft_devx21[4]                    0.57 1.00     6477     2578
## prjusedrg_mostthft_av12x21[1]                   0.32 1.00     7675     2579
## prjusedrg_mostthft_av12x21[2]                   0.31 1.00     6499     2700
## prjusedrg_mostthft_av12x21[3]                   0.33 1.00     7381     2306
## prjusedrg_mostthft_av12x21[4]                   0.33 1.00     7064     2285
## prjusedrg_mostthft_av12x21[5]                   0.31 1.00     7037     2214
## prjusedrg_mostthft_av12x21[6]                   0.31 1.00     6143     2535
## prjusedrg_mostthft_av12x21[7]                   0.32 1.00     7631     2904
## prjusedrg_mostthft_av12x21[8]                   0.32 1.00     7599     2442
## prjusedrg_mostthft_devx2:rural.ses.med21[1]     0.72 1.00     4603     2538
## prjusedrg_mostthft_devx2:rural.ses.med21[2]     0.65 1.00     6325     3034
## prjusedrg_mostthft_devx2:rural.ses.med21[3]     0.68 1.00     5566     2497
## prjusedrg_mostthft_devx2:rural.ses.med21[4]     0.74 1.00     5951     3026
## prjusedrg_mostthft_devx2:rural.ses.med31[1]     0.69 1.00     5144     2209
## prjusedrg_mostthft_devx2:rural.ses.med31[2]     0.62 1.00     3889     2329
## prjusedrg_mostthft_devx2:rural.ses.med31[3]     0.77 1.00     5309     2680
## prjusedrg_mostthft_devx2:rural.ses.med31[4]     0.74 1.00     5913     2561
## prjusedrg_mostthft_devx2:rural.ses.med41[1]     0.73 1.00     5306     2657
## prjusedrg_mostthft_devx2:rural.ses.med41[2]     0.64 1.00     4459     1802
## prjusedrg_mostthft_devx2:rural.ses.med41[3]     0.68 1.00     5368     2223
## prjusedrg_mostthft_devx2:rural.ses.med41[4]     0.76 1.00     4555     2823
## prjhack_mostthft_devx21[1]                      0.59 1.00     6955     2197
## prjhack_mostthft_devx21[2]                      0.59 1.00     7219     2810
## prjhack_mostthft_devx21[3]                      0.57 1.00     6592     2629
## prjhack_mostthft_devx21[4]                      0.56 1.00     6893     2685
## prjhack_mostthft_av12x21[1]                     0.32 1.00     8880     2326
## prjhack_mostthft_av12x21[2]                     0.32 1.00     6458     2297
## prjhack_mostthft_av12x21[3]                     0.32 1.00     6483     2222
## prjhack_mostthft_av12x21[4]                     0.32 1.00     6842     2618
## prjhack_mostthft_av12x21[5]                     0.31 1.00     6307     2030
## prjhack_mostthft_av12x21[6]                     0.32 1.00     7308     3049
## prjhack_mostthft_av12x21[7]                     0.33 1.00     7624     3031
## prjhack_mostthft_av12x21[8]                     0.32 1.00     6667     2713
## prjhack_mostthft_devx2:rural.ses.med21[1]       0.71 1.00     5313     2493
## prjhack_mostthft_devx2:rural.ses.med21[2]       0.63 1.00     5699     2376
## prjhack_mostthft_devx2:rural.ses.med21[3]       0.70 1.00     5876     2641
## prjhack_mostthft_devx2:rural.ses.med21[4]       0.71 1.00     4928     2369
## prjhack_mostthft_devx2:rural.ses.med31[1]       0.70 1.00     5427     2080
## prjhack_mostthft_devx2:rural.ses.med31[2]       0.66 1.00     5350     2291
## prjhack_mostthft_devx2:rural.ses.med31[3]       0.68 1.00     5934     2431
## prjhack_mostthft_devx2:rural.ses.med31[4]       0.75 1.00     5037     2162
## prjhack_mostthft_devx2:rural.ses.med41[1]       0.68 1.00     5532     2265
## prjhack_mostthft_devx2:rural.ses.med41[2]       0.67 1.00     4348     2350
## prjhack_mostthft_devx2:rural.ses.med41[3]       0.71 1.00     5742     2987
## prjhack_mostthft_devx2:rural.ses.med41[4]       0.76 1.00     4867     3025
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.1.6.4 Prior summary
out.chg.prjcrime.stthft.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##          prjhack                          user
##          prjhack                          user
##          prjhack                          user
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjharm                          user
##          prjharm                          user
##          prjharm                          user
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##                                        default
##          prjhack                          user
##          prjharm                          user
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthreat                          user
##        prjusedrg                          user
##          prjhack             0         default
##          prjharm             0         default
##        prjthfgt5             0         default
##        prjthflt5             0         default
##        prjthreat             0         default
##        prjusedrg             0         default
##     id   prjhack             0    (vectorized)
##     id   prjhack             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##          prjhack                          user
##          prjhack                       default
##          prjhack                       default
##          prjhack                       default
##          prjhack                          user
##          prjharm                          user
##          prjharm                       default
##          prjharm                       default
##          prjharm                       default
##          prjharm                          user
##        prjthfgt5                          user
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                          user
##        prjthreat                          user
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                          user
##        prjusedrg                          user
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                          user

8.1.1.7 Corr X Community: stmug & prj crime

#Community Change: criminal intent items ~ mo(stmug)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmug_devx2', 
                  resp = prjdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostmug_av12x2', 
                  resp = prjdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmug_devx21', 
                  resp = prjdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostmug_av12x21', 
                  resp = prjdv_names)
  )

# drop year from model to avoid inappropriately partially out systematic stress change differences.  
  # also, with two waves, can only add random int OR random slope for year
chg.prjcrime.stmug.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 +
    mo(stmug_devx2) + mo(stmug_av12x2) + 
    rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_prjcrime_stmug_comm_fit",
      file_refit = "on_change"
  )

out.chg.prjcrime.stmug.comm.fit <- ppchecks(chg.prjcrime.stmug.comm.fit)
8.1.1.7.1 Coefficient plot (intervals)
out.chg.prjcrime.stmug.comm.fit[[10]]

8.1.1.7.2 PPcheck (density)
p1 <- out.chg.prjcrime.stmug.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stmug.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stmug.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stmug.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stmug.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stmug.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

8.1.1.7.3 Fit summary
out.chg.prjcrime.stmug.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          prjharm ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          prjhack ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.93      0.56     2.96     5.13 1.01     1407
## sd(prjthfgt5_Intercept)     3.36      0.50     2.47     4.42 1.00     1583
## sd(prjthreat_Intercept)     3.24      0.56     2.25     4.45 1.00     1675
## sd(prjharm_Intercept)       2.99      0.54     2.03     4.16 1.00     1391
## sd(prjusedrg_Intercept)     2.85      0.52     1.95     3.93 1.00     1738
## sd(prjhack_Intercept)       0.85      0.55     0.04     2.02 1.00      723
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2333
## sd(prjthfgt5_Intercept)     2468
## sd(prjthreat_Intercept)     2788
## sd(prjharm_Intercept)       2389
## sd(prjusedrg_Intercept)     2526
## sd(prjhack_Intercept)       1707
## 
## Regression Coefficients:
##                                        Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_Intercept                       -5.61      0.84    -7.37    -4.06
## prjthfgt5_Intercept                       -5.31      0.80    -6.88    -3.78
## prjthreat_Intercept                       -6.07      0.91    -7.95    -4.39
## prjharm_Intercept                         -6.09      0.92    -7.96    -4.35
## prjusedrg_Intercept                       -6.01      0.95    -7.95    -4.21
## prjhack_Intercept                         -4.33      0.72    -5.87    -2.99
## prjthflt5_rural.ses.med2                  -0.57      0.86    -2.26     1.15
## prjthflt5_rural.ses.med3                   1.25      0.80    -0.43     2.75
## prjthflt5_rural.ses.med4                   1.33      0.85    -0.44     2.86
## prjthfgt5_rural.ses.med2                  -0.56      0.89    -2.26     1.22
## prjthfgt5_rural.ses.med3                   1.08      0.77    -0.50     2.53
## prjthfgt5_rural.ses.med4                   1.14      0.79    -0.48     2.61
## prjthreat_rural.ses.med2                  -0.57      0.91    -2.29     1.24
## prjthreat_rural.ses.med3                   0.57      0.79    -0.97     2.07
## prjthreat_rural.ses.med4                   1.76      0.78     0.13     3.24
## prjharm_rural.ses.med2                    -0.63      0.82    -2.26     1.04
## prjharm_rural.ses.med3                     0.68      0.79    -0.81     2.26
## prjharm_rural.ses.med4                     0.95      0.77    -0.63     2.44
## prjusedrg_rural.ses.med2                  -0.37      0.84    -2.01     1.34
## prjusedrg_rural.ses.med3                  -0.06      0.83    -1.64     1.61
## prjusedrg_rural.ses.med4                   1.20      0.76    -0.31     2.70
## prjhack_rural.ses.med2                    -0.52      0.86    -2.19     1.17
## prjhack_rural.ses.med3                     0.01      0.76    -1.53     1.52
## prjhack_rural.ses.med4                     1.04      0.72    -0.37     2.46
## prjthflt5_mostmug_devx2                   -0.11      0.21    -0.51     0.29
## prjthflt5_mostmug_av12x2                  -0.03      0.09    -0.23     0.14
## prjthflt5_mostmug_devx2:rural.ses.med2    -0.64      0.53    -1.78     0.37
## prjthflt5_mostmug_devx2:rural.ses.med3     0.11      0.45    -0.75     1.04
## prjthflt5_mostmug_devx2:rural.ses.med4     0.48      0.41    -0.27     1.34
## prjthfgt5_mostmug_devx2                   -0.05      0.23    -0.50     0.39
## prjthfgt5_mostmug_av12x2                  -0.04      0.09    -0.21     0.14
## prjthfgt5_mostmug_devx2:rural.ses.med2    -0.72      0.52    -1.79     0.25
## prjthfgt5_mostmug_devx2:rural.ses.med3     0.16      0.43    -0.71     1.04
## prjthfgt5_mostmug_devx2:rural.ses.med4     0.51      0.36    -0.17     1.27
## prjthreat_mostmug_devx2                   -0.17      0.22    -0.62     0.26
## prjthreat_mostmug_av12x2                  -0.03      0.09    -0.22     0.16
## prjthreat_mostmug_devx2:rural.ses.med2    -0.43      0.58    -1.58     0.67
## prjthreat_mostmug_devx2:rural.ses.med3    -0.05      0.49    -1.06     0.94
## prjthreat_mostmug_devx2:rural.ses.med4    -0.08      0.45    -1.09     0.72
## prjharm_mostmug_devx2                     -0.08      0.23    -0.54     0.37
## prjharm_mostmug_av12x2                    -0.01      0.10    -0.21     0.19
## prjharm_mostmug_devx2:rural.ses.med2       0.17      0.51    -0.80     1.21
## prjharm_mostmug_devx2:rural.ses.med3      -0.32      0.49    -1.37     0.61
## prjharm_mostmug_devx2:rural.ses.med4       0.04      0.42    -0.88     0.80
## prjusedrg_mostmug_devx2                   -0.08      0.25    -0.58     0.40
## prjusedrg_mostmug_av12x2                  -0.01      0.09    -0.19     0.17
## prjusedrg_mostmug_devx2:rural.ses.med2    -0.23      0.53    -1.36     0.76
## prjusedrg_mostmug_devx2:rural.ses.med3    -0.40      0.53    -1.53     0.59
## prjusedrg_mostmug_devx2:rural.ses.med4     0.46      0.39    -0.33     1.17
## prjhack_mostmug_devx2                     -0.00      0.22    -0.46     0.42
## prjhack_mostmug_av12x2                     0.01      0.08    -0.15     0.17
## prjhack_mostmug_devx2:rural.ses.med2      -0.40      0.55    -1.50     0.64
## prjhack_mostmug_devx2:rural.ses.med3       0.06      0.46    -0.88     0.91
## prjhack_mostmug_devx2:rural.ses.med4      -0.12      0.40    -0.99     0.60
##                                        Rhat Bulk_ESS Tail_ESS
## prjthflt5_Intercept                    1.00     2539     3277
## prjthfgt5_Intercept                    1.00     3211     2746
## prjthreat_Intercept                    1.00     2898     3266
## prjharm_Intercept                      1.00     2431     2803
## prjusedrg_Intercept                    1.00     2667     3059
## prjhack_Intercept                      1.00     2443     2750
## prjthflt5_rural.ses.med2               1.00     7097     2978
## prjthflt5_rural.ses.med3               1.00     4479     2914
## prjthflt5_rural.ses.med4               1.00     5271     3327
## prjthfgt5_rural.ses.med2               1.00     5456     3261
## prjthfgt5_rural.ses.med3               1.00     5171     3001
## prjthfgt5_rural.ses.med4               1.00     5538     3443
## prjthreat_rural.ses.med2               1.00     5373     3023
## prjthreat_rural.ses.med3               1.00     5602     3494
## prjthreat_rural.ses.med4               1.00     5477     3300
## prjharm_rural.ses.med2                 1.00     6183     2838
## prjharm_rural.ses.med3                 1.00     5148     3106
## prjharm_rural.ses.med4                 1.00     5665     3036
## prjusedrg_rural.ses.med2               1.00     6701     3319
## prjusedrg_rural.ses.med3               1.00     6886     3069
## prjusedrg_rural.ses.med4               1.00     4548     2832
## prjhack_rural.ses.med2                 1.00     6311     3195
## prjhack_rural.ses.med3                 1.00     4771     2625
## prjhack_rural.ses.med4                 1.00     5978     3418
## prjthflt5_mostmug_devx2                1.00     5334     3415
## prjthflt5_mostmug_av12x2               1.00     4515     3219
## prjthflt5_mostmug_devx2:rural.ses.med2 1.00     3939     2621
## prjthflt5_mostmug_devx2:rural.ses.med3 1.00     3244     2770
## prjthflt5_mostmug_devx2:rural.ses.med4 1.00     3493     2926
## prjthfgt5_mostmug_devx2                1.00     4508     3350
## prjthfgt5_mostmug_av12x2               1.00     4010     3522
## prjthfgt5_mostmug_devx2:rural.ses.med2 1.00     4169     3329
## prjthfgt5_mostmug_devx2:rural.ses.med3 1.00     3087     2550
## prjthfgt5_mostmug_devx2:rural.ses.med4 1.00     3929     3233
## prjthreat_mostmug_devx2                1.00     4787     3230
## prjthreat_mostmug_av12x2               1.00     5407     3274
## prjthreat_mostmug_devx2:rural.ses.med2 1.00     4628     3097
## prjthreat_mostmug_devx2:rural.ses.med3 1.00     3828     2955
## prjthreat_mostmug_devx2:rural.ses.med4 1.00     3702     2880
## prjharm_mostmug_devx2                  1.00     4737     3089
## prjharm_mostmug_av12x2                 1.00     5645     2729
## prjharm_mostmug_devx2:rural.ses.med2   1.00     3651     3071
## prjharm_mostmug_devx2:rural.ses.med3   1.00     4340     2845
## prjharm_mostmug_devx2:rural.ses.med4   1.00     5111     3150
## prjusedrg_mostmug_devx2                1.00     3666     3453
## prjusedrg_mostmug_av12x2               1.00     5037     3276
## prjusedrg_mostmug_devx2:rural.ses.med2 1.00     4916     3254
## prjusedrg_mostmug_devx2:rural.ses.med3 1.00     4719     3320
## prjusedrg_mostmug_devx2:rural.ses.med4 1.00     3223     2668
## prjhack_mostmug_devx2                  1.00     5358     3380
## prjhack_mostmug_av12x2                 1.00     7504     2997
## prjhack_mostmug_devx2:rural.ses.med2   1.00     4812     3149
## prjhack_mostmug_devx2:rural.ses.med3   1.00     3935     2853
## prjhack_mostmug_devx2:rural.ses.med4   1.00     4628     3081
## 
## Monotonic Simplex Parameters:
##                                            Estimate Est.Error l-95% CI u-95% CI
## prjthflt5_mostmug_devx21[1]                    0.27      0.15     0.04     0.60
## prjthflt5_mostmug_devx21[2]                    0.26      0.14     0.04     0.58
## prjthflt5_mostmug_devx21[3]                    0.23      0.14     0.03     0.57
## prjthflt5_mostmug_devx21[4]                    0.25      0.15     0.03     0.59
## prjthflt5_mostmug_av12x21[1]                   0.12      0.08     0.02     0.31
## prjthflt5_mostmug_av12x21[2]                   0.12      0.08     0.02     0.31
## prjthflt5_mostmug_av12x21[3]                   0.12      0.08     0.02     0.31
## prjthflt5_mostmug_av12x21[4]                   0.13      0.08     0.02     0.32
## prjthflt5_mostmug_av12x21[5]                   0.13      0.08     0.02     0.33
## prjthflt5_mostmug_av12x21[6]                   0.13      0.08     0.02     0.33
## prjthflt5_mostmug_av12x21[7]                   0.13      0.08     0.02     0.33
## prjthflt5_mostmug_av12x21[8]                   0.13      0.08     0.02     0.33
## prjthflt5_mostmug_devx2:rural.ses.med21[1]     0.31      0.21     0.01     0.76
## prjthflt5_mostmug_devx2:rural.ses.med21[2]     0.23      0.18     0.01     0.66
## prjthflt5_mostmug_devx2:rural.ses.med21[3]     0.21      0.17     0.01     0.63
## prjthflt5_mostmug_devx2:rural.ses.med21[4]     0.26      0.19     0.01     0.70
## prjthflt5_mostmug_devx2:rural.ses.med31[1]     0.28      0.21     0.01     0.75
## prjthflt5_mostmug_devx2:rural.ses.med31[2]     0.21      0.18     0.01     0.66
## prjthflt5_mostmug_devx2:rural.ses.med31[3]     0.22      0.18     0.01     0.65
## prjthflt5_mostmug_devx2:rural.ses.med31[4]     0.30      0.22     0.01     0.77
## prjthflt5_mostmug_devx2:rural.ses.med41[1]     0.33      0.21     0.02     0.78
## prjthflt5_mostmug_devx2:rural.ses.med41[2]     0.23      0.18     0.01     0.66
## prjthflt5_mostmug_devx2:rural.ses.med41[3]     0.19      0.16     0.01     0.60
## prjthflt5_mostmug_devx2:rural.ses.med41[4]     0.25      0.19     0.01     0.69
## prjthfgt5_mostmug_devx21[1]                    0.26      0.15     0.04     0.61
## prjthfgt5_mostmug_devx21[2]                    0.25      0.15     0.03     0.58
## prjthfgt5_mostmug_devx21[3]                    0.24      0.15     0.03     0.60
## prjthfgt5_mostmug_devx21[4]                    0.25      0.14     0.03     0.58
## prjthfgt5_mostmug_av12x21[1]                   0.12      0.08     0.02     0.31
## prjthfgt5_mostmug_av12x21[2]                   0.12      0.08     0.02     0.31
## prjthfgt5_mostmug_av12x21[3]                   0.12      0.08     0.02     0.31
## prjthfgt5_mostmug_av12x21[4]                   0.13      0.08     0.02     0.33
## prjthfgt5_mostmug_av12x21[5]                   0.13      0.08     0.02     0.33
## prjthfgt5_mostmug_av12x21[6]                   0.13      0.08     0.02     0.33
## prjthfgt5_mostmug_av12x21[7]                   0.13      0.09     0.01     0.34
## prjthfgt5_mostmug_av12x21[8]                   0.13      0.08     0.02     0.33
## prjthfgt5_mostmug_devx2:rural.ses.med21[1]     0.31      0.21     0.01     0.76
## prjthfgt5_mostmug_devx2:rural.ses.med21[2]     0.25      0.19     0.01     0.70
## prjthfgt5_mostmug_devx2:rural.ses.med21[3]     0.19      0.16     0.00     0.59
## prjthfgt5_mostmug_devx2:rural.ses.med21[4]     0.25      0.19     0.01     0.70
## prjthfgt5_mostmug_devx2:rural.ses.med31[1]     0.28      0.21     0.01     0.75
## prjthfgt5_mostmug_devx2:rural.ses.med31[2]     0.20      0.18     0.01     0.65
## prjthfgt5_mostmug_devx2:rural.ses.med31[3]     0.23      0.19     0.01     0.69
## prjthfgt5_mostmug_devx2:rural.ses.med31[4]     0.29      0.21     0.01     0.76
## prjthfgt5_mostmug_devx2:rural.ses.med41[1]     0.29      0.20     0.01     0.72
## prjthfgt5_mostmug_devx2:rural.ses.med41[2]     0.25      0.19     0.01     0.68
## prjthfgt5_mostmug_devx2:rural.ses.med41[3]     0.22      0.17     0.01     0.66
## prjthfgt5_mostmug_devx2:rural.ses.med41[4]     0.24      0.19     0.01     0.67
## prjthreat_mostmug_devx21[1]                    0.28      0.16     0.04     0.61
## prjthreat_mostmug_devx21[2]                    0.26      0.14     0.04     0.58
## prjthreat_mostmug_devx21[3]                    0.22      0.13     0.03     0.53
## prjthreat_mostmug_devx21[4]                    0.25      0.14     0.04     0.57
## prjthreat_mostmug_av12x21[1]                   0.12      0.08     0.02     0.31
## prjthreat_mostmug_av12x21[2]                   0.12      0.08     0.02     0.31
## prjthreat_mostmug_av12x21[3]                   0.13      0.08     0.02     0.32
## prjthreat_mostmug_av12x21[4]                   0.12      0.08     0.02     0.31
## prjthreat_mostmug_av12x21[5]                   0.13      0.08     0.02     0.33
## prjthreat_mostmug_av12x21[6]                   0.13      0.08     0.02     0.32
## prjthreat_mostmug_av12x21[7]                   0.13      0.08     0.02     0.32
## prjthreat_mostmug_av12x21[8]                   0.13      0.08     0.02     0.33
## prjthreat_mostmug_devx2:rural.ses.med21[1]     0.29      0.21     0.01     0.76
## prjthreat_mostmug_devx2:rural.ses.med21[2]     0.22      0.18     0.01     0.67
## prjthreat_mostmug_devx2:rural.ses.med21[3]     0.21      0.18     0.00     0.66
## prjthreat_mostmug_devx2:rural.ses.med21[4]     0.28      0.21     0.01     0.74
## prjthreat_mostmug_devx2:rural.ses.med31[1]     0.24      0.19     0.01     0.68
## prjthreat_mostmug_devx2:rural.ses.med31[2]     0.23      0.18     0.01     0.68
## prjthreat_mostmug_devx2:rural.ses.med31[3]     0.23      0.18     0.01     0.68
## prjthreat_mostmug_devx2:rural.ses.med31[4]     0.30      0.21     0.01     0.77
## prjthreat_mostmug_devx2:rural.ses.med41[1]     0.24      0.20     0.01     0.71
## prjthreat_mostmug_devx2:rural.ses.med41[2]     0.22      0.18     0.01     0.68
## prjthreat_mostmug_devx2:rural.ses.med41[3]     0.24      0.19     0.01     0.68
## prjthreat_mostmug_devx2:rural.ses.med41[4]     0.30      0.22     0.01     0.77
## prjharm_mostmug_devx21[1]                      0.27      0.15     0.04     0.61
## prjharm_mostmug_devx21[2]                      0.25      0.14     0.04     0.57
## prjharm_mostmug_devx21[3]                      0.23      0.14     0.03     0.55
## prjharm_mostmug_devx21[4]                      0.25      0.14     0.04     0.59
## prjharm_mostmug_av12x21[1]                     0.12      0.08     0.02     0.32
## prjharm_mostmug_av12x21[2]                     0.12      0.08     0.02     0.32
## prjharm_mostmug_av12x21[3]                     0.12      0.08     0.02     0.32
## prjharm_mostmug_av12x21[4]                     0.12      0.08     0.02     0.31
## prjharm_mostmug_av12x21[5]                     0.13      0.08     0.02     0.32
## prjharm_mostmug_av12x21[6]                     0.13      0.08     0.02     0.32
## prjharm_mostmug_av12x21[7]                     0.13      0.08     0.02     0.34
## prjharm_mostmug_av12x21[8]                     0.13      0.08     0.01     0.32
## prjharm_mostmug_devx2:rural.ses.med21[1]       0.22      0.18     0.01     0.68
## prjharm_mostmug_devx2:rural.ses.med21[2]       0.21      0.18     0.01     0.65
## prjharm_mostmug_devx2:rural.ses.med21[3]       0.25      0.19     0.01     0.71
## prjharm_mostmug_devx2:rural.ses.med21[4]       0.31      0.22     0.01     0.79
## prjharm_mostmug_devx2:rural.ses.med31[1]       0.22      0.18     0.01     0.65
## prjharm_mostmug_devx2:rural.ses.med31[2]       0.24      0.18     0.01     0.68
## prjharm_mostmug_devx2:rural.ses.med31[3]       0.24      0.18     0.01     0.67
## prjharm_mostmug_devx2:rural.ses.med31[4]       0.29      0.20     0.02     0.73
## prjharm_mostmug_devx2:rural.ses.med41[1]       0.24      0.19     0.01     0.70
## prjharm_mostmug_devx2:rural.ses.med41[2]       0.23      0.19     0.01     0.69
## prjharm_mostmug_devx2:rural.ses.med41[3]       0.24      0.19     0.01     0.71
## prjharm_mostmug_devx2:rural.ses.med41[4]       0.28      0.21     0.01     0.76
## prjusedrg_mostmug_devx21[1]                    0.27      0.16     0.04     0.61
## prjusedrg_mostmug_devx21[2]                    0.24      0.14     0.03     0.57
## prjusedrg_mostmug_devx21[3]                    0.24      0.16     0.03     0.61
## prjusedrg_mostmug_devx21[4]                    0.25      0.15     0.03     0.58
## prjusedrg_mostmug_av12x21[1]                   0.12      0.08     0.02     0.32
## prjusedrg_mostmug_av12x21[2]                   0.12      0.08     0.02     0.32
## prjusedrg_mostmug_av12x21[3]                   0.12      0.08     0.02     0.32
## prjusedrg_mostmug_av12x21[4]                   0.12      0.08     0.02     0.31
## prjusedrg_mostmug_av12x21[5]                   0.13      0.08     0.02     0.32
## prjusedrg_mostmug_av12x21[6]                   0.13      0.08     0.02     0.32
## prjusedrg_mostmug_av12x21[7]                   0.13      0.08     0.02     0.32
## prjusedrg_mostmug_av12x21[8]                   0.13      0.08     0.02     0.32
## prjusedrg_mostmug_devx2:rural.ses.med21[1]     0.26      0.19     0.01     0.70
## prjusedrg_mostmug_devx2:rural.ses.med21[2]     0.22      0.18     0.01     0.66
## prjusedrg_mostmug_devx2:rural.ses.med21[3]     0.24      0.19     0.01     0.69
## prjusedrg_mostmug_devx2:rural.ses.med21[4]     0.29      0.21     0.01     0.76
## prjusedrg_mostmug_devx2:rural.ses.med31[1]     0.26      0.20     0.01     0.71
## prjusedrg_mostmug_devx2:rural.ses.med31[2]     0.23      0.18     0.01     0.66
## prjusedrg_mostmug_devx2:rural.ses.med31[3]     0.24      0.18     0.01     0.67
## prjusedrg_mostmug_devx2:rural.ses.med31[4]     0.28      0.21     0.01     0.73
## prjusedrg_mostmug_devx2:rural.ses.med41[1]     0.24      0.18     0.01     0.67
## prjusedrg_mostmug_devx2:rural.ses.med41[2]     0.17      0.16     0.00     0.61
## prjusedrg_mostmug_devx2:rural.ses.med41[3]     0.38      0.22     0.02     0.81
## prjusedrg_mostmug_devx2:rural.ses.med41[4]     0.21      0.18     0.01     0.67
## prjhack_mostmug_devx21[1]                      0.26      0.15     0.04     0.59
## prjhack_mostmug_devx21[2]                      0.24      0.14     0.04     0.56
## prjhack_mostmug_devx21[3]                      0.25      0.15     0.04     0.59
## prjhack_mostmug_devx21[4]                      0.25      0.14     0.04     0.57
## prjhack_mostmug_av12x21[1]                     0.12      0.08     0.02     0.32
## prjhack_mostmug_av12x21[2]                     0.12      0.08     0.02     0.32
## prjhack_mostmug_av12x21[3]                     0.12      0.08     0.02     0.31
## prjhack_mostmug_av12x21[4]                     0.13      0.08     0.02     0.32
## prjhack_mostmug_av12x21[5]                     0.12      0.08     0.02     0.31
## prjhack_mostmug_av12x21[6]                     0.13      0.08     0.02     0.32
## prjhack_mostmug_av12x21[7]                     0.13      0.08     0.02     0.32
## prjhack_mostmug_av12x21[8]                     0.13      0.08     0.02     0.32
## prjhack_mostmug_devx2:rural.ses.med21[1]       0.28      0.20     0.01     0.72
## prjhack_mostmug_devx2:rural.ses.med21[2]       0.24      0.19     0.01     0.68
## prjhack_mostmug_devx2:rural.ses.med21[3]       0.21      0.18     0.01     0.66
## prjhack_mostmug_devx2:rural.ses.med21[4]       0.27      0.20     0.01     0.71
## prjhack_mostmug_devx2:rural.ses.med31[1]       0.23      0.19     0.01     0.69
## prjhack_mostmug_devx2:rural.ses.med31[2]       0.23      0.19     0.01     0.68
## prjhack_mostmug_devx2:rural.ses.med31[3]       0.24      0.19     0.01     0.69
## prjhack_mostmug_devx2:rural.ses.med31[4]       0.30      0.22     0.01     0.77
## prjhack_mostmug_devx2:rural.ses.med41[1]       0.24      0.19     0.01     0.69
## prjhack_mostmug_devx2:rural.ses.med41[2]       0.23      0.18     0.01     0.66
## prjhack_mostmug_devx2:rural.ses.med41[3]       0.24      0.19     0.01     0.67
## prjhack_mostmug_devx2:rural.ses.med41[4]       0.30      0.21     0.01     0.78
##                                            Rhat Bulk_ESS Tail_ESS
## prjthflt5_mostmug_devx21[1]                1.00     8031     2284
## prjthflt5_mostmug_devx21[2]                1.00     6573     2778
## prjthflt5_mostmug_devx21[3]                1.00     6545     2862
## prjthflt5_mostmug_devx21[4]                1.00     7110     2711
## prjthflt5_mostmug_av12x21[1]               1.00     5692     2680
## prjthflt5_mostmug_av12x21[2]               1.00     8280     2743
## prjthflt5_mostmug_av12x21[3]               1.00     7280     2614
## prjthflt5_mostmug_av12x21[4]               1.00     9993     2960
## prjthflt5_mostmug_av12x21[5]               1.00     6827     2392
## prjthflt5_mostmug_av12x21[6]               1.00     7895     2713
## prjthflt5_mostmug_av12x21[7]               1.00     7285     2647
## prjthflt5_mostmug_av12x21[8]               1.00     8855     2850
## prjthflt5_mostmug_devx2:rural.ses.med21[1] 1.00     5210     2462
## prjthflt5_mostmug_devx2:rural.ses.med21[2] 1.00     5881     2660
## prjthflt5_mostmug_devx2:rural.ses.med21[3] 1.00     5507     2618
## prjthflt5_mostmug_devx2:rural.ses.med21[4] 1.00     5168     2633
## prjthflt5_mostmug_devx2:rural.ses.med31[1] 1.00     4283     2620
## prjthflt5_mostmug_devx2:rural.ses.med31[2] 1.00     5302     2781
## prjthflt5_mostmug_devx2:rural.ses.med31[3] 1.00     5815     3061
## prjthflt5_mostmug_devx2:rural.ses.med31[4] 1.00     5779     2507
## prjthflt5_mostmug_devx2:rural.ses.med41[1] 1.00     4910     2775
## prjthflt5_mostmug_devx2:rural.ses.med41[2] 1.00     5728     2542
## prjthflt5_mostmug_devx2:rural.ses.med41[3] 1.00     4958     2419
## prjthflt5_mostmug_devx2:rural.ses.med41[4] 1.00     5582     2981
## prjthfgt5_mostmug_devx21[1]                1.00     8221     2824
## prjthfgt5_mostmug_devx21[2]                1.00     5935     3008
## prjthfgt5_mostmug_devx21[3]                1.00     5563     3135
## prjthfgt5_mostmug_devx21[4]                1.00     6977     2911
## prjthfgt5_mostmug_av12x21[1]               1.00     6404     2535
## prjthfgt5_mostmug_av12x21[2]               1.00     6310     2450
## prjthfgt5_mostmug_av12x21[3]               1.00     7374     2792
## prjthfgt5_mostmug_av12x21[4]               1.00     6929     2432
## prjthfgt5_mostmug_av12x21[5]               1.00     6858     2286
## prjthfgt5_mostmug_av12x21[6]               1.00     7205     2769
## prjthfgt5_mostmug_av12x21[7]               1.00     9768     2379
## prjthfgt5_mostmug_av12x21[8]               1.00     6018     2681
## prjthfgt5_mostmug_devx2:rural.ses.med21[1] 1.00     6000     2789
## prjthfgt5_mostmug_devx2:rural.ses.med21[2] 1.00     5938     2432
## prjthfgt5_mostmug_devx2:rural.ses.med21[3] 1.00     5810     2795
## prjthfgt5_mostmug_devx2:rural.ses.med21[4] 1.00     6207     2855
## prjthfgt5_mostmug_devx2:rural.ses.med31[1] 1.00     5774     2986
## prjthfgt5_mostmug_devx2:rural.ses.med31[2] 1.00     6035     2659
## prjthfgt5_mostmug_devx2:rural.ses.med31[3] 1.00     4772     3032
## prjthfgt5_mostmug_devx2:rural.ses.med31[4] 1.00     5466     3302
## prjthfgt5_mostmug_devx2:rural.ses.med41[1] 1.00     5946     2878
## prjthfgt5_mostmug_devx2:rural.ses.med41[2] 1.00     6035     3026
## prjthfgt5_mostmug_devx2:rural.ses.med41[3] 1.00     5259     2755
## prjthfgt5_mostmug_devx2:rural.ses.med41[4] 1.00     5815     2475
## prjthreat_mostmug_devx21[1]                1.00     7022     2923
## prjthreat_mostmug_devx21[2]                1.00     7772     2959
## prjthreat_mostmug_devx21[3]                1.00     6373     3275
## prjthreat_mostmug_devx21[4]                1.00     9105     2980
## prjthreat_mostmug_av12x21[1]               1.00     8181     2571
## prjthreat_mostmug_av12x21[2]               1.00     6996     2467
## prjthreat_mostmug_av12x21[3]               1.00     8249     2506
## prjthreat_mostmug_av12x21[4]               1.00     6863     2403
## prjthreat_mostmug_av12x21[5]               1.00     8816     2636
## prjthreat_mostmug_av12x21[6]               1.00     7383     2480
## prjthreat_mostmug_av12x21[7]               1.00     7315     2482
## prjthreat_mostmug_av12x21[8]               1.00     6595     2559
## prjthreat_mostmug_devx2:rural.ses.med21[1] 1.00     5948     2454
## prjthreat_mostmug_devx2:rural.ses.med21[2] 1.00     5805     2807
## prjthreat_mostmug_devx2:rural.ses.med21[3] 1.00     5640     2574
## prjthreat_mostmug_devx2:rural.ses.med21[4] 1.00     5639     2542
## prjthreat_mostmug_devx2:rural.ses.med31[1] 1.00     6587     2343
## prjthreat_mostmug_devx2:rural.ses.med31[2] 1.00     6724     2730
## prjthreat_mostmug_devx2:rural.ses.med31[3] 1.00     5665     2172
## prjthreat_mostmug_devx2:rural.ses.med31[4] 1.00     5607     2804
## prjthreat_mostmug_devx2:rural.ses.med41[1] 1.00     5618     2498
## prjthreat_mostmug_devx2:rural.ses.med41[2] 1.00     6511     2666
## prjthreat_mostmug_devx2:rural.ses.med41[3] 1.00     5393     2610
## prjthreat_mostmug_devx2:rural.ses.med41[4] 1.00     5642     2812
## prjharm_mostmug_devx21[1]                  1.00     7339     2911
## prjharm_mostmug_devx21[2]                  1.00     8401     2926
## prjharm_mostmug_devx21[3]                  1.00     4581     2946
## prjharm_mostmug_devx21[4]                  1.00     8157     3024
## prjharm_mostmug_av12x21[1]                 1.00     6356     2147
## prjharm_mostmug_av12x21[2]                 1.00     8491     2297
## prjharm_mostmug_av12x21[3]                 1.00     7313     2770
## prjharm_mostmug_av12x21[4]                 1.00     7160     2546
## prjharm_mostmug_av12x21[5]                 1.00     6993     2730
## prjharm_mostmug_av12x21[6]                 1.00     7647     2066
## prjharm_mostmug_av12x21[7]                 1.00     7694     2805
## prjharm_mostmug_av12x21[8]                 1.00     7661     2574
## prjharm_mostmug_devx2:rural.ses.med21[1]   1.00     5662     2840
## prjharm_mostmug_devx2:rural.ses.med21[2]   1.00     5350     2989
## prjharm_mostmug_devx2:rural.ses.med21[3]   1.00     5892     2473
## prjharm_mostmug_devx2:rural.ses.med21[4]   1.00     5482     3317
## prjharm_mostmug_devx2:rural.ses.med31[1]   1.00     6906     2825
## prjharm_mostmug_devx2:rural.ses.med31[2]   1.00     5568     2662
## prjharm_mostmug_devx2:rural.ses.med31[3]   1.00     5571     2522
## prjharm_mostmug_devx2:rural.ses.med31[4]   1.00     5737     3239
## prjharm_mostmug_devx2:rural.ses.med41[1]   1.00     6880     2478
## prjharm_mostmug_devx2:rural.ses.med41[2]   1.00     6054     2589
## prjharm_mostmug_devx2:rural.ses.med41[3]   1.00     6702     2560
## prjharm_mostmug_devx2:rural.ses.med41[4]   1.00     5330     3100
## prjusedrg_mostmug_devx21[1]                1.00     7049     3081
## prjusedrg_mostmug_devx21[2]                1.00     7461     2678
## prjusedrg_mostmug_devx21[3]                1.00     4667     3640
## prjusedrg_mostmug_devx21[4]                1.00     7494     2551
## prjusedrg_mostmug_av12x21[1]               1.00     7900     2115
## prjusedrg_mostmug_av12x21[2]               1.00     7274     2474
## prjusedrg_mostmug_av12x21[3]               1.00     6768     2245
## prjusedrg_mostmug_av12x21[4]               1.00     6384     2204
## prjusedrg_mostmug_av12x21[5]               1.00     8128     2452
## prjusedrg_mostmug_av12x21[6]               1.00     7306     2437
## prjusedrg_mostmug_av12x21[7]               1.00     6804     2943
## prjusedrg_mostmug_av12x21[8]               1.00     6599     2285
## prjusedrg_mostmug_devx2:rural.ses.med21[1] 1.00     7258     2935
## prjusedrg_mostmug_devx2:rural.ses.med21[2] 1.00     6158     2509
## prjusedrg_mostmug_devx2:rural.ses.med21[3] 1.00     7100     2542
## prjusedrg_mostmug_devx2:rural.ses.med21[4] 1.00     5194     2535
## prjusedrg_mostmug_devx2:rural.ses.med31[1] 1.00     7164     2990
## prjusedrg_mostmug_devx2:rural.ses.med31[2] 1.00     6471     2640
## prjusedrg_mostmug_devx2:rural.ses.med31[3] 1.00     6039     2656
## prjusedrg_mostmug_devx2:rural.ses.med31[4] 1.00     6666     2632
## prjusedrg_mostmug_devx2:rural.ses.med41[1] 1.00     6059     2495
## prjusedrg_mostmug_devx2:rural.ses.med41[2] 1.00     5714     2704
## prjusedrg_mostmug_devx2:rural.ses.med41[3] 1.00     3768     3050
## prjusedrg_mostmug_devx2:rural.ses.med41[4] 1.00     4853     2519
## prjhack_mostmug_devx21[1]                  1.00     7506     2969
## prjhack_mostmug_devx21[2]                  1.00     9142     2935
## prjhack_mostmug_devx21[3]                  1.00     8376     2677
## prjhack_mostmug_devx21[4]                  1.00     7240     2615
## prjhack_mostmug_av12x21[1]                 1.00     6601     2395
## prjhack_mostmug_av12x21[2]                 1.00     6174     2284
## prjhack_mostmug_av12x21[3]                 1.00     8560     2569
## prjhack_mostmug_av12x21[4]                 1.00     6944     2547
## prjhack_mostmug_av12x21[5]                 1.00     8402     2731
## prjhack_mostmug_av12x21[6]                 1.00     7109     2670
## prjhack_mostmug_av12x21[7]                 1.00     7032     2771
## prjhack_mostmug_av12x21[8]                 1.00     7120     2824
## prjhack_mostmug_devx2:rural.ses.med21[1]   1.00     6510     2822
## prjhack_mostmug_devx2:rural.ses.med21[2]   1.00     6902     2784
## prjhack_mostmug_devx2:rural.ses.med21[3]   1.00     5390     2904
## prjhack_mostmug_devx2:rural.ses.med21[4]   1.00     5803     2759
## prjhack_mostmug_devx2:rural.ses.med31[1]   1.00     7159     2428
## prjhack_mostmug_devx2:rural.ses.med31[2]   1.00     5534     2300
## prjhack_mostmug_devx2:rural.ses.med31[3]   1.00     5422     2944
## prjhack_mostmug_devx2:rural.ses.med31[4]   1.00     6351     2697
## prjhack_mostmug_devx2:rural.ses.med41[1]   1.00     5596     2678
## prjhack_mostmug_devx2:rural.ses.med41[2]   1.00     7852     2668
## prjhack_mostmug_devx2:rural.ses.med41[3]   1.00     6035     3048
## prjhack_mostmug_devx2:rural.ses.med41[4]   1.00     5603     2626
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.1.7.4 Prior summary
out.chg.prjcrime.stmug.comm.fit[[2]]
##                              prior     class                          coef
##                             (flat)         b                              
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                             (flat) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##          prjhack                          user
##          prjhack                          user
##          prjhack                          user
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjhack                  (vectorized)
##          prjharm                          user
##          prjharm                          user
##          prjharm                          user
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##          prjharm                  (vectorized)
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                          user
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthfgt5                  (vectorized)
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                          user
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthflt5                  (vectorized)
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                          user
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjthreat                  (vectorized)
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                          user
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##        prjusedrg                  (vectorized)
##                                        default
##          prjhack                          user
##          prjharm                          user
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthreat                          user
##        prjusedrg                          user
##          prjhack             0         default
##          prjharm             0         default
##        prjthfgt5             0         default
##        prjthflt5             0         default
##        prjthreat             0         default
##        prjusedrg             0         default
##     id   prjhack             0    (vectorized)
##     id   prjhack             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id   prjharm             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthfgt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthflt5             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjthreat             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##     id prjusedrg             0    (vectorized)
##          prjhack                          user
##          prjhack                       default
##          prjhack                       default
##          prjhack                       default
##          prjhack                          user
##          prjharm                          user
##          prjharm                       default
##          prjharm                       default
##          prjharm                       default
##          prjharm                          user
##        prjthfgt5                          user
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                       default
##        prjthfgt5                          user
##        prjthflt5                          user
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                       default
##        prjthflt5                          user
##        prjthreat                          user
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                       default
##        prjthreat                          user
##        prjusedrg                          user
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                       default
##        prjusedrg                          user

8.1.1.8 Corr X Community: stress & “any” crim intent

#Community Change: any criminal intent ~ mo(stress)

#Create function for repetitive prior settings
setmyprior <- function(mochgcoefname, moavcoefname, 
                       simochgcoefname, simoavcoefname) {
  c(
  set_prior('normal(0, 2)', class = 'Intercept'),
  set_prior('normal(0, 1)', class = 'b'),
  set_prior('normal(0, 0.25)', class = 'b', coef = mochgcoefname), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = moavcoefname), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = simochgcoefname),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = simoavcoefname))
  }

#Update function to call all ppchecks for bivar any crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit)
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95)
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95)  
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, plotcoefs, plotcoefs2)
  return(allchecks)
}

myprior <- setmyprior('mostmony_devx2', 'mostmony_av12x2', 
                      'mostmony_devx21', 'mostmony_av12x21')
chg.anyprjcrime.stmony.comm.fit <- brm(
  prjany ~ 1 +
    mo(stmony_devx2) + mo(stmony_av12x2) + 
    rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id),
  data = stress.long, family = "bernoulli", prior = myprior,
  cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
  file = "Models/chg_anyprjcrime_stmony_comm_fit", file_refit = "on_change"
  )
out.chg.anyprjcrime.stmony.comm.fit <- ppchecks(chg.anyprjcrime.stmony.comm.fit)

myprior <- setmyprior('mosttran_devx2', 'mosttran_av12x2', 
                      'mosttran_devx21', 'mosttran_av12x21')
chg.anyprjcrime.sttran.comm.fit <- brm(
  prjany ~ 1 +
    mo(sttran_devx2) + mo(sttran_av12x2) + 
    rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id),
  data = stress.long, family = "bernoulli", prior = myprior,
  cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
  file = "Models/chg_anyprjcrime_sttran_comm_fit", file_refit = "on_change"
  )
out.chg.anyprjcrime.sttran.comm.fit <- ppchecks(chg.anyprjcrime.sttran.comm.fit)

myprior <- setmyprior('mostresp_devx2', 'mostresp_av12x2', 
                      'mostresp_devx21', 'mostresp_av12x21')
chg.anyprjcrime.stresp.comm.fit <- brm(
  prjany ~ 1 +
    mo(stresp_devx2) + mo(stresp_av12x2) + 
    rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id),
  data = stress.long, family = "bernoulli", prior = myprior,
  cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
  file = "Models/chg_anyprjcrime_stresp_comm_fit", file_refit = "on_change"
  )
out.chg.anyprjcrime.stresp.comm.fit <- ppchecks(chg.anyprjcrime.stresp.comm.fit)

myprior <- setmyprior('mostfair_devx2', 'mostfair_av12x2', 
                      'mostfair_devx21', 'mostfair_av12x21')
chg.anyprjcrime.stfair.comm.fit <- brm(
  prjany ~ 1 +
    mo(stfair_devx2) + mo(stfair_av12x2) + 
    rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id),
  data = stress.long, family = "bernoulli", prior = myprior,
  cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
  file = "Models/chg_anyprjcrime_stfair_comm_fit", file_refit = "on_change"
  )
out.chg.anyprjcrime.stfair.comm.fit <- ppchecks(chg.anyprjcrime.stfair.comm.fit)

myprior <- setmyprior('mostjob_devx2', 'mostjob_av12x2', 
                      'mostjob_devx21', 'mostjob_av12x21')
chg.anyprjcrime.stjob.comm.fit <- brm(
  prjany ~ 1 +
    mo(stjob_devx2) + mo(stjob_av12x2) + 
    rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id),
  data = stress.long, family = "bernoulli", prior = myprior,
  cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
  file = "Models/chg_anyprjcrime_stjob_comm_fit", file_refit = "on_change"
  )
out.chg.anyprjcrime.stjob.comm.fit <- ppchecks(chg.anyprjcrime.stjob.comm.fit)

myprior <- setmyprior('mostthft_devx2', 'mostthft_av12x2', 
                      'mostthft_devx21', 'mostthft_av12x21')
chg.anyprjcrime.stthft.comm.fit <- brm(
  prjany ~ 1 +
    mo(stthft_devx2) + mo(stthft_av12x2) + 
    rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id),
  data = stress.long, family = "bernoulli", prior = myprior,
  cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
  file = "Models/chg_anyprjcrime_stthft_comm_fit", file_refit = "on_change"
  )
out.chg.anyprjcrime.stthft.comm.fit <- ppchecks(chg.anyprjcrime.stthft.comm.fit)

myprior <- setmyprior('mostmug_devx2', 'mostmug_av12x2', 
                      'mostmug_devx21', 'mostmug_av12x21')
chg.anyprjcrime.stmug.comm.fit <- brm(
  prjany ~ 1 +
    mo(stmug_devx2) + mo(stmug_av12x2) + 
    rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id),
  data = stress.long, family = "bernoulli", prior = myprior,
  cores = nCoresphys, chains = 4, backend = "cmdstanr", seed = 8675309, 
  file = "Models/chg_anyprjcrime_stmug_comm_fit", file_refit = "on_change"
  )
out.chg.anyprjcrime.stmug.comm.fit<- ppchecks(chg.anyprjcrime.stmug.comm.fit)
8.1.1.8.1 Coefficient plot (intervals)
p1 <- out.chg.anyprjcrime.stmony.comm.fit[[5]]
p2 <- out.chg.anyprjcrime.sttran.comm.fit[[5]]
p3 <- out.chg.anyprjcrime.stresp.comm.fit[[5]]
p4 <- out.chg.anyprjcrime.stfair.comm.fit[[5]]
p5 <- out.chg.anyprjcrime.stjob.comm.fit[[5]]
p6 <- out.chg.anyprjcrime.stthft.comm.fit[[5]]
p7 <- out.chg.anyprjcrime.stmug.comm.fit[[5]]

playout <- '
AB
CD
E#
FG
'
p1 + p2 + p3 + p4 + p5 + p6 + p7 +
  plot_layout(design = playout) +
  plot_annotation(
  title = 'Coefficient plot',
  subtitle = 'Posterior intervals for monotonic ordinal within-person ("devx2") and between-person ("av12x2") stress\ncoefficients predicting "any criminal intent" with medians, 80% (thick line), and 95% (thin line) intervals')

8.1.1.8.2 PPcheck (density)
p1 <- out.chg.anyprjcrime.stmony.comm.fit[[3]] + labs(title = "Any crime intent/stmony (chg)") 
p2 <- out.chg.anyprjcrime.sttran.comm.fit[[3]] + labs(title = "Any crime intent/sttran (chg)")
p3 <- out.chg.anyprjcrime.stresp.comm.fit[[3]] + labs(title = "Any crime intent/stresp (chg)")
p4 <- out.chg.anyprjcrime.stfair.comm.fit[[3]] + labs(title = "Any crime intent/stfair (chg)")
p5 <- out.chg.anyprjcrime.stjob.comm.fit[[3]] + labs(title = "Any crime intent/stjob (chg)")
p6 <- out.chg.anyprjcrime.stthft.comm.fit[[3]] + labs(title = "Any crime intent/stthft (chg)")
p7 <- out.chg.anyprjcrime.stmug.comm.fit[[3]] + labs(title = "Any crime intent/stmug (chg)")

(p1 + p2) / (p3 + p4) / (p5 + plot_spacer()) / (p6 + p7)

8.1.1.9 Fit + prior summaries (Chg Any past crime/all stress)

8.1.1.9.1 stmony
out.chg.anyprjcrime.stmony.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.16      0.43     2.41     4.09 1.00     1316     1982
## 
## Regression Coefficients:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept                        -4.31      0.71    -5.82    -2.97 1.00
## rural.ses.med2                   -0.32      0.79    -1.84     1.25 1.00
## rural.ses.med3                    0.59      0.78    -0.96     2.07 1.00
## rural.ses.med4                    1.43      0.95    -0.61     3.10 1.00
## mostmony_devx2                    0.14      0.18    -0.24     0.49 1.00
## mostmony_av12x2                  -0.06      0.08    -0.22     0.09 1.00
## mostmony_devx2:rural.ses.med2    -0.41      0.44    -1.35     0.41 1.00
## mostmony_devx2:rural.ses.med3     0.39      0.36    -0.33     1.14 1.00
## mostmony_devx2:rural.ses.med4     0.54      0.44    -0.28     1.45 1.00
##                               Bulk_ESS Tail_ESS
## Intercept                         1938     2719
## rural.ses.med2                    2354     2144
## rural.ses.med3                    2022     2674
## rural.ses.med4                    1745     2397
## mostmony_devx2                    2488     2165
## mostmony_av12x2                   1903     2714
## mostmony_devx2:rural.ses.med2     1879     1993
## mostmony_devx2:rural.ses.med3     1577     2016
## mostmony_devx2:rural.ses.med4     1043     1850
## 
## Monotonic Simplex Parameters:
##                                   Estimate Est.Error l-95% CI u-95% CI Rhat
## mostmony_devx21[1]                    0.25      0.14     0.04     0.58 1.00
## mostmony_devx21[2]                    0.25      0.14     0.04     0.56 1.00
## mostmony_devx21[3]                    0.26      0.15     0.04     0.59 1.00
## mostmony_devx21[4]                    0.25      0.14     0.04     0.57 1.00
## mostmony_av12x21[1]                   0.12      0.08     0.02     0.32 1.00
## mostmony_av12x21[2]                   0.13      0.09     0.02     0.34 1.00
## mostmony_av12x21[3]                   0.13      0.08     0.02     0.33 1.00
## mostmony_av12x21[4]                   0.13      0.08     0.02     0.34 1.00
## mostmony_av12x21[5]                   0.12      0.08     0.02     0.32 1.00
## mostmony_av12x21[6]                   0.12      0.08     0.01     0.31 1.00
## mostmony_av12x21[7]                   0.12      0.08     0.02     0.31 1.00
## mostmony_av12x21[8]                   0.12      0.08     0.02     0.32 1.00
## mostmony_devx2:rural.ses.med21[1]     0.27      0.20     0.01     0.71 1.00
## mostmony_devx2:rural.ses.med21[2]     0.21      0.18     0.01     0.66 1.00
## mostmony_devx2:rural.ses.med21[3]     0.24      0.18     0.01     0.69 1.00
## mostmony_devx2:rural.ses.med21[4]     0.28      0.21     0.01     0.75 1.00
## mostmony_devx2:rural.ses.med31[1]     0.26      0.20     0.01     0.73 1.00
## mostmony_devx2:rural.ses.med31[2]     0.31      0.20     0.01     0.75 1.00
## mostmony_devx2:rural.ses.med31[3]     0.17      0.16     0.00     0.59 1.00
## mostmony_devx2:rural.ses.med31[4]     0.26      0.20     0.01     0.71 1.00
## mostmony_devx2:rural.ses.med41[1]     0.43      0.23     0.02     0.85 1.00
## mostmony_devx2:rural.ses.med41[2]     0.17      0.15     0.00     0.57 1.00
## mostmony_devx2:rural.ses.med41[3]     0.16      0.15     0.01     0.56 1.00
## mostmony_devx2:rural.ses.med41[4]     0.24      0.19     0.01     0.68 1.00
##                                   Bulk_ESS Tail_ESS
## mostmony_devx21[1]                    4586     2795
## mostmony_devx21[2]                    5091     2675
## mostmony_devx21[3]                    4602     2946
## mostmony_devx21[4]                    4852     2686
## mostmony_av12x21[1]                   4901     2342
## mostmony_av12x21[2]                   4234     2320
## mostmony_av12x21[3]                   5143     2634
## mostmony_av12x21[4]                   4326     2398
## mostmony_av12x21[5]                   5155     2498
## mostmony_av12x21[6]                   4619     2763
## mostmony_av12x21[7]                   4678     3010
## mostmony_av12x21[8]                   4750     3191
## mostmony_devx2:rural.ses.med21[1]     3452     1894
## mostmony_devx2:rural.ses.med21[2]     3731     1946
## mostmony_devx2:rural.ses.med21[3]     4455     2275
## mostmony_devx2:rural.ses.med21[4]     4023     2641
## mostmony_devx2:rural.ses.med31[1]     3535     2207
## mostmony_devx2:rural.ses.med31[2]     2811     2391
## mostmony_devx2:rural.ses.med31[3]     2724     3055
## mostmony_devx2:rural.ses.med31[4]     3289     2424
## mostmony_devx2:rural.ses.med41[1]     1802     1968
## mostmony_devx2:rural.ses.med41[2]     2464     2107
## mostmony_devx2:rural.ses.med41[3]     2879     2668
## mostmony_devx2:rural.ses.med41[4]     3495     2978
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stmony.comm.fit[[2]]
##                              prior     class                           coef
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  group resp dpar nlpar lb ub       source
##                                      user
##                                      user
##                                      user
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                                      user
##                         0         default
##     id                  0    (vectorized)
##     id                  0    (vectorized)
##                                      user
##                                   default
##                                   default
##                                   default
##                                      user
8.1.1.9.2 sttran
out.chg.anyprjcrime.sttran.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.12      0.42     2.38     4.04 1.00     1102     2204
## 
## Regression Coefficients:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept                        -3.57      0.70    -4.95    -2.20 1.00
## rural.ses.med2                   -0.07      0.83    -1.65     1.66 1.00
## rural.ses.med3                    0.84      0.74    -0.75     2.17 1.00
## rural.ses.med4                    1.42      0.92    -0.47     3.04 1.00
## mosttran_devx2                   -0.03      0.17    -0.38     0.31 1.00
## mosttran_av12x2                  -0.13      0.08    -0.29     0.03 1.00
## mosttran_devx2:rural.ses.med2    -0.65      0.46    -1.63     0.19 1.00
## mosttran_devx2:rural.ses.med3     0.26      0.36    -0.42     1.05 1.00
## mosttran_devx2:rural.ses.med4     0.61      0.42    -0.12     1.49 1.00
##                               Bulk_ESS Tail_ESS
## Intercept                         1935     2587
## rural.ses.med2                    3204     2750
## rural.ses.med3                    2111     2513
## rural.ses.med4                    2353     3105
## mosttran_devx2                    2049     2462
## mosttran_av12x2                   2282     2980
## mosttran_devx2:rural.ses.med2     2426     2248
## mosttran_devx2:rural.ses.med3     1766     2032
## mosttran_devx2:rural.ses.med4     1514     2415
## 
## Monotonic Simplex Parameters:
##                                   Estimate Est.Error l-95% CI u-95% CI Rhat
## mosttran_devx21[1]                    0.27      0.15     0.04     0.61 1.00
## mosttran_devx21[2]                    0.24      0.14     0.04     0.57 1.00
## mosttran_devx21[3]                    0.24      0.14     0.03     0.56 1.00
## mosttran_devx21[4]                    0.26      0.15     0.04     0.59 1.00
## mosttran_av12x21[1]                   0.12      0.08     0.02     0.31 1.00
## mosttran_av12x21[2]                   0.13      0.08     0.02     0.32 1.00
## mosttran_av12x21[3]                   0.14      0.08     0.02     0.34 1.00
## mosttran_av12x21[4]                   0.16      0.09     0.02     0.37 1.00
## mosttran_av12x21[5]                   0.13      0.08     0.02     0.32 1.00
## mosttran_av12x21[6]                   0.11      0.07     0.01     0.28 1.00
## mosttran_av12x21[7]                   0.11      0.07     0.01     0.29 1.00
## mosttran_av12x21[8]                   0.11      0.07     0.01     0.30 1.00
## mosttran_devx2:rural.ses.med21[1]     0.30      0.20     0.01     0.74 1.00
## mosttran_devx2:rural.ses.med21[2]     0.17      0.15     0.00     0.55 1.00
## mosttran_devx2:rural.ses.med21[3]     0.26      0.19     0.01     0.70 1.00
## mosttran_devx2:rural.ses.med21[4]     0.27      0.20     0.01     0.71 1.00
## mosttran_devx2:rural.ses.med31[1]     0.29      0.20     0.01     0.73 1.00
## mosttran_devx2:rural.ses.med31[2]     0.24      0.18     0.01     0.68 1.00
## mosttran_devx2:rural.ses.med31[3]     0.19      0.17     0.00     0.63 1.00
## mosttran_devx2:rural.ses.med31[4]     0.28      0.21     0.01     0.75 1.00
## mosttran_devx2:rural.ses.med41[1]     0.42      0.23     0.02     0.84 1.00
## mosttran_devx2:rural.ses.med41[2]     0.14      0.14     0.00     0.52 1.00
## mosttran_devx2:rural.ses.med41[3]     0.15      0.14     0.00     0.52 1.00
## mosttran_devx2:rural.ses.med41[4]     0.28      0.20     0.01     0.73 1.00
##                                   Bulk_ESS Tail_ESS
## mosttran_devx21[1]                    4556     2565
## mosttran_devx21[2]                    3970     2961
## mosttran_devx21[3]                    5047     2717
## mosttran_devx21[4]                    4540     2794
## mosttran_av12x21[1]                   4104     2219
## mosttran_av12x21[2]                   4543     2341
## mosttran_av12x21[3]                   3998     3027
## mosttran_av12x21[4]                   4063     2388
## mosttran_av12x21[5]                   4576     2663
## mosttran_av12x21[6]                   4210     2406
## mosttran_av12x21[7]                   4211     2674
## mosttran_av12x21[8]                   4489     2820
## mosttran_devx2:rural.ses.med21[1]     3730     2129
## mosttran_devx2:rural.ses.med21[2]     3348     2523
## mosttran_devx2:rural.ses.med21[3]     4323     2159
## mosttran_devx2:rural.ses.med21[4]     3206     1999
## mosttran_devx2:rural.ses.med31[1]     3420     1912
## mosttran_devx2:rural.ses.med31[2]     3830     2626
## mosttran_devx2:rural.ses.med31[3]     3358     2374
## mosttran_devx2:rural.ses.med31[4]     3397     2422
## mosttran_devx2:rural.ses.med41[1]     2357     2072
## mosttran_devx2:rural.ses.med41[2]     2690     2246
## mosttran_devx2:rural.ses.med41[3]     3201     2210
## mosttran_devx2:rural.ses.med41[4]     2977     2383
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.sttran.comm.fit[[2]]
##                              prior     class                           coef
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  group resp dpar nlpar lb ub       source
##                                      user
##                                      user
##                                      user
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                                      user
##                         0         default
##     id                  0    (vectorized)
##     id                  0    (vectorized)
##                                      user
##                                   default
##                                   default
##                                   default
##                                      user
8.1.1.9.3 stresp
out.chg.anyprjcrime.stresp.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.01      0.40     2.28     3.82 1.00      998     2399
## 
## Regression Coefficients:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept                        -4.33      0.66    -5.67    -3.05 1.00
## rural.ses.med2                   -0.56      0.74    -2.01     0.95 1.00
## rural.ses.med3                    1.07      0.65    -0.25     2.31 1.00
## rural.ses.med4                    1.44      0.86    -0.40     2.94 1.00
## mostresp_devx2                   -0.24      0.19    -0.62     0.11 1.00
## mostresp_av12x2                   0.15      0.07     0.02     0.28 1.00
## mostresp_devx2:rural.ses.med2    -0.26      0.41    -1.18     0.48 1.00
## mostresp_devx2:rural.ses.med3     0.04      0.34    -0.75     0.62 1.00
## mostresp_devx2:rural.ses.med4     0.42      0.35    -0.24     1.11 1.00
##                               Bulk_ESS Tail_ESS
## Intercept                         1910     2307
## rural.ses.med2                    2468     2858
## rural.ses.med3                    2290     2704
## rural.ses.med4                    2250     2901
## mostresp_devx2                    2592     2916
## mostresp_av12x2                   1838     2654
## mostresp_devx2:rural.ses.med2     2391     2372
## mostresp_devx2:rural.ses.med3     1752     1699
## mostresp_devx2:rural.ses.med4     1760     2643
## 
## Monotonic Simplex Parameters:
##                                   Estimate Est.Error l-95% CI u-95% CI Rhat
## mostresp_devx21[1]                    0.26      0.15     0.04     0.59 1.00
## mostresp_devx21[2]                    0.24      0.14     0.04     0.54 1.00
## mostresp_devx21[3]                    0.23      0.13     0.03     0.53 1.00
## mostresp_devx21[4]                    0.27      0.15     0.05     0.59 1.00
## mostresp_av12x21[1]                   0.12      0.08     0.02     0.31 1.00
## mostresp_av12x21[2]                   0.12      0.07     0.02     0.30 1.00
## mostresp_av12x21[3]                   0.13      0.08     0.02     0.34 1.00
## mostresp_av12x21[4]                   0.13      0.08     0.02     0.33 1.00
## mostresp_av12x21[5]                   0.13      0.08     0.02     0.32 1.00
## mostresp_av12x21[6]                   0.13      0.08     0.02     0.33 1.00
## mostresp_av12x21[7]                   0.12      0.08     0.02     0.31 1.00
## mostresp_av12x21[8]                   0.11      0.07     0.02     0.29 1.00
## mostresp_devx2:rural.ses.med21[1]     0.27      0.20     0.01     0.72 1.00
## mostresp_devx2:rural.ses.med21[2]     0.23      0.18     0.01     0.67 1.00
## mostresp_devx2:rural.ses.med21[3]     0.20      0.17     0.01     0.63 1.00
## mostresp_devx2:rural.ses.med21[4]     0.29      0.21     0.01     0.75 1.00
## mostresp_devx2:rural.ses.med31[1]     0.26      0.19     0.01     0.70 1.00
## mostresp_devx2:rural.ses.med31[2]     0.24      0.19     0.01     0.70 1.00
## mostresp_devx2:rural.ses.med31[3]     0.22      0.18     0.01     0.64 1.00
## mostresp_devx2:rural.ses.med31[4]     0.29      0.22     0.01     0.79 1.00
## mostresp_devx2:rural.ses.med41[1]     0.41      0.23     0.02     0.84 1.00
## mostresp_devx2:rural.ses.med41[2]     0.19      0.17     0.00     0.62 1.00
## mostresp_devx2:rural.ses.med41[3]     0.17      0.15     0.00     0.57 1.00
## mostresp_devx2:rural.ses.med41[4]     0.23      0.18     0.01     0.65 1.00
##                                   Bulk_ESS Tail_ESS
## mostresp_devx21[1]                    4858     2482
## mostresp_devx21[2]                    4422     2753
## mostresp_devx21[3]                    5162     3256
## mostresp_devx21[4]                    4993     3354
## mostresp_av12x21[1]                   4901     2717
## mostresp_av12x21[2]                   4846     2602
## mostresp_av12x21[3]                   5105     2584
## mostresp_av12x21[4]                   4386     2135
## mostresp_av12x21[5]                   4854     2551
## mostresp_av12x21[6]                   4607     2829
## mostresp_av12x21[7]                   4741     3020
## mostresp_av12x21[8]                   4858     3165
## mostresp_devx2:rural.ses.med21[1]     3565     2328
## mostresp_devx2:rural.ses.med21[2]     4449     2908
## mostresp_devx2:rural.ses.med21[3]     3914     2523
## mostresp_devx2:rural.ses.med21[4]     3993     2741
## mostresp_devx2:rural.ses.med31[1]     4280     2047
## mostresp_devx2:rural.ses.med31[2]     3180     2138
## mostresp_devx2:rural.ses.med31[3]     3911     2206
## mostresp_devx2:rural.ses.med31[4]     2590     2329
## mostresp_devx2:rural.ses.med41[1]     2495     2414
## mostresp_devx2:rural.ses.med41[2]     3840     2451
## mostresp_devx2:rural.ses.med41[3]     3306     2443
## mostresp_devx2:rural.ses.med41[4]     4295     2850
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stresp.comm.fit[[2]]
##                              prior     class                           coef
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  group resp dpar nlpar lb ub       source
##                                      user
##                                      user
##                                      user
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                                      user
##                         0         default
##     id                  0    (vectorized)
##     id                  0    (vectorized)
##                                      user
##                                   default
##                                   default
##                                   default
##                                      user
8.1.1.9.4 stfair
out.chg.anyprjcrime.stfair.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.05      0.40     2.34     3.92 1.00      991     1781
## 
## Regression Coefficients:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept                        -4.72      0.69    -6.10    -3.33 1.00
## rural.ses.med2                   -0.31      0.79    -1.83     1.32 1.00
## rural.ses.med3                    0.63      0.70    -0.79     1.92 1.00
## rural.ses.med4                    1.19      0.90    -0.76     2.79 1.00
## mostfair_devx2                   -0.07      0.19    -0.45     0.28 1.00
## mostfair_av12x2                   0.14      0.07     0.01     0.28 1.00
## mostfair_devx2:rural.ses.med2    -0.44      0.45    -1.43     0.37 1.00
## mostfair_devx2:rural.ses.med3     0.32      0.31    -0.26     0.97 1.00
## mostfair_devx2:rural.ses.med4     0.58      0.38    -0.10     1.36 1.00
##                               Bulk_ESS Tail_ESS
## Intercept                         1915     2812
## rural.ses.med2                    2935     2142
## rural.ses.med3                    2691     2917
## rural.ses.med4                    2721     3028
## mostfair_devx2                    3004     2574
## mostfair_av12x2                   1987     2661
## mostfair_devx2:rural.ses.med2     2438     2269
## mostfair_devx2:rural.ses.med3     2517     2465
## mostfair_devx2:rural.ses.med4     2038     2709
## 
## Monotonic Simplex Parameters:
##                                   Estimate Est.Error l-95% CI u-95% CI Rhat
## mostfair_devx21[1]                    0.27      0.15     0.04     0.60 1.00
## mostfair_devx21[2]                    0.24      0.14     0.04     0.56 1.00
## mostfair_devx21[3]                    0.23      0.14     0.03     0.54 1.00
## mostfair_devx21[4]                    0.26      0.15     0.04     0.58 1.00
## mostfair_av12x21[1]                   0.12      0.08     0.02     0.31 1.00
## mostfair_av12x21[2]                   0.11      0.07     0.02     0.29 1.00
## mostfair_av12x21[3]                   0.14      0.09     0.02     0.35 1.00
## mostfair_av12x21[4]                   0.12      0.08     0.02     0.32 1.00
## mostfair_av12x21[5]                   0.12      0.07     0.01     0.30 1.00
## mostfair_av12x21[6]                   0.12      0.08     0.01     0.30 1.00
## mostfair_av12x21[7]                   0.14      0.08     0.02     0.34 1.00
## mostfair_av12x21[8]                   0.13      0.08     0.02     0.33 1.00
## mostfair_devx2:rural.ses.med21[1]     0.27      0.19     0.01     0.70 1.00
## mostfair_devx2:rural.ses.med21[2]     0.21      0.17     0.01     0.63 1.00
## mostfair_devx2:rural.ses.med21[3]     0.23      0.18     0.01     0.66 1.00
## mostfair_devx2:rural.ses.med21[4]     0.29      0.21     0.01     0.74 1.00
## mostfair_devx2:rural.ses.med31[1]     0.28      0.20     0.01     0.71 1.00
## mostfair_devx2:rural.ses.med31[2]     0.25      0.19     0.01     0.68 1.00
## mostfair_devx2:rural.ses.med31[3]     0.22      0.17     0.01     0.63 1.00
## mostfair_devx2:rural.ses.med31[4]     0.26      0.19     0.01     0.70 1.00
## mostfair_devx2:rural.ses.med41[1]     0.38      0.22     0.02     0.80 1.00
## mostfair_devx2:rural.ses.med41[2]     0.20      0.16     0.01     0.61 1.00
## mostfair_devx2:rural.ses.med41[3]     0.20      0.16     0.01     0.59 1.00
## mostfair_devx2:rural.ses.med41[4]     0.22      0.18     0.01     0.66 1.00
##                                   Bulk_ESS Tail_ESS
## mostfair_devx21[1]                    4917     2446
## mostfair_devx21[2]                    4912     2940
## mostfair_devx21[3]                    5171     2809
## mostfair_devx21[4]                    4814     3072
## mostfair_av12x21[1]                   4466     2373
## mostfair_av12x21[2]                   4371     2493
## mostfair_av12x21[3]                   4244     2301
## mostfair_av12x21[4]                   5129     2348
## mostfair_av12x21[5]                   4455     2326
## mostfair_av12x21[6]                   5080     2558
## mostfair_av12x21[7]                   4852     2727
## mostfair_av12x21[8]                   5089     2824
## mostfair_devx2:rural.ses.med21[1]     3673     1890
## mostfair_devx2:rural.ses.med21[2]     4107     2085
## mostfair_devx2:rural.ses.med21[3]     4701     2556
## mostfair_devx2:rural.ses.med21[4]     4255     2910
## mostfair_devx2:rural.ses.med31[1]     2807     1497
## mostfair_devx2:rural.ses.med31[2]     3468     1781
## mostfair_devx2:rural.ses.med31[3]     4046     3010
## mostfair_devx2:rural.ses.med31[4]     3628     2682
## mostfair_devx2:rural.ses.med41[1]     2960     2092
## mostfair_devx2:rural.ses.med41[2]     3269     2442
## mostfair_devx2:rural.ses.med41[3]     3856     2497
## mostfair_devx2:rural.ses.med41[4]     4104     2596
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stfair.comm.fit[[2]]
##                              prior     class                           coef
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  group resp dpar nlpar lb ub       source
##                                      user
##                                      user
##                                      user
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                                      user
##                         0         default
##     id                  0    (vectorized)
##     id                  0    (vectorized)
##                                      user
##                                   default
##                                   default
##                                   default
##                                      user
8.1.1.9.5 stjob
out.chg.anyprjcrime.stjob.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     2.95      0.39     2.26     3.80 1.00     1150     2124
## 
## Regression Coefficients:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept                       -4.88      0.69    -6.30    -3.58 1.00     2007
## rural.ses.med2                  -0.29      0.77    -1.71     1.27 1.00     2843
## rural.ses.med3                   0.38      0.74    -1.17     1.74 1.00     3269
## rural.ses.med4                   1.77      0.98    -0.40     3.38 1.00     1574
## mostjob_devx2                    0.03      0.18    -0.33     0.38 1.00     2526
## mostjob_av12x2                   0.17      0.06     0.05     0.29 1.00     1977
## mostjob_devx2:rural.ses.med2    -0.46      0.43    -1.38     0.28 1.00     2528
## mostjob_devx2:rural.ses.med3     0.39      0.31    -0.20     1.01 1.00     2638
## mostjob_devx2:rural.ses.med4     0.19      0.52    -0.90     1.14 1.00     1203
##                              Tail_ESS
## Intercept                        2074
## rural.ses.med2                   2391
## rural.ses.med3                   2790
## rural.ses.med4                   2475
## mostjob_devx2                    2644
## mostjob_av12x2                   2745
## mostjob_devx2:rural.ses.med2     1949
## mostjob_devx2:rural.ses.med3     2654
## mostjob_devx2:rural.ses.med4     2286
## 
## Monotonic Simplex Parameters:
##                                  Estimate Est.Error l-95% CI u-95% CI Rhat
## mostjob_devx21[1]                    0.26      0.15     0.04     0.59 1.00
## mostjob_devx21[2]                    0.25      0.15     0.04     0.59 1.00
## mostjob_devx21[3]                    0.24      0.14     0.03     0.56 1.00
## mostjob_devx21[4]                    0.26      0.14     0.04     0.58 1.00
## mostjob_av12x21[1]                   0.11      0.07     0.01     0.27 1.00
## mostjob_av12x21[2]                   0.11      0.07     0.01     0.29 1.00
## mostjob_av12x21[3]                   0.11      0.07     0.01     0.28 1.00
## mostjob_av12x21[4]                   0.12      0.08     0.02     0.30 1.00
## mostjob_av12x21[5]                   0.13      0.08     0.02     0.33 1.00
## mostjob_av12x21[6]                   0.15      0.09     0.02     0.36 1.00
## mostjob_av12x21[7]                   0.15      0.09     0.02     0.35 1.00
## mostjob_av12x21[8]                   0.12      0.08     0.02     0.30 1.00
## mostjob_devx2:rural.ses.med21[1]     0.26      0.18     0.01     0.67 1.00
## mostjob_devx2:rural.ses.med21[2]     0.22      0.17     0.01     0.64 1.00
## mostjob_devx2:rural.ses.med21[3]     0.25      0.18     0.01     0.68 1.00
## mostjob_devx2:rural.ses.med21[4]     0.28      0.20     0.01     0.73 1.00
## mostjob_devx2:rural.ses.med31[1]     0.28      0.20     0.02     0.71 1.00
## mostjob_devx2:rural.ses.med31[2]     0.28      0.19     0.01     0.70 1.00
## mostjob_devx2:rural.ses.med31[3]     0.19      0.16     0.01     0.59 1.00
## mostjob_devx2:rural.ses.med31[4]     0.25      0.19     0.01     0.67 1.00
## mostjob_devx2:rural.ses.med41[1]     0.36      0.25     0.01     0.85 1.00
## mostjob_devx2:rural.ses.med41[2]     0.18      0.16     0.00     0.62 1.00
## mostjob_devx2:rural.ses.med41[3]     0.20      0.19     0.00     0.68 1.00
## mostjob_devx2:rural.ses.med41[4]     0.26      0.20     0.01     0.74 1.00
##                                  Bulk_ESS Tail_ESS
## mostjob_devx21[1]                    5612     2699
## mostjob_devx21[2]                    4955     2832
## mostjob_devx21[3]                    5308     2806
## mostjob_devx21[4]                    5200     2615
## mostjob_av12x21[1]                   4393     2373
## mostjob_av12x21[2]                   5115     2226
## mostjob_av12x21[3]                   4628     2552
## mostjob_av12x21[4]                   5704     2826
## mostjob_av12x21[5]                   4674     2738
## mostjob_av12x21[6]                   5072     2922
## mostjob_av12x21[7]                   5395     3266
## mostjob_av12x21[8]                   4844     3091
## mostjob_devx2:rural.ses.med21[1]     4419     2247
## mostjob_devx2:rural.ses.med21[2]     3656     2403
## mostjob_devx2:rural.ses.med21[3]     4346     2842
## mostjob_devx2:rural.ses.med21[4]     3046     2370
## mostjob_devx2:rural.ses.med31[1]     3934     2506
## mostjob_devx2:rural.ses.med31[2]     3525     2319
## mostjob_devx2:rural.ses.med31[3]     4039     2904
## mostjob_devx2:rural.ses.med31[4]     4544     2844
## mostjob_devx2:rural.ses.med41[1]     1680     2799
## mostjob_devx2:rural.ses.med41[2]     4137     2090
## mostjob_devx2:rural.ses.med41[3]     1970     2937
## mostjob_devx2:rural.ses.med41[4]     3936     2965
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stjob.comm.fit[[2]]
##                              prior     class                          coef
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 2) Intercept                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  group resp dpar nlpar lb ub       source
##                                      user
##                                      user
##                                      user
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                                      user
##                         0         default
##     id                  0    (vectorized)
##     id                  0    (vectorized)
##                                      user
##                                   default
##                                   default
##                                   default
##                                      user
8.1.1.9.6 stthft
out.chg.anyprjcrime.stthft.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.10      0.42     2.36     4.00 1.00     1113     2120
## 
## Regression Coefficients:
##                               Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept                        -3.74      0.64    -5.03    -2.55 1.00
## rural.ses.med2                   -0.39      0.82    -1.92     1.21 1.00
## rural.ses.med3                    0.46      0.73    -1.08     1.82 1.00
## rural.ses.med4                    1.76      0.77     0.14     3.17 1.00
## mostthft_devx2                   -0.25      0.19    -0.62     0.13 1.00
## mostthft_av12x2                   0.03      0.08    -0.11     0.19 1.00
## mostthft_devx2:rural.ses.med2    -0.38      0.50    -1.43     0.55 1.00
## mostthft_devx2:rural.ses.med3     0.43      0.35    -0.20     1.20 1.00
## mostthft_devx2:rural.ses.med4     0.37      0.34    -0.30     1.03 1.00
##                               Bulk_ESS Tail_ESS
## Intercept                         2055     2717
## rural.ses.med2                    2896     3094
## rural.ses.med3                    2480     2730
## rural.ses.med4                    2220     2678
## mostthft_devx2                    2281     2524
## mostthft_av12x2                   2070     2625
## mostthft_devx2:rural.ses.med2     2107     2076
## mostthft_devx2:rural.ses.med3     2163     2719
## mostthft_devx2:rural.ses.med4     1737     1926
## 
## Monotonic Simplex Parameters:
##                                   Estimate Est.Error l-95% CI u-95% CI Rhat
## mostthft_devx21[1]                    0.25      0.14     0.04     0.56 1.00
## mostthft_devx21[2]                    0.30      0.15     0.05     0.62 1.00
## mostthft_devx21[3]                    0.21      0.13     0.03     0.51 1.00
## mostthft_devx21[4]                    0.24      0.14     0.04     0.57 1.00
## mostthft_av12x21[1]                   0.13      0.08     0.02     0.33 1.00
## mostthft_av12x21[2]                   0.12      0.08     0.02     0.31 1.00
## mostthft_av12x21[3]                   0.12      0.08     0.02     0.31 1.00
## mostthft_av12x21[4]                   0.12      0.08     0.01     0.32 1.00
## mostthft_av12x21[5]                   0.13      0.08     0.02     0.33 1.00
## mostthft_av12x21[6]                   0.13      0.08     0.02     0.33 1.00
## mostthft_av12x21[7]                   0.13      0.08     0.02     0.32 1.00
## mostthft_av12x21[8]                   0.12      0.08     0.02     0.31 1.00
## mostthft_devx2:rural.ses.med21[1]     0.27      0.20     0.01     0.72 1.00
## mostthft_devx2:rural.ses.med21[2]     0.23      0.18     0.01     0.66 1.00
## mostthft_devx2:rural.ses.med21[3]     0.20      0.17     0.01     0.64 1.00
## mostthft_devx2:rural.ses.med21[4]     0.29      0.21     0.01     0.76 1.00
## mostthft_devx2:rural.ses.med31[1]     0.30      0.20     0.01     0.74 1.00
## mostthft_devx2:rural.ses.med31[2]     0.23      0.18     0.01     0.67 1.00
## mostthft_devx2:rural.ses.med31[3]     0.17      0.15     0.01     0.57 1.00
## mostthft_devx2:rural.ses.med31[4]     0.30      0.20     0.01     0.74 1.00
## mostthft_devx2:rural.ses.med41[1]     0.35      0.22     0.02     0.78 1.00
## mostthft_devx2:rural.ses.med41[2]     0.19      0.16     0.01     0.63 1.00
## mostthft_devx2:rural.ses.med41[3]     0.25      0.18     0.01     0.67 1.00
## mostthft_devx2:rural.ses.med41[4]     0.22      0.18     0.01     0.68 1.00
##                                   Bulk_ESS Tail_ESS
## mostthft_devx21[1]                    4371     2655
## mostthft_devx21[2]                    3926     2468
## mostthft_devx21[3]                    4613     2993
## mostthft_devx21[4]                    4965     2834
## mostthft_av12x21[1]                   4799     2176
## mostthft_av12x21[2]                   4430     2142
## mostthft_av12x21[3]                   4782     2416
## mostthft_av12x21[4]                   5660     2308
## mostthft_av12x21[5]                   4601     2036
## mostthft_av12x21[6]                   5658     2557
## mostthft_av12x21[7]                   5684     3212
## mostthft_av12x21[8]                   5106     3118
## mostthft_devx2:rural.ses.med21[1]     3840     2363
## mostthft_devx2:rural.ses.med21[2]     4175     2545
## mostthft_devx2:rural.ses.med21[3]     4814     2903
## mostthft_devx2:rural.ses.med21[4]     4330     2785
## mostthft_devx2:rural.ses.med31[1]     3388     2291
## mostthft_devx2:rural.ses.med31[2]     3433     2377
## mostthft_devx2:rural.ses.med31[3]     3700     2872
## mostthft_devx2:rural.ses.med31[4]     3291     2581
## mostthft_devx2:rural.ses.med41[1]     2635     2396
## mostthft_devx2:rural.ses.med41[2]     3425     2611
## mostthft_devx2:rural.ses.med41[3]     3766     2451
## mostthft_devx2:rural.ses.med41[4]     3374     2250
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stthft.comm.fit[[2]]
##                              prior     class                           coef
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  group resp dpar nlpar lb ub       source
##                                      user
##                                      user
##                                      user
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                                      user
##                         0         default
##     id                  0    (vectorized)
##     id                  0    (vectorized)
##                                      user
##                                   default
##                                   default
##                                   default
##                                      user
8.1.1.9.7 stmug
out.chg.anyprjcrime.stmug.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.06      0.41     2.31     3.93 1.00     1098     1502
## 
## Regression Coefficients:
##                              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept                       -3.98      0.63    -5.24    -2.74 1.00     1848
## rural.ses.med2                  -1.05      0.74    -2.45     0.48 1.00     2697
## rural.ses.med3                   1.49      0.74    -0.13     2.89 1.00     2069
## rural.ses.med4                   1.63      0.90    -0.32     3.18 1.00     1974
## mostmug_devx2                   -0.03      0.21    -0.43     0.40 1.00     2111
## mostmug_av12x2                  -0.05      0.08    -0.21     0.11 1.00     2098
## mostmug_devx2:rural.ses.med2     0.12      0.41    -0.65     0.94 1.00     1941
## mostmug_devx2:rural.ses.med3    -0.19      0.43    -1.06     0.72 1.00     1458
## mostmug_devx2:rural.ses.med4     0.42      0.40    -0.34     1.24 1.00     1496
##                              Tail_ESS
## Intercept                        2512
## rural.ses.med2                   2556
## rural.ses.med3                   2148
## rural.ses.med4                   2240
## mostmug_devx2                    2845
## mostmug_av12x2                   2878
## mostmug_devx2:rural.ses.med2     2680
## mostmug_devx2:rural.ses.med3     1692
## mostmug_devx2:rural.ses.med4     2111
## 
## Monotonic Simplex Parameters:
##                                  Estimate Est.Error l-95% CI u-95% CI Rhat
## mostmug_devx21[1]                    0.26      0.15     0.04     0.59 1.00
## mostmug_devx21[2]                    0.25      0.15     0.03     0.60 1.00
## mostmug_devx21[3]                    0.24      0.15     0.03     0.59 1.00
## mostmug_devx21[4]                    0.26      0.14     0.04     0.58 1.00
## mostmug_av12x21[1]                   0.12      0.08     0.01     0.31 1.00
## mostmug_av12x21[2]                   0.12      0.08     0.02     0.32 1.00
## mostmug_av12x21[3]                   0.12      0.08     0.02     0.31 1.00
## mostmug_av12x21[4]                   0.13      0.08     0.02     0.33 1.00
## mostmug_av12x21[5]                   0.13      0.08     0.02     0.32 1.00
## mostmug_av12x21[6]                   0.12      0.08     0.02     0.31 1.00
## mostmug_av12x21[7]                   0.12      0.08     0.02     0.32 1.00
## mostmug_av12x21[8]                   0.13      0.08     0.02     0.33 1.00
## mostmug_devx2:rural.ses.med21[1]     0.24      0.19     0.01     0.69 1.00
## mostmug_devx2:rural.ses.med21[2]     0.21      0.18     0.01     0.65 1.00
## mostmug_devx2:rural.ses.med21[3]     0.25      0.19     0.01     0.71 1.00
## mostmug_devx2:rural.ses.med21[4]     0.30      0.22     0.01     0.76 1.00
## mostmug_devx2:rural.ses.med31[1]     0.23      0.19     0.01     0.70 1.00
## mostmug_devx2:rural.ses.med31[2]     0.23      0.19     0.01     0.68 1.00
## mostmug_devx2:rural.ses.med31[3]     0.24      0.19     0.01     0.70 1.00
## mostmug_devx2:rural.ses.med31[4]     0.30      0.21     0.01     0.77 1.00
## mostmug_devx2:rural.ses.med41[1]     0.39      0.24     0.01     0.83 1.00
## mostmug_devx2:rural.ses.med41[2]     0.17      0.16     0.00     0.60 1.00
## mostmug_devx2:rural.ses.med41[3]     0.20      0.17     0.01     0.64 1.00
## mostmug_devx2:rural.ses.med41[4]     0.24      0.19     0.01     0.68 1.00
##                                  Bulk_ESS Tail_ESS
## mostmug_devx21[1]                    4322     2590
## mostmug_devx21[2]                    3892     2557
## mostmug_devx21[3]                    3515     3192
## mostmug_devx21[4]                    5219     2841
## mostmug_av12x21[1]                   4488     2130
## mostmug_av12x21[2]                   4559     2385
## mostmug_av12x21[3]                   5039     2454
## mostmug_av12x21[4]                   4354     2385
## mostmug_av12x21[5]                   4849     2852
## mostmug_av12x21[6]                   4898     2503
## mostmug_av12x21[7]                   5174     2738
## mostmug_av12x21[8]                   5217     3079
## mostmug_devx2:rural.ses.med21[1]     3376     2510
## mostmug_devx2:rural.ses.med21[2]     4386     2706
## mostmug_devx2:rural.ses.med21[3]     4382     3153
## mostmug_devx2:rural.ses.med21[4]     4234     3058
## mostmug_devx2:rural.ses.med31[1]     2454     2169
## mostmug_devx2:rural.ses.med31[2]     3188     2485
## mostmug_devx2:rural.ses.med31[3]     3342     2653
## mostmug_devx2:rural.ses.med31[4]     3558     2822
## mostmug_devx2:rural.ses.med41[1]     2064     1501
## mostmug_devx2:rural.ses.med41[2]     3423     2319
## mostmug_devx2:rural.ses.med41[3]     3507     2150
## mostmug_devx2:rural.ses.med41[4]     3852     2917
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
out.chg.anyprjcrime.stmug.comm.fit[[2]]
##                              prior     class                          coef
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 2) Intercept                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  group resp dpar nlpar lb ub       source
##                                      user
##                                      user
##                                      user
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                              (vectorized)
##                                      user
##                         0         default
##     id                  0    (vectorized)
##     id                  0    (vectorized)
##                                      user
##                                   default
##                                   default
##                                   default
##                                      user

8.1.2 Negative Emotions & Stress x Community Correlation Models

8.1.2.1 Corr X Community: stmony & negative emotions

#Community Change: negative emotions items ~ mo(stmony)
 
#Vectorize priors:

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmony_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostmony_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmony_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostmony_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stmony.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + 
         rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stmony_comm_fit",
      file_refit = "on_change"
  )

##Update function to call all ppchecks for bivar depressive symptom chg models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="depcantgo")
  ppcheckdv2 <-pp_check(modelfit, resp="depeffort")
  ppcheckdv3 <-pp_check(modelfit, resp="deplonely")
  ppcheckdv4 <-pp_check(modelfit, resp="depblues")
  ppcheckdv5 <-pp_check(modelfit, resp="depunfair")
  ppcheckdv6 <-pp_check(modelfit, resp="depmistrt")
  ppcheckdv7 <-pp_check(modelfit, resp="depbetray")
  plotcoefs <- mcmc_areas(modelfit, regex_pars = "^bsp_", prob = 0.95) +
    labs(title = "Coefficient plot",
         subtitle = "Posterior distributions for monotonic ordinal stress coefficients \nwith medians and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^bsp_", regex = TRUE, 
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for monotonic ordinal stress coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, ppcheckdv3, 
                    ppcheckdv4, ppcheckdv5, ppcheckdv6, ppcheckdv7, 
                    plotcoefs, plotcoefs2)
  return(allchecks)
}


out.chg.alldepress.stmony.comm.fit <- ppchecks(chg.alldepress.stmony.comm.fit)
8.1.2.1.1 Coefficient plot (intervals)
out.chg.alldepress.stmony.comm.fit[[11]]

8.1.2.1.2 PPcheck (density)
p1 <- out.chg.alldepress.stmony.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stmony.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stmony.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stmony.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stmony.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stmony.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stmony.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

8.1.2.1.3 Fit summary
out.chg.alldepress.stmony.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          depeffort ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          deplonely ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          depblues ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          depunfair ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##          depbetray ~ 1 + mo(stmony_devx2) + mo(stmony_av12x2) + rural.ses.med + mo(stmony_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.30      0.19     0.01     0.70 1.00      689
## sd(depeffort_Intercept)     0.46      0.27     0.03     1.02 1.01      546
## sd(deplonely_Intercept)     0.46      0.24     0.03     0.91 1.01      462
## sd(depblues_Intercept)      0.68      0.32     0.07     1.27 1.00      532
## sd(depunfair_Intercept)     0.22      0.16     0.01     0.59 1.00      889
## sd(depmistrt_Intercept)     0.32      0.22     0.02     0.80 1.00      917
## sd(depbetray_Intercept)     0.41      0.25     0.02     0.95 1.01      439
##                         Tail_ESS
## sd(depcantgo_Intercept)     1676
## sd(depeffort_Intercept)     1366
## sd(deplonely_Intercept)     1146
## sd(depblues_Intercept)       923
## sd(depunfair_Intercept)     1823
## sd(depmistrt_Intercept)     1779
## sd(depbetray_Intercept)     1283
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## depcantgo_Intercept                        -1.18      0.35    -1.91    -0.57
## depeffort_Intercept                        -2.22      0.44    -3.14    -1.42
## deplonely_Intercept                        -1.24      0.40    -2.06    -0.49
## depblues_Intercept                         -2.17      0.47    -3.08    -1.21
## depunfair_Intercept                        -2.33      0.35    -3.09    -1.69
## depmistrt_Intercept                        -2.65      0.41    -3.48    -1.85
## depbetray_Intercept                        -2.99      0.45    -3.92    -2.13
## depcantgo_rural.ses.med2                    0.30      0.53    -0.94     1.26
## depcantgo_rural.ses.med3                    0.34      0.49    -0.60     1.38
## depcantgo_rural.ses.med4                   -0.07      0.52    -1.06     1.05
## depeffort_rural.ses.med2                    0.16      0.56    -0.99     1.30
## depeffort_rural.ses.med3                    0.38      0.58    -0.90     1.47
## depeffort_rural.ses.med4                    0.17      0.58    -0.98     1.31
## deplonely_rural.ses.med2                   -0.20      0.56    -1.37     0.92
## deplonely_rural.ses.med3                    0.34      0.53    -0.66     1.52
## deplonely_rural.ses.med4                   -0.27      0.55    -1.53     0.69
## depblues_rural.ses.med2                     0.18      0.61    -0.92     1.60
## depblues_rural.ses.med3                    -0.15      0.58    -1.38     0.92
## depblues_rural.ses.med4                     0.80      0.59    -0.40     1.99
## depunfair_rural.ses.med2                    0.01      0.51    -1.01     1.04
## depunfair_rural.ses.med3                    0.73      0.50    -0.28     1.71
## depunfair_rural.ses.med4                    0.76      0.59    -0.60     1.79
## depmistrt_rural.ses.med2                    0.44      0.54    -0.63     1.52
## depmistrt_rural.ses.med3                    0.56      0.55    -0.60     1.62
## depmistrt_rural.ses.med4                    0.22      0.60    -1.12     1.24
## depbetray_rural.ses.med2                    0.05      0.58    -1.18     1.11
## depbetray_rural.ses.med3                    1.16      0.46     0.29     2.11
## depbetray_rural.ses.med4                    0.62      0.65    -0.83     1.77
## depcantgo_mostmony_devx2                    0.25      0.13    -0.00     0.53
## depcantgo_mostmony_av12x2                   0.05      0.03    -0.01     0.12
## depcantgo_mostmony_devx2:rural.ses.med2     0.01      0.30    -0.45     0.79
## depcantgo_mostmony_devx2:rural.ses.med3    -0.16      0.24    -0.65     0.31
## depcantgo_mostmony_devx2:rural.ses.med4     0.11      0.31    -0.45     0.80
## depeffort_mostmony_devx2                    0.10      0.16    -0.22     0.41
## depeffort_mostmony_av12x2                   0.00      0.04    -0.08     0.08
## depeffort_mostmony_devx2:rural.ses.med2    -0.11      0.32    -0.88     0.45
## depeffort_mostmony_devx2:rural.ses.med3     0.05      0.30    -0.50     0.70
## depeffort_mostmony_devx2:rural.ses.med4     0.20      0.29    -0.40     0.73
## deplonely_mostmony_devx2                    0.11      0.15    -0.22     0.38
## deplonely_mostmony_av12x2                  -0.01      0.04    -0.08     0.06
## deplonely_mostmony_devx2:rural.ses.med2    -0.15      0.34    -0.95     0.45
## deplonely_mostmony_devx2:rural.ses.med3    -0.26      0.32    -1.00     0.27
## deplonely_mostmony_devx2:rural.ses.med4     0.45      0.35    -0.08     1.32
## depblues_mostmony_devx2                    -0.17      0.16    -0.51     0.14
## depblues_mostmony_av12x2                    0.06      0.05    -0.03     0.15
## depblues_mostmony_devx2:rural.ses.med2      0.07      0.32    -0.56     0.77
## depblues_mostmony_devx2:rural.ses.med3      0.24      0.28    -0.32     0.81
## depblues_mostmony_devx2:rural.ses.med4     -0.14      0.34    -0.90     0.48
## depunfair_mostmony_devx2                    0.25      0.13    -0.01     0.50
## depunfair_mostmony_av12x2                   0.07      0.04     0.00     0.15
## depunfair_mostmony_devx2:rural.ses.med2     0.17      0.26    -0.33     0.70
## depunfair_mostmony_devx2:rural.ses.med3    -0.03      0.25    -0.51     0.47
## depunfair_mostmony_devx2:rural.ses.med4     0.07      0.29    -0.55     0.65
## depmistrt_mostmony_devx2                    0.08      0.15    -0.21     0.37
## depmistrt_mostmony_av12x2                   0.10      0.04     0.02     0.19
## depmistrt_mostmony_devx2:rural.ses.med2     0.06      0.27    -0.52     0.56
## depmistrt_mostmony_devx2:rural.ses.med3    -0.04      0.29    -0.67     0.49
## depmistrt_mostmony_devx2:rural.ses.med4     0.37      0.37    -0.21     1.27
## depbetray_mostmony_devx2                    0.06      0.16    -0.27     0.38
## depbetray_mostmony_av12x2                   0.14      0.05     0.06     0.24
## depbetray_mostmony_devx2:rural.ses.med2     0.20      0.29    -0.39     0.73
## depbetray_mostmony_devx2:rural.ses.med3    -0.40      0.34    -1.18     0.19
## depbetray_mostmony_devx2:rural.ses.med4     0.18      0.31    -0.45     0.80
##                                         Rhat Bulk_ESS Tail_ESS
## depcantgo_Intercept                     1.00     3924     3067
## depeffort_Intercept                     1.00     3664     3136
## deplonely_Intercept                     1.00     2797     2898
## depblues_Intercept                      1.00     2997     2966
## depunfair_Intercept                     1.00     4153     3072
## depmistrt_Intercept                     1.00     3884     2840
## depbetray_Intercept                     1.00     3264     3213
## depcantgo_rural.ses.med2                1.00     2860     2375
## depcantgo_rural.ses.med3                1.00     3482     2831
## depcantgo_rural.ses.med4                1.00     3469     2792
## depeffort_rural.ses.med2                1.00     4149     3034
## depeffort_rural.ses.med3                1.00     2845     2633
## depeffort_rural.ses.med4                1.00     3281     2367
## deplonely_rural.ses.med2                1.00     2558     2532
## deplonely_rural.ses.med3                1.00     3282     2850
## deplonely_rural.ses.med4                1.00     3578     2780
## depblues_rural.ses.med2                 1.00     3698     2722
## depblues_rural.ses.med3                 1.00     4057     2906
## depblues_rural.ses.med4                 1.00     3490     2448
## depunfair_rural.ses.med2                1.00     3607     2494
## depunfair_rural.ses.med3                1.00     3322     2910
## depunfair_rural.ses.med4                1.00     3020     2276
## depmistrt_rural.ses.med2                1.00     3759     2843
## depmistrt_rural.ses.med3                1.00     3837     2716
## depmistrt_rural.ses.med4                1.00     3388     2610
## depbetray_rural.ses.med2                1.00     3399     2814
## depbetray_rural.ses.med3                1.00     4024     2569
## depbetray_rural.ses.med4                1.00     3332     2980
## depcantgo_mostmony_devx2                1.00     3105     3093
## depcantgo_mostmony_av12x2               1.00     6651     3128
## depcantgo_mostmony_devx2:rural.ses.med2 1.00     2296     1964
## depcantgo_mostmony_devx2:rural.ses.med3 1.00     3374     2835
## depcantgo_mostmony_devx2:rural.ses.med4 1.00     2622     2129
## depeffort_mostmony_devx2                1.00     3965     3186
## depeffort_mostmony_av12x2               1.00     6441     3014
## depeffort_mostmony_devx2:rural.ses.med2 1.00     3438     2552
## depeffort_mostmony_devx2:rural.ses.med3 1.00     2532     2293
## depeffort_mostmony_devx2:rural.ses.med4 1.00     3140     2377
## deplonely_mostmony_devx2                1.00     2741     2953
## deplonely_mostmony_av12x2               1.00     6687     3238
## deplonely_mostmony_devx2:rural.ses.med2 1.00     2168     2144
## deplonely_mostmony_devx2:rural.ses.med3 1.00     2949     2689
## deplonely_mostmony_devx2:rural.ses.med4 1.00     2607     1933
## depblues_mostmony_devx2                 1.00     3474     3038
## depblues_mostmony_av12x2                1.00     5978     2843
## depblues_mostmony_devx2:rural.ses.med2  1.00     3229     2340
## depblues_mostmony_devx2:rural.ses.med3  1.00     3408     2361
## depblues_mostmony_devx2:rural.ses.med4  1.00     3118     2779
## depunfair_mostmony_devx2                1.00     3629     2658
## depunfair_mostmony_av12x2               1.00     6582     2977
## depunfair_mostmony_devx2:rural.ses.med2 1.00     3142     2629
## depunfair_mostmony_devx2:rural.ses.med3 1.00     2977     2480
## depunfair_mostmony_devx2:rural.ses.med4 1.00     2565     2681
## depmistrt_mostmony_devx2                1.00     3388     2933
## depmistrt_mostmony_av12x2               1.00     6002     3085
## depmistrt_mostmony_devx2:rural.ses.med2 1.00     3182     2262
## depmistrt_mostmony_devx2:rural.ses.med3 1.00     3241     2153
## depmistrt_mostmony_devx2:rural.ses.med4 1.00     2912     2261
## depbetray_mostmony_devx2                1.00     3083     2982
## depbetray_mostmony_av12x2               1.00     6475     3227
## depbetray_mostmony_devx2:rural.ses.med2 1.00     2930     2399
## depbetray_mostmony_devx2:rural.ses.med3 1.00     2760     2553
## depbetray_mostmony_devx2:rural.ses.med4 1.00     2640     2506
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## depcantgo_mostmony_devx21[1]                    0.23      0.13     0.03
## depcantgo_mostmony_devx21[2]                    0.29      0.13     0.06
## depcantgo_mostmony_devx21[3]                    0.20      0.11     0.03
## depcantgo_mostmony_devx21[4]                    0.28      0.15     0.05
## depcantgo_mostmony_av12x21[1]                   0.12      0.08     0.01
## depcantgo_mostmony_av12x21[2]                   0.13      0.08     0.02
## depcantgo_mostmony_av12x21[3]                   0.13      0.08     0.02
## depcantgo_mostmony_av12x21[4]                   0.14      0.09     0.02
## depcantgo_mostmony_av12x21[5]                   0.12      0.08     0.01
## depcantgo_mostmony_av12x21[6]                   0.12      0.08     0.01
## depcantgo_mostmony_av12x21[7]                   0.12      0.08     0.02
## depcantgo_mostmony_av12x21[8]                   0.12      0.08     0.02
## depcantgo_mostmony_devx2:rural.ses.med21[1]     0.26      0.20     0.01
## depcantgo_mostmony_devx2:rural.ses.med21[2]     0.22      0.18     0.01
## depcantgo_mostmony_devx2:rural.ses.med21[3]     0.22      0.18     0.01
## depcantgo_mostmony_devx2:rural.ses.med21[4]     0.30      0.22     0.01
## depcantgo_mostmony_devx2:rural.ses.med31[1]     0.27      0.19     0.01
## depcantgo_mostmony_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## depcantgo_mostmony_devx2:rural.ses.med31[3]     0.22      0.17     0.01
## depcantgo_mostmony_devx2:rural.ses.med31[4]     0.29      0.21     0.01
## depcantgo_mostmony_devx2:rural.ses.med41[1]     0.25      0.20     0.01
## depcantgo_mostmony_devx2:rural.ses.med41[2]     0.21      0.17     0.01
## depcantgo_mostmony_devx2:rural.ses.med41[3]     0.21      0.17     0.01
## depcantgo_mostmony_devx2:rural.ses.med41[4]     0.32      0.23     0.01
## depeffort_mostmony_devx21[1]                    0.25      0.14     0.04
## depeffort_mostmony_devx21[2]                    0.27      0.15     0.04
## depeffort_mostmony_devx21[3]                    0.22      0.13     0.03
## depeffort_mostmony_devx21[4]                    0.26      0.15     0.04
## depeffort_mostmony_av12x21[1]                   0.13      0.08     0.02
## depeffort_mostmony_av12x21[2]                   0.13      0.08     0.02
## depeffort_mostmony_av12x21[3]                   0.12      0.08     0.02
## depeffort_mostmony_av12x21[4]                   0.12      0.08     0.02
## depeffort_mostmony_av12x21[5]                   0.12      0.08     0.02
## depeffort_mostmony_av12x21[6]                   0.12      0.08     0.02
## depeffort_mostmony_av12x21[7]                   0.12      0.08     0.02
## depeffort_mostmony_av12x21[8]                   0.13      0.09     0.01
## depeffort_mostmony_devx2:rural.ses.med21[1]     0.25      0.19     0.01
## depeffort_mostmony_devx2:rural.ses.med21[2]     0.21      0.17     0.01
## depeffort_mostmony_devx2:rural.ses.med21[3]     0.23      0.18     0.01
## depeffort_mostmony_devx2:rural.ses.med21[4]     0.31      0.22     0.01
## depeffort_mostmony_devx2:rural.ses.med31[1]     0.26      0.20     0.01
## depeffort_mostmony_devx2:rural.ses.med31[2]     0.21      0.17     0.01
## depeffort_mostmony_devx2:rural.ses.med31[3]     0.22      0.19     0.01
## depeffort_mostmony_devx2:rural.ses.med31[4]     0.30      0.21     0.01
## depeffort_mostmony_devx2:rural.ses.med41[1]     0.23      0.18     0.01
## depeffort_mostmony_devx2:rural.ses.med41[2]     0.28      0.20     0.01
## depeffort_mostmony_devx2:rural.ses.med41[3]     0.22      0.17     0.01
## depeffort_mostmony_devx2:rural.ses.med41[4]     0.27      0.20     0.01
## deplonely_mostmony_devx21[1]                    0.24      0.14     0.04
## deplonely_mostmony_devx21[2]                    0.32      0.17     0.04
## deplonely_mostmony_devx21[3]                    0.21      0.13     0.03
## deplonely_mostmony_devx21[4]                    0.23      0.14     0.03
## deplonely_mostmony_av12x21[1]                   0.13      0.09     0.02
## deplonely_mostmony_av12x21[2]                   0.13      0.08     0.02
## deplonely_mostmony_av12x21[3]                   0.13      0.08     0.02
## deplonely_mostmony_av12x21[4]                   0.12      0.08     0.02
## deplonely_mostmony_av12x21[5]                   0.12      0.08     0.02
## deplonely_mostmony_av12x21[6]                   0.12      0.08     0.02
## deplonely_mostmony_av12x21[7]                   0.13      0.08     0.02
## deplonely_mostmony_av12x21[8]                   0.13      0.08     0.02
## deplonely_mostmony_devx2:rural.ses.med21[1]     0.24      0.19     0.01
## deplonely_mostmony_devx2:rural.ses.med21[2]     0.19      0.18     0.00
## deplonely_mostmony_devx2:rural.ses.med21[3]     0.25      0.19     0.01
## deplonely_mostmony_devx2:rural.ses.med21[4]     0.32      0.22     0.01
## deplonely_mostmony_devx2:rural.ses.med31[1]     0.25      0.19     0.01
## deplonely_mostmony_devx2:rural.ses.med31[2]     0.19      0.16     0.01
## deplonely_mostmony_devx2:rural.ses.med31[3]     0.22      0.17     0.01
## deplonely_mostmony_devx2:rural.ses.med31[4]     0.33      0.22     0.01
## deplonely_mostmony_devx2:rural.ses.med41[1]     0.23      0.18     0.01
## deplonely_mostmony_devx2:rural.ses.med41[2]     0.21      0.16     0.01
## deplonely_mostmony_devx2:rural.ses.med41[3]     0.23      0.17     0.01
## deplonely_mostmony_devx2:rural.ses.med41[4]     0.33      0.22     0.01
## depblues_mostmony_devx21[1]                     0.28      0.15     0.04
## depblues_mostmony_devx21[2]                     0.24      0.13     0.04
## depblues_mostmony_devx21[3]                     0.23      0.13     0.03
## depblues_mostmony_devx21[4]                     0.25      0.14     0.04
## depblues_mostmony_av12x21[1]                    0.13      0.08     0.02
## depblues_mostmony_av12x21[2]                    0.13      0.08     0.02
## depblues_mostmony_av12x21[3]                    0.13      0.08     0.02
## depblues_mostmony_av12x21[4]                    0.13      0.08     0.02
## depblues_mostmony_av12x21[5]                    0.12      0.08     0.02
## depblues_mostmony_av12x21[6]                    0.12      0.08     0.02
## depblues_mostmony_av12x21[7]                    0.13      0.08     0.02
## depblues_mostmony_av12x21[8]                    0.13      0.08     0.02
## depblues_mostmony_devx2:rural.ses.med21[1]      0.26      0.21     0.01
## depblues_mostmony_devx2:rural.ses.med21[2]      0.22      0.17     0.01
## depblues_mostmony_devx2:rural.ses.med21[3]      0.22      0.18     0.01
## depblues_mostmony_devx2:rural.ses.med21[4]      0.31      0.22     0.01
## depblues_mostmony_devx2:rural.ses.med31[1]      0.26      0.19     0.01
## depblues_mostmony_devx2:rural.ses.med31[2]      0.23      0.18     0.01
## depblues_mostmony_devx2:rural.ses.med31[3]      0.24      0.18     0.01
## depblues_mostmony_devx2:rural.ses.med31[4]      0.28      0.20     0.01
## depblues_mostmony_devx2:rural.ses.med41[1]      0.26      0.20     0.01
## depblues_mostmony_devx2:rural.ses.med41[2]      0.20      0.17     0.01
## depblues_mostmony_devx2:rural.ses.med41[3]      0.22      0.18     0.01
## depblues_mostmony_devx2:rural.ses.med41[4]      0.31      0.22     0.01
## depunfair_mostmony_devx21[1]                    0.20      0.12     0.03
## depunfair_mostmony_devx21[2]                    0.26      0.13     0.05
## depunfair_mostmony_devx21[3]                    0.33      0.14     0.07
## depunfair_mostmony_devx21[4]                    0.22      0.13     0.03
## depunfair_mostmony_av12x21[1]                   0.13      0.08     0.02
## depunfair_mostmony_av12x21[2]                   0.13      0.08     0.02
## depunfair_mostmony_av12x21[3]                   0.10      0.07     0.01
## depunfair_mostmony_av12x21[4]                   0.11      0.07     0.02
## depunfair_mostmony_av12x21[5]                   0.12      0.08     0.02
## depunfair_mostmony_av12x21[6]                   0.12      0.08     0.02
## depunfair_mostmony_av12x21[7]                   0.14      0.08     0.02
## depunfair_mostmony_av12x21[8]                   0.15      0.09     0.02
## depunfair_mostmony_devx2:rural.ses.med21[1]     0.23      0.18     0.01
## depunfair_mostmony_devx2:rural.ses.med21[2]     0.24      0.18     0.01
## depunfair_mostmony_devx2:rural.ses.med21[3]     0.23      0.18     0.01
## depunfair_mostmony_devx2:rural.ses.med21[4]     0.29      0.20     0.01
## depunfair_mostmony_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## depunfair_mostmony_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## depunfair_mostmony_devx2:rural.ses.med31[3]     0.22      0.17     0.01
## depunfair_mostmony_devx2:rural.ses.med31[4]     0.29      0.21     0.01
## depunfair_mostmony_devx2:rural.ses.med41[1]     0.28      0.21     0.01
## depunfair_mostmony_devx2:rural.ses.med41[2]     0.22      0.17     0.01
## depunfair_mostmony_devx2:rural.ses.med41[3]     0.21      0.17     0.01
## depunfair_mostmony_devx2:rural.ses.med41[4]     0.29      0.21     0.01
## depmistrt_mostmony_devx21[1]                    0.25      0.15     0.03
## depmistrt_mostmony_devx21[2]                    0.22      0.13     0.03
## depmistrt_mostmony_devx21[3]                    0.26      0.14     0.04
## depmistrt_mostmony_devx21[4]                    0.27      0.15     0.04
## depmistrt_mostmony_av12x21[1]                   0.13      0.08     0.02
## depmistrt_mostmony_av12x21[2]                   0.14      0.09     0.02
## depmistrt_mostmony_av12x21[3]                   0.13      0.08     0.02
## depmistrt_mostmony_av12x21[4]                   0.12      0.07     0.02
## depmistrt_mostmony_av12x21[5]                   0.10      0.06     0.01
## depmistrt_mostmony_av12x21[6]                   0.10      0.07     0.01
## depmistrt_mostmony_av12x21[7]                   0.16      0.09     0.03
## depmistrt_mostmony_av12x21[8]                   0.13      0.08     0.02
## depmistrt_mostmony_devx2:rural.ses.med21[1]     0.25      0.19     0.01
## depmistrt_mostmony_devx2:rural.ses.med21[2]     0.22      0.17     0.01
## depmistrt_mostmony_devx2:rural.ses.med21[3]     0.25      0.18     0.01
## depmistrt_mostmony_devx2:rural.ses.med21[4]     0.28      0.21     0.01
## depmistrt_mostmony_devx2:rural.ses.med31[1]     0.26      0.20     0.01
## depmistrt_mostmony_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## depmistrt_mostmony_devx2:rural.ses.med31[3]     0.22      0.17     0.01
## depmistrt_mostmony_devx2:rural.ses.med31[4]     0.30      0.22     0.01
## depmistrt_mostmony_devx2:rural.ses.med41[1]     0.25      0.19     0.01
## depmistrt_mostmony_devx2:rural.ses.med41[2]     0.17      0.16     0.01
## depmistrt_mostmony_devx2:rural.ses.med41[3]     0.22      0.17     0.01
## depmistrt_mostmony_devx2:rural.ses.med41[4]     0.35      0.23     0.01
## depbetray_mostmony_devx21[1]                    0.27      0.15     0.04
## depbetray_mostmony_devx21[2]                    0.24      0.13     0.04
## depbetray_mostmony_devx21[3]                    0.24      0.14     0.04
## depbetray_mostmony_devx21[4]                    0.25      0.14     0.04
## depbetray_mostmony_av12x21[1]                   0.12      0.08     0.02
## depbetray_mostmony_av12x21[2]                   0.13      0.08     0.02
## depbetray_mostmony_av12x21[3]                   0.11      0.07     0.02
## depbetray_mostmony_av12x21[4]                   0.12      0.07     0.02
## depbetray_mostmony_av12x21[5]                   0.11      0.07     0.02
## depbetray_mostmony_av12x21[6]                   0.10      0.07     0.01
## depbetray_mostmony_av12x21[7]                   0.16      0.09     0.03
## depbetray_mostmony_av12x21[8]                   0.15      0.09     0.02
## depbetray_mostmony_devx2:rural.ses.med21[1]     0.26      0.19     0.01
## depbetray_mostmony_devx2:rural.ses.med21[2]     0.20      0.17     0.01
## depbetray_mostmony_devx2:rural.ses.med21[3]     0.27      0.19     0.01
## depbetray_mostmony_devx2:rural.ses.med21[4]     0.26      0.20     0.01
## depbetray_mostmony_devx2:rural.ses.med31[1]     0.17      0.16     0.00
## depbetray_mostmony_devx2:rural.ses.med31[2]     0.18      0.15     0.01
## depbetray_mostmony_devx2:rural.ses.med31[3]     0.34      0.21     0.02
## depbetray_mostmony_devx2:rural.ses.med31[4]     0.31      0.21     0.01
## depbetray_mostmony_devx2:rural.ses.med41[1]     0.28      0.20     0.01
## depbetray_mostmony_devx2:rural.ses.med41[2]     0.25      0.19     0.01
## depbetray_mostmony_devx2:rural.ses.med41[3]     0.18      0.16     0.01
## depbetray_mostmony_devx2:rural.ses.med41[4]     0.28      0.20     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## depcantgo_mostmony_devx21[1]                    0.54 1.00     5918     3185
## depcantgo_mostmony_devx21[2]                    0.57 1.00     5330     2734
## depcantgo_mostmony_devx21[3]                    0.45 1.00     5772     2822
## depcantgo_mostmony_devx21[4]                    0.60 1.00     7156     2821
## depcantgo_mostmony_av12x21[1]                   0.31 1.00     7540     2424
## depcantgo_mostmony_av12x21[2]                   0.32 1.00     8507     2624
## depcantgo_mostmony_av12x21[3]                   0.31 1.00     7770     2515
## depcantgo_mostmony_av12x21[4]                   0.34 1.00     6780     2773
## depcantgo_mostmony_av12x21[5]                   0.30 1.00     7451     2174
## depcantgo_mostmony_av12x21[6]                   0.31 1.00     7731     2615
## depcantgo_mostmony_av12x21[7]                   0.30 1.00     6348     2751
## depcantgo_mostmony_av12x21[8]                   0.31 1.00     6567     2859
## depcantgo_mostmony_devx2:rural.ses.med21[1]     0.73 1.00     6284     2481
## depcantgo_mostmony_devx2:rural.ses.med21[2]     0.67 1.00     4511     2574
## depcantgo_mostmony_devx2:rural.ses.med21[3]     0.65 1.00     4251     2746
## depcantgo_mostmony_devx2:rural.ses.med21[4]     0.80 1.00     4588     2915
## depcantgo_mostmony_devx2:rural.ses.med31[1]     0.72 1.00     4508     2070
## depcantgo_mostmony_devx2:rural.ses.med31[2]     0.66 1.00     4827     2792
## depcantgo_mostmony_devx2:rural.ses.med31[3]     0.64 1.00     4751     2592
## depcantgo_mostmony_devx2:rural.ses.med31[4]     0.75 1.00     5720     2731
## depcantgo_mostmony_devx2:rural.ses.med41[1]     0.71 1.00     5002     2496
## depcantgo_mostmony_devx2:rural.ses.med41[2]     0.64 1.00     5419     2839
## depcantgo_mostmony_devx2:rural.ses.med41[3]     0.63 1.00     4822     2738
## depcantgo_mostmony_devx2:rural.ses.med41[4]     0.82 1.00     4467     2344
## depeffort_mostmony_devx21[1]                    0.57 1.00     6615     2412
## depeffort_mostmony_devx21[2]                    0.59 1.00     6172     2297
## depeffort_mostmony_devx21[3]                    0.52 1.00     6373     2713
## depeffort_mostmony_devx21[4]                    0.59 1.00     7883     2750
## depeffort_mostmony_av12x21[1]                   0.33 1.00     7280     2385
## depeffort_mostmony_av12x21[2]                   0.33 1.00     6873     2640
## depeffort_mostmony_av12x21[3]                   0.31 1.00     7312     2320
## depeffort_mostmony_av12x21[4]                   0.32 1.00     9145     2636
## depeffort_mostmony_av12x21[5]                   0.32 1.00     8284     2202
## depeffort_mostmony_av12x21[6]                   0.31 1.00     6748     2647
## depeffort_mostmony_av12x21[7]                   0.31 1.00     8366     2248
## depeffort_mostmony_av12x21[8]                   0.34 1.00     7020     2596
## depeffort_mostmony_devx2:rural.ses.med21[1]     0.70 1.00     6720     2903
## depeffort_mostmony_devx2:rural.ses.med21[2]     0.65 1.00     5563     2110
## depeffort_mostmony_devx2:rural.ses.med21[3]     0.67 1.00     5268     2943
## depeffort_mostmony_devx2:rural.ses.med21[4]     0.79 1.00     4816     2172
## depeffort_mostmony_devx2:rural.ses.med31[1]     0.71 1.00     5909     2661
## depeffort_mostmony_devx2:rural.ses.med31[2]     0.64 1.00     6360     2349
## depeffort_mostmony_devx2:rural.ses.med31[3]     0.68 1.00     3924     2874
## depeffort_mostmony_devx2:rural.ses.med31[4]     0.76 1.00     6472     3256
## depeffort_mostmony_devx2:rural.ses.med41[1]     0.67 1.00     6180     2359
## depeffort_mostmony_devx2:rural.ses.med41[2]     0.72 1.00     4533     2442
## depeffort_mostmony_devx2:rural.ses.med41[3]     0.64 1.00     4468     2518
## depeffort_mostmony_devx2:rural.ses.med41[4]     0.76 1.00     5295     2726
## deplonely_mostmony_devx21[1]                    0.57 1.00     6814     2945
## deplonely_mostmony_devx21[2]                    0.65 1.00     3622     2937
## deplonely_mostmony_devx21[3]                    0.51 1.00     4909     2734
## deplonely_mostmony_devx21[4]                    0.56 1.00     6527     3155
## deplonely_mostmony_av12x21[1]                   0.33 1.00     7601     2486
## deplonely_mostmony_av12x21[2]                   0.33 1.00     7121     2493
## deplonely_mostmony_av12x21[3]                   0.31 1.00     8613     2895
## deplonely_mostmony_av12x21[4]                   0.30 1.00     7452     2476
## deplonely_mostmony_av12x21[5]                   0.30 1.00     7777     2556
## deplonely_mostmony_av12x21[6]                   0.32 1.00     7273     2379
## deplonely_mostmony_av12x21[7]                   0.32 1.00     6649     2563
## deplonely_mostmony_av12x21[8]                   0.33 1.00     5944     3010
## deplonely_mostmony_devx2:rural.ses.med21[1]     0.71 1.00     5043     2121
## deplonely_mostmony_devx2:rural.ses.med21[2]     0.64 1.00     3597     2022
## deplonely_mostmony_devx2:rural.ses.med21[3]     0.69 1.00     4348     3163
## deplonely_mostmony_devx2:rural.ses.med21[4]     0.80 1.00     5105     2985
## deplonely_mostmony_devx2:rural.ses.med31[1]     0.69 1.00     5374     2617
## deplonely_mostmony_devx2:rural.ses.med31[2]     0.60 1.00     4971     2620
## deplonely_mostmony_devx2:rural.ses.med31[3]     0.64 1.00     4271     3195
## deplonely_mostmony_devx2:rural.ses.med31[4]     0.80 1.00     4796     2742
## deplonely_mostmony_devx2:rural.ses.med41[1]     0.67 1.00     5378     2547
## deplonely_mostmony_devx2:rural.ses.med41[2]     0.63 1.00     5601     2522
## deplonely_mostmony_devx2:rural.ses.med41[3]     0.63 1.00     3790     2664
## deplonely_mostmony_devx2:rural.ses.med41[4]     0.78 1.00     5025     2853
## depblues_mostmony_devx21[1]                     0.62 1.00     7083     2756
## depblues_mostmony_devx21[2]                     0.56 1.00     7582     2648
## depblues_mostmony_devx21[3]                     0.53 1.00     6891     2919
## depblues_mostmony_devx21[4]                     0.57 1.00     7344     2800
## depblues_mostmony_av12x21[1]                    0.32 1.00     7017     2428
## depblues_mostmony_av12x21[2]                    0.32 1.00     7719     2027
## depblues_mostmony_av12x21[3]                    0.32 1.00     6719     2090
## depblues_mostmony_av12x21[4]                    0.32 1.00     7302     2667
## depblues_mostmony_av12x21[5]                    0.31 1.00     7754     2511
## depblues_mostmony_av12x21[6]                    0.30 1.00     7546     2439
## depblues_mostmony_av12x21[7]                    0.32 1.00     6389     3004
## depblues_mostmony_av12x21[8]                    0.34 1.00     7364     2995
## depblues_mostmony_devx2:rural.ses.med21[1]      0.75 1.00     4832     2361
## depblues_mostmony_devx2:rural.ses.med21[2]      0.64 1.00     6082     2951
## depblues_mostmony_devx2:rural.ses.med21[3]      0.66 1.00     5095     2334
## depblues_mostmony_devx2:rural.ses.med21[4]      0.80 1.00     5596     2954
## depblues_mostmony_devx2:rural.ses.med31[1]      0.68 1.00     5542     2773
## depblues_mostmony_devx2:rural.ses.med31[2]      0.66 1.00     6176     2613
## depblues_mostmony_devx2:rural.ses.med31[3]      0.66 1.00     5607     2620
## depblues_mostmony_devx2:rural.ses.med31[4]      0.73 1.00     5535     2724
## depblues_mostmony_devx2:rural.ses.med41[1]      0.72 1.00     5611     2151
## depblues_mostmony_devx2:rural.ses.med41[2]      0.62 1.00     5539     2553
## depblues_mostmony_devx2:rural.ses.med41[3]      0.66 1.00     5696     2373
## depblues_mostmony_devx2:rural.ses.med41[4]      0.80 1.00     4882     2714
## depunfair_mostmony_devx21[1]                    0.47 1.00     5611     2828
## depunfair_mostmony_devx21[2]                    0.55 1.00     6035     2441
## depunfair_mostmony_devx21[3]                    0.63 1.00     4908     2876
## depunfair_mostmony_devx21[4]                    0.52 1.00     6722     3066
## depunfair_mostmony_av12x21[1]                   0.33 1.00     7431     2050
## depunfair_mostmony_av12x21[2]                   0.32 1.00     7278     2642
## depunfair_mostmony_av12x21[3]                   0.27 1.00     7006     2628
## depunfair_mostmony_av12x21[4]                   0.27 1.00     8049     2593
## depunfair_mostmony_av12x21[5]                   0.31 1.00     7266     1998
## depunfair_mostmony_av12x21[6]                   0.31 1.00     7811     2651
## depunfair_mostmony_av12x21[7]                   0.34 1.00     6975     2592
## depunfair_mostmony_av12x21[8]                   0.36 1.00     6520     3210
## depunfair_mostmony_devx2:rural.ses.med21[1]     0.67 1.00     5183     2081
## depunfair_mostmony_devx2:rural.ses.med21[2]     0.66 1.00     5648     2228
## depunfair_mostmony_devx2:rural.ses.med21[3]     0.65 1.00     5358     3021
## depunfair_mostmony_devx2:rural.ses.med21[4]     0.73 1.00     6344     3046
## depunfair_mostmony_devx2:rural.ses.med31[1]     0.72 1.00     4931     2090
## depunfair_mostmony_devx2:rural.ses.med31[2]     0.66 1.00     5765     2539
## depunfair_mostmony_devx2:rural.ses.med31[3]     0.66 1.00     5867     2605
## depunfair_mostmony_devx2:rural.ses.med31[4]     0.75 1.00     6342     2551
## depunfair_mostmony_devx2:rural.ses.med41[1]     0.74 1.00     5308     2705
## depunfair_mostmony_devx2:rural.ses.med41[2]     0.65 1.00     5519     2586
## depunfair_mostmony_devx2:rural.ses.med41[3]     0.65 1.00     5338     2884
## depunfair_mostmony_devx2:rural.ses.med41[4]     0.77 1.00     5553     2716
## depmistrt_mostmony_devx21[1]                    0.59 1.00     7159     2299
## depmistrt_mostmony_devx21[2]                    0.53 1.00     7814     2747
## depmistrt_mostmony_devx21[3]                    0.58 1.00     5704     3122
## depmistrt_mostmony_devx21[4]                    0.60 1.00     7454     2944
## depmistrt_mostmony_av12x21[1]                   0.31 1.00     7084     2561
## depmistrt_mostmony_av12x21[2]                   0.35 1.00     7072     2414
## depmistrt_mostmony_av12x21[3]                   0.31 1.00     7532     1958
## depmistrt_mostmony_av12x21[4]                   0.28 1.00     8679     2989
## depmistrt_mostmony_av12x21[5]                   0.25 1.00     6888     2838
## depmistrt_mostmony_av12x21[6]                   0.27 1.00     6822     2779
## depmistrt_mostmony_av12x21[7]                   0.37 1.00     5839     2469
## depmistrt_mostmony_av12x21[8]                   0.33 1.01     6724     2151
## depmistrt_mostmony_devx2:rural.ses.med21[1]     0.68 1.00     6058     2627
## depmistrt_mostmony_devx2:rural.ses.med21[2]     0.64 1.00     6335     2816
## depmistrt_mostmony_devx2:rural.ses.med21[3]     0.67 1.00     4944     2702
## depmistrt_mostmony_devx2:rural.ses.med21[4]     0.76 1.00     5525     2944
## depmistrt_mostmony_devx2:rural.ses.med31[1]     0.72 1.00     5327     2218
## depmistrt_mostmony_devx2:rural.ses.med31[2]     0.65 1.00     6178     2671
## depmistrt_mostmony_devx2:rural.ses.med31[3]     0.66 1.00     5354     2857
## depmistrt_mostmony_devx2:rural.ses.med31[4]     0.78 1.00     5138     2788
## depmistrt_mostmony_devx2:rural.ses.med41[1]     0.68 1.00     5830     2731
## depmistrt_mostmony_devx2:rural.ses.med41[2]     0.60 1.00     4758     2985
## depmistrt_mostmony_devx2:rural.ses.med41[3]     0.65 1.00     4880     3476
## depmistrt_mostmony_devx2:rural.ses.med41[4]     0.82 1.00     4156     2817
## depbetray_mostmony_devx21[1]                    0.61 1.00     6928     2690
## depbetray_mostmony_devx21[2]                    0.55 1.00     8355     2584
## depbetray_mostmony_devx21[3]                    0.56 1.00     7080     2704
## depbetray_mostmony_devx21[4]                    0.57 1.00     7217     2878
## depbetray_mostmony_av12x21[1]                   0.31 1.00     7778     2589
## depbetray_mostmony_av12x21[2]                   0.32 1.00     7172     2953
## depbetray_mostmony_av12x21[3]                   0.27 1.00     6798     2481
## depbetray_mostmony_av12x21[4]                   0.29 1.00     7889     2715
## depbetray_mostmony_av12x21[5]                   0.27 1.00     6680     2968
## depbetray_mostmony_av12x21[6]                   0.26 1.00     7917     2831
## depbetray_mostmony_av12x21[7]                   0.36 1.00     7644     3044
## depbetray_mostmony_av12x21[8]                   0.36 1.00     7886     2609
## depbetray_mostmony_devx2:rural.ses.med21[1]     0.71 1.00     6238     2697
## depbetray_mostmony_devx2:rural.ses.med21[2]     0.62 1.00     5838     2550
## depbetray_mostmony_devx2:rural.ses.med21[3]     0.70 1.00     4447     3065
## depbetray_mostmony_devx2:rural.ses.med21[4]     0.71 1.00     5020     2781
## depbetray_mostmony_devx2:rural.ses.med31[1]     0.58 1.00     4894     2705
## depbetray_mostmony_devx2:rural.ses.med31[2]     0.57 1.00     6087     2475
## depbetray_mostmony_devx2:rural.ses.med31[3]     0.77 1.00     4041     2481
## depbetray_mostmony_devx2:rural.ses.med31[4]     0.77 1.00     4970     2804
## depbetray_mostmony_devx2:rural.ses.med41[1]     0.73 1.00     6013     2811
## depbetray_mostmony_devx2:rural.ses.med41[2]     0.70 1.00     4852     2568
## depbetray_mostmony_devx2:rural.ses.med41[3]     0.58 1.00     4691     2497
## depbetray_mostmony_devx2:rural.ses.med41[4]     0.75 1.00     5726     2482
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.2.1.4 Prior summary
out.chg.alldepress.stmony.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostmony_av12x2
##                    normal(0, 0.25)         b                 mostmony_devx2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmony_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmony_av12x21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmony_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmony_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##        depbetray                          user
##        depbetray                          user
##        depbetray                          user
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##         depblues                          user
##         depblues                          user
##         depblues                          user
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depeffort                          user
##        depeffort                          user
##        depeffort                          user
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        deplonely                          user
##        deplonely                          user
##        deplonely                          user
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depunfair                          user
##        depunfair                          user
##        depunfair                          user
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##                                        default
##        depbetray                          user
##         depblues                          user
##        depcantgo                          user
##        depeffort                          user
##        deplonely                          user
##        depmistrt                          user
##        depunfair                          user
##        depbetray             0         default
##         depblues             0         default
##        depcantgo             0         default
##        depeffort             0         default
##        deplonely             0         default
##        depmistrt             0         default
##        depunfair             0         default
##     id depbetray             0    (vectorized)
##     id depbetray             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depunfair             0    (vectorized)
##     id depunfair             0    (vectorized)
##        depbetray                          user
##        depbetray                       default
##        depbetray                       default
##        depbetray                       default
##        depbetray                          user
##         depblues                          user
##         depblues                       default
##         depblues                       default
##         depblues                       default
##         depblues                          user
##        depcantgo                          user
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                          user
##        depeffort                          user
##        depeffort                       default
##        depeffort                       default
##        depeffort                       default
##        depeffort                          user
##        deplonely                          user
##        deplonely                       default
##        deplonely                       default
##        deplonely                       default
##        deplonely                          user
##        depmistrt                          user
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                          user
##        depunfair                          user
##        depunfair                       default
##        depunfair                       default
##        depunfair                       default
##        depunfair                          user

8.1.2.2 Corr X Community: sttran & negative emotions

#Community Change: negative emotions items ~ mo(sttran)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mosttran_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mosttran_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mosttran_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mosttran_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.sttran.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + 
         rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_sttran_comm_fit",
      file_refit = "on_change"
  )


out.chg.alldepress.sttran.comm.fit <- ppchecks(chg.alldepress.sttran.comm.fit)
8.1.2.2.1 Coefficient plot (intervals)
out.chg.alldepress.sttran.comm.fit[[11]]

8.1.2.2.2 PPcheck (density)
p1 <- out.chg.alldepress.sttran.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.sttran.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.sttran.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.sttran.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.sttran.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.sttran.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.sttran.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

8.1.2.2.3 Fit summary
out.chg.alldepress.sttran.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          depeffort ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          deplonely ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          depblues ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          depunfair ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##          depbetray ~ 1 + mo(sttran_devx2) + mo(sttran_av12x2) + rural.ses.med + mo(sttran_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.35      0.21     0.02     0.77 1.01      629
## sd(depeffort_Intercept)     0.43      0.27     0.02     0.98 1.01      475
## sd(deplonely_Intercept)     0.43      0.24     0.03     0.90 1.01      517
## sd(depblues_Intercept)      0.69      0.32     0.06     1.29 1.01      451
## sd(depunfair_Intercept)     0.23      0.17     0.01     0.62 1.00      990
## sd(depmistrt_Intercept)     0.34      0.22     0.01     0.80 1.00      851
## sd(depbetray_Intercept)     0.45      0.26     0.02     0.97 1.01      595
##                         Tail_ESS
## sd(depcantgo_Intercept)     1499
## sd(depeffort_Intercept)     1343
## sd(deplonely_Intercept)     1138
## sd(depblues_Intercept)       753
## sd(depunfair_Intercept)     1969
## sd(depmistrt_Intercept)     1716
## sd(depbetray_Intercept)     1429
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## depcantgo_Intercept                        -1.06      0.34    -1.76    -0.41
## depeffort_Intercept                        -1.95      0.42    -2.77    -1.11
## deplonely_Intercept                        -1.02      0.37    -1.69    -0.22
## depblues_Intercept                         -2.34      0.43    -3.25    -1.51
## depunfair_Intercept                        -2.33      0.37    -3.08    -1.60
## depmistrt_Intercept                        -2.50      0.42    -3.32    -1.66
## depbetray_Intercept                        -2.62      0.42    -3.47    -1.77
## depcantgo_rural.ses.med2                   -0.35      0.52    -1.48     0.55
## depcantgo_rural.ses.med3                    0.57      0.44    -0.23     1.51
## depcantgo_rural.ses.med4                   -0.17      0.47    -1.14     0.80
## depeffort_rural.ses.med2                   -0.26      0.68    -1.59     1.13
## depeffort_rural.ses.med3                    0.59      0.54    -0.57     1.63
## depeffort_rural.ses.med4                    0.61      0.55    -0.58     1.68
## deplonely_rural.ses.med2                   -0.05      0.61    -1.11     1.32
## deplonely_rural.ses.med3                    0.04      0.52    -1.05     1.12
## deplonely_rural.ses.med4                    0.03      0.43    -0.78     0.96
## depblues_rural.ses.med2                     0.43      0.58    -0.77     1.58
## depblues_rural.ses.med3                     0.37      0.54    -0.77     1.43
## depblues_rural.ses.med4                     0.51      0.60    -0.82     1.58
## depunfair_rural.ses.med2                   -0.24      0.67    -1.54     1.11
## depunfair_rural.ses.med3                    0.46      0.56    -0.79     1.52
## depunfair_rural.ses.med4                    0.75      0.50    -0.18     1.87
## depmistrt_rural.ses.med2                    0.85      0.57    -0.22     2.11
## depmistrt_rural.ses.med3                    0.91      0.57    -0.13     2.15
## depmistrt_rural.ses.med4                    0.73      0.57    -0.41     1.96
## depbetray_rural.ses.med2                    0.84      0.58    -0.26     2.08
## depbetray_rural.ses.med3                    0.75      0.56    -0.43     1.80
## depbetray_rural.ses.med4                    1.10      0.52    -0.02     2.10
## depcantgo_mosttran_devx2                    0.19      0.12    -0.04     0.44
## depcantgo_mosttran_av12x2                   0.05      0.04    -0.02     0.12
## depcantgo_mosttran_devx2:rural.ses.med2     0.40      0.32    -0.10     1.16
## depcantgo_mosttran_devx2:rural.ses.med3    -0.34      0.30    -1.08     0.11
## depcantgo_mosttran_devx2:rural.ses.med4     0.12      0.24    -0.33     0.65
## depeffort_mosttran_devx2                    0.04      0.16    -0.28     0.35
## depeffort_mosttran_av12x2                  -0.03      0.04    -0.12     0.06
## depeffort_mosttran_devx2:rural.ses.med2     0.12      0.34    -0.63     0.73
## depeffort_mosttran_devx2:rural.ses.med3    -0.10      0.32    -0.82     0.49
## depeffort_mosttran_devx2:rural.ses.med4     0.01      0.30    -0.48     0.73
## deplonely_mosttran_devx2                    0.07      0.15    -0.25     0.34
## deplonely_mosttran_av12x2                  -0.03      0.04    -0.11     0.05
## deplonely_mosttran_devx2:rural.ses.med2    -0.19      0.34    -1.00     0.37
## deplonely_mosttran_devx2:rural.ses.med3    -0.01      0.31    -0.52     0.72
## deplonely_mosttran_devx2:rural.ses.med4     0.29      0.24    -0.21     0.78
## depblues_mosttran_devx2                    -0.08      0.16    -0.39     0.25
## depblues_mosttran_av12x2                    0.05      0.05    -0.05     0.15
## depblues_mosttran_devx2:rural.ses.med2     -0.20      0.37    -1.00     0.48
## depblues_mosttran_devx2:rural.ses.med3     -0.07      0.31    -0.73     0.54
## depblues_mosttran_devx2:rural.ses.med4      0.01      0.30    -0.54     0.70
## depunfair_mosttran_devx2                    0.23      0.14    -0.07     0.48
## depunfair_mosttran_av12x2                   0.07      0.04    -0.01     0.15
## depunfair_mosttran_devx2:rural.ses.med2     0.26      0.31    -0.45     0.81
## depunfair_mosttran_devx2:rural.ses.med3     0.10      0.27    -0.46     0.65
## depunfair_mosttran_devx2:rural.ses.med4     0.17      0.26    -0.37     0.72
## depmistrt_mosttran_devx2                    0.13      0.16    -0.24     0.41
## depmistrt_mosttran_av12x2                   0.06      0.05    -0.03     0.17
## depmistrt_mosttran_devx2:rural.ses.med2    -0.20      0.33    -0.98     0.37
## depmistrt_mosttran_devx2:rural.ses.med3    -0.24      0.32    -1.00     0.33
## depmistrt_mosttran_devx2:rural.ses.med4    -0.05      0.32    -0.79     0.46
## depbetray_mosttran_devx2                    0.04      0.16    -0.27     0.35
## depbetray_mosttran_av12x2                   0.08      0.05    -0.01     0.17
## depbetray_mosttran_devx2:rural.ses.med2    -0.27      0.35    -1.08     0.35
## depbetray_mosttran_devx2:rural.ses.med3    -0.08      0.32    -0.75     0.54
## depbetray_mosttran_devx2:rural.ses.med4    -0.05      0.25    -0.54     0.48
##                                         Rhat Bulk_ESS Tail_ESS
## depcantgo_Intercept                     1.00     3917     2947
## depeffort_Intercept                     1.00     2857     2725
## deplonely_Intercept                     1.00     2803     2366
## depblues_Intercept                      1.00     3231     2997
## depunfair_Intercept                     1.00     3050     2496
## depmistrt_Intercept                     1.00     2797     2427
## depbetray_Intercept                     1.00     3381     3357
## depcantgo_rural.ses.med2                1.00     3754     3036
## depcantgo_rural.ses.med3                1.00     3740     2755
## depcantgo_rural.ses.med4                1.00     3260     2781
## depeffort_rural.ses.med2                1.00     3204     2528
## depeffort_rural.ses.med3                1.00     3044     2892
## depeffort_rural.ses.med4                1.00     3028     2550
## deplonely_rural.ses.med2                1.00     2606     2513
## deplonely_rural.ses.med3                1.00     2595     2189
## deplonely_rural.ses.med4                1.00     2622     1993
## depblues_rural.ses.med2                 1.00     3698     3012
## depblues_rural.ses.med3                 1.00     3574     2628
## depblues_rural.ses.med4                 1.00     3357     2466
## depunfair_rural.ses.med2                1.00     2498     2019
## depunfair_rural.ses.med3                1.00     2525     2395
## depunfair_rural.ses.med4                1.00     2496     1797
## depmistrt_rural.ses.med2                1.00     3265     2301
## depmistrt_rural.ses.med3                1.00     3107     2790
## depmistrt_rural.ses.med4                1.00     3173     2772
## depbetray_rural.ses.med2                1.00     3775     2589
## depbetray_rural.ses.med3                1.00     3154     2412
## depbetray_rural.ses.med4                1.00     3592     2730
## depcantgo_mosttran_devx2                1.00     3712     2959
## depcantgo_mosttran_av12x2               1.00     5526     2886
## depcantgo_mosttran_devx2:rural.ses.med2 1.00     3081     2169
## depcantgo_mosttran_devx2:rural.ses.med3 1.00     2820     2049
## depcantgo_mosttran_devx2:rural.ses.med4 1.00     3297     2655
## depeffort_mosttran_devx2                1.00     2865     2699
## depeffort_mosttran_av12x2               1.00     5889     3281
## depeffort_mosttran_devx2:rural.ses.med2 1.00     2965     2964
## depeffort_mosttran_devx2:rural.ses.med3 1.00     2756     2228
## depeffort_mosttran_devx2:rural.ses.med4 1.00     2359     2487
## deplonely_mosttran_devx2                1.00     2550     2523
## deplonely_mosttran_av12x2               1.00     4790     3037
## deplonely_mosttran_devx2:rural.ses.med2 1.00     2546     2220
## deplonely_mosttran_devx2:rural.ses.med3 1.00     2131     1588
## deplonely_mosttran_devx2:rural.ses.med4 1.00     2237     1648
## depblues_mosttran_devx2                 1.00     3913     3103
## depblues_mosttran_av12x2                1.00     5067     3139
## depblues_mosttran_devx2:rural.ses.med2  1.00     3299     2650
## depblues_mosttran_devx2:rural.ses.med3  1.00     3239     2434
## depblues_mosttran_devx2:rural.ses.med4  1.00     2984     2549
## depunfair_mosttran_devx2                1.00     2343     2371
## depunfair_mosttran_av12x2               1.00     6050     3069
## depunfair_mosttran_devx2:rural.ses.med2 1.00     2380     1823
## depunfair_mosttran_devx2:rural.ses.med3 1.00     2376     2575
## depunfair_mosttran_devx2:rural.ses.med4 1.00     2160     1910
## depmistrt_mosttran_devx2                1.00     2116     1960
## depmistrt_mosttran_av12x2               1.00     5456     2969
## depmistrt_mosttran_devx2:rural.ses.med2 1.00     2990     2194
## depmistrt_mosttran_devx2:rural.ses.med3 1.00     2489     2196
## depmistrt_mosttran_devx2:rural.ses.med4 1.00     2460     2466
## depbetray_mosttran_devx2                1.00     3197     3000
## depbetray_mosttran_av12x2               1.00     6035     3273
## depbetray_mosttran_devx2:rural.ses.med2 1.00     3209     2280
## depbetray_mosttran_devx2:rural.ses.med3 1.00     2623     2204
## depbetray_mosttran_devx2:rural.ses.med4 1.00     3338     2685
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## depcantgo_mosttran_devx21[1]                    0.23      0.14     0.03
## depcantgo_mosttran_devx21[2]                    0.29      0.14     0.06
## depcantgo_mosttran_devx21[3]                    0.26      0.13     0.04
## depcantgo_mosttran_devx21[4]                    0.22      0.13     0.03
## depcantgo_mosttran_av12x21[1]                   0.12      0.08     0.01
## depcantgo_mosttran_av12x21[2]                   0.13      0.08     0.02
## depcantgo_mosttran_av12x21[3]                   0.11      0.07     0.01
## depcantgo_mosttran_av12x21[4]                   0.12      0.08     0.01
## depcantgo_mosttran_av12x21[5]                   0.13      0.08     0.02
## depcantgo_mosttran_av12x21[6]                   0.12      0.08     0.02
## depcantgo_mosttran_av12x21[7]                   0.14      0.09     0.02
## depcantgo_mosttran_av12x21[8]                   0.14      0.09     0.02
## depcantgo_mosttran_devx2:rural.ses.med21[1]     0.23      0.18     0.01
## depcantgo_mosttran_devx2:rural.ses.med21[2]     0.22      0.16     0.01
## depcantgo_mosttran_devx2:rural.ses.med21[3]     0.23      0.17     0.01
## depcantgo_mosttran_devx2:rural.ses.med21[4]     0.32      0.22     0.02
## depcantgo_mosttran_devx2:rural.ses.med31[1]     0.21      0.17     0.01
## depcantgo_mosttran_devx2:rural.ses.med31[2]     0.22      0.17     0.01
## depcantgo_mosttran_devx2:rural.ses.med31[3]     0.24      0.17     0.01
## depcantgo_mosttran_devx2:rural.ses.med31[4]     0.32      0.22     0.01
## depcantgo_mosttran_devx2:rural.ses.med41[1]     0.25      0.20     0.01
## depcantgo_mosttran_devx2:rural.ses.med41[2]     0.23      0.18     0.01
## depcantgo_mosttran_devx2:rural.ses.med41[3]     0.22      0.17     0.01
## depcantgo_mosttran_devx2:rural.ses.med41[4]     0.30      0.21     0.01
## depeffort_mosttran_devx21[1]                    0.26      0.15     0.04
## depeffort_mosttran_devx21[2]                    0.24      0.14     0.04
## depeffort_mosttran_devx21[3]                    0.24      0.14     0.03
## depeffort_mosttran_devx21[4]                    0.27      0.15     0.04
## depeffort_mosttran_av12x21[1]                   0.13      0.08     0.02
## depeffort_mosttran_av12x21[2]                   0.13      0.08     0.02
## depeffort_mosttran_av12x21[3]                   0.13      0.08     0.02
## depeffort_mosttran_av12x21[4]                   0.12      0.08     0.01
## depeffort_mosttran_av12x21[5]                   0.12      0.08     0.02
## depeffort_mosttran_av12x21[6]                   0.12      0.08     0.02
## depeffort_mosttran_av12x21[7]                   0.12      0.08     0.01
## depeffort_mosttran_av12x21[8]                   0.13      0.08     0.02
## depeffort_mosttran_devx2:rural.ses.med21[1]     0.23      0.19     0.01
## depeffort_mosttran_devx2:rural.ses.med21[2]     0.29      0.22     0.01
## depeffort_mosttran_devx2:rural.ses.med21[3]     0.20      0.17     0.01
## depeffort_mosttran_devx2:rural.ses.med21[4]     0.28      0.20     0.01
## depeffort_mosttran_devx2:rural.ses.med31[1]     0.25      0.20     0.01
## depeffort_mosttran_devx2:rural.ses.med31[2]     0.20      0.17     0.01
## depeffort_mosttran_devx2:rural.ses.med31[3]     0.24      0.19     0.01
## depeffort_mosttran_devx2:rural.ses.med31[4]     0.31      0.22     0.01
## depeffort_mosttran_devx2:rural.ses.med41[1]     0.25      0.19     0.01
## depeffort_mosttran_devx2:rural.ses.med41[2]     0.22      0.19     0.01
## depeffort_mosttran_devx2:rural.ses.med41[3]     0.22      0.18     0.01
## depeffort_mosttran_devx2:rural.ses.med41[4]     0.31      0.23     0.01
## deplonely_mosttran_devx21[1]                    0.24      0.14     0.04
## deplonely_mosttran_devx21[2]                    0.23      0.13     0.03
## deplonely_mosttran_devx21[3]                    0.27      0.15     0.04
## deplonely_mosttran_devx21[4]                    0.26      0.15     0.04
## deplonely_mosttran_av12x21[1]                   0.13      0.08     0.02
## deplonely_mosttran_av12x21[2]                   0.13      0.08     0.02
## deplonely_mosttran_av12x21[3]                   0.13      0.08     0.02
## deplonely_mosttran_av12x21[4]                   0.12      0.08     0.02
## deplonely_mosttran_av12x21[5]                   0.11      0.07     0.01
## deplonely_mosttran_av12x21[6]                   0.12      0.08     0.01
## deplonely_mosttran_av12x21[7]                   0.12      0.08     0.02
## deplonely_mosttran_av12x21[8]                   0.13      0.08     0.02
## deplonely_mosttran_devx2:rural.ses.med21[1]     0.28      0.20     0.01
## deplonely_mosttran_devx2:rural.ses.med21[2]     0.19      0.16     0.01
## deplonely_mosttran_devx2:rural.ses.med21[3]     0.21      0.17     0.01
## deplonely_mosttran_devx2:rural.ses.med21[4]     0.31      0.22     0.01
## deplonely_mosttran_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## deplonely_mosttran_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## deplonely_mosttran_devx2:rural.ses.med31[3]     0.21      0.17     0.01
## deplonely_mosttran_devx2:rural.ses.med31[4]     0.30      0.22     0.01
## deplonely_mosttran_devx2:rural.ses.med41[1]     0.18      0.16     0.00
## deplonely_mosttran_devx2:rural.ses.med41[2]     0.18      0.15     0.01
## deplonely_mosttran_devx2:rural.ses.med41[3]     0.37      0.21     0.02
## deplonely_mosttran_devx2:rural.ses.med41[4]     0.28      0.19     0.01
## depblues_mosttran_devx21[1]                     0.25      0.15     0.03
## depblues_mosttran_devx21[2]                     0.23      0.13     0.03
## depblues_mosttran_devx21[3]                     0.26      0.15     0.04
## depblues_mosttran_devx21[4]                     0.26      0.15     0.04
## depblues_mosttran_av12x21[1]                    0.13      0.08     0.02
## depblues_mosttran_av12x21[2]                    0.13      0.08     0.02
## depblues_mosttran_av12x21[3]                    0.12      0.08     0.02
## depblues_mosttran_av12x21[4]                    0.13      0.08     0.02
## depblues_mosttran_av12x21[5]                    0.11      0.07     0.01
## depblues_mosttran_av12x21[6]                    0.12      0.08     0.01
## depblues_mosttran_av12x21[7]                    0.13      0.08     0.02
## depblues_mosttran_av12x21[8]                    0.13      0.08     0.02
## depblues_mosttran_devx2:rural.ses.med21[1]      0.23      0.18     0.01
## depblues_mosttran_devx2:rural.ses.med21[2]      0.18      0.17     0.00
## depblues_mosttran_devx2:rural.ses.med21[3]      0.28      0.20     0.01
## depblues_mosttran_devx2:rural.ses.med21[4]      0.30      0.22     0.01
## depblues_mosttran_devx2:rural.ses.med31[1]      0.25      0.19     0.01
## depblues_mosttran_devx2:rural.ses.med31[2]      0.20      0.17     0.00
## depblues_mosttran_devx2:rural.ses.med31[3]      0.23      0.18     0.01
## depblues_mosttran_devx2:rural.ses.med31[4]      0.31      0.22     0.01
## depblues_mosttran_devx2:rural.ses.med41[1]      0.26      0.20     0.01
## depblues_mosttran_devx2:rural.ses.med41[2]      0.21      0.17     0.01
## depblues_mosttran_devx2:rural.ses.med41[3]      0.23      0.19     0.01
## depblues_mosttran_devx2:rural.ses.med41[4]      0.29      0.21     0.01
## depunfair_mosttran_devx21[1]                    0.18      0.12     0.03
## depunfair_mosttran_devx21[2]                    0.31      0.14     0.06
## depunfair_mosttran_devx21[3]                    0.29      0.13     0.06
## depunfair_mosttran_devx21[4]                    0.21      0.12     0.03
## depunfair_mosttran_av12x21[1]                   0.12      0.08     0.02
## depunfair_mosttran_av12x21[2]                   0.12      0.08     0.02
## depunfair_mosttran_av12x21[3]                   0.11      0.07     0.01
## depunfair_mosttran_av12x21[4]                   0.11      0.07     0.01
## depunfair_mosttran_av12x21[5]                   0.11      0.07     0.02
## depunfair_mosttran_av12x21[6]                   0.13      0.08     0.02
## depunfair_mosttran_av12x21[7]                   0.16      0.09     0.02
## depunfair_mosttran_av12x21[8]                   0.14      0.08     0.02
## depunfair_mosttran_devx2:rural.ses.med21[1]     0.20      0.17     0.01
## depunfair_mosttran_devx2:rural.ses.med21[2]     0.36      0.22     0.01
## depunfair_mosttran_devx2:rural.ses.med21[3]     0.18      0.15     0.01
## depunfair_mosttran_devx2:rural.ses.med21[4]     0.26      0.19     0.01
## depunfair_mosttran_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## depunfair_mosttran_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## depunfair_mosttran_devx2:rural.ses.med31[3]     0.21      0.17     0.01
## depunfair_mosttran_devx2:rural.ses.med31[4]     0.29      0.21     0.01
## depunfair_mosttran_devx2:rural.ses.med41[1]     0.22      0.19     0.01
## depunfair_mosttran_devx2:rural.ses.med41[2]     0.22      0.17     0.01
## depunfair_mosttran_devx2:rural.ses.med41[3]     0.27      0.19     0.01
## depunfair_mosttran_devx2:rural.ses.med41[4]     0.29      0.20     0.01
## depmistrt_mosttran_devx21[1]                    0.22      0.14     0.03
## depmistrt_mosttran_devx21[2]                    0.21      0.13     0.03
## depmistrt_mosttran_devx21[3]                    0.33      0.17     0.04
## depmistrt_mosttran_devx21[4]                    0.24      0.14     0.03
## depmistrt_mosttran_av12x21[1]                   0.13      0.08     0.02
## depmistrt_mosttran_av12x21[2]                   0.14      0.09     0.02
## depmistrt_mosttran_av12x21[3]                   0.13      0.08     0.02
## depmistrt_mosttran_av12x21[4]                   0.11      0.07     0.02
## depmistrt_mosttran_av12x21[5]                   0.10      0.07     0.01
## depmistrt_mosttran_av12x21[6]                   0.10      0.07     0.01
## depmistrt_mosttran_av12x21[7]                   0.15      0.09     0.02
## depmistrt_mosttran_av12x21[8]                   0.14      0.09     0.02
## depmistrt_mosttran_devx2:rural.ses.med21[1]     0.26      0.19     0.01
## depmistrt_mosttran_devx2:rural.ses.med21[2]     0.21      0.17     0.01
## depmistrt_mosttran_devx2:rural.ses.med21[3]     0.22      0.17     0.01
## depmistrt_mosttran_devx2:rural.ses.med21[4]     0.31      0.22     0.01
## depmistrt_mosttran_devx2:rural.ses.med31[1]     0.25      0.19     0.01
## depmistrt_mosttran_devx2:rural.ses.med31[2]     0.25      0.19     0.01
## depmistrt_mosttran_devx2:rural.ses.med31[3]     0.19      0.17     0.01
## depmistrt_mosttran_devx2:rural.ses.med31[4]     0.31      0.22     0.01
## depmistrt_mosttran_devx2:rural.ses.med41[1]     0.25      0.19     0.01
## depmistrt_mosttran_devx2:rural.ses.med41[2]     0.22      0.18     0.01
## depmistrt_mosttran_devx2:rural.ses.med41[3]     0.22      0.18     0.01
## depmistrt_mosttran_devx2:rural.ses.med41[4]     0.30      0.22     0.01
## depbetray_mosttran_devx21[1]                    0.26      0.15     0.04
## depbetray_mosttran_devx21[2]                    0.24      0.14     0.04
## depbetray_mosttran_devx21[3]                    0.24      0.14     0.04
## depbetray_mosttran_devx21[4]                    0.27      0.15     0.04
## depbetray_mosttran_av12x21[1]                   0.13      0.08     0.02
## depbetray_mosttran_av12x21[2]                   0.13      0.08     0.02
## depbetray_mosttran_av12x21[3]                   0.12      0.08     0.02
## depbetray_mosttran_av12x21[4]                   0.11      0.07     0.02
## depbetray_mosttran_av12x21[5]                   0.10      0.07     0.01
## depbetray_mosttran_av12x21[6]                   0.13      0.08     0.02
## depbetray_mosttran_av12x21[7]                   0.16      0.10     0.02
## depbetray_mosttran_av12x21[8]                   0.12      0.08     0.02
## depbetray_mosttran_devx2:rural.ses.med21[1]     0.25      0.19     0.01
## depbetray_mosttran_devx2:rural.ses.med21[2]     0.19      0.16     0.01
## depbetray_mosttran_devx2:rural.ses.med21[3]     0.25      0.19     0.01
## depbetray_mosttran_devx2:rural.ses.med21[4]     0.31      0.22     0.01
## depbetray_mosttran_devx2:rural.ses.med31[1]     0.25      0.20     0.01
## depbetray_mosttran_devx2:rural.ses.med31[2]     0.20      0.17     0.01
## depbetray_mosttran_devx2:rural.ses.med31[3]     0.24      0.19     0.01
## depbetray_mosttran_devx2:rural.ses.med31[4]     0.31      0.22     0.02
## depbetray_mosttran_devx2:rural.ses.med41[1]     0.26      0.20     0.01
## depbetray_mosttran_devx2:rural.ses.med41[2]     0.23      0.18     0.01
## depbetray_mosttran_devx2:rural.ses.med41[3]     0.23      0.18     0.01
## depbetray_mosttran_devx2:rural.ses.med41[4]     0.29      0.21     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## depcantgo_mosttran_devx21[1]                    0.54 1.00     7256     2660
## depcantgo_mosttran_devx21[2]                    0.59 1.00     7064     2716
## depcantgo_mosttran_devx21[3]                    0.55 1.00     6126     2725
## depcantgo_mosttran_devx21[4]                    0.52 1.00     7770     3273
## depcantgo_mosttran_av12x21[1]                   0.31 1.00     9181     2258
## depcantgo_mosttran_av12x21[2]                   0.32 1.00     8982     2192
## depcantgo_mosttran_av12x21[3]                   0.29 1.00     7417     2515
## depcantgo_mosttran_av12x21[4]                   0.31 1.00     7923     2070
## depcantgo_mosttran_av12x21[5]                   0.32 1.00     7963     2621
## depcantgo_mosttran_av12x21[6]                   0.30 1.00     8110     2733
## depcantgo_mosttran_av12x21[7]                   0.34 1.00     6055     2877
## depcantgo_mosttran_av12x21[8]                   0.35 1.00     7297     2831
## depcantgo_mosttran_devx2:rural.ses.med21[1]     0.67 1.00     5159     2118
## depcantgo_mosttran_devx2:rural.ses.med21[2]     0.62 1.00     4942     2581
## depcantgo_mosttran_devx2:rural.ses.med21[3]     0.63 1.00     4003     2388
## depcantgo_mosttran_devx2:rural.ses.med21[4]     0.78 1.00     5044     2720
## depcantgo_mosttran_devx2:rural.ses.med31[1]     0.63 1.00     4665     2692
## depcantgo_mosttran_devx2:rural.ses.med31[2]     0.62 1.00     4768     2797
## depcantgo_mosttran_devx2:rural.ses.med31[3]     0.66 1.00     4594     2859
## depcantgo_mosttran_devx2:rural.ses.med31[4]     0.79 1.00     4806     2567
## depcantgo_mosttran_devx2:rural.ses.med41[1]     0.72 1.00     5028     2524
## depcantgo_mosttran_devx2:rural.ses.med41[2]     0.67 1.00     5612     2585
## depcantgo_mosttran_devx2:rural.ses.med41[3]     0.63 1.00     5446     2968
## depcantgo_mosttran_devx2:rural.ses.med41[4]     0.76 1.00     5512     3097
## depeffort_mosttran_devx21[1]                    0.59 1.00     7269     2839
## depeffort_mosttran_devx21[2]                    0.56 1.00     7292     2774
## depeffort_mosttran_devx21[3]                    0.55 1.00     7099     2704
## depeffort_mosttran_devx21[4]                    0.60 1.00     7483     2783
## depeffort_mosttran_av12x21[1]                   0.33 1.00     8011     2805
## depeffort_mosttran_av12x21[2]                   0.33 1.00     7467     2416
## depeffort_mosttran_av12x21[3]                   0.31 1.00     7850     2992
## depeffort_mosttran_av12x21[4]                   0.32 1.00     7017     2133
## depeffort_mosttran_av12x21[5]                   0.31 1.00     7880     2532
## depeffort_mosttran_av12x21[6]                   0.30 1.00     7812     2678
## depeffort_mosttran_av12x21[7]                   0.30 1.00     7250     2484
## depeffort_mosttran_av12x21[8]                   0.33 1.00     7989     2309
## depeffort_mosttran_devx2:rural.ses.med21[1]     0.69 1.00     4661     2329
## depeffort_mosttran_devx2:rural.ses.med21[2]     0.77 1.00     3849     3151
## depeffort_mosttran_devx2:rural.ses.med21[3]     0.65 1.00     5385     3016
## depeffort_mosttran_devx2:rural.ses.med21[4]     0.74 1.00     5872     2832
## depeffort_mosttran_devx2:rural.ses.med31[1]     0.72 1.00     4419     2463
## depeffort_mosttran_devx2:rural.ses.med31[2]     0.63 1.00     5800     2739
## depeffort_mosttran_devx2:rural.ses.med31[3]     0.67 1.00     4827     3250
## depeffort_mosttran_devx2:rural.ses.med31[4]     0.79 1.00     4875     2912
## depeffort_mosttran_devx2:rural.ses.med41[1]     0.70 1.00     6310     2424
## depeffort_mosttran_devx2:rural.ses.med41[2]     0.69 1.00     5080     2384
## depeffort_mosttran_devx2:rural.ses.med41[3]     0.65 1.00     3893     2610
## depeffort_mosttran_devx2:rural.ses.med41[4]     0.81 1.00     3899     2905
## deplonely_mosttran_devx21[1]                    0.58 1.00     4770     3111
## deplonely_mosttran_devx21[2]                    0.54 1.00     6309     2296
## deplonely_mosttran_devx21[3]                    0.59 1.00     3658     2557
## deplonely_mosttran_devx21[4]                    0.59 1.00     6330     2472
## deplonely_mosttran_av12x21[1]                   0.32 1.01     7517     2433
## deplonely_mosttran_av12x21[2]                   0.32 1.00     7137     1879
## deplonely_mosttran_av12x21[3]                   0.33 1.00     7773     2194
## deplonely_mosttran_av12x21[4]                   0.32 1.00     8480     2602
## deplonely_mosttran_av12x21[5]                   0.29 1.00     6523     2845
## deplonely_mosttran_av12x21[6]                   0.30 1.00     7858     2737
## deplonely_mosttran_av12x21[7]                   0.32 1.00     8172     2775
## deplonely_mosttran_av12x21[8]                   0.33 1.00     6076     2586
## deplonely_mosttran_devx2:rural.ses.med21[1]     0.75 1.00     5861     2530
## deplonely_mosttran_devx2:rural.ses.med21[2]     0.62 1.00     4779     2859
## deplonely_mosttran_devx2:rural.ses.med21[3]     0.62 1.00     4568     2691
## deplonely_mosttran_devx2:rural.ses.med21[4]     0.78 1.00     4441     2419
## deplonely_mosttran_devx2:rural.ses.med31[1]     0.72 1.00     5619     2541
## deplonely_mosttran_devx2:rural.ses.med31[2]     0.65 1.00     4423     2876
## deplonely_mosttran_devx2:rural.ses.med31[3]     0.64 1.00     3985     2805
## deplonely_mosttran_devx2:rural.ses.med31[4]     0.80 1.00     4328     2377
## deplonely_mosttran_devx2:rural.ses.med41[1]     0.61 1.00     3912     2861
## deplonely_mosttran_devx2:rural.ses.med41[2]     0.55 1.00     5228     2839
## deplonely_mosttran_devx2:rural.ses.med41[3]     0.78 1.00     3418     2236
## deplonely_mosttran_devx2:rural.ses.med41[4]     0.70 1.00     6604     2934
## depblues_mosttran_devx21[1]                     0.59 1.00     4981     2084
## depblues_mosttran_devx21[2]                     0.53 1.00     6783     2739
## depblues_mosttran_devx21[3]                     0.59 1.00     5037     2822
## depblues_mosttran_devx21[4]                     0.59 1.00     7085     2646
## depblues_mosttran_av12x21[1]                    0.32 1.00     7471     2677
## depblues_mosttran_av12x21[2]                    0.33 1.01     7306     2222
## depblues_mosttran_av12x21[3]                    0.31 1.00     7403     2507
## depblues_mosttran_av12x21[4]                    0.33 1.00     8072     2542
## depblues_mosttran_av12x21[5]                    0.29 1.00     6951     2334
## depblues_mosttran_av12x21[6]                    0.30 1.00     7849     2091
## depblues_mosttran_av12x21[7]                    0.33 1.00     7655     2857
## depblues_mosttran_av12x21[8]                    0.33 1.00     7311     2702
## depblues_mosttran_devx2:rural.ses.med21[1]      0.68 1.00     5661     2485
## depblues_mosttran_devx2:rural.ses.med21[2]      0.62 1.00     4974     2366
## depblues_mosttran_devx2:rural.ses.med21[3]      0.75 1.00     4921     3134
## depblues_mosttran_devx2:rural.ses.med21[4]      0.77 1.00     6081     2869
## depblues_mosttran_devx2:rural.ses.med31[1]      0.69 1.00     5314     2063
## depblues_mosttran_devx2:rural.ses.med31[2]      0.63 1.00     5959     2739
## depblues_mosttran_devx2:rural.ses.med31[3]      0.69 1.00     4331     2649
## depblues_mosttran_devx2:rural.ses.med31[4]      0.78 1.00     5391     2834
## depblues_mosttran_devx2:rural.ses.med41[1]      0.74 1.00     5013     1885
## depblues_mosttran_devx2:rural.ses.med41[2]      0.65 1.00     4714     2351
## depblues_mosttran_devx2:rural.ses.med41[3]      0.69 1.00     4743     2943
## depblues_mosttran_devx2:rural.ses.med41[4]      0.75 1.00     4639     2625
## depunfair_mosttran_devx21[1]                    0.47 1.00     5015     2941
## depunfair_mosttran_devx21[2]                    0.61 1.00     5313     2657
## depunfair_mosttran_devx21[3]                    0.58 1.00     5198     2827
## depunfair_mosttran_devx21[4]                    0.51 1.00     7296     2853
## depunfair_mosttran_av12x21[1]                   0.32 1.00     6551     2257
## depunfair_mosttran_av12x21[2]                   0.31 1.00     6552     2254
## depunfair_mosttran_av12x21[3]                   0.29 1.00     7506     2401
## depunfair_mosttran_av12x21[4]                   0.29 1.00     9009     2897
## depunfair_mosttran_av12x21[5]                   0.29 1.00     7400     2889
## depunfair_mosttran_av12x21[6]                   0.32 1.00     7083     2311
## depunfair_mosttran_av12x21[7]                   0.38 1.00     7614     3018
## depunfair_mosttran_av12x21[8]                   0.33 1.00     6687     2836
## depunfair_mosttran_devx2:rural.ses.med21[1]     0.66 1.00     4968     2456
## depunfair_mosttran_devx2:rural.ses.med21[2]     0.79 1.00     2998     2189
## depunfair_mosttran_devx2:rural.ses.med21[3]     0.56 1.00     5113     2788
## depunfair_mosttran_devx2:rural.ses.med21[4]     0.71 1.00     5432     2572
## depunfair_mosttran_devx2:rural.ses.med31[1]     0.74 1.00     6063     2940
## depunfair_mosttran_devx2:rural.ses.med31[2]     0.66 1.00     5469     2781
## depunfair_mosttran_devx2:rural.ses.med31[3]     0.62 1.00     5146     2344
## depunfair_mosttran_devx2:rural.ses.med31[4]     0.76 1.00     5669     2990
## depunfair_mosttran_devx2:rural.ses.med41[1]     0.69 1.00     4088     2710
## depunfair_mosttran_devx2:rural.ses.med41[2]     0.63 1.00     6782     2729
## depunfair_mosttran_devx2:rural.ses.med41[3]     0.71 1.00     3769     2595
## depunfair_mosttran_devx2:rural.ses.med41[4]     0.74 1.00     6163     2195
## depmistrt_mosttran_devx21[1]                    0.56 1.00     4024     3056
## depmistrt_mosttran_devx21[2]                    0.50 1.00     8454     2639
## depmistrt_mosttran_devx21[3]                    0.66 1.00     2849     2654
## depmistrt_mosttran_devx21[4]                    0.56 1.00     7923     2931
## depmistrt_mosttran_av12x21[1]                   0.33 1.00     7373     2625
## depmistrt_mosttran_av12x21[2]                   0.35 1.00     7178     2601
## depmistrt_mosttran_av12x21[3]                   0.33 1.00     7387     2781
## depmistrt_mosttran_av12x21[4]                   0.28 1.00     8335     2734
## depmistrt_mosttran_av12x21[5]                   0.27 1.00     7167     2739
## depmistrt_mosttran_av12x21[6]                   0.28 1.00     6428     3233
## depmistrt_mosttran_av12x21[7]                   0.36 1.00     7184     2921
## depmistrt_mosttran_av12x21[8]                   0.34 1.00     7323     2396
## depmistrt_mosttran_devx2:rural.ses.med21[1]     0.71 1.00     5790     2540
## depmistrt_mosttran_devx2:rural.ses.med21[2]     0.62 1.00     5437     2790
## depmistrt_mosttran_devx2:rural.ses.med21[3]     0.65 1.00     4196     2296
## depmistrt_mosttran_devx2:rural.ses.med21[4]     0.79 1.00     4929     2637
## depmistrt_mosttran_devx2:rural.ses.med31[1]     0.68 1.00     5295     2010
## depmistrt_mosttran_devx2:rural.ses.med31[2]     0.69 1.00     4883     2620
## depmistrt_mosttran_devx2:rural.ses.med31[3]     0.64 1.00     5025     2690
## depmistrt_mosttran_devx2:rural.ses.med31[4]     0.79 1.00     4831     2821
## depmistrt_mosttran_devx2:rural.ses.med41[1]     0.70 1.00     6738     2491
## depmistrt_mosttran_devx2:rural.ses.med41[2]     0.68 1.00     4803     2669
## depmistrt_mosttran_devx2:rural.ses.med41[3]     0.66 1.00     4722     2958
## depmistrt_mosttran_devx2:rural.ses.med41[4]     0.78 1.00     4969     2673
## depbetray_mosttran_devx21[1]                    0.58 1.00     7298     2757
## depbetray_mosttran_devx21[2]                    0.55 1.00     7551     2578
## depbetray_mosttran_devx21[3]                    0.55 1.00     7642     3101
## depbetray_mosttran_devx21[4]                    0.60 1.00     7933     2634
## depbetray_mosttran_av12x21[1]                   0.31 1.00     8182     2750
## depbetray_mosttran_av12x21[2]                   0.33 1.00     7994     2338
## depbetray_mosttran_av12x21[3]                   0.31 1.00     8665     2553
## depbetray_mosttran_av12x21[4]                   0.29 1.00     8010     2701
## depbetray_mosttran_av12x21[5]                   0.26 1.00     6796     2916
## depbetray_mosttran_av12x21[6]                   0.31 1.00     8284     2603
## depbetray_mosttran_av12x21[7]                   0.39 1.00     6375     3094
## depbetray_mosttran_av12x21[8]                   0.30 1.00     8611     2754
## depbetray_mosttran_devx2:rural.ses.med21[1]     0.69 1.00     5678     2668
## depbetray_mosttran_devx2:rural.ses.med21[2]     0.61 1.00     6190     2627
## depbetray_mosttran_devx2:rural.ses.med21[3]     0.68 1.00     5178     2914
## depbetray_mosttran_devx2:rural.ses.med21[4]     0.77 1.00     4946     2360
## depbetray_mosttran_devx2:rural.ses.med31[1]     0.71 1.00     5024     2519
## depbetray_mosttran_devx2:rural.ses.med31[2]     0.65 1.00     5855     3089
## depbetray_mosttran_devx2:rural.ses.med31[3]     0.71 1.00     4119     3193
## depbetray_mosttran_devx2:rural.ses.med31[4]     0.78 1.00     5519     3219
## depbetray_mosttran_devx2:rural.ses.med41[1]     0.70 1.00     5200     2818
## depbetray_mosttran_devx2:rural.ses.med41[2]     0.66 1.00     5188     2255
## depbetray_mosttran_devx2:rural.ses.med41[3]     0.64 1.00     5140     2767
## depbetray_mosttran_devx2:rural.ses.med41[4]     0.76 1.00     6337     2726
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.2.2.4 Prior summary
out.chg.alldepress.sttran.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mosttran_av12x2
##                    normal(0, 0.25)         b                 mosttran_devx2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med2
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med3
##                       normal(0, 1)         b  mosttran_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mosttran_av12x21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med21
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med31
##                       dirichlet(1)      simo mosttran_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mosttran_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##        depbetray                          user
##        depbetray                          user
##        depbetray                          user
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##         depblues                          user
##         depblues                          user
##         depblues                          user
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depeffort                          user
##        depeffort                          user
##        depeffort                          user
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        deplonely                          user
##        deplonely                          user
##        deplonely                          user
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depunfair                          user
##        depunfair                          user
##        depunfair                          user
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##                                        default
##        depbetray                          user
##         depblues                          user
##        depcantgo                          user
##        depeffort                          user
##        deplonely                          user
##        depmistrt                          user
##        depunfair                          user
##        depbetray             0         default
##         depblues             0         default
##        depcantgo             0         default
##        depeffort             0         default
##        deplonely             0         default
##        depmistrt             0         default
##        depunfair             0         default
##     id depbetray             0    (vectorized)
##     id depbetray             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depunfair             0    (vectorized)
##     id depunfair             0    (vectorized)
##        depbetray                          user
##        depbetray                       default
##        depbetray                       default
##        depbetray                       default
##        depbetray                          user
##         depblues                          user
##         depblues                       default
##         depblues                       default
##         depblues                       default
##         depblues                          user
##        depcantgo                          user
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                          user
##        depeffort                          user
##        depeffort                       default
##        depeffort                       default
##        depeffort                       default
##        depeffort                          user
##        deplonely                          user
##        deplonely                       default
##        deplonely                       default
##        deplonely                       default
##        deplonely                          user
##        depmistrt                          user
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                          user
##        depunfair                          user
##        depunfair                       default
##        depunfair                       default
##        depunfair                       default
##        depunfair                          user

8.1.2.3 Corr X Community: stresp & negative emotions

#Community Change: negative emotions items ~ mo(stresp)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostresp_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostresp_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostresp_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostresp_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stresp.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + 
         rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stresp_comm_fit",
      file_refit = "on_change"
  )


out.chg.alldepress.stresp.comm.fit <- ppchecks(chg.alldepress.stresp.comm.fit)
8.1.2.3.1 Coefficient plot (intervals)
out.chg.alldepress.stresp.comm.fit[[11]]

8.1.2.3.2 PPcheck (density)
p1 <- out.chg.alldepress.stresp.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stresp.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stresp.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stresp.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stresp.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stresp.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stresp.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

8.1.2.3.3 Fit summary
out.chg.alldepress.stresp.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          depeffort ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          deplonely ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          depblues ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          depunfair ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##          depbetray ~ 1 + mo(stresp_devx2) + mo(stresp_av12x2) + rural.ses.med + mo(stresp_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.31      0.20     0.02     0.73 1.01      525
## sd(depeffort_Intercept)     0.44      0.27     0.02     0.99 1.00      759
## sd(deplonely_Intercept)     0.41      0.24     0.02     0.89 1.01      543
## sd(depblues_Intercept)      0.68      0.33     0.06     1.29 1.00      560
## sd(depunfair_Intercept)     0.23      0.17     0.01     0.62 1.01      967
## sd(depmistrt_Intercept)     0.30      0.21     0.01     0.74 1.00      850
## sd(depbetray_Intercept)     0.41      0.25     0.03     0.94 1.01      608
##                         Tail_ESS
## sd(depcantgo_Intercept)     1379
## sd(depeffort_Intercept)     1575
## sd(deplonely_Intercept)     1178
## sd(depblues_Intercept)       763
## sd(depunfair_Intercept)     2032
## sd(depmistrt_Intercept)     1570
## sd(depbetray_Intercept)     1720
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## depcantgo_Intercept                        -0.53      0.32    -1.18     0.11
## depeffort_Intercept                        -2.36      0.43    -3.27    -1.58
## deplonely_Intercept                        -1.05      0.34    -1.74    -0.36
## depblues_Intercept                         -2.16      0.43    -3.02    -1.28
## depunfair_Intercept                        -2.02      0.36    -2.71    -1.29
## depmistrt_Intercept                        -2.58      0.45    -3.46    -1.64
## depbetray_Intercept                        -2.92      0.42    -3.75    -2.10
## depcantgo_rural.ses.med2                    0.18      0.45    -0.68     1.14
## depcantgo_rural.ses.med3                    0.03      0.47    -1.08     0.86
## depcantgo_rural.ses.med4                    0.44      0.53    -0.47     1.59
## depeffort_rural.ses.med2                   -0.43      0.58    -1.63     0.62
## depeffort_rural.ses.med3                    0.13      0.57    -1.16     1.15
## depeffort_rural.ses.med4                    0.68      0.51    -0.32     1.69
## deplonely_rural.ses.med2                   -0.56      0.48    -1.49     0.47
## deplonely_rural.ses.med3                   -0.27      0.46    -1.25     0.61
## deplonely_rural.ses.med4                    0.26      0.44    -0.61     1.20
## depblues_rural.ses.med2                     0.31      0.59    -0.75     1.57
## depblues_rural.ses.med3                     0.33      0.54    -0.87     1.29
## depblues_rural.ses.med4                     0.22      0.55    -0.95     1.24
## depunfair_rural.ses.med2                   -0.70      0.53    -1.80     0.27
## depunfair_rural.ses.med3                    0.65      0.45    -0.31     1.52
## depunfair_rural.ses.med4                    0.62      0.47    -0.39     1.47
## depmistrt_rural.ses.med2                    0.14      0.63    -1.23     1.28
## depmistrt_rural.ses.med3                    0.30      0.50    -0.69     1.30
## depmistrt_rural.ses.med4                    0.18      0.57    -0.97     1.25
## depbetray_rural.ses.med2                    0.37      0.58    -0.92     1.45
## depbetray_rural.ses.med3                    0.98      0.51     0.02     2.08
## depbetray_rural.ses.med4                    0.83      0.54    -0.31     1.82
## depcantgo_mostresp_devx2                    0.10      0.14    -0.18     0.37
## depcantgo_mostresp_av12x2                  -0.03      0.03    -0.08     0.02
## depcantgo_mostresp_devx2:rural.ses.med2     0.04      0.23    -0.49     0.44
## depcantgo_mostresp_devx2:rural.ses.med3     0.03      0.21    -0.34     0.51
## depcantgo_mostresp_devx2:rural.ses.med4    -0.14      0.23    -0.59     0.29
## depeffort_mostresp_devx2                    0.08      0.16    -0.23     0.41
## depeffort_mostresp_av12x2                   0.04      0.03    -0.03     0.11
## depeffort_mostresp_devx2:rural.ses.med2     0.22      0.27    -0.29     0.78
## depeffort_mostresp_devx2:rural.ses.med3     0.18      0.26    -0.27     0.74
## depeffort_mostresp_devx2:rural.ses.med4    -0.10      0.24    -0.59     0.38
## deplonely_mostresp_devx2                    0.01      0.14    -0.27     0.30
## deplonely_mostresp_av12x2                   0.01      0.03    -0.05     0.06
## deplonely_mostresp_devx2:rural.ses.med2     0.12      0.23    -0.37     0.56
## deplonely_mostresp_devx2:rural.ses.med3     0.10      0.21    -0.32     0.51
## deplonely_mostresp_devx2:rural.ses.med4     0.11      0.22    -0.32     0.53
## depblues_mostresp_devx2                    -0.11      0.16    -0.43     0.21
## depblues_mostresp_av12x2                    0.02      0.04    -0.06     0.09
## depblues_mostresp_devx2:rural.ses.med2     -0.02      0.29    -0.62     0.52
## depblues_mostresp_devx2:rural.ses.med3     -0.04      0.31    -0.77     0.50
## depblues_mostresp_devx2:rural.ses.med4      0.23      0.27    -0.27     0.78
## depunfair_mostresp_devx2                    0.10      0.15    -0.23     0.37
## depunfair_mostresp_av12x2                   0.05      0.03    -0.00     0.11
## depunfair_mostresp_devx2:rural.ses.med2     0.52      0.23     0.11     0.99
## depunfair_mostresp_devx2:rural.ses.med3     0.05      0.21    -0.35     0.48
## depunfair_mostresp_devx2:rural.ses.med4     0.20      0.21    -0.21     0.64
## depmistrt_mostresp_devx2                   -0.07      0.18    -0.42     0.28
## depmistrt_mostresp_av12x2                   0.13      0.03     0.07     0.20
## depmistrt_mostresp_devx2:rural.ses.med2     0.40      0.43    -0.31     1.27
## depmistrt_mostresp_devx2:rural.ses.med3     0.18      0.24    -0.28     0.65
## depmistrt_mostresp_devx2:rural.ses.med4     0.24      0.24    -0.28     0.69
## depbetray_mostresp_devx2                    0.08      0.16    -0.23     0.38
## depbetray_mostresp_av12x2                   0.10      0.03     0.04     0.17
## depbetray_mostresp_devx2:rural.ses.med2     0.02      0.30    -0.67     0.55
## depbetray_mostresp_devx2:rural.ses.med3    -0.09      0.24    -0.58     0.38
## depbetray_mostresp_devx2:rural.ses.med4     0.09      0.24    -0.36     0.59
##                                         Rhat Bulk_ESS Tail_ESS
## depcantgo_Intercept                     1.00     2962     2980
## depeffort_Intercept                     1.00     3267     2956
## deplonely_Intercept                     1.00     2853     2986
## depblues_Intercept                      1.00     2963     2903
## depunfair_Intercept                     1.00     3012     2648
## depmistrt_Intercept                     1.00     2643     2819
## depbetray_Intercept                     1.00     2743     2715
## depcantgo_rural.ses.med2                1.00     3458     2849
## depcantgo_rural.ses.med3                1.00     2601     2578
## depcantgo_rural.ses.med4                1.00     3023     2898
## depeffort_rural.ses.med2                1.00     3944     2990
## depeffort_rural.ses.med3                1.00     3293     2783
## depeffort_rural.ses.med4                1.00     4181     2856
## deplonely_rural.ses.med2                1.00     3058     2569
## deplonely_rural.ses.med3                1.00     2453     2461
## deplonely_rural.ses.med4                1.00     3378     3065
## depblues_rural.ses.med2                 1.00     3248     2689
## depblues_rural.ses.med3                 1.00     3304     2648
## depblues_rural.ses.med4                 1.00     3789     2942
## depunfair_rural.ses.med2                1.00     3776     2590
## depunfair_rural.ses.med3                1.00     3110     2319
## depunfair_rural.ses.med4                1.00     3083     2344
## depmistrt_rural.ses.med2                1.00     2315     2794
## depmistrt_rural.ses.med3                1.00     3561     2776
## depmistrt_rural.ses.med4                1.00     2991     2987
## depbetray_rural.ses.med2                1.00     3334     2679
## depbetray_rural.ses.med3                1.00     2995     2906
## depbetray_rural.ses.med4                1.00     3255     2964
## depcantgo_mostresp_devx2                1.00     2550     2752
## depcantgo_mostresp_av12x2               1.00     7460     3242
## depcantgo_mostresp_devx2:rural.ses.med2 1.00     2857     2768
## depcantgo_mostresp_devx2:rural.ses.med3 1.00     2321     2381
## depcantgo_mostresp_devx2:rural.ses.med4 1.00     2819     3216
## depeffort_mostresp_devx2                1.00     3127     3315
## depeffort_mostresp_av12x2               1.00     6638     3070
## depeffort_mostresp_devx2:rural.ses.med2 1.00     3850     3134
## depeffort_mostresp_devx2:rural.ses.med3 1.00     3299     3369
## depeffort_mostresp_devx2:rural.ses.med4 1.00     4137     3091
## deplonely_mostresp_devx2                1.00     2788     3094
## deplonely_mostresp_av12x2               1.00     6035     3108
## deplonely_mostresp_devx2:rural.ses.med2 1.00     2779     2309
## deplonely_mostresp_devx2:rural.ses.med3 1.00     2621     2727
## deplonely_mostresp_devx2:rural.ses.med4 1.00     3200     2719
## depblues_mostresp_devx2                 1.00     3048     3140
## depblues_mostresp_av12x2                1.00     5719     3191
## depblues_mostresp_devx2:rural.ses.med2  1.00     3194     3078
## depblues_mostresp_devx2:rural.ses.med3  1.00     2594     2388
## depblues_mostresp_devx2:rural.ses.med4  1.00     3575     3023
## depunfair_mostresp_devx2                1.00     2790     2657
## depunfair_mostresp_av12x2               1.00     6670     3194
## depunfair_mostresp_devx2:rural.ses.med2 1.00     2761     2748
## depunfair_mostresp_devx2:rural.ses.med3 1.00     3032     2654
## depunfair_mostresp_devx2:rural.ses.med4 1.00     3258     2790
## depmistrt_mostresp_devx2                1.00     2145     3034
## depmistrt_mostresp_av12x2               1.00     6116     2882
## depmistrt_mostresp_devx2:rural.ses.med2 1.00     1940     2629
## depmistrt_mostresp_devx2:rural.ses.med3 1.00     2738     2969
## depmistrt_mostresp_devx2:rural.ses.med4 1.00     2567     2505
## depbetray_mostresp_devx2                1.00     2730     3071
## depbetray_mostresp_av12x2               1.00     6319     3219
## depbetray_mostresp_devx2:rural.ses.med2 1.00     2752     2210
## depbetray_mostresp_devx2:rural.ses.med3 1.00     2778     2896
## depbetray_mostresp_devx2:rural.ses.med4 1.00     3183     3059
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## depcantgo_mostresp_devx21[1]                    0.26      0.14     0.04
## depcantgo_mostresp_devx21[2]                    0.21      0.13     0.03
## depcantgo_mostresp_devx21[3]                    0.27      0.14     0.04
## depcantgo_mostresp_devx21[4]                    0.26      0.15     0.04
## depcantgo_mostresp_av12x21[1]                   0.13      0.08     0.02
## depcantgo_mostresp_av12x21[2]                   0.13      0.09     0.01
## depcantgo_mostresp_av12x21[3]                   0.12      0.08     0.01
## depcantgo_mostresp_av12x21[4]                   0.11      0.07     0.01
## depcantgo_mostresp_av12x21[5]                   0.12      0.08     0.02
## depcantgo_mostresp_av12x21[6]                   0.12      0.08     0.02
## depcantgo_mostresp_av12x21[7]                   0.12      0.08     0.02
## depcantgo_mostresp_av12x21[8]                   0.14      0.09     0.02
## depcantgo_mostresp_devx2:rural.ses.med21[1]     0.26      0.19     0.01
## depcantgo_mostresp_devx2:rural.ses.med21[2]     0.21      0.17     0.01
## depcantgo_mostresp_devx2:rural.ses.med21[3]     0.25      0.20     0.01
## depcantgo_mostresp_devx2:rural.ses.med21[4]     0.28      0.21     0.01
## depcantgo_mostresp_devx2:rural.ses.med31[1]     0.28      0.21     0.01
## depcantgo_mostresp_devx2:rural.ses.med31[2]     0.22      0.19     0.01
## depcantgo_mostresp_devx2:rural.ses.med31[3]     0.21      0.17     0.01
## depcantgo_mostresp_devx2:rural.ses.med31[4]     0.29      0.21     0.01
## depcantgo_mostresp_devx2:rural.ses.med41[1]     0.28      0.20     0.01
## depcantgo_mostresp_devx2:rural.ses.med41[2]     0.27      0.20     0.01
## depcantgo_mostresp_devx2:rural.ses.med41[3]     0.19      0.17     0.00
## depcantgo_mostresp_devx2:rural.ses.med41[4]     0.25      0.19     0.01
## depeffort_mostresp_devx21[1]                    0.27      0.15     0.04
## depeffort_mostresp_devx21[2]                    0.25      0.14     0.04
## depeffort_mostresp_devx21[3]                    0.22      0.14     0.03
## depeffort_mostresp_devx21[4]                    0.26      0.15     0.04
## depeffort_mostresp_av12x21[1]                   0.12      0.08     0.02
## depeffort_mostresp_av12x21[2]                   0.14      0.09     0.02
## depeffort_mostresp_av12x21[3]                   0.12      0.07     0.02
## depeffort_mostresp_av12x21[4]                   0.12      0.08     0.02
## depeffort_mostresp_av12x21[5]                   0.12      0.08     0.02
## depeffort_mostresp_av12x21[6]                   0.13      0.08     0.02
## depeffort_mostresp_av12x21[7]                   0.13      0.08     0.02
## depeffort_mostresp_av12x21[8]                   0.13      0.08     0.02
## depeffort_mostresp_devx2:rural.ses.med21[1]     0.24      0.19     0.01
## depeffort_mostresp_devx2:rural.ses.med21[2]     0.28      0.20     0.01
## depeffort_mostresp_devx2:rural.ses.med21[3]     0.20      0.17     0.01
## depeffort_mostresp_devx2:rural.ses.med21[4]     0.28      0.20     0.01
## depeffort_mostresp_devx2:rural.ses.med31[1]     0.29      0.20     0.01
## depeffort_mostresp_devx2:rural.ses.med31[2]     0.21      0.17     0.01
## depeffort_mostresp_devx2:rural.ses.med31[3]     0.19      0.17     0.00
## depeffort_mostresp_devx2:rural.ses.med31[4]     0.32      0.21     0.01
## depeffort_mostresp_devx2:rural.ses.med41[1]     0.25      0.19     0.01
## depeffort_mostresp_devx2:rural.ses.med41[2]     0.23      0.19     0.01
## depeffort_mostresp_devx2:rural.ses.med41[3]     0.23      0.18     0.01
## depeffort_mostresp_devx2:rural.ses.med41[4]     0.28      0.21     0.01
## deplonely_mostresp_devx21[1]                    0.26      0.15     0.04
## deplonely_mostresp_devx21[2]                    0.24      0.14     0.04
## deplonely_mostresp_devx21[3]                    0.24      0.14     0.04
## deplonely_mostresp_devx21[4]                    0.26      0.15     0.04
## deplonely_mostresp_av12x21[1]                   0.13      0.08     0.02
## deplonely_mostresp_av12x21[2]                   0.13      0.08     0.02
## deplonely_mostresp_av12x21[3]                   0.12      0.08     0.02
## deplonely_mostresp_av12x21[4]                   0.12      0.08     0.02
## deplonely_mostresp_av12x21[5]                   0.12      0.08     0.02
## deplonely_mostresp_av12x21[6]                   0.12      0.08     0.02
## deplonely_mostresp_av12x21[7]                   0.12      0.08     0.02
## deplonely_mostresp_av12x21[8]                   0.13      0.08     0.02
## deplonely_mostresp_devx2:rural.ses.med21[1]     0.24      0.19     0.01
## deplonely_mostresp_devx2:rural.ses.med21[2]     0.20      0.16     0.01
## deplonely_mostresp_devx2:rural.ses.med21[3]     0.28      0.20     0.01
## deplonely_mostresp_devx2:rural.ses.med21[4]     0.28      0.20     0.01
## deplonely_mostresp_devx2:rural.ses.med31[1]     0.27      0.19     0.01
## deplonely_mostresp_devx2:rural.ses.med31[2]     0.25      0.19     0.01
## deplonely_mostresp_devx2:rural.ses.med31[3]     0.21      0.17     0.01
## deplonely_mostresp_devx2:rural.ses.med31[4]     0.28      0.20     0.01
## deplonely_mostresp_devx2:rural.ses.med41[1]     0.25      0.19     0.01
## deplonely_mostresp_devx2:rural.ses.med41[2]     0.21      0.17     0.01
## deplonely_mostresp_devx2:rural.ses.med41[3]     0.27      0.19     0.01
## deplonely_mostresp_devx2:rural.ses.med41[4]     0.28      0.20     0.01
## depblues_mostresp_devx21[1]                     0.26      0.14     0.04
## depblues_mostresp_devx21[2]                     0.24      0.14     0.04
## depblues_mostresp_devx21[3]                     0.24      0.14     0.04
## depblues_mostresp_devx21[4]                     0.26      0.15     0.04
## depblues_mostresp_av12x21[1]                    0.12      0.08     0.02
## depblues_mostresp_av12x21[2]                    0.12      0.08     0.02
## depblues_mostresp_av12x21[3]                    0.12      0.08     0.02
## depblues_mostresp_av12x21[4]                    0.12      0.08     0.02
## depblues_mostresp_av12x21[5]                    0.12      0.08     0.01
## depblues_mostresp_av12x21[6]                    0.13      0.09     0.02
## depblues_mostresp_av12x21[7]                    0.13      0.08     0.02
## depblues_mostresp_av12x21[8]                    0.13      0.08     0.02
## depblues_mostresp_devx2:rural.ses.med21[1]      0.27      0.21     0.01
## depblues_mostresp_devx2:rural.ses.med21[2]      0.22      0.19     0.01
## depblues_mostresp_devx2:rural.ses.med21[3]      0.23      0.18     0.01
## depblues_mostresp_devx2:rural.ses.med21[4]      0.28      0.20     0.01
## depblues_mostresp_devx2:rural.ses.med31[1]      0.26      0.20     0.01
## depblues_mostresp_devx2:rural.ses.med31[2]      0.21      0.17     0.01
## depblues_mostresp_devx2:rural.ses.med31[3]      0.22      0.17     0.01
## depblues_mostresp_devx2:rural.ses.med31[4]      0.31      0.22     0.01
## depblues_mostresp_devx2:rural.ses.med41[1]      0.25      0.19     0.01
## depblues_mostresp_devx2:rural.ses.med41[2]      0.19      0.17     0.00
## depblues_mostresp_devx2:rural.ses.med41[3]      0.26      0.19     0.01
## depblues_mostresp_devx2:rural.ses.med41[4]      0.29      0.20     0.01
## depunfair_mostresp_devx21[1]                    0.23      0.14     0.03
## depunfair_mostresp_devx21[2]                    0.25      0.14     0.04
## depunfair_mostresp_devx21[3]                    0.25      0.14     0.04
## depunfair_mostresp_devx21[4]                    0.26      0.14     0.04
## depunfair_mostresp_av12x21[1]                   0.11      0.07     0.01
## depunfair_mostresp_av12x21[2]                   0.13      0.08     0.02
## depunfair_mostresp_av12x21[3]                   0.13      0.08     0.02
## depunfair_mostresp_av12x21[4]                   0.12      0.08     0.02
## depunfair_mostresp_av12x21[5]                   0.12      0.08     0.01
## depunfair_mostresp_av12x21[6]                   0.12      0.08     0.02
## depunfair_mostresp_av12x21[7]                   0.14      0.08     0.02
## depunfair_mostresp_av12x21[8]                   0.14      0.08     0.02
## depunfair_mostresp_devx2:rural.ses.med21[1]     0.12      0.11     0.00
## depunfair_mostresp_devx2:rural.ses.med21[2]     0.43      0.18     0.07
## depunfair_mostresp_devx2:rural.ses.med21[3]     0.21      0.14     0.01
## depunfair_mostresp_devx2:rural.ses.med21[4]     0.24      0.16     0.01
## depunfair_mostresp_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## depunfair_mostresp_devx2:rural.ses.med31[2]     0.23      0.18     0.01
## depunfair_mostresp_devx2:rural.ses.med31[3]     0.22      0.17     0.01
## depunfair_mostresp_devx2:rural.ses.med31[4]     0.28      0.20     0.01
## depunfair_mostresp_devx2:rural.ses.med41[1]     0.26      0.18     0.01
## depunfair_mostresp_devx2:rural.ses.med41[2]     0.25      0.18     0.01
## depunfair_mostresp_devx2:rural.ses.med41[3]     0.23      0.16     0.01
## depunfair_mostresp_devx2:rural.ses.med41[4]     0.27      0.19     0.01
## depmistrt_mostresp_devx21[1]                    0.29      0.16     0.04
## depmistrt_mostresp_devx21[2]                    0.22      0.14     0.03
## depmistrt_mostresp_devx21[3]                    0.24      0.14     0.04
## depmistrt_mostresp_devx21[4]                    0.25      0.15     0.04
## depmistrt_mostresp_av12x21[1]                   0.09      0.06     0.01
## depmistrt_mostresp_av12x21[2]                   0.12      0.07     0.02
## depmistrt_mostresp_av12x21[3]                   0.14      0.08     0.02
## depmistrt_mostresp_av12x21[4]                   0.15      0.09     0.02
## depmistrt_mostresp_av12x21[5]                   0.12      0.07     0.02
## depmistrt_mostresp_av12x21[6]                   0.13      0.08     0.02
## depmistrt_mostresp_av12x21[7]                   0.13      0.08     0.02
## depmistrt_mostresp_av12x21[8]                   0.13      0.08     0.02
## depmistrt_mostresp_devx2:rural.ses.med21[1]     0.25      0.18     0.01
## depmistrt_mostresp_devx2:rural.ses.med21[2]     0.15      0.15     0.00
## depmistrt_mostresp_devx2:rural.ses.med21[3]     0.15      0.16     0.00
## depmistrt_mostresp_devx2:rural.ses.med21[4]     0.45      0.26     0.02
## depmistrt_mostresp_devx2:rural.ses.med31[1]     0.24      0.18     0.01
## depmistrt_mostresp_devx2:rural.ses.med31[2]     0.25      0.18     0.01
## depmistrt_mostresp_devx2:rural.ses.med31[3]     0.22      0.17     0.01
## depmistrt_mostresp_devx2:rural.ses.med31[4]     0.30      0.20     0.01
## depmistrt_mostresp_devx2:rural.ses.med41[1]     0.21      0.18     0.01
## depmistrt_mostresp_devx2:rural.ses.med41[2]     0.35      0.22     0.02
## depmistrt_mostresp_devx2:rural.ses.med41[3]     0.20      0.16     0.01
## depmistrt_mostresp_devx2:rural.ses.med41[4]     0.24      0.18     0.01
## depbetray_mostresp_devx21[1]                    0.25      0.14     0.04
## depbetray_mostresp_devx21[2]                    0.24      0.14     0.04
## depbetray_mostresp_devx21[3]                    0.24      0.14     0.04
## depbetray_mostresp_devx21[4]                    0.26      0.14     0.04
## depbetray_mostresp_av12x21[1]                   0.11      0.07     0.01
## depbetray_mostresp_av12x21[2]                   0.13      0.08     0.02
## depbetray_mostresp_av12x21[3]                   0.13      0.08     0.02
## depbetray_mostresp_av12x21[4]                   0.14      0.08     0.02
## depbetray_mostresp_av12x21[5]                   0.13      0.08     0.02
## depbetray_mostresp_av12x21[6]                   0.14      0.09     0.02
## depbetray_mostresp_av12x21[7]                   0.13      0.08     0.02
## depbetray_mostresp_av12x21[8]                   0.10      0.07     0.01
## depbetray_mostresp_devx2:rural.ses.med21[1]     0.27      0.20     0.01
## depbetray_mostresp_devx2:rural.ses.med21[2]     0.22      0.18     0.01
## depbetray_mostresp_devx2:rural.ses.med21[3]     0.21      0.17     0.01
## depbetray_mostresp_devx2:rural.ses.med21[4]     0.29      0.22     0.01
## depbetray_mostresp_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## depbetray_mostresp_devx2:rural.ses.med31[2]     0.20      0.17     0.01
## depbetray_mostresp_devx2:rural.ses.med31[3]     0.26      0.19     0.01
## depbetray_mostresp_devx2:rural.ses.med31[4]     0.27      0.20     0.01
## depbetray_mostresp_devx2:rural.ses.med41[1]     0.28      0.20     0.01
## depbetray_mostresp_devx2:rural.ses.med41[2]     0.21      0.18     0.01
## depbetray_mostresp_devx2:rural.ses.med41[3]     0.23      0.18     0.01
## depbetray_mostresp_devx2:rural.ses.med41[4]     0.27      0.20     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## depcantgo_mostresp_devx21[1]                    0.58 1.00     6901     2593
## depcantgo_mostresp_devx21[2]                    0.53 1.00     7431     3070
## depcantgo_mostresp_devx21[3]                    0.57 1.00     5555     2670
## depcantgo_mostresp_devx21[4]                    0.58 1.00     7779     3140
## depcantgo_mostresp_av12x21[1]                   0.33 1.00     8749     2821
## depcantgo_mostresp_av12x21[2]                   0.33 1.00     9293     2270
## depcantgo_mostresp_av12x21[3]                   0.31 1.00     7196     2139
## depcantgo_mostresp_av12x21[4]                   0.30 1.00     7618     2699
## depcantgo_mostresp_av12x21[5]                   0.30 1.00     7833     3104
## depcantgo_mostresp_av12x21[6]                   0.31 1.00     7337     2553
## depcantgo_mostresp_av12x21[7]                   0.31 1.00     7224     2678
## depcantgo_mostresp_av12x21[8]                   0.35 1.00     6692     2878
## depcantgo_mostresp_devx2:rural.ses.med21[1]     0.69 1.00     5838     2448
## depcantgo_mostresp_devx2:rural.ses.med21[2]     0.64 1.00     7078     2971
## depcantgo_mostresp_devx2:rural.ses.med21[3]     0.70 1.00     4158     2827
## depcantgo_mostresp_devx2:rural.ses.med21[4]     0.75 1.00     5177     2896
## depcantgo_mostresp_devx2:rural.ses.med31[1]     0.74 1.00     4748     2674
## depcantgo_mostresp_devx2:rural.ses.med31[2]     0.68 1.00     3971     2755
## depcantgo_mostresp_devx2:rural.ses.med31[3]     0.63 1.00     5211     2740
## depcantgo_mostresp_devx2:rural.ses.med31[4]     0.73 1.00     5586     2917
## depcantgo_mostresp_devx2:rural.ses.med41[1]     0.72 1.00     5754     2212
## depcantgo_mostresp_devx2:rural.ses.med41[2]     0.73 1.00     5515     2699
## depcantgo_mostresp_devx2:rural.ses.med41[3]     0.64 1.00     4622     3191
## depcantgo_mostresp_devx2:rural.ses.med41[4]     0.71 1.00     6605     3031
## depeffort_mostresp_devx21[1]                    0.60 1.00     7610     3079
## depeffort_mostresp_devx21[2]                    0.57 1.00     5891     2915
## depeffort_mostresp_devx21[3]                    0.54 1.00     5364     3305
## depeffort_mostresp_devx21[4]                    0.59 1.00     6308     2460
## depeffort_mostresp_av12x21[1]                   0.31 1.00     7769     2600
## depeffort_mostresp_av12x21[2]                   0.35 1.00     8315     2679
## depeffort_mostresp_av12x21[3]                   0.30 1.00     6366     2063
## depeffort_mostresp_av12x21[4]                   0.30 1.00     7891     2388
## depeffort_mostresp_av12x21[5]                   0.31 1.00     6758     2578
## depeffort_mostresp_av12x21[6]                   0.33 1.00     6912     2121
## depeffort_mostresp_av12x21[7]                   0.31 1.00     7242     2640
## depeffort_mostresp_av12x21[8]                   0.33 1.00     8575     2517
## depeffort_mostresp_devx2:rural.ses.med21[1]     0.67 1.00     6654     2647
## depeffort_mostresp_devx2:rural.ses.med21[2]     0.72 1.00     6093     2352
## depeffort_mostresp_devx2:rural.ses.med21[3]     0.62 1.00     6012     2567
## depeffort_mostresp_devx2:rural.ses.med21[4]     0.73 1.00     6253     2897
## depeffort_mostresp_devx2:rural.ses.med31[1]     0.73 1.00     5334     2227
## depeffort_mostresp_devx2:rural.ses.med31[2]     0.64 1.00     5260     2474
## depeffort_mostresp_devx2:rural.ses.med31[3]     0.64 1.00     4734     2649
## depeffort_mostresp_devx2:rural.ses.med31[4]     0.77 1.00     5301     2873
## depeffort_mostresp_devx2:rural.ses.med41[1]     0.72 1.00     7871     2516
## depeffort_mostresp_devx2:rural.ses.med41[2]     0.69 1.00     6697     2004
## depeffort_mostresp_devx2:rural.ses.med41[3]     0.67 1.00     6708     2414
## depeffort_mostresp_devx2:rural.ses.med41[4]     0.73 1.00     5723     2321
## deplonely_mostresp_devx21[1]                    0.59 1.00     7148     2080
## deplonely_mostresp_devx21[2]                    0.56 1.00     7702     2976
## deplonely_mostresp_devx21[3]                    0.55 1.00     6149     2800
## deplonely_mostresp_devx21[4]                    0.60 1.01     8966     2546
## deplonely_mostresp_av12x21[1]                   0.33 1.00     8180     3064
## deplonely_mostresp_av12x21[2]                   0.33 1.00     7168     2700
## deplonely_mostresp_av12x21[3]                   0.31 1.00     6874     2356
## deplonely_mostresp_av12x21[4]                   0.32 1.00     8168     2466
## deplonely_mostresp_av12x21[5]                   0.31 1.00     8251     2596
## deplonely_mostresp_av12x21[6]                   0.32 1.00     7607     2871
## deplonely_mostresp_av12x21[7]                   0.32 1.00     7458     2765
## deplonely_mostresp_av12x21[8]                   0.33 1.00     6701     3092
## deplonely_mostresp_devx2:rural.ses.med21[1]     0.70 1.00     5388     2733
## deplonely_mostresp_devx2:rural.ses.med21[2]     0.60 1.00     4671     2580
## deplonely_mostresp_devx2:rural.ses.med21[3]     0.71 1.00     4000     2886
## deplonely_mostresp_devx2:rural.ses.med21[4]     0.73 1.00     6086     3021
## deplonely_mostresp_devx2:rural.ses.med31[1]     0.71 1.00     5792     2306
## deplonely_mostresp_devx2:rural.ses.med31[2]     0.69 1.00     6764     2623
## deplonely_mostresp_devx2:rural.ses.med31[3]     0.62 1.00     5026     2965
## deplonely_mostresp_devx2:rural.ses.med31[4]     0.73 1.00     6335     2649
## deplonely_mostresp_devx2:rural.ses.med41[1]     0.70 1.00     6100     2233
## deplonely_mostresp_devx2:rural.ses.med41[2]     0.62 1.00     7297     2611
## deplonely_mostresp_devx2:rural.ses.med41[3]     0.69 1.00     5253     2966
## deplonely_mostresp_devx2:rural.ses.med41[4]     0.73 1.00     6368     2547
## depblues_mostresp_devx21[1]                     0.58 1.00     7396     2830
## depblues_mostresp_devx21[2]                     0.56 1.00     8032     3021
## depblues_mostresp_devx21[3]                     0.55 1.00     7088     3012
## depblues_mostresp_devx21[4]                     0.58 1.00     7533     2171
## depblues_mostresp_av12x21[1]                    0.31 1.00     7677     2732
## depblues_mostresp_av12x21[2]                    0.30 1.00     7589     2600
## depblues_mostresp_av12x21[3]                    0.32 1.00     8558     2509
## depblues_mostresp_av12x21[4]                    0.31 1.00     8820     2502
## depblues_mostresp_av12x21[5]                    0.32 1.00     8548     2193
## depblues_mostresp_av12x21[6]                    0.34 1.00     7696     2912
## depblues_mostresp_av12x21[7]                    0.33 1.00     7682     3176
## depblues_mostresp_av12x21[8]                    0.32 1.00     8207     2763
## depblues_mostresp_devx2:rural.ses.med21[1]      0.73 1.00     5095     2528
## depblues_mostresp_devx2:rural.ses.med21[2]      0.68 1.00     4479     2624
## depblues_mostresp_devx2:rural.ses.med21[3]      0.68 1.00     5615     2744
## depblues_mostresp_devx2:rural.ses.med21[4]      0.74 1.00     6414     2477
## depblues_mostresp_devx2:rural.ses.med31[1]      0.73 1.00     4422     2661
## depblues_mostresp_devx2:rural.ses.med31[2]      0.64 1.00     5398     2662
## depblues_mostresp_devx2:rural.ses.med31[3]      0.65 1.00     5234     3009
## depblues_mostresp_devx2:rural.ses.med31[4]      0.80 1.00     4464     2749
## depblues_mostresp_devx2:rural.ses.med41[1]      0.69 1.00     5060     1945
## depblues_mostresp_devx2:rural.ses.med41[2]      0.64 1.00     6596     2762
## depblues_mostresp_devx2:rural.ses.med41[3]      0.70 1.00     5925     2533
## depblues_mostresp_devx2:rural.ses.med41[4]      0.75 1.00     6510     2641
## depunfair_mostresp_devx21[1]                    0.56 1.00     4875     2994
## depunfair_mostresp_devx21[2]                    0.56 1.00     5826     2081
## depunfair_mostresp_devx21[3]                    0.56 1.00     5243     3034
## depunfair_mostresp_devx21[4]                    0.58 1.00     7773     3156
## depunfair_mostresp_av12x21[1]                   0.29 1.00     7875     2429
## depunfair_mostresp_av12x21[2]                   0.33 1.00     7197     1925
## depunfair_mostresp_av12x21[3]                   0.33 1.00     7058     2658
## depunfair_mostresp_av12x21[4]                   0.30 1.00     7235     2322
## depunfair_mostresp_av12x21[5]                   0.31 1.00     8298     2058
## depunfair_mostresp_av12x21[6]                   0.31 1.00     7932     2653
## depunfair_mostresp_av12x21[7]                   0.35 1.00     7086     2678
## depunfair_mostresp_av12x21[8]                   0.33 1.00     6581     2680
## depunfair_mostresp_devx2:rural.ses.med21[1]     0.41 1.00     5893     2520
## depunfair_mostresp_devx2:rural.ses.med21[2]     0.78 1.00     4534     2160
## depunfair_mostresp_devx2:rural.ses.med21[3]     0.54 1.00     4618     2753
## depunfair_mostresp_devx2:rural.ses.med21[4]     0.61 1.00     6487     2901
## depunfair_mostresp_devx2:rural.ses.med31[1]     0.70 1.00     5462     2158
## depunfair_mostresp_devx2:rural.ses.med31[2]     0.64 1.00     6582     2738
## depunfair_mostresp_devx2:rural.ses.med31[3]     0.65 1.00     5808     2899
## depunfair_mostresp_devx2:rural.ses.med31[4]     0.74 1.00     5833     2529
## depunfair_mostresp_devx2:rural.ses.med41[1]     0.68 1.00     5823     2214
## depunfair_mostresp_devx2:rural.ses.med41[2]     0.68 1.00     7225     2704
## depunfair_mostresp_devx2:rural.ses.med41[3]     0.62 1.00     5745     2771
## depunfair_mostresp_devx2:rural.ses.med41[4]     0.69 1.00     7380     3026
## depmistrt_mostresp_devx21[1]                    0.64 1.00     4919     2881
## depmistrt_mostresp_devx21[2]                    0.55 1.00     5568     2752
## depmistrt_mostresp_devx21[3]                    0.56 1.00     5676     3183
## depmistrt_mostresp_devx21[4]                    0.59 1.00     7064     2618
## depmistrt_mostresp_av12x21[1]                   0.23 1.00     6992     2090
## depmistrt_mostresp_av12x21[2]                   0.30 1.00     6673     2328
## depmistrt_mostresp_av12x21[3]                   0.33 1.00     7378     2461
## depmistrt_mostresp_av12x21[4]                   0.35 1.00     6790     2113
## depmistrt_mostresp_av12x21[5]                   0.29 1.00     6394     2292
## depmistrt_mostresp_av12x21[6]                   0.33 1.00     8571     2480
## depmistrt_mostresp_av12x21[7]                   0.32 1.00     7276     2676
## depmistrt_mostresp_av12x21[8]                   0.31 1.00     7053     2210
## depmistrt_mostresp_devx2:rural.ses.med21[1]     0.68 1.00     5081     2413
## depmistrt_mostresp_devx2:rural.ses.med21[2]     0.58 1.00     3723     3347
## depmistrt_mostresp_devx2:rural.ses.med21[3]     0.60 1.00     2939     2876
## depmistrt_mostresp_devx2:rural.ses.med21[4]     0.88 1.00     2570     2995
## depmistrt_mostresp_devx2:rural.ses.med31[1]     0.68 1.00     5691     2679
## depmistrt_mostresp_devx2:rural.ses.med31[2]     0.66 1.00     5514     2548
## depmistrt_mostresp_devx2:rural.ses.med31[3]     0.63 1.00     5815     2788
## depmistrt_mostresp_devx2:rural.ses.med31[4]     0.72 1.00     5949     3121
## depmistrt_mostresp_devx2:rural.ses.med41[1]     0.64 1.00     5856     2164
## depmistrt_mostresp_devx2:rural.ses.med41[2]     0.79 1.00     3666     2915
## depmistrt_mostresp_devx2:rural.ses.med41[3]     0.62 1.00     5752     2899
## depmistrt_mostresp_devx2:rural.ses.med41[4]     0.67 1.00     6307     2564
## depbetray_mostresp_devx21[1]                    0.58 1.00     5784     2780
## depbetray_mostresp_devx21[2]                    0.55 1.00     8502     2758
## depbetray_mostresp_devx21[3]                    0.55 1.00     6983     2800
## depbetray_mostresp_devx21[4]                    0.58 1.00     8191     2632
## depbetray_mostresp_av12x21[1]                   0.27 1.00     6674     2195
## depbetray_mostresp_av12x21[2]                   0.31 1.00     8197     2525
## depbetray_mostresp_av12x21[3]                   0.34 1.00     7109     2371
## depbetray_mostresp_av12x21[4]                   0.34 1.00     7891     2164
## depbetray_mostresp_av12x21[5]                   0.32 1.00     7993     2528
## depbetray_mostresp_av12x21[6]                   0.34 1.00     6892     2652
## depbetray_mostresp_av12x21[7]                   0.32 1.00     6540     2905
## depbetray_mostresp_av12x21[8]                   0.27 1.00     6389     2511
## depbetray_mostresp_devx2:rural.ses.med21[1]     0.72 1.00     4828     2524
## depbetray_mostresp_devx2:rural.ses.med21[2]     0.67 1.00     5930     2618
## depbetray_mostresp_devx2:rural.ses.med21[3]     0.65 1.00     4833     2827
## depbetray_mostresp_devx2:rural.ses.med21[4]     0.77 1.00     4390     2807
## depbetray_mostresp_devx2:rural.ses.med31[1]     0.73 1.00     6188     2637
## depbetray_mostresp_devx2:rural.ses.med31[2]     0.65 1.00     5113     2654
## depbetray_mostresp_devx2:rural.ses.med31[3]     0.69 1.00     4366     2580
## depbetray_mostresp_devx2:rural.ses.med31[4]     0.73 1.00     5473     2554
## depbetray_mostresp_devx2:rural.ses.med41[1]     0.73 1.00     6196     2324
## depbetray_mostresp_devx2:rural.ses.med41[2]     0.66 1.00     6257     2818
## depbetray_mostresp_devx2:rural.ses.med41[3]     0.67 1.00     5351     2814
## depbetray_mostresp_devx2:rural.ses.med41[4]     0.73 1.00     5893     2416
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.2.3.4 Prior summary
out.chg.alldepress.stresp.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostresp_av12x2
##                    normal(0, 0.25)         b                 mostresp_devx2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostresp_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostresp_av12x21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostresp_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostresp_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##        depbetray                          user
##        depbetray                          user
##        depbetray                          user
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##         depblues                          user
##         depblues                          user
##         depblues                          user
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depeffort                          user
##        depeffort                          user
##        depeffort                          user
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        deplonely                          user
##        deplonely                          user
##        deplonely                          user
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depunfair                          user
##        depunfair                          user
##        depunfair                          user
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##                                        default
##        depbetray                          user
##         depblues                          user
##        depcantgo                          user
##        depeffort                          user
##        deplonely                          user
##        depmistrt                          user
##        depunfair                          user
##        depbetray             0         default
##         depblues             0         default
##        depcantgo             0         default
##        depeffort             0         default
##        deplonely             0         default
##        depmistrt             0         default
##        depunfair             0         default
##     id depbetray             0    (vectorized)
##     id depbetray             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depunfair             0    (vectorized)
##     id depunfair             0    (vectorized)
##        depbetray                          user
##        depbetray                       default
##        depbetray                       default
##        depbetray                       default
##        depbetray                          user
##         depblues                          user
##         depblues                       default
##         depblues                       default
##         depblues                       default
##         depblues                          user
##        depcantgo                          user
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                          user
##        depeffort                          user
##        depeffort                       default
##        depeffort                       default
##        depeffort                       default
##        depeffort                          user
##        deplonely                          user
##        deplonely                       default
##        deplonely                       default
##        deplonely                       default
##        deplonely                          user
##        depmistrt                          user
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                          user
##        depunfair                          user
##        depunfair                       default
##        depunfair                       default
##        depunfair                       default
##        depunfair                          user

8.1.2.4 Corr X Community: stfair & negative emotions

# Community Change: negative emotions items ~ mo(stfair)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostfair_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostfair_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostfair_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostfair_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stfair.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + 
         rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stfair_comm_fit",
      file_refit = "on_change"
  )


out.chg.alldepress.stfair.comm.fit <- ppchecks(chg.alldepress.stfair.comm.fit)
8.1.2.4.1 Coefficient plot (intervals)
out.chg.alldepress.stfair.comm.fit[[11]]

8.1.2.4.2 PPcheck (density)
p1 <- out.chg.alldepress.stfair.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stfair.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stfair.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stfair.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stfair.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stfair.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stfair.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

8.1.2.4.3 Fit summary
out.chg.alldepress.stfair.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          depeffort ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          deplonely ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          depblues ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          depunfair ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##          depbetray ~ 1 + mo(stfair_devx2) + mo(stfair_av12x2) + rural.ses.med + mo(stfair_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.32      0.20     0.01     0.72 1.00      565
## sd(depeffort_Intercept)     0.42      0.27     0.02     0.97 1.01      614
## sd(deplonely_Intercept)     0.42      0.24     0.02     0.88 1.01      530
## sd(depblues_Intercept)      0.71      0.31     0.06     1.29 1.01      558
## sd(depunfair_Intercept)     0.23      0.17     0.01     0.61 1.00     1034
## sd(depmistrt_Intercept)     0.30      0.21     0.01     0.75 1.00      795
## sd(depbetray_Intercept)     0.42      0.27     0.02     0.97 1.00      519
##                         Tail_ESS
## sd(depcantgo_Intercept)     1318
## sd(depeffort_Intercept)     1129
## sd(deplonely_Intercept)      818
## sd(depblues_Intercept)       672
## sd(depunfair_Intercept)     1859
## sd(depmistrt_Intercept)     1416
## sd(depbetray_Intercept)     1169
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## depcantgo_Intercept                        -0.77      0.37    -1.57    -0.11
## depeffort_Intercept                        -2.45      0.45    -3.36    -1.61
## deplonely_Intercept                        -1.20      0.35    -1.95    -0.55
## depblues_Intercept                         -2.38      0.44    -3.31    -1.54
## depunfair_Intercept                        -2.15      0.37    -2.93    -1.47
## depmistrt_Intercept                        -2.74      0.42    -3.55    -1.90
## depbetray_Intercept                        -3.09      0.47    -4.06    -2.22
## depcantgo_rural.ses.med2                   -0.53      0.56    -1.78     0.43
## depcantgo_rural.ses.med3                    0.23      0.47    -0.75     1.16
## depcantgo_rural.ses.med4                    0.44      0.49    -0.47     1.50
## depeffort_rural.ses.med2                   -0.27      0.57    -1.45     0.85
## depeffort_rural.ses.med3                   -0.20      0.66    -1.57     1.01
## depeffort_rural.ses.med4                    0.58      0.59    -0.64     1.74
## deplonely_rural.ses.med2                   -0.68      0.52    -1.75     0.39
## deplonely_rural.ses.med3                    0.04      0.49    -1.06     0.93
## deplonely_rural.ses.med4                    0.42      0.52    -0.65     1.44
## depblues_rural.ses.med2                     0.19      0.60    -1.10     1.29
## depblues_rural.ses.med3                     0.02      0.57    -1.21     1.05
## depblues_rural.ses.med4                     0.56      0.58    -0.62     1.75
## depunfair_rural.ses.med2                   -0.26      0.60    -1.45     0.91
## depunfair_rural.ses.med3                    0.73      0.50    -0.38     1.66
## depunfair_rural.ses.med4                    0.75      0.53    -0.37     1.81
## depmistrt_rural.ses.med2                   -0.01      0.63    -1.36     1.07
## depmistrt_rural.ses.med3                    0.02      0.57    -1.22     1.06
## depmistrt_rural.ses.med4                    0.49      0.57    -0.77     1.55
## depbetray_rural.ses.med2                    0.19      0.60    -1.14     1.28
## depbetray_rural.ses.med3                    0.46      0.65    -0.95     1.59
## depbetray_rural.ses.med4                    0.77      0.63    -0.74     1.84
## depcantgo_mostfair_devx2                    0.16      0.15    -0.11     0.48
## depcantgo_mostfair_av12x2                  -0.01      0.02    -0.06     0.04
## depcantgo_mostfair_devx2:rural.ses.med2     0.48      0.35    -0.04     1.34
## depcantgo_mostfair_devx2:rural.ses.med3    -0.06      0.22    -0.48     0.42
## depcantgo_mostfair_devx2:rural.ses.med4    -0.19      0.24    -0.69     0.30
## depeffort_mostfair_devx2                    0.14      0.17    -0.20     0.47
## depeffort_mostfair_av12x2                   0.03      0.03    -0.03     0.10
## depeffort_mostfair_devx2:rural.ses.med2     0.18      0.30    -0.39     0.85
## depeffort_mostfair_devx2:rural.ses.med3     0.33      0.31    -0.27     0.95
## depeffort_mostfair_devx2:rural.ses.med4    -0.07      0.32    -0.78     0.50
## deplonely_mostfair_devx2                    0.10      0.15    -0.19     0.41
## deplonely_mostfair_av12x2                   0.00      0.03    -0.06     0.05
## deplonely_mostfair_devx2:rural.ses.med2     0.15      0.26    -0.41     0.62
## deplonely_mostfair_devx2:rural.ses.med3    -0.05      0.23    -0.45     0.50
## deplonely_mostfair_devx2:rural.ses.med4     0.01      0.26    -0.50     0.57
## depblues_mostfair_devx2                    -0.02      0.17    -0.39     0.30
## depblues_mostfair_av12x2                    0.02      0.04    -0.05     0.09
## depblues_mostfair_devx2:rural.ses.med2     -0.01      0.34    -0.75     0.59
## depblues_mostfair_devx2:rural.ses.med3      0.15      0.27    -0.42     0.65
## depblues_mostfair_devx2:rural.ses.med4      0.01      0.32    -0.66     0.58
## depunfair_mostfair_devx2                    0.21      0.14    -0.08     0.51
## depunfair_mostfair_av12x2                   0.03      0.03    -0.03     0.09
## depunfair_mostfair_devx2:rural.ses.med2     0.29      0.28    -0.28     0.86
## depunfair_mostfair_devx2:rural.ses.med3    -0.01      0.24    -0.45     0.52
## depunfair_mostfair_devx2:rural.ses.med4     0.15      0.27    -0.37     0.70
## depmistrt_mostfair_devx2                    0.01      0.16    -0.33     0.31
## depmistrt_mostfair_av12x2                   0.13      0.03     0.06     0.19
## depmistrt_mostfair_devx2:rural.ses.med2     0.31      0.31    -0.24     0.97
## depmistrt_mostfair_devx2:rural.ses.med3     0.27      0.25    -0.28     0.73
## depmistrt_mostfair_devx2:rural.ses.med4     0.06      0.29    -0.54     0.60
## depbetray_mostfair_devx2                    0.11      0.17    -0.22     0.45
## depbetray_mostfair_av12x2                   0.11      0.04     0.05     0.19
## depbetray_mostfair_devx2:rural.ses.med2     0.17      0.31    -0.40     0.85
## depbetray_mostfair_devx2:rural.ses.med3     0.10      0.32    -0.58     0.64
## depbetray_mostfair_devx2:rural.ses.med4     0.12      0.31    -0.41     0.79
##                                         Rhat Bulk_ESS Tail_ESS
## depcantgo_Intercept                     1.00     2543     2338
## depeffort_Intercept                     1.00     2537     3253
## deplonely_Intercept                     1.00     3096     2901
## depblues_Intercept                      1.00     2428     2837
## depunfair_Intercept                     1.00     3427     2916
## depmistrt_Intercept                     1.00     3280     3057
## depbetray_Intercept                     1.00     2681     3107
## depcantgo_rural.ses.med2                1.00     3286     2650
## depcantgo_rural.ses.med3                1.00     2186     2138
## depcantgo_rural.ses.med4                1.00     2978     2701
## depeffort_rural.ses.med2                1.00     3205     2777
## depeffort_rural.ses.med3                1.00     2759     2914
## depeffort_rural.ses.med4                1.00     3303     2794
## deplonely_rural.ses.med2                1.00     2926     2495
## deplonely_rural.ses.med3                1.00     2733     2053
## deplonely_rural.ses.med4                1.00     3078     2735
## depblues_rural.ses.med2                 1.00     3842     3069
## depblues_rural.ses.med3                 1.00     3024     3000
## depblues_rural.ses.med4                 1.00     3656     2786
## depunfair_rural.ses.med2                1.00     2647     2128
## depunfair_rural.ses.med3                1.00     2983     2583
## depunfair_rural.ses.med4                1.00     3019     2682
## depmistrt_rural.ses.med2                1.00     3354     2837
## depmistrt_rural.ses.med3                1.00     3038     2405
## depmistrt_rural.ses.med4                1.00     3180     2520
## depbetray_rural.ses.med2                1.00     3015     2670
## depbetray_rural.ses.med3                1.00     2292     3089
## depbetray_rural.ses.med4                1.00     2955     2588
## depcantgo_mostfair_devx2                1.00     2626     2729
## depcantgo_mostfair_av12x2               1.00     7142     3351
## depcantgo_mostfair_devx2:rural.ses.med2 1.00     2616     2103
## depcantgo_mostfair_devx2:rural.ses.med3 1.00     2001     2569
## depcantgo_mostfair_devx2:rural.ses.med4 1.00     2928     2417
## depeffort_mostfair_devx2                1.00     2802     3333
## depeffort_mostfair_av12x2               1.00     6284     3100
## depeffort_mostfair_devx2:rural.ses.med2 1.00     3287     2809
## depeffort_mostfair_devx2:rural.ses.med3 1.00     2473     3002
## depeffort_mostfair_devx2:rural.ses.med4 1.00     2753     2266
## deplonely_mostfair_devx2                1.00     3010     3056
## deplonely_mostfair_av12x2               1.00     7150     2980
## deplonely_mostfair_devx2:rural.ses.med2 1.00     2910     1931
## deplonely_mostfair_devx2:rural.ses.med3 1.00     2771     2328
## deplonely_mostfair_devx2:rural.ses.med4 1.00     2936     2636
## depblues_mostfair_devx2                 1.00     3007     3070
## depblues_mostfair_av12x2                1.00     4909     2826
## depblues_mostfair_devx2:rural.ses.med2  1.00     3364     2691
## depblues_mostfair_devx2:rural.ses.med3  1.00     2599     1825
## depblues_mostfair_devx2:rural.ses.med4  1.00     2919     2469
## depunfair_mostfair_devx2                1.00     2903     3167
## depunfair_mostfair_av12x2               1.00     6352     2809
## depunfair_mostfair_devx2:rural.ses.med2 1.00     2350     2005
## depunfair_mostfair_devx2:rural.ses.med3 1.00     2784     2901
## depunfair_mostfair_devx2:rural.ses.med4 1.00     2788     2787
## depmistrt_mostfair_devx2                1.00     2930     3114
## depmistrt_mostfair_av12x2               1.00     6472     3089
## depmistrt_mostfair_devx2:rural.ses.med2 1.00     2867     2705
## depmistrt_mostfair_devx2:rural.ses.med3 1.00     2664     1790
## depmistrt_mostfair_devx2:rural.ses.med4 1.00     2752     2273
## depbetray_mostfair_devx2                1.00     2500     3294
## depbetray_mostfair_av12x2               1.00     6023     3094
## depbetray_mostfair_devx2:rural.ses.med2 1.00     2736     2175
## depbetray_mostfair_devx2:rural.ses.med3 1.00     2018     2432
## depbetray_mostfair_devx2:rural.ses.med4 1.00     2695     2970
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## depcantgo_mostfair_devx21[1]                    0.26      0.15     0.04
## depcantgo_mostfair_devx21[2]                    0.25      0.13     0.04
## depcantgo_mostfair_devx21[3]                    0.21      0.13     0.03
## depcantgo_mostfair_devx21[4]                    0.28      0.15     0.04
## depcantgo_mostfair_av12x21[1]                   0.13      0.08     0.02
## depcantgo_mostfair_av12x21[2]                   0.13      0.08     0.02
## depcantgo_mostfair_av12x21[3]                   0.12      0.08     0.02
## depcantgo_mostfair_av12x21[4]                   0.12      0.08     0.02
## depcantgo_mostfair_av12x21[5]                   0.13      0.08     0.02
## depcantgo_mostfair_av12x21[6]                   0.12      0.08     0.02
## depcantgo_mostfair_av12x21[7]                   0.13      0.08     0.02
## depcantgo_mostfair_av12x21[8]                   0.13      0.08     0.02
## depcantgo_mostfair_devx2:rural.ses.med21[1]     0.22      0.17     0.01
## depcantgo_mostfair_devx2:rural.ses.med21[2]     0.29      0.18     0.02
## depcantgo_mostfair_devx2:rural.ses.med21[3]     0.14      0.13     0.00
## depcantgo_mostfair_devx2:rural.ses.med21[4]     0.35      0.22     0.01
## depcantgo_mostfair_devx2:rural.ses.med31[1]     0.26      0.20     0.01
## depcantgo_mostfair_devx2:rural.ses.med31[2]     0.26      0.20     0.01
## depcantgo_mostfair_devx2:rural.ses.med31[3]     0.20      0.17     0.01
## depcantgo_mostfair_devx2:rural.ses.med31[4]     0.28      0.20     0.01
## depcantgo_mostfair_devx2:rural.ses.med41[1]     0.25      0.19     0.01
## depcantgo_mostfair_devx2:rural.ses.med41[2]     0.22      0.18     0.01
## depcantgo_mostfair_devx2:rural.ses.med41[3]     0.25      0.18     0.01
## depcantgo_mostfair_devx2:rural.ses.med41[4]     0.27      0.20     0.01
## depeffort_mostfair_devx21[1]                    0.24      0.14     0.03
## depeffort_mostfair_devx21[2]                    0.30      0.16     0.05
## depeffort_mostfair_devx21[3]                    0.20      0.13     0.03
## depeffort_mostfair_devx21[4]                    0.26      0.15     0.04
## depeffort_mostfair_av12x21[1]                   0.13      0.08     0.02
## depeffort_mostfair_av12x21[2]                   0.13      0.08     0.02
## depeffort_mostfair_av12x21[3]                   0.13      0.08     0.02
## depeffort_mostfair_av12x21[4]                   0.12      0.08     0.02
## depeffort_mostfair_av12x21[5]                   0.12      0.07     0.02
## depeffort_mostfair_av12x21[6]                   0.12      0.08     0.02
## depeffort_mostfair_av12x21[7]                   0.12      0.08     0.02
## depeffort_mostfair_av12x21[8]                   0.13      0.09     0.02
## depeffort_mostfair_devx2:rural.ses.med21[1]     0.24      0.19     0.01
## depeffort_mostfair_devx2:rural.ses.med21[2]     0.21      0.17     0.01
## depeffort_mostfair_devx2:rural.ses.med21[3]     0.23      0.18     0.01
## depeffort_mostfair_devx2:rural.ses.med21[4]     0.31      0.22     0.01
## depeffort_mostfair_devx2:rural.ses.med31[1]     0.24      0.18     0.01
## depeffort_mostfair_devx2:rural.ses.med31[2]     0.32      0.20     0.01
## depeffort_mostfair_devx2:rural.ses.med31[3]     0.14      0.14     0.00
## depeffort_mostfair_devx2:rural.ses.med31[4]     0.31      0.20     0.01
## depeffort_mostfair_devx2:rural.ses.med41[1]     0.25      0.19     0.01
## depeffort_mostfair_devx2:rural.ses.med41[2]     0.22      0.19     0.01
## depeffort_mostfair_devx2:rural.ses.med41[3]     0.22      0.18     0.01
## depeffort_mostfair_devx2:rural.ses.med41[4]     0.30      0.22     0.01
## deplonely_mostfair_devx21[1]                    0.27      0.15     0.05
## deplonely_mostfair_devx21[2]                    0.22      0.13     0.03
## deplonely_mostfair_devx21[3]                    0.24      0.14     0.03
## deplonely_mostfair_devx21[4]                    0.27      0.15     0.04
## deplonely_mostfair_av12x21[1]                   0.13      0.08     0.02
## deplonely_mostfair_av12x21[2]                   0.13      0.08     0.02
## deplonely_mostfair_av12x21[3]                   0.12      0.08     0.01
## deplonely_mostfair_av12x21[4]                   0.12      0.08     0.02
## deplonely_mostfair_av12x21[5]                   0.12      0.08     0.01
## deplonely_mostfair_av12x21[6]                   0.12      0.08     0.01
## deplonely_mostfair_av12x21[7]                   0.13      0.08     0.02
## deplonely_mostfair_av12x21[8]                   0.13      0.08     0.02
## deplonely_mostfair_devx2:rural.ses.med21[1]     0.25      0.18     0.01
## deplonely_mostfair_devx2:rural.ses.med21[2]     0.23      0.18     0.01
## deplonely_mostfair_devx2:rural.ses.med21[3]     0.26      0.18     0.01
## deplonely_mostfair_devx2:rural.ses.med21[4]     0.27      0.20     0.01
## deplonely_mostfair_devx2:rural.ses.med31[1]     0.26      0.20     0.01
## deplonely_mostfair_devx2:rural.ses.med31[2]     0.24      0.19     0.01
## deplonely_mostfair_devx2:rural.ses.med31[3]     0.22      0.18     0.01
## deplonely_mostfair_devx2:rural.ses.med31[4]     0.28      0.20     0.01
## deplonely_mostfair_devx2:rural.ses.med41[1]     0.27      0.19     0.01
## deplonely_mostfair_devx2:rural.ses.med41[2]     0.22      0.18     0.01
## deplonely_mostfair_devx2:rural.ses.med41[3]     0.22      0.17     0.01
## deplonely_mostfair_devx2:rural.ses.med41[4]     0.29      0.21     0.01
## depblues_mostfair_devx21[1]                     0.26      0.15     0.04
## depblues_mostfair_devx21[2]                     0.24      0.14     0.03
## depblues_mostfair_devx21[3]                     0.24      0.14     0.04
## depblues_mostfair_devx21[4]                     0.27      0.15     0.04
## depblues_mostfair_av12x21[1]                    0.12      0.08     0.02
## depblues_mostfair_av12x21[2]                    0.12      0.08     0.02
## depblues_mostfair_av12x21[3]                    0.12      0.08     0.02
## depblues_mostfair_av12x21[4]                    0.12      0.08     0.02
## depblues_mostfair_av12x21[5]                    0.12      0.08     0.02
## depblues_mostfair_av12x21[6]                    0.13      0.08     0.02
## depblues_mostfair_av12x21[7]                    0.13      0.08     0.02
## depblues_mostfair_av12x21[8]                    0.14      0.09     0.02
## depblues_mostfair_devx2:rural.ses.med21[1]      0.25      0.19     0.01
## depblues_mostfair_devx2:rural.ses.med21[2]      0.22      0.18     0.01
## depblues_mostfair_devx2:rural.ses.med21[3]      0.23      0.18     0.01
## depblues_mostfair_devx2:rural.ses.med21[4]      0.30      0.22     0.01
## depblues_mostfair_devx2:rural.ses.med31[1]      0.26      0.20     0.01
## depblues_mostfair_devx2:rural.ses.med31[2]      0.24      0.18     0.01
## depblues_mostfair_devx2:rural.ses.med31[3]      0.23      0.18     0.01
## depblues_mostfair_devx2:rural.ses.med31[4]      0.27      0.20     0.01
## depblues_mostfair_devx2:rural.ses.med41[1]      0.25      0.19     0.01
## depblues_mostfair_devx2:rural.ses.med41[2]      0.22      0.19     0.01
## depblues_mostfair_devx2:rural.ses.med41[3]      0.23      0.18     0.01
## depblues_mostfair_devx2:rural.ses.med41[4]      0.30      0.22     0.01
## depunfair_mostfair_devx21[1]                    0.21      0.12     0.03
## depunfair_mostfair_devx21[2]                    0.30      0.14     0.05
## depunfair_mostfair_devx21[3]                    0.24      0.12     0.04
## depunfair_mostfair_devx21[4]                    0.25      0.13     0.04
## depunfair_mostfair_av12x21[1]                   0.12      0.08     0.02
## depunfair_mostfair_av12x21[2]                   0.12      0.08     0.02
## depunfair_mostfair_av12x21[3]                   0.12      0.08     0.02
## depunfair_mostfair_av12x21[4]                   0.12      0.08     0.02
## depunfair_mostfair_av12x21[5]                   0.12      0.08     0.02
## depunfair_mostfair_av12x21[6]                   0.12      0.08     0.02
## depunfair_mostfair_av12x21[7]                   0.14      0.08     0.02
## depunfair_mostfair_av12x21[8]                   0.13      0.08     0.02
## depunfair_mostfair_devx2:rural.ses.med21[1]     0.20      0.17     0.01
## depunfair_mostfair_devx2:rural.ses.med21[2]     0.35      0.21     0.01
## depunfair_mostfair_devx2:rural.ses.med21[3]     0.18      0.15     0.01
## depunfair_mostfair_devx2:rural.ses.med21[4]     0.28      0.20     0.01
## depunfair_mostfair_devx2:rural.ses.med31[1]     0.26      0.19     0.01
## depunfair_mostfair_devx2:rural.ses.med31[2]     0.22      0.18     0.01
## depunfair_mostfair_devx2:rural.ses.med31[3]     0.24      0.19     0.01
## depunfair_mostfair_devx2:rural.ses.med31[4]     0.28      0.20     0.01
## depunfair_mostfair_devx2:rural.ses.med41[1]     0.26      0.19     0.01
## depunfair_mostfair_devx2:rural.ses.med41[2]     0.20      0.17     0.01
## depunfair_mostfair_devx2:rural.ses.med41[3]     0.26      0.19     0.01
## depunfair_mostfair_devx2:rural.ses.med41[4]     0.28      0.20     0.01
## depmistrt_mostfair_devx21[1]                    0.27      0.15     0.04
## depmistrt_mostfair_devx21[2]                    0.23      0.13     0.03
## depmistrt_mostfair_devx21[3]                    0.24      0.14     0.03
## depmistrt_mostfair_devx21[4]                    0.26      0.15     0.04
## depmistrt_mostfair_av12x21[1]                   0.10      0.06     0.01
## depmistrt_mostfair_av12x21[2]                   0.12      0.08     0.02
## depmistrt_mostfair_av12x21[3]                   0.13      0.08     0.02
## depmistrt_mostfair_av12x21[4]                   0.15      0.09     0.02
## depmistrt_mostfair_av12x21[5]                   0.13      0.08     0.02
## depmistrt_mostfair_av12x21[6]                   0.11      0.07     0.02
## depmistrt_mostfair_av12x21[7]                   0.17      0.09     0.03
## depmistrt_mostfair_av12x21[8]                   0.11      0.07     0.02
## depmistrt_mostfair_devx2:rural.ses.med21[1]     0.24      0.19     0.01
## depmistrt_mostfair_devx2:rural.ses.med21[2]     0.27      0.19     0.01
## depmistrt_mostfair_devx2:rural.ses.med21[3]     0.17      0.15     0.00
## depmistrt_mostfair_devx2:rural.ses.med21[4]     0.32      0.21     0.01
## depmistrt_mostfair_devx2:rural.ses.med31[1]     0.27      0.19     0.01
## depmistrt_mostfair_devx2:rural.ses.med31[2]     0.17      0.15     0.00
## depmistrt_mostfair_devx2:rural.ses.med31[3]     0.34      0.21     0.02
## depmistrt_mostfair_devx2:rural.ses.med31[4]     0.22      0.18     0.01
## depmistrt_mostfair_devx2:rural.ses.med41[1]     0.27      0.20     0.01
## depmistrt_mostfair_devx2:rural.ses.med41[2]     0.22      0.18     0.01
## depmistrt_mostfair_devx2:rural.ses.med41[3]     0.22      0.17     0.01
## depmistrt_mostfair_devx2:rural.ses.med41[4]     0.29      0.22     0.01
## depbetray_mostfair_devx21[1]                    0.26      0.15     0.04
## depbetray_mostfair_devx21[2]                    0.27      0.14     0.04
## depbetray_mostfair_devx21[3]                    0.21      0.13     0.03
## depbetray_mostfair_devx21[4]                    0.25      0.14     0.04
## depbetray_mostfair_av12x21[1]                   0.12      0.07     0.02
## depbetray_mostfair_av12x21[2]                   0.14      0.08     0.02
## depbetray_mostfair_av12x21[3]                   0.14      0.09     0.02
## depbetray_mostfair_av12x21[4]                   0.15      0.09     0.02
## depbetray_mostfair_av12x21[5]                   0.10      0.07     0.01
## depbetray_mostfair_av12x21[6]                   0.10      0.06     0.01
## depbetray_mostfair_av12x21[7]                   0.12      0.08     0.02
## depbetray_mostfair_av12x21[8]                   0.13      0.08     0.02
## depbetray_mostfair_devx2:rural.ses.med21[1]     0.26      0.19     0.01
## depbetray_mostfair_devx2:rural.ses.med21[2]     0.22      0.18     0.01
## depbetray_mostfair_devx2:rural.ses.med21[3]     0.20      0.18     0.01
## depbetray_mostfair_devx2:rural.ses.med21[4]     0.31      0.22     0.01
## depbetray_mostfair_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## depbetray_mostfair_devx2:rural.ses.med31[2]     0.27      0.21     0.01
## depbetray_mostfair_devx2:rural.ses.med31[3]     0.19      0.17     0.01
## depbetray_mostfair_devx2:rural.ses.med31[4]     0.27      0.21     0.01
## depbetray_mostfair_devx2:rural.ses.med41[1]     0.28      0.20     0.01
## depbetray_mostfair_devx2:rural.ses.med41[2]     0.21      0.17     0.01
## depbetray_mostfair_devx2:rural.ses.med41[3]     0.21      0.18     0.01
## depbetray_mostfair_devx2:rural.ses.med41[4]     0.30      0.21     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## depcantgo_mostfair_devx21[1]                    0.59 1.00     5746     2882
## depcantgo_mostfair_devx21[2]                    0.55 1.00     5569     2820
## depcantgo_mostfair_devx21[3]                    0.51 1.00     5552     3232
## depcantgo_mostfair_devx21[4]                    0.61 1.00     7078     2774
## depcantgo_mostfair_av12x21[1]                   0.32 1.00     7154     2377
## depcantgo_mostfair_av12x21[2]                   0.32 1.00     7627     2116
## depcantgo_mostfair_av12x21[3]                   0.32 1.00     7633     2091
## depcantgo_mostfair_av12x21[4]                   0.32 1.00     7209     2564
## depcantgo_mostfair_av12x21[5]                   0.32 1.00     8755     2486
## depcantgo_mostfair_av12x21[6]                   0.30 1.00     7666     2904
## depcantgo_mostfair_av12x21[7]                   0.32 1.00     7325     2399
## depcantgo_mostfair_av12x21[8]                   0.33 1.00     8387     3193
## depcantgo_mostfair_devx2:rural.ses.med21[1]     0.62 1.00     5611     2796
## depcantgo_mostfair_devx2:rural.ses.med21[2]     0.71 1.00     4570     2135
## depcantgo_mostfair_devx2:rural.ses.med21[3]     0.49 1.00     4534     2686
## depcantgo_mostfair_devx2:rural.ses.med21[4]     0.78 1.00     4225     3090
## depcantgo_mostfair_devx2:rural.ses.med31[1]     0.72 1.00     4773     2541
## depcantgo_mostfair_devx2:rural.ses.med31[2]     0.71 1.00     4361     2609
## depcantgo_mostfair_devx2:rural.ses.med31[3]     0.62 1.00     4713     3003
## depcantgo_mostfair_devx2:rural.ses.med31[4]     0.74 1.00     5163     2594
## depcantgo_mostfair_devx2:rural.ses.med41[1]     0.71 1.00     5488     2365
## depcantgo_mostfair_devx2:rural.ses.med41[2]     0.64 1.00     4995     2442
## depcantgo_mostfair_devx2:rural.ses.med41[3]     0.68 1.00     5099     2810
## depcantgo_mostfair_devx2:rural.ses.med41[4]     0.73 1.00     5899     2461
## depeffort_mostfair_devx21[1]                    0.58 1.00     6710     2613
## depeffort_mostfair_devx21[2]                    0.63 1.00     5055     2619
## depeffort_mostfair_devx21[3]                    0.50 1.00     5510     2804
## depeffort_mostfair_devx21[4]                    0.59 1.00     8336     2857
## depeffort_mostfair_av12x21[1]                   0.32 1.00     6422     2520
## depeffort_mostfair_av12x21[2]                   0.34 1.00     7248     2161
## depeffort_mostfair_av12x21[3]                   0.33 1.00     7624     2764
## depeffort_mostfair_av12x21[4]                   0.32 1.00     7569     2307
## depeffort_mostfair_av12x21[5]                   0.29 1.00     7051     2891
## depeffort_mostfair_av12x21[6]                   0.30 1.00     6964     2527
## depeffort_mostfair_av12x21[7]                   0.31 1.00     6770     2937
## depeffort_mostfair_av12x21[8]                   0.34 1.00     7214     2896
## depeffort_mostfair_devx2:rural.ses.med21[1]     0.68 1.00     5136     2561
## depeffort_mostfair_devx2:rural.ses.med21[2]     0.65 1.00     6379     2559
## depeffort_mostfair_devx2:rural.ses.med21[3]     0.67 1.00     4559     2614
## depeffort_mostfair_devx2:rural.ses.med21[4]     0.77 1.00     5757     2512
## depeffort_mostfair_devx2:rural.ses.med31[1]     0.68 1.00     5859     2771
## depeffort_mostfair_devx2:rural.ses.med31[2]     0.75 1.00     4294     2731
## depeffort_mostfair_devx2:rural.ses.med31[3]     0.55 1.00     3521     2942
## depeffort_mostfair_devx2:rural.ses.med31[4]     0.72 1.00     5700     3059
## depeffort_mostfair_devx2:rural.ses.med41[1]     0.70 1.00     5472     2576
## depeffort_mostfair_devx2:rural.ses.med41[2]     0.69 1.00     4531     2525
## depeffort_mostfair_devx2:rural.ses.med41[3]     0.66 1.00     4895     2770
## depeffort_mostfair_devx2:rural.ses.med41[4]     0.79 1.00     5373     3140
## deplonely_mostfair_devx21[1]                    0.59 1.00     6248     2735
## deplonely_mostfair_devx21[2]                    0.53 1.00     6281     2367
## deplonely_mostfair_devx21[3]                    0.57 1.00     6046     2711
## deplonely_mostfair_devx21[4]                    0.59 1.00     6581     2946
## deplonely_mostfair_av12x21[1]                   0.33 1.00     7421     2484
## deplonely_mostfair_av12x21[2]                   0.32 1.00     7650     2528
## deplonely_mostfair_av12x21[3]                   0.32 1.00     7150     2232
## deplonely_mostfair_av12x21[4]                   0.32 1.00     8775     2390
## deplonely_mostfair_av12x21[5]                   0.32 1.00     7217     1947
## deplonely_mostfair_av12x21[6]                   0.32 1.00     6564     2344
## deplonely_mostfair_av12x21[7]                   0.32 1.00     6779     2944
## deplonely_mostfair_av12x21[8]                   0.32 1.00     7996     3101
## deplonely_mostfair_devx2:rural.ses.med21[1]     0.66 1.00     5752     2746
## deplonely_mostfair_devx2:rural.ses.med21[2]     0.67 1.00     5904     2940
## deplonely_mostfair_devx2:rural.ses.med21[3]     0.69 1.00     4864     2831
## deplonely_mostfair_devx2:rural.ses.med21[4]     0.73 1.00     4261     3055
## deplonely_mostfair_devx2:rural.ses.med31[1]     0.72 1.00     5327     2318
## deplonely_mostfair_devx2:rural.ses.med31[2]     0.68 1.00     4358     2484
## deplonely_mostfair_devx2:rural.ses.med31[3]     0.66 1.00     4246     2616
## deplonely_mostfair_devx2:rural.ses.med31[4]     0.73 1.00     5267     2851
## deplonely_mostfair_devx2:rural.ses.med41[1]     0.71 1.00     6090     2472
## deplonely_mostfair_devx2:rural.ses.med41[2]     0.66 1.00     5144     2629
## deplonely_mostfair_devx2:rural.ses.med41[3]     0.62 1.00     4511     2251
## deplonely_mostfair_devx2:rural.ses.med41[4]     0.75 1.00     5760     2844
## depblues_mostfair_devx21[1]                     0.59 1.00     6973     2678
## depblues_mostfair_devx21[2]                     0.57 1.00     5934     2694
## depblues_mostfair_devx21[3]                     0.55 1.00     7109     3013
## depblues_mostfair_devx21[4]                     0.61 1.00     6907     2817
## depblues_mostfair_av12x21[1]                    0.32 1.00     7024     2594
## depblues_mostfair_av12x21[2]                    0.31 1.00     7236     2304
## depblues_mostfair_av12x21[3]                    0.30 1.00     8494     2986
## depblues_mostfair_av12x21[4]                    0.30 1.00     6039     2472
## depblues_mostfair_av12x21[5]                    0.30 1.00     7908     2561
## depblues_mostfair_av12x21[6]                    0.32 1.00     7167     2663
## depblues_mostfair_av12x21[7]                    0.33 1.00     8168     2683
## depblues_mostfair_av12x21[8]                    0.34 1.00     6157     2901
## depblues_mostfair_devx2:rural.ses.med21[1]      0.69 1.00     5801     2958
## depblues_mostfair_devx2:rural.ses.med21[2]      0.66 1.00     4867     2686
## depblues_mostfair_devx2:rural.ses.med21[3]      0.67 1.00     5419     3140
## depblues_mostfair_devx2:rural.ses.med21[4]      0.78 1.00     4891     2722
## depblues_mostfair_devx2:rural.ses.med31[1]      0.72 1.00     4849     2401
## depblues_mostfair_devx2:rural.ses.med31[2]      0.68 1.00     5155     2281
## depblues_mostfair_devx2:rural.ses.med31[3]      0.66 1.00     4494     2737
## depblues_mostfair_devx2:rural.ses.med31[4]      0.74 1.00     4111     2519
## depblues_mostfair_devx2:rural.ses.med41[1]      0.69 1.00     5870     2729
## depblues_mostfair_devx2:rural.ses.med41[2]      0.69 1.00     6134     2352
## depblues_mostfair_devx2:rural.ses.med41[3]      0.67 1.00     4171     2678
## depblues_mostfair_devx2:rural.ses.med41[4]      0.79 1.00     5218     2784
## depunfair_mostfair_devx21[1]                    0.50 1.00     6565     2357
## depunfair_mostfair_devx21[2]                    0.61 1.00     5154     2414
## depunfair_mostfair_devx21[3]                    0.52 1.00     5985     2952
## depunfair_mostfair_devx21[4]                    0.55 1.00     6631     2768
## depunfair_mostfair_av12x21[1]                   0.30 1.00     8246     2297
## depunfair_mostfair_av12x21[2]                   0.33 1.00     7189     2485
## depunfair_mostfair_av12x21[3]                   0.32 1.00     6611     2359
## depunfair_mostfair_av12x21[4]                   0.32 1.00     7153     2296
## depunfair_mostfair_av12x21[5]                   0.31 1.00     5683     2056
## depunfair_mostfair_av12x21[6]                   0.32 1.00     6900     2434
## depunfair_mostfair_av12x21[7]                   0.34 1.00     7163     3053
## depunfair_mostfair_av12x21[8]                   0.33 1.00     7725     2210
## depunfair_mostfair_devx2:rural.ses.med21[1]     0.65 1.00     4761     2532
## depunfair_mostfair_devx2:rural.ses.med21[2]     0.78 1.00     3956     2545
## depunfair_mostfair_devx2:rural.ses.med21[3]     0.58 1.00     4808     2900
## depunfair_mostfair_devx2:rural.ses.med21[4]     0.71 1.00     6029     3027
## depunfair_mostfair_devx2:rural.ses.med31[1]     0.69 1.00     4813     2544
## depunfair_mostfair_devx2:rural.ses.med31[2]     0.69 1.00     6605     2137
## depunfair_mostfair_devx2:rural.ses.med31[3]     0.68 1.00     4083     2760
## depunfair_mostfair_devx2:rural.ses.med31[4]     0.72 1.00     4982     2745
## depunfair_mostfair_devx2:rural.ses.med41[1]     0.71 1.00     5150     2570
## depunfair_mostfair_devx2:rural.ses.med41[2]     0.63 1.00     5333     2272
## depunfair_mostfair_devx2:rural.ses.med41[3]     0.69 1.00     4704     3113
## depunfair_mostfair_devx2:rural.ses.med41[4]     0.74 1.00     5432     2615
## depmistrt_mostfair_devx21[1]                    0.61 1.00     8524     2811
## depmistrt_mostfair_devx21[2]                    0.54 1.00     8106     2715
## depmistrt_mostfair_devx21[3]                    0.56 1.00     5524     3037
## depmistrt_mostfair_devx21[4]                    0.60 1.00     6416     2878
## depmistrt_mostfair_av12x21[1]                   0.25 1.00     7773     2576
## depmistrt_mostfair_av12x21[2]                   0.31 1.00     6590     2124
## depmistrt_mostfair_av12x21[3]                   0.31 1.00     8067     2624
## depmistrt_mostfair_av12x21[4]                   0.36 1.00     7249     2752
## depmistrt_mostfair_av12x21[5]                   0.30 1.00     7291     2160
## depmistrt_mostfair_av12x21[6]                   0.29 1.00     8257     2475
## depmistrt_mostfair_av12x21[7]                   0.38 1.00     6827     3166
## depmistrt_mostfair_av12x21[8]                   0.26 1.00     7591     3002
## depmistrt_mostfair_devx2:rural.ses.med21[1]     0.68 1.00     5420     2190
## depmistrt_mostfair_devx2:rural.ses.med21[2]     0.70 1.00     4133     2202
## depmistrt_mostfair_devx2:rural.ses.med21[3]     0.58 1.00     4397     2153
## depmistrt_mostfair_devx2:rural.ses.med21[4]     0.76 1.00     5310     2877
## depmistrt_mostfair_devx2:rural.ses.med31[1]     0.70 1.00     4725     2388
## depmistrt_mostfair_devx2:rural.ses.med31[2]     0.57 1.00     5911     2603
## depmistrt_mostfair_devx2:rural.ses.med31[3]     0.76 1.00     3418     2522
## depmistrt_mostfair_devx2:rural.ses.med31[4]     0.69 1.00     4643     2396
## depmistrt_mostfair_devx2:rural.ses.med41[1]     0.73 1.00     4745     2453
## depmistrt_mostfair_devx2:rural.ses.med41[2]     0.66 1.00     6867     2493
## depmistrt_mostfair_devx2:rural.ses.med41[3]     0.64 1.00     5856     2509
## depmistrt_mostfair_devx2:rural.ses.med41[4]     0.77 1.00     5123     2751
## depbetray_mostfair_devx21[1]                    0.58 1.00     7536     2694
## depbetray_mostfair_devx21[2]                    0.58 1.00     5017     2466
## depbetray_mostfair_devx21[3]                    0.52 1.00     6159     3032
## depbetray_mostfair_devx21[4]                    0.58 1.00     8438     2831
## depbetray_mostfair_av12x21[1]                   0.30 1.00     7388     2761
## depbetray_mostfair_av12x21[2]                   0.34 1.00     6397     2477
## depbetray_mostfair_av12x21[3]                   0.34 1.00     6986     2737
## depbetray_mostfair_av12x21[4]                   0.37 1.00     6869     2718
## depbetray_mostfair_av12x21[5]                   0.27 1.00     7947     2781
## depbetray_mostfair_av12x21[6]                   0.26 1.00     6903     2575
## depbetray_mostfair_av12x21[7]                   0.31 1.00     6569     2872
## depbetray_mostfair_av12x21[8]                   0.31 1.00     6214     2835
## depbetray_mostfair_devx2:rural.ses.med21[1]     0.70 1.00     5745     2732
## depbetray_mostfair_devx2:rural.ses.med21[2]     0.65 1.00     5789     2758
## depbetray_mostfair_devx2:rural.ses.med21[3]     0.65 1.00     4515     2941
## depbetray_mostfair_devx2:rural.ses.med21[4]     0.75 1.00     5310     2946
## depbetray_mostfair_devx2:rural.ses.med31[1]     0.72 1.00     4844     2796
## depbetray_mostfair_devx2:rural.ses.med31[2]     0.73 1.00     3476     3053
## depbetray_mostfair_devx2:rural.ses.med31[3]     0.63 1.00     4284     2916
## depbetray_mostfair_devx2:rural.ses.med31[4]     0.75 1.00     4038     2617
## depbetray_mostfair_devx2:rural.ses.med41[1]     0.74 1.00     4098     2522
## depbetray_mostfair_devx2:rural.ses.med41[2]     0.64 1.00     4436     2279
## depbetray_mostfair_devx2:rural.ses.med41[3]     0.67 1.00     4637     3152
## depbetray_mostfair_devx2:rural.ses.med41[4]     0.75 1.00     5832     3315
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.2.4.4 Prior summary
out.chg.alldepress.stfair.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostfair_av12x2
##                    normal(0, 0.25)         b                 mostfair_devx2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostfair_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostfair_av12x21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostfair_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostfair_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##        depbetray                          user
##        depbetray                          user
##        depbetray                          user
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##         depblues                          user
##         depblues                          user
##         depblues                          user
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depeffort                          user
##        depeffort                          user
##        depeffort                          user
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        deplonely                          user
##        deplonely                          user
##        deplonely                          user
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depunfair                          user
##        depunfair                          user
##        depunfair                          user
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##                                        default
##        depbetray                          user
##         depblues                          user
##        depcantgo                          user
##        depeffort                          user
##        deplonely                          user
##        depmistrt                          user
##        depunfair                          user
##        depbetray             0         default
##         depblues             0         default
##        depcantgo             0         default
##        depeffort             0         default
##        deplonely             0         default
##        depmistrt             0         default
##        depunfair             0         default
##     id depbetray             0    (vectorized)
##     id depbetray             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depunfair             0    (vectorized)
##     id depunfair             0    (vectorized)
##        depbetray                          user
##        depbetray                       default
##        depbetray                       default
##        depbetray                       default
##        depbetray                          user
##         depblues                          user
##         depblues                       default
##         depblues                       default
##         depblues                       default
##         depblues                          user
##        depcantgo                          user
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                          user
##        depeffort                          user
##        depeffort                       default
##        depeffort                       default
##        depeffort                       default
##        depeffort                          user
##        deplonely                          user
##        deplonely                       default
##        deplonely                       default
##        deplonely                       default
##        deplonely                          user
##        depmistrt                          user
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                          user
##        depunfair                          user
##        depunfair                       default
##        depunfair                       default
##        depunfair                       default
##        depunfair                          user

8.1.2.5 Corr X Community: stjob & negative emotions

#Community Change: negative emotions items ~ mo(stjob)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostjob_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostjob_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostjob_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostjob_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stjob.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + 
         rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stjob_comm_fit",
      file_refit = "on_change"
  )


out.chg.alldepress.stjob.comm.fit <- ppchecks(chg.alldepress.stjob.comm.fit)
8.1.2.5.1 Coefficient plot (intervals)
out.chg.alldepress.stjob.comm.fit[[11]]

8.1.2.5.2 PPcheck (density)
p1 <- out.chg.alldepress.stjob.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stjob.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stjob.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stjob.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stjob.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stjob.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stjob.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

8.1.2.5.3 Fit summary
out.chg.alldepress.stjob.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          depeffort ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          deplonely ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          depblues ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          depunfair ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##          depbetray ~ 1 + mo(stjob_devx2) + mo(stjob_av12x2) + rural.ses.med + mo(stjob_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.30      0.20     0.01     0.72 1.00      637
## sd(depeffort_Intercept)     0.44      0.27     0.02     1.00 1.00      603
## sd(deplonely_Intercept)     0.41      0.24     0.03     0.87 1.00      536
## sd(depblues_Intercept)      0.70      0.33     0.06     1.31 1.01      521
## sd(depunfair_Intercept)     0.22      0.16     0.01     0.58 1.00     1106
## sd(depmistrt_Intercept)     0.34      0.23     0.01     0.82 1.00      681
## sd(depbetray_Intercept)     0.45      0.27     0.03     1.00 1.01      637
##                         Tail_ESS
## sd(depcantgo_Intercept)     1392
## sd(depeffort_Intercept)     1430
## sd(deplonely_Intercept)     1203
## sd(depblues_Intercept)       906
## sd(depunfair_Intercept)     2019
## sd(depmistrt_Intercept)     1750
## sd(depbetray_Intercept)     1479
## 
## Regression Coefficients:
##                                        Estimate Est.Error l-95% CI u-95% CI
## depcantgo_Intercept                       -0.61      0.29    -1.20    -0.05
## depeffort_Intercept                       -2.26      0.40    -3.11    -1.50
## deplonely_Intercept                       -1.28      0.31    -1.92    -0.69
## depblues_Intercept                        -2.17      0.42    -3.01    -1.34
## depunfair_Intercept                       -2.08      0.37    -2.82    -1.37
## depmistrt_Intercept                       -2.31      0.44    -3.13    -1.33
## depbetray_Intercept                       -3.02      0.43    -3.86    -2.18
## depcantgo_rural.ses.med2                  -0.12      0.54    -1.37     0.83
## depcantgo_rural.ses.med3                   0.81      0.41     0.02     1.64
## depcantgo_rural.ses.med4                   0.17      0.59    -0.81     1.60
## depeffort_rural.ses.med2                  -0.15      0.56    -1.33     0.90
## depeffort_rural.ses.med3                   0.30      0.59    -1.01     1.30
## depeffort_rural.ses.med4                   0.24      0.53    -0.88     1.31
## deplonely_rural.ses.med2                  -0.02      0.48    -0.94     1.01
## deplonely_rural.ses.med3                   0.39      0.44    -0.44     1.30
## deplonely_rural.ses.med4                   0.50      0.52    -0.50     1.59
## depblues_rural.ses.med2                    0.06      0.55    -1.06     1.14
## depblues_rural.ses.med3                    0.18      0.57    -1.12     1.18
## depblues_rural.ses.med4                    0.35      0.68    -1.12     1.63
## depunfair_rural.ses.med2                  -0.32      0.54    -1.53     0.62
## depunfair_rural.ses.med3                   0.84      0.48    -0.15     1.74
## depunfair_rural.ses.med4                   0.27      0.46    -0.73     1.04
## depmistrt_rural.ses.med2                   0.32      0.57    -0.83     1.46
## depmistrt_rural.ses.med3                   0.96      0.54    -0.04     2.11
## depmistrt_rural.ses.med4                   0.62      0.55    -0.48     1.79
## depbetray_rural.ses.med2                  -0.32      0.51    -1.40     0.61
## depbetray_rural.ses.med3                   0.85      0.50    -0.19     1.78
## depbetray_rural.ses.med4                   1.08      0.58    -0.19     2.15
## depcantgo_mostjob_devx2                    0.23      0.13    -0.04     0.48
## depcantgo_mostjob_av12x2                  -0.06      0.02    -0.11    -0.01
## depcantgo_mostjob_devx2:rural.ses.med2     0.22      0.27    -0.25     0.79
## depcantgo_mostjob_devx2:rural.ses.med3    -0.35      0.18    -0.70     0.02
## depcantgo_mostjob_devx2:rural.ses.med4     0.04      0.29    -0.57     0.59
## depeffort_mostjob_devx2                    0.08      0.15    -0.23     0.37
## depeffort_mostjob_av12x2                   0.02      0.03    -0.04     0.09
## depeffort_mostjob_devx2:rural.ses.med2     0.11      0.28    -0.43     0.72
## depeffort_mostjob_devx2:rural.ses.med3     0.03      0.31    -0.68     0.53
## depeffort_mostjob_devx2:rural.ses.med4     0.23      0.31    -0.31     0.92
## deplonely_mostjob_devx2                    0.18      0.13    -0.08     0.44
## deplonely_mostjob_av12x2                  -0.01      0.03    -0.06     0.05
## deplonely_mostjob_devx2:rural.ses.med2    -0.29      0.32    -1.06     0.23
## deplonely_mostjob_devx2:rural.ses.med3    -0.25      0.20    -0.67     0.14
## deplonely_mostjob_devx2:rural.ses.med4    -0.03      0.24    -0.50     0.47
## depblues_mostjob_devx2                    -0.14      0.16    -0.45     0.17
## depblues_mostjob_av12x2                    0.02      0.04    -0.05     0.10
## depblues_mostjob_devx2:rural.ses.med2      0.12      0.30    -0.53     0.65
## depblues_mostjob_devx2:rural.ses.med3      0.06      0.30    -0.61     0.60
## depblues_mostjob_devx2:rural.ses.med4      0.20      0.41    -0.52     1.10
## depunfair_mostjob_devx2                    0.09      0.15    -0.21     0.38
## depunfair_mostjob_av12x2                   0.07      0.03     0.02     0.12
## depunfair_mostjob_devx2:rural.ses.med2     0.37      0.23    -0.09     0.84
## depunfair_mostjob_devx2:rural.ses.med3    -0.08      0.22    -0.53     0.38
## depunfair_mostjob_devx2:rural.ses.med4     0.55      0.25     0.08     1.07
## depmistrt_mostjob_devx2                    0.01      0.18    -0.40     0.32
## depmistrt_mostjob_av12x2                   0.05      0.03    -0.01     0.11
## depmistrt_mostjob_devx2:rural.ses.med2     0.12      0.29    -0.50     0.61
## depmistrt_mostjob_devx2:rural.ses.med3    -0.28      0.35    -1.08     0.26
## depmistrt_mostjob_devx2:rural.ses.med4     0.09      0.28    -0.47     0.66
## depbetray_mostjob_devx2                    0.12      0.16    -0.21     0.43
## depbetray_mostjob_av12x2                   0.11      0.04     0.04     0.18
## depbetray_mostjob_devx2:rural.ses.med2     0.51      0.23     0.04     0.98
## depbetray_mostjob_devx2:rural.ses.med3    -0.07      0.24    -0.55     0.38
## depbetray_mostjob_devx2:rural.ses.med4    -0.06      0.30    -0.65     0.53
##                                        Rhat Bulk_ESS Tail_ESS
## depcantgo_Intercept                    1.00     3387     3076
## depeffort_Intercept                    1.00     2370     2564
## deplonely_Intercept                    1.00     3464     3172
## depblues_Intercept                     1.00     2415     3196
## depunfair_Intercept                    1.00     3087     3094
## depmistrt_Intercept                    1.00     2362     2633
## depbetray_Intercept                    1.00     3539     3394
## depcantgo_rural.ses.med2               1.00     2686     2560
## depcantgo_rural.ses.med3               1.00     3095     2579
## depcantgo_rural.ses.med4               1.00     2676     2443
## depeffort_rural.ses.med2               1.00     3865     3156
## depeffort_rural.ses.med3               1.00     3451     2924
## depeffort_rural.ses.med4               1.00     4060     3156
## deplonely_rural.ses.med2               1.00     3538     2862
## deplonely_rural.ses.med3               1.00     3462     3249
## deplonely_rural.ses.med4               1.00     3607     3162
## depblues_rural.ses.med2                1.00     3637     2745
## depblues_rural.ses.med3                1.00     3567     2854
## depblues_rural.ses.med4                1.00     3389     3087
## depunfair_rural.ses.med2               1.00     2980     2920
## depunfair_rural.ses.med3               1.00     2426     2071
## depunfair_rural.ses.med4               1.00     4017     3215
## depmistrt_rural.ses.med2               1.00     2944     2256
## depmistrt_rural.ses.med3               1.00     3064     3231
## depmistrt_rural.ses.med4               1.00     2736     2713
## depbetray_rural.ses.med2               1.00     4052     2901
## depbetray_rural.ses.med3               1.00     3237     3131
## depbetray_rural.ses.med4               1.00     3307     2754
## depcantgo_mostjob_devx2                1.00     2317     2442
## depcantgo_mostjob_av12x2               1.00     6378     3407
## depcantgo_mostjob_devx2:rural.ses.med2 1.00     2473     2690
## depcantgo_mostjob_devx2:rural.ses.med3 1.00     2388     2360
## depcantgo_mostjob_devx2:rural.ses.med4 1.00     2440     2582
## depeffort_mostjob_devx2                1.00     2262     2812
## depeffort_mostjob_av12x2               1.00     5948     3269
## depeffort_mostjob_devx2:rural.ses.med2 1.00     3190     2859
## depeffort_mostjob_devx2:rural.ses.med3 1.00     2918     2006
## depeffort_mostjob_devx2:rural.ses.med4 1.00     3603     2936
## deplonely_mostjob_devx2                1.00     3142     2846
## deplonely_mostjob_av12x2               1.00     6639     3670
## deplonely_mostjob_devx2:rural.ses.med2 1.00     3013     2064
## deplonely_mostjob_devx2:rural.ses.med3 1.00     3243     3162
## deplonely_mostjob_devx2:rural.ses.med4 1.00     3648     3049
## depblues_mostjob_devx2                 1.00     3344     3151
## depblues_mostjob_av12x2                1.00     6001     3363
## depblues_mostjob_devx2:rural.ses.med2  1.00     2996     2280
## depblues_mostjob_devx2:rural.ses.med3  1.00     2767     1914
## depblues_mostjob_devx2:rural.ses.med4  1.00     2942     3003
## depunfair_mostjob_devx2                1.00     2723     3025
## depunfair_mostjob_av12x2               1.00     7377     3132
## depunfair_mostjob_devx2:rural.ses.med2 1.00     2906     2761
## depunfair_mostjob_devx2:rural.ses.med3 1.00     2522     2078
## depunfair_mostjob_devx2:rural.ses.med4 1.00     3525     3161
## depmistrt_mostjob_devx2                1.00     1928     2707
## depmistrt_mostjob_av12x2               1.00     8263     3414
## depmistrt_mostjob_devx2:rural.ses.med2 1.00     2489     1863
## depmistrt_mostjob_devx2:rural.ses.med3 1.00     2525     2653
## depmistrt_mostjob_devx2:rural.ses.med4 1.00     2743     2739
## depbetray_mostjob_devx2                1.00     3110     3137
## depbetray_mostjob_av12x2               1.00     7693     3600
## depbetray_mostjob_devx2:rural.ses.med2 1.00     2920     2602
## depbetray_mostjob_devx2:rural.ses.med3 1.00     3179     3213
## depbetray_mostjob_devx2:rural.ses.med4 1.00     3111     2778
## 
## Monotonic Simplex Parameters:
##                                            Estimate Est.Error l-95% CI u-95% CI
## depcantgo_mostjob_devx21[1]                    0.20      0.12     0.03     0.48
## depcantgo_mostjob_devx21[2]                    0.20      0.12     0.03     0.48
## depcantgo_mostjob_devx21[3]                    0.36      0.15     0.08     0.65
## depcantgo_mostjob_devx21[4]                    0.24      0.13     0.03     0.53
## depcantgo_mostjob_av12x21[1]                   0.10      0.07     0.01     0.26
## depcantgo_mostjob_av12x21[2]                   0.10      0.07     0.01     0.27
## depcantgo_mostjob_av12x21[3]                   0.11      0.07     0.01     0.28
## depcantgo_mostjob_av12x21[4]                   0.12      0.08     0.02     0.31
## depcantgo_mostjob_av12x21[5]                   0.14      0.08     0.02     0.34
## depcantgo_mostjob_av12x21[6]                   0.16      0.10     0.02     0.38
## depcantgo_mostjob_av12x21[7]                   0.14      0.09     0.02     0.35
## depcantgo_mostjob_av12x21[8]                   0.13      0.08     0.02     0.31
## depcantgo_mostjob_devx2:rural.ses.med21[1]     0.29      0.20     0.01     0.73
## depcantgo_mostjob_devx2:rural.ses.med21[2]     0.17      0.16     0.00     0.61
## depcantgo_mostjob_devx2:rural.ses.med21[3]     0.27      0.19     0.01     0.70
## depcantgo_mostjob_devx2:rural.ses.med21[4]     0.28      0.20     0.01     0.72
## depcantgo_mostjob_devx2:rural.ses.med31[1]     0.17      0.14     0.01     0.54
## depcantgo_mostjob_devx2:rural.ses.med31[2]     0.35      0.18     0.03     0.72
## depcantgo_mostjob_devx2:rural.ses.med31[3]     0.28      0.17     0.02     0.64
## depcantgo_mostjob_devx2:rural.ses.med31[4]     0.21      0.16     0.01     0.59
## depcantgo_mostjob_devx2:rural.ses.med41[1]     0.26      0.21     0.01     0.75
## depcantgo_mostjob_devx2:rural.ses.med41[2]     0.21      0.17     0.01     0.62
## depcantgo_mostjob_devx2:rural.ses.med41[3]     0.26      0.20     0.01     0.73
## depcantgo_mostjob_devx2:rural.ses.med41[4]     0.28      0.20     0.01     0.73
## depeffort_mostjob_devx21[1]                    0.25      0.15     0.04     0.58
## depeffort_mostjob_devx21[2]                    0.26      0.14     0.04     0.58
## depeffort_mostjob_devx21[3]                    0.23      0.13     0.04     0.53
## depeffort_mostjob_devx21[4]                    0.26      0.15     0.04     0.59
## depeffort_mostjob_av12x21[1]                   0.12      0.08     0.02     0.31
## depeffort_mostjob_av12x21[2]                   0.13      0.08     0.02     0.33
## depeffort_mostjob_av12x21[3]                   0.12      0.08     0.02     0.30
## depeffort_mostjob_av12x21[4]                   0.12      0.08     0.02     0.31
## depeffort_mostjob_av12x21[5]                   0.12      0.08     0.01     0.32
## depeffort_mostjob_av12x21[6]                   0.12      0.08     0.02     0.31
## depeffort_mostjob_av12x21[7]                   0.13      0.08     0.02     0.32
## depeffort_mostjob_av12x21[8]                   0.13      0.08     0.02     0.34
## depeffort_mostjob_devx2:rural.ses.med21[1]     0.25      0.19     0.01     0.70
## depeffort_mostjob_devx2:rural.ses.med21[2]     0.22      0.18     0.01     0.65
## depeffort_mostjob_devx2:rural.ses.med21[3]     0.23      0.18     0.01     0.66
## depeffort_mostjob_devx2:rural.ses.med21[4]     0.30      0.22     0.01     0.77
## depeffort_mostjob_devx2:rural.ses.med31[1]     0.28      0.21     0.01     0.75
## depeffort_mostjob_devx2:rural.ses.med31[2]     0.22      0.18     0.01     0.68
## depeffort_mostjob_devx2:rural.ses.med31[3]     0.21      0.17     0.01     0.64
## depeffort_mostjob_devx2:rural.ses.med31[4]     0.29      0.22     0.01     0.81
## depeffort_mostjob_devx2:rural.ses.med41[1]     0.23      0.18     0.01     0.66
## depeffort_mostjob_devx2:rural.ses.med41[2]     0.19      0.17     0.01     0.63
## depeffort_mostjob_devx2:rural.ses.med41[3]     0.24      0.18     0.01     0.68
## depeffort_mostjob_devx2:rural.ses.med41[4]     0.34      0.23     0.01     0.79
## deplonely_mostjob_devx21[1]                    0.21      0.13     0.03     0.52
## deplonely_mostjob_devx21[2]                    0.25      0.13     0.04     0.54
## deplonely_mostjob_devx21[3]                    0.29      0.14     0.05     0.60
## deplonely_mostjob_devx21[4]                    0.26      0.14     0.04     0.58
## deplonely_mostjob_av12x21[1]                   0.13      0.08     0.02     0.31
## deplonely_mostjob_av12x21[2]                   0.13      0.08     0.02     0.33
## deplonely_mostjob_av12x21[3]                   0.13      0.08     0.02     0.32
## deplonely_mostjob_av12x21[4]                   0.12      0.08     0.02     0.32
## deplonely_mostjob_av12x21[5]                   0.12      0.08     0.02     0.31
## deplonely_mostjob_av12x21[6]                   0.12      0.08     0.01     0.32
## deplonely_mostjob_av12x21[7]                   0.13      0.08     0.02     0.33
## deplonely_mostjob_av12x21[8]                   0.13      0.08     0.02     0.33
## deplonely_mostjob_devx2:rural.ses.med21[1]     0.23      0.18     0.01     0.66
## deplonely_mostjob_devx2:rural.ses.med21[2]     0.19      0.16     0.01     0.59
## deplonely_mostjob_devx2:rural.ses.med21[3]     0.25      0.18     0.01     0.67
## deplonely_mostjob_devx2:rural.ses.med21[4]     0.33      0.22     0.01     0.80
## deplonely_mostjob_devx2:rural.ses.med31[1]     0.24      0.18     0.01     0.66
## deplonely_mostjob_devx2:rural.ses.med31[2]     0.25      0.18     0.01     0.68
## deplonely_mostjob_devx2:rural.ses.med31[3]     0.26      0.18     0.01     0.66
## deplonely_mostjob_devx2:rural.ses.med31[4]     0.25      0.19     0.01     0.68
## deplonely_mostjob_devx2:rural.ses.med41[1]     0.26      0.20     0.01     0.73
## deplonely_mostjob_devx2:rural.ses.med41[2]     0.23      0.18     0.01     0.65
## deplonely_mostjob_devx2:rural.ses.med41[3]     0.23      0.18     0.01     0.66
## deplonely_mostjob_devx2:rural.ses.med41[4]     0.28      0.20     0.01     0.74
## depblues_mostjob_devx21[1]                     0.24      0.14     0.04     0.57
## depblues_mostjob_devx21[2]                     0.26      0.14     0.05     0.58
## depblues_mostjob_devx21[3]                     0.24      0.14     0.04     0.55
## depblues_mostjob_devx21[4]                     0.25      0.14     0.04     0.57
## depblues_mostjob_av12x21[1]                    0.13      0.08     0.02     0.33
## depblues_mostjob_av12x21[2]                    0.12      0.08     0.02     0.32
## depblues_mostjob_av12x21[3]                    0.12      0.08     0.02     0.32
## depblues_mostjob_av12x21[4]                    0.13      0.08     0.02     0.32
## depblues_mostjob_av12x21[5]                    0.13      0.08     0.02     0.32
## depblues_mostjob_av12x21[6]                    0.13      0.08     0.02     0.32
## depblues_mostjob_av12x21[7]                    0.13      0.08     0.02     0.32
## depblues_mostjob_av12x21[8]                    0.12      0.08     0.02     0.31
## depblues_mostjob_devx2:rural.ses.med21[1]      0.24      0.19     0.01     0.70
## depblues_mostjob_devx2:rural.ses.med21[2]      0.22      0.18     0.01     0.67
## depblues_mostjob_devx2:rural.ses.med21[3]      0.27      0.20     0.01     0.71
## depblues_mostjob_devx2:rural.ses.med21[4]      0.28      0.21     0.01     0.77
## depblues_mostjob_devx2:rural.ses.med31[1]      0.27      0.20     0.01     0.73
## depblues_mostjob_devx2:rural.ses.med31[2]      0.21      0.17     0.01     0.63
## depblues_mostjob_devx2:rural.ses.med31[3]      0.23      0.18     0.01     0.66
## depblues_mostjob_devx2:rural.ses.med31[4]      0.29      0.22     0.01     0.79
## depblues_mostjob_devx2:rural.ses.med41[1]      0.26      0.19     0.01     0.72
## depblues_mostjob_devx2:rural.ses.med41[2]      0.19      0.17     0.00     0.61
## depblues_mostjob_devx2:rural.ses.med41[3]      0.20      0.19     0.00     0.66
## depblues_mostjob_devx2:rural.ses.med41[4]      0.35      0.24     0.01     0.84
## depunfair_mostjob_devx21[1]                    0.25      0.14     0.04     0.58
## depunfair_mostjob_devx21[2]                    0.22      0.13     0.03     0.54
## depunfair_mostjob_devx21[3]                    0.27      0.15     0.04     0.60
## depunfair_mostjob_devx21[4]                    0.25      0.14     0.04     0.58
## depunfair_mostjob_av12x21[1]                   0.11      0.07     0.02     0.30
## depunfair_mostjob_av12x21[2]                   0.12      0.08     0.01     0.31
## depunfair_mostjob_av12x21[3]                   0.13      0.08     0.02     0.32
## depunfair_mostjob_av12x21[4]                   0.13      0.08     0.02     0.33
## depunfair_mostjob_av12x21[5]                   0.12      0.08     0.02     0.31
## depunfair_mostjob_av12x21[6]                   0.11      0.07     0.01     0.28
## depunfair_mostjob_av12x21[7]                   0.15      0.09     0.02     0.36
## depunfair_mostjob_av12x21[8]                   0.13      0.08     0.02     0.32
## depunfair_mostjob_devx2:rural.ses.med21[1]     0.24      0.18     0.01     0.66
## depunfair_mostjob_devx2:rural.ses.med21[2]     0.20      0.15     0.01     0.58
## depunfair_mostjob_devx2:rural.ses.med21[3]     0.33      0.19     0.02     0.72
## depunfair_mostjob_devx2:rural.ses.med21[4]     0.23      0.18     0.01     0.65
## depunfair_mostjob_devx2:rural.ses.med31[1]     0.25      0.19     0.01     0.72
## depunfair_mostjob_devx2:rural.ses.med31[2]     0.24      0.19     0.01     0.70
## depunfair_mostjob_devx2:rural.ses.med31[3]     0.23      0.18     0.01     0.68
## depunfair_mostjob_devx2:rural.ses.med31[4]     0.28      0.20     0.01     0.72
## depunfair_mostjob_devx2:rural.ses.med41[1]     0.15      0.13     0.00     0.49
## depunfair_mostjob_devx2:rural.ses.med41[2]     0.15      0.12     0.01     0.44
## depunfair_mostjob_devx2:rural.ses.med41[3]     0.48      0.18     0.09     0.81
## depunfair_mostjob_devx2:rural.ses.med41[4]     0.22      0.16     0.01     0.61
## depmistrt_mostjob_devx21[1]                    0.26      0.15     0.04     0.63
## depmistrt_mostjob_devx21[2]                    0.23      0.13     0.04     0.54
## depmistrt_mostjob_devx21[3]                    0.25      0.15     0.03     0.58
## depmistrt_mostjob_devx21[4]                    0.26      0.15     0.04     0.59
## depmistrt_mostjob_av12x21[1]                   0.14      0.09     0.02     0.36
## depmistrt_mostjob_av12x21[2]                   0.13      0.08     0.02     0.33
## depmistrt_mostjob_av12x21[3]                   0.13      0.08     0.02     0.32
## depmistrt_mostjob_av12x21[4]                   0.13      0.08     0.02     0.33
## depmistrt_mostjob_av12x21[5]                   0.12      0.08     0.02     0.30
## depmistrt_mostjob_av12x21[6]                   0.12      0.07     0.02     0.30
## depmistrt_mostjob_av12x21[7]                   0.12      0.08     0.02     0.31
## depmistrt_mostjob_av12x21[8]                   0.12      0.08     0.02     0.32
## depmistrt_mostjob_devx2:rural.ses.med21[1]     0.25      0.19     0.01     0.72
## depmistrt_mostjob_devx2:rural.ses.med21[2]     0.23      0.17     0.01     0.64
## depmistrt_mostjob_devx2:rural.ses.med21[3]     0.25      0.19     0.01     0.69
## depmistrt_mostjob_devx2:rural.ses.med21[4]     0.27      0.21     0.01     0.77
## depmistrt_mostjob_devx2:rural.ses.med31[1]     0.26      0.19     0.01     0.70
## depmistrt_mostjob_devx2:rural.ses.med31[2]     0.20      0.17     0.01     0.63
## depmistrt_mostjob_devx2:rural.ses.med31[3]     0.18      0.17     0.00     0.62
## depmistrt_mostjob_devx2:rural.ses.med31[4]     0.35      0.23     0.02     0.82
## depmistrt_mostjob_devx2:rural.ses.med41[1]     0.24      0.19     0.01     0.69
## depmistrt_mostjob_devx2:rural.ses.med41[2]     0.23      0.18     0.01     0.67
## depmistrt_mostjob_devx2:rural.ses.med41[3]     0.25      0.19     0.01     0.68
## depmistrt_mostjob_devx2:rural.ses.med41[4]     0.29      0.21     0.01     0.75
## depbetray_mostjob_devx21[1]                    0.24      0.14     0.03     0.57
## depbetray_mostjob_devx21[2]                    0.25      0.14     0.04     0.58
## depbetray_mostjob_devx21[3]                    0.27      0.15     0.04     0.59
## depbetray_mostjob_devx21[4]                    0.24      0.14     0.04     0.55
## depbetray_mostjob_av12x21[1]                   0.14      0.09     0.02     0.35
## depbetray_mostjob_av12x21[2]                   0.12      0.08     0.02     0.30
## depbetray_mostjob_av12x21[3]                   0.11      0.07     0.02     0.29
## depbetray_mostjob_av12x21[4]                   0.11      0.07     0.01     0.28
## depbetray_mostjob_av12x21[5]                   0.11      0.07     0.01     0.29
## depbetray_mostjob_av12x21[6]                   0.10      0.07     0.02     0.26
## depbetray_mostjob_av12x21[7]                   0.13      0.08     0.02     0.32
## depbetray_mostjob_av12x21[8]                   0.18      0.10     0.03     0.40
## depbetray_mostjob_devx2:rural.ses.med21[1]     0.16      0.13     0.00     0.49
## depbetray_mostjob_devx2:rural.ses.med21[2]     0.19      0.15     0.01     0.55
## depbetray_mostjob_devx2:rural.ses.med21[3]     0.44      0.19     0.07     0.80
## depbetray_mostjob_devx2:rural.ses.med21[4]     0.22      0.16     0.01     0.60
## depbetray_mostjob_devx2:rural.ses.med31[1]     0.25      0.20     0.01     0.71
## depbetray_mostjob_devx2:rural.ses.med31[2]     0.22      0.17     0.01     0.64
## depbetray_mostjob_devx2:rural.ses.med31[3]     0.24      0.18     0.01     0.68
## depbetray_mostjob_devx2:rural.ses.med31[4]     0.29      0.21     0.01     0.76
## depbetray_mostjob_devx2:rural.ses.med41[1]     0.24      0.18     0.01     0.68
## depbetray_mostjob_devx2:rural.ses.med41[2]     0.22      0.18     0.01     0.64
## depbetray_mostjob_devx2:rural.ses.med41[3]     0.26      0.20     0.01     0.71
## depbetray_mostjob_devx2:rural.ses.med41[4]     0.28      0.20     0.01     0.73
##                                            Rhat Bulk_ESS Tail_ESS
## depcantgo_mostjob_devx21[1]                1.00     6542     2622
## depcantgo_mostjob_devx21[2]                1.00     6442     2541
## depcantgo_mostjob_devx21[3]                1.00     3769     2808
## depcantgo_mostjob_devx21[4]                1.00     7426     2552
## depcantgo_mostjob_av12x21[1]               1.00     7753     2666
## depcantgo_mostjob_av12x21[2]               1.00     7798     2648
## depcantgo_mostjob_av12x21[3]               1.00     7035     2386
## depcantgo_mostjob_av12x21[4]               1.00     8586     2413
## depcantgo_mostjob_av12x21[5]               1.00     7222     2662
## depcantgo_mostjob_av12x21[6]               1.00     8315     2397
## depcantgo_mostjob_av12x21[7]               1.00     6512     2698
## depcantgo_mostjob_av12x21[8]               1.00     7840     2932
## depcantgo_mostjob_devx2:rural.ses.med21[1] 1.00     4841     2674
## depcantgo_mostjob_devx2:rural.ses.med21[2] 1.00     4930     2818
## depcantgo_mostjob_devx2:rural.ses.med21[3] 1.00     4976     2977
## depcantgo_mostjob_devx2:rural.ses.med21[4] 1.00     6075     2838
## depcantgo_mostjob_devx2:rural.ses.med31[1] 1.00     5375     2618
## depcantgo_mostjob_devx2:rural.ses.med31[2] 1.00     5533     2213
## depcantgo_mostjob_devx2:rural.ses.med31[3] 1.00     4499     2924
## depcantgo_mostjob_devx2:rural.ses.med31[4] 1.00     5875     2600
## depcantgo_mostjob_devx2:rural.ses.med41[1] 1.00     3729     2524
## depcantgo_mostjob_devx2:rural.ses.med41[2] 1.00     5591     2594
## depcantgo_mostjob_devx2:rural.ses.med41[3] 1.00     3666     2739
## depcantgo_mostjob_devx2:rural.ses.med41[4] 1.00     5971     2827
## depeffort_mostjob_devx21[1]                1.00     6273     2488
## depeffort_mostjob_devx21[2]                1.00     5364     2795
## depeffort_mostjob_devx21[3]                1.00     5991     2695
## depeffort_mostjob_devx21[4]                1.00     7004     2888
## depeffort_mostjob_av12x21[1]               1.00     8657     2641
## depeffort_mostjob_av12x21[2]               1.00     8637     2458
## depeffort_mostjob_av12x21[3]               1.00     8303     2462
## depeffort_mostjob_av12x21[4]               1.00     7556     2502
## depeffort_mostjob_av12x21[5]               1.00     7487     2636
## depeffort_mostjob_av12x21[6]               1.00     8872     3100
## depeffort_mostjob_av12x21[7]               1.00     7874     2780
## depeffort_mostjob_av12x21[8]               1.00     6443     2866
## depeffort_mostjob_devx2:rural.ses.med21[1] 1.00     5871     2276
## depeffort_mostjob_devx2:rural.ses.med21[2] 1.00     6141     2741
## depeffort_mostjob_devx2:rural.ses.med21[3] 1.00     6087     3170
## depeffort_mostjob_devx2:rural.ses.med21[4] 1.00     5510     2874
## depeffort_mostjob_devx2:rural.ses.med31[1] 1.00     4353     2539
## depeffort_mostjob_devx2:rural.ses.med31[2] 1.00     4969     2611
## depeffort_mostjob_devx2:rural.ses.med31[3] 1.00     5047     2745
## depeffort_mostjob_devx2:rural.ses.med31[4] 1.00     4261     2932
## depeffort_mostjob_devx2:rural.ses.med41[1] 1.00     5612     2196
## depeffort_mostjob_devx2:rural.ses.med41[2] 1.00     5356     2479
## depeffort_mostjob_devx2:rural.ses.med41[3] 1.00     4090     2813
## depeffort_mostjob_devx2:rural.ses.med41[4] 1.00     4990     2289
## deplonely_mostjob_devx21[1]                1.00     6529     3073
## deplonely_mostjob_devx21[2]                1.00     8605     2345
## deplonely_mostjob_devx21[3]                1.00     5341     3090
## deplonely_mostjob_devx21[4]                1.00     7684     2677
## deplonely_mostjob_av12x21[1]               1.00     7040     2450
## deplonely_mostjob_av12x21[2]               1.00     7177     2305
## deplonely_mostjob_av12x21[3]               1.00     8345     2401
## deplonely_mostjob_av12x21[4]               1.00     6661     2425
## deplonely_mostjob_av12x21[5]               1.00     8498     2932
## deplonely_mostjob_av12x21[6]               1.00     9048     2642
## deplonely_mostjob_av12x21[7]               1.00     7353     2469
## deplonely_mostjob_av12x21[8]               1.00     7345     2619
## deplonely_mostjob_devx2:rural.ses.med21[1] 1.00     5041     2538
## deplonely_mostjob_devx2:rural.ses.med21[2] 1.00     5743     2755
## deplonely_mostjob_devx2:rural.ses.med21[3] 1.00     5450     3014
## deplonely_mostjob_devx2:rural.ses.med21[4] 1.00     4699     2622
## deplonely_mostjob_devx2:rural.ses.med31[1] 1.00     6146     2324
## deplonely_mostjob_devx2:rural.ses.med31[2] 1.00     6126     2544
## deplonely_mostjob_devx2:rural.ses.med31[3] 1.00     5951     3012
## deplonely_mostjob_devx2:rural.ses.med31[4] 1.00     6828     2625
## deplonely_mostjob_devx2:rural.ses.med41[1] 1.00     6021     2513
## deplonely_mostjob_devx2:rural.ses.med41[2] 1.00     6493     2429
## deplonely_mostjob_devx2:rural.ses.med41[3] 1.00     5997     2128
## deplonely_mostjob_devx2:rural.ses.med41[4] 1.00     5849     3315
## depblues_mostjob_devx21[1]                 1.00     8029     2682
## depblues_mostjob_devx21[2]                 1.00     6185     2604
## depblues_mostjob_devx21[3]                 1.00     8739     3199
## depblues_mostjob_devx21[4]                 1.00     7402     2528
## depblues_mostjob_av12x21[1]                1.00     8172     1970
## depblues_mostjob_av12x21[2]                1.00     7514     2605
## depblues_mostjob_av12x21[3]                1.00     8255     2937
## depblues_mostjob_av12x21[4]                1.00     8178     2937
## depblues_mostjob_av12x21[5]                1.00     9025     2769
## depblues_mostjob_av12x21[6]                1.00     7641     2556
## depblues_mostjob_av12x21[7]                1.00     7327     2994
## depblues_mostjob_av12x21[8]                1.00     7272     3279
## depblues_mostjob_devx2:rural.ses.med21[1]  1.00     5945     2561
## depblues_mostjob_devx2:rural.ses.med21[2]  1.00     7266     2115
## depblues_mostjob_devx2:rural.ses.med21[3]  1.00     4463     3217
## depblues_mostjob_devx2:rural.ses.med21[4]  1.00     5255     2298
## depblues_mostjob_devx2:rural.ses.med31[1]  1.00     4742     2342
## depblues_mostjob_devx2:rural.ses.med31[2]  1.00     5833     2572
## depblues_mostjob_devx2:rural.ses.med31[3]  1.00     5465     2548
## depblues_mostjob_devx2:rural.ses.med31[4]  1.00     4788     2368
## depblues_mostjob_devx2:rural.ses.med41[1]  1.00     5258     2895
## depblues_mostjob_devx2:rural.ses.med41[2]  1.00     3890     2772
## depblues_mostjob_devx2:rural.ses.med41[3]  1.00     3813     3272
## depblues_mostjob_devx2:rural.ses.med41[4]  1.00     3909     3159
## depunfair_mostjob_devx21[1]                1.00     7160     2895
## depunfair_mostjob_devx21[2]                1.00     7721     2837
## depunfair_mostjob_devx21[3]                1.00     4884     2965
## depunfair_mostjob_devx21[4]                1.00     6549     2740
## depunfair_mostjob_av12x21[1]               1.00     6917     2965
## depunfair_mostjob_av12x21[2]               1.00     7670     2387
## depunfair_mostjob_av12x21[3]               1.00     7204     2314
## depunfair_mostjob_av12x21[4]               1.00     7804     2709
## depunfair_mostjob_av12x21[5]               1.00     8569     2692
## depunfair_mostjob_av12x21[6]               1.00     7374     2866
## depunfair_mostjob_av12x21[7]               1.00     7158     2919
## depunfair_mostjob_av12x21[8]               1.00     8388     2611
## depunfair_mostjob_devx2:rural.ses.med21[1] 1.00     4766     2166
## depunfair_mostjob_devx2:rural.ses.med21[2] 1.00     5547     2496
## depunfair_mostjob_devx2:rural.ses.med21[3] 1.00     4174     2610
## depunfair_mostjob_devx2:rural.ses.med21[4] 1.00     6167     2595
## depunfair_mostjob_devx2:rural.ses.med31[1] 1.00     4047     2325
## depunfair_mostjob_devx2:rural.ses.med31[2] 1.00     5007     2197
## depunfair_mostjob_devx2:rural.ses.med31[3] 1.00     5116     2848
## depunfair_mostjob_devx2:rural.ses.med31[4] 1.00     6646     2691
## depunfair_mostjob_devx2:rural.ses.med41[1] 1.00     5272     2586
## depunfair_mostjob_devx2:rural.ses.med41[2] 1.00     5362     2585
## depunfair_mostjob_devx2:rural.ses.med41[3] 1.00     4458     2816
## depunfair_mostjob_devx2:rural.ses.med41[4] 1.00     6007     2543
## depmistrt_mostjob_devx21[1]                1.00     4060     2933
## depmistrt_mostjob_devx21[2]                1.00     7712     2992
## depmistrt_mostjob_devx21[3]                1.00     3423     2795
## depmistrt_mostjob_devx21[4]                1.00     6540     2945
## depmistrt_mostjob_av12x21[1]               1.00     7699     2292
## depmistrt_mostjob_av12x21[2]               1.00     7367     2113
## depmistrt_mostjob_av12x21[3]               1.00     6966     2353
## depmistrt_mostjob_av12x21[4]               1.00     7594     2320
## depmistrt_mostjob_av12x21[5]               1.00     6548     2411
## depmistrt_mostjob_av12x21[6]               1.00     7298     2609
## depmistrt_mostjob_av12x21[7]               1.00     7205     3015
## depmistrt_mostjob_av12x21[8]               1.00     6601     2574
## depmistrt_mostjob_devx2:rural.ses.med21[1] 1.00     5586     2298
## depmistrt_mostjob_devx2:rural.ses.med21[2] 1.00     5956     2899
## depmistrt_mostjob_devx2:rural.ses.med21[3] 1.00     3732     2753
## depmistrt_mostjob_devx2:rural.ses.med21[4] 1.00     3810     2361
## depmistrt_mostjob_devx2:rural.ses.med31[1] 1.00     5648     2795
## depmistrt_mostjob_devx2:rural.ses.med31[2] 1.00     5677     2490
## depmistrt_mostjob_devx2:rural.ses.med31[3] 1.00     3847     2555
## depmistrt_mostjob_devx2:rural.ses.med31[4] 1.00     4236     3059
## depmistrt_mostjob_devx2:rural.ses.med41[1] 1.00     5532     2298
## depmistrt_mostjob_devx2:rural.ses.med41[2] 1.00     6275     2247
## depmistrt_mostjob_devx2:rural.ses.med41[3] 1.00     5846     2679
## depmistrt_mostjob_devx2:rural.ses.med41[4] 1.00     5574     2715
## depbetray_mostjob_devx21[1]                1.00     6501     2422
## depbetray_mostjob_devx21[2]                1.00     7030     2578
## depbetray_mostjob_devx21[3]                1.00     6025     3055
## depbetray_mostjob_devx21[4]                1.00     6846     3243
## depbetray_mostjob_av12x21[1]               1.00     7897     2284
## depbetray_mostjob_av12x21[2]               1.00     7994     2375
## depbetray_mostjob_av12x21[3]               1.00     9269     2438
## depbetray_mostjob_av12x21[4]               1.00     6690     2694
## depbetray_mostjob_av12x21[5]               1.00     9584     2223
## depbetray_mostjob_av12x21[6]               1.00     7133     2875
## depbetray_mostjob_av12x21[7]               1.00     8021     2917
## depbetray_mostjob_av12x21[8]               1.00     7770     2801
## depbetray_mostjob_devx2:rural.ses.med21[1] 1.00     4879     2406
## depbetray_mostjob_devx2:rural.ses.med21[2] 1.00     6108     2867
## depbetray_mostjob_devx2:rural.ses.med21[3] 1.00     4408     2558
## depbetray_mostjob_devx2:rural.ses.med21[4] 1.00     5661     2591
## depbetray_mostjob_devx2:rural.ses.med31[1] 1.00     6368     2104
## depbetray_mostjob_devx2:rural.ses.med31[2] 1.00     7188     2462
## depbetray_mostjob_devx2:rural.ses.med31[3] 1.00     5447     3070
## depbetray_mostjob_devx2:rural.ses.med31[4] 1.00     6576     2650
## depbetray_mostjob_devx2:rural.ses.med41[1] 1.00     5220     2455
## depbetray_mostjob_devx2:rural.ses.med41[2] 1.00     5927     2546
## depbetray_mostjob_devx2:rural.ses.med41[3] 1.00     3975     3241
## depbetray_mostjob_devx2:rural.ses.med41[4] 1.00     7829     3000
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.2.5.4 Prior summary
out.chg.alldepress.stjob.comm.fit[[2]]
##                              prior     class                          coef
##                             (flat)         b                              
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostjob_av12x2
##                    normal(0, 0.25)         b                 mostjob_devx2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostjob_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                             (flat) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostjob_av12x21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostjob_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostjob_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##        depbetray                          user
##        depbetray                          user
##        depbetray                          user
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##         depblues                          user
##         depblues                          user
##         depblues                          user
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depeffort                          user
##        depeffort                          user
##        depeffort                          user
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        deplonely                          user
##        deplonely                          user
##        deplonely                          user
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depunfair                          user
##        depunfair                          user
##        depunfair                          user
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##                                        default
##        depbetray                          user
##         depblues                          user
##        depcantgo                          user
##        depeffort                          user
##        deplonely                          user
##        depmistrt                          user
##        depunfair                          user
##        depbetray             0         default
##         depblues             0         default
##        depcantgo             0         default
##        depeffort             0         default
##        deplonely             0         default
##        depmistrt             0         default
##        depunfair             0         default
##     id depbetray             0    (vectorized)
##     id depbetray             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depunfair             0    (vectorized)
##     id depunfair             0    (vectorized)
##        depbetray                          user
##        depbetray                       default
##        depbetray                       default
##        depbetray                       default
##        depbetray                          user
##         depblues                          user
##         depblues                       default
##         depblues                       default
##         depblues                       default
##         depblues                          user
##        depcantgo                          user
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                          user
##        depeffort                          user
##        depeffort                       default
##        depeffort                       default
##        depeffort                       default
##        depeffort                          user
##        deplonely                          user
##        deplonely                       default
##        deplonely                       default
##        deplonely                       default
##        deplonely                          user
##        depmistrt                          user
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                          user
##        depunfair                          user
##        depunfair                       default
##        depunfair                       default
##        depunfair                       default
##        depunfair                          user

8.1.2.6 Corr X Community: stthft & negative emotions

#Community Change: negative emotions items ~ mo(stthft)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostthft_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostthft_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostthft_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostthft_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stthft.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + 
         rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stthft_comm_fit",
      file_refit = "on_change"
  )


out.chg.alldepress.stthft.comm.fit <- ppchecks(chg.alldepress.stthft.comm.fit)
8.1.2.6.1 Coefficient plot (intervals)
out.chg.alldepress.stthft.comm.fit[[11]]

8.1.2.6.2 PPcheck (density)
p1 <- out.chg.alldepress.stthft.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stthft.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stthft.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stthft.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stthft.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stthft.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stthft.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

8.1.2.6.3 Fit summary
out.chg.alldepress.stthft.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          depeffort ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          deplonely ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          depblues ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          depunfair ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##          depbetray ~ 1 + mo(stthft_devx2) + mo(stthft_av12x2) + rural.ses.med + mo(stthft_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.32      0.20     0.02     0.73 1.00      662
## sd(depeffort_Intercept)     0.43      0.27     0.02     0.99 1.01      506
## sd(deplonely_Intercept)     0.44      0.24     0.02     0.90 1.00      579
## sd(depblues_Intercept)      0.72      0.31     0.10     1.31 1.02      387
## sd(depunfair_Intercept)     0.23      0.16     0.01     0.60 1.00      832
## sd(depmistrt_Intercept)     0.35      0.23     0.02     0.86 1.00      619
## sd(depbetray_Intercept)     0.53      0.29     0.03     1.09 1.01      365
##                         Tail_ESS
## sd(depcantgo_Intercept)     1436
## sd(depeffort_Intercept)      937
## sd(deplonely_Intercept)     1158
## sd(depblues_Intercept)       714
## sd(depunfair_Intercept)     1619
## sd(depmistrt_Intercept)     1298
## sd(depbetray_Intercept)      908
## 
## Regression Coefficients:
##                                         Estimate Est.Error l-95% CI u-95% CI
## depcantgo_Intercept                        -0.81      0.33    -1.48    -0.17
## depeffort_Intercept                        -1.97      0.39    -2.79    -1.23
## deplonely_Intercept                        -1.54      0.36    -2.26    -0.85
## depblues_Intercept                         -2.39      0.45    -3.33    -1.56
## depunfair_Intercept                        -1.64      0.39    -2.44    -0.90
## depmistrt_Intercept                        -2.29      0.41    -3.06    -1.45
## depbetray_Intercept                        -2.49      0.46    -3.37    -1.53
## depcantgo_rural.ses.med2                   -0.46      0.53    -1.68     0.43
## depcantgo_rural.ses.med3                    0.34      0.51    -0.56     1.52
## depcantgo_rural.ses.med4                   -0.02      0.47    -0.99     0.89
## depeffort_rural.ses.med2                    0.31      0.59    -0.87     1.59
## depeffort_rural.ses.med3                    0.04      0.58    -1.21     1.10
## depeffort_rural.ses.med4                    0.27      0.54    -0.87     1.29
## deplonely_rural.ses.med2                   -0.74      0.59    -1.91     0.51
## deplonely_rural.ses.med3                    0.45      0.55    -0.53     1.64
## deplonely_rural.ses.med4                    0.42      0.54    -0.53     1.61
## depblues_rural.ses.med2                     0.30      0.67    -1.16     1.52
## depblues_rural.ses.med3                     0.44      0.57    -0.76     1.54
## depblues_rural.ses.med4                    -0.21      0.60    -1.54     0.85
## depunfair_rural.ses.med2                    0.13      0.61    -1.19     1.25
## depunfair_rural.ses.med3                   -0.40      0.61    -1.63     0.82
## depunfair_rural.ses.med4                    0.42      0.48    -0.64     1.24
## depmistrt_rural.ses.med2                   -0.10      0.63    -1.43     1.02
## depmistrt_rural.ses.med3                    0.88      0.50    -0.09     1.88
## depmistrt_rural.ses.med4                    0.54      0.53    -0.51     1.64
## depbetray_rural.ses.med2                   -0.61      0.69    -2.02     0.65
## depbetray_rural.ses.med3                   -0.06      0.55    -1.19     0.91
## depbetray_rural.ses.med4                    0.83      0.54    -0.27     1.84
## depcantgo_mostthft_devx2                    0.12      0.15    -0.18     0.42
## depcantgo_mostthft_av12x2                   0.05      0.03    -0.01     0.12
## depcantgo_mostthft_devx2:rural.ses.med2     0.47      0.33    -0.05     1.28
## depcantgo_mostthft_devx2:rural.ses.med3    -0.18      0.26    -0.79     0.26
## depcantgo_mostthft_devx2:rural.ses.med4     0.02      0.23    -0.39     0.52
## depeffort_mostthft_devx2                    0.02      0.16    -0.29     0.36
## depeffort_mostthft_av12x2                  -0.03      0.04    -0.11     0.04
## depeffort_mostthft_devx2:rural.ses.med2    -0.21      0.38    -1.05     0.50
## depeffort_mostthft_devx2:rural.ses.med3     0.19      0.27    -0.42     0.67
## depeffort_mostthft_devx2:rural.ses.med4     0.21      0.28    -0.29     0.79
## deplonely_mostthft_devx2                    0.26      0.15    -0.06     0.54
## deplonely_mostthft_av12x2                   0.02      0.03    -0.05     0.09
## deplonely_mostthft_devx2:rural.ses.med2     0.22      0.36    -0.44     1.00
## deplonely_mostthft_devx2:rural.ses.med3    -0.39      0.38    -1.27     0.19
## deplonely_mostthft_devx2:rural.ses.med4     0.03      0.28    -0.46     0.67
## depblues_mostthft_devx2                     0.08      0.18    -0.28     0.44
## depblues_mostthft_av12x2                   -0.07      0.04    -0.15     0.02
## depblues_mostthft_devx2:rural.ses.med2     -0.05      0.44    -0.94     0.79
## depblues_mostthft_devx2:rural.ses.med3     -0.01      0.30    -0.69     0.54
## depblues_mostthft_devx2:rural.ses.med4      0.61      0.32     0.02     1.27
## depunfair_mostthft_devx2                   -0.01      0.17    -0.34     0.32
## depunfair_mostthft_av12x2                   0.00      0.03    -0.06     0.07
## depunfair_mostthft_devx2:rural.ses.med2     0.13      0.34    -0.54     0.86
## depunfair_mostthft_devx2:rural.ses.med3     0.45      0.22    -0.03     0.89
## depunfair_mostthft_devx2:rural.ses.med4     0.37      0.21    -0.04     0.81
## depmistrt_mostthft_devx2                    0.08      0.19    -0.32     0.41
## depmistrt_mostthft_av12x2                   0.04      0.04    -0.04     0.11
## depmistrt_mostthft_devx2:rural.ses.med2     0.38      0.34    -0.23     1.14
## depmistrt_mostthft_devx2:rural.ses.med3    -0.24      0.32    -0.95     0.29
## depmistrt_mostthft_devx2:rural.ses.med4     0.13      0.27    -0.46     0.63
## depbetray_mostthft_devx2                   -0.01      0.19    -0.41     0.34
## depbetray_mostthft_av12x2                   0.05      0.04    -0.03     0.14
## depbetray_mostthft_devx2:rural.ses.med2     0.59      0.36    -0.03     1.44
## depbetray_mostthft_devx2:rural.ses.med3     0.44      0.23     0.01     0.91
## depbetray_mostthft_devx2:rural.ses.med4     0.17      0.25    -0.36     0.63
##                                         Rhat Bulk_ESS Tail_ESS
## depcantgo_Intercept                     1.00     3021     2863
## depeffort_Intercept                     1.00     2696     2714
## deplonely_Intercept                     1.00     2519     2366
## depblues_Intercept                      1.00     1760     2506
## depunfair_Intercept                     1.00     2055     2323
## depmistrt_Intercept                     1.00     1813     2655
## depbetray_Intercept                     1.00     2320     2794
## depcantgo_rural.ses.med2                1.00     2468     1838
## depcantgo_rural.ses.med3                1.00     2311     2342
## depcantgo_rural.ses.med4                1.00     2632     2539
## depeffort_rural.ses.med2                1.00     3002     2841
## depeffort_rural.ses.med3                1.00     2449     2634
## depeffort_rural.ses.med4                1.00     2838     2574
## deplonely_rural.ses.med2                1.00     2332     1933
## deplonely_rural.ses.med3                1.00     2771     3071
## deplonely_rural.ses.med4                1.00     2410     2913
## depblues_rural.ses.med2                 1.00     2519     2558
## depblues_rural.ses.med3                 1.00     2646     2422
## depblues_rural.ses.med4                 1.00     3560     2635
## depunfair_rural.ses.med2                1.00     2867     2694
## depunfair_rural.ses.med3                1.00     1890     1212
## depunfair_rural.ses.med4                1.00     2484     2901
## depmistrt_rural.ses.med2                1.00     2835     2701
## depmistrt_rural.ses.med3                1.00     2968     2775
## depmistrt_rural.ses.med4                1.00     2489     2472
## depbetray_rural.ses.med2                1.00     3285     2597
## depbetray_rural.ses.med3                1.00     3171     3108
## depbetray_rural.ses.med4                1.00     2677     2753
## depcantgo_mostthft_devx2                1.00     2688     2784
## depcantgo_mostthft_av12x2               1.00     5986     2878
## depcantgo_mostthft_devx2:rural.ses.med2 1.00     1998     1676
## depcantgo_mostthft_devx2:rural.ses.med3 1.00     2344     2495
## depcantgo_mostthft_devx2:rural.ses.med4 1.00     2585     2558
## depeffort_mostthft_devx2                1.00     2803     2883
## depeffort_mostthft_av12x2               1.00     6861     3395
## depeffort_mostthft_devx2:rural.ses.med2 1.00     2406     2480
## depeffort_mostthft_devx2:rural.ses.med3 1.00     2213     1590
## depeffort_mostthft_devx2:rural.ses.med4 1.00     2610     2814
## deplonely_mostthft_devx2                1.00     2026     1973
## deplonely_mostthft_av12x2               1.00     5598     2728
## deplonely_mostthft_devx2:rural.ses.med2 1.00     1908     1699
## deplonely_mostthft_devx2:rural.ses.med3 1.00     2042     2262
## deplonely_mostthft_devx2:rural.ses.med4 1.00     2089     2586
## depblues_mostthft_devx2                 1.00     2703     2515
## depblues_mostthft_av12x2                1.00     4457     3202
## depblues_mostthft_devx2:rural.ses.med2  1.00     2440     2755
## depblues_mostthft_devx2:rural.ses.med3  1.00     2364     2233
## depblues_mostthft_devx2:rural.ses.med4  1.00     2982     3007
## depunfair_mostthft_devx2                1.00     2042     1790
## depunfair_mostthft_av12x2               1.00     6583     2730
## depunfair_mostthft_devx2:rural.ses.med2 1.00     2243     2381
## depunfair_mostthft_devx2:rural.ses.med3 1.00     1949     1276
## depunfair_mostthft_devx2:rural.ses.med4 1.00     2359     2657
## depmistrt_mostthft_devx2                1.00     1706     2477
## depmistrt_mostthft_av12x2               1.00     5966     2767
## depmistrt_mostthft_devx2:rural.ses.med2 1.00     2513     2384
## depmistrt_mostthft_devx2:rural.ses.med3 1.00     2275     2185
## depmistrt_mostthft_devx2:rural.ses.med4 1.00     1901     2128
## depbetray_mostthft_devx2                1.00     2254     2623
## depbetray_mostthft_av12x2               1.00     5355     3353
## depbetray_mostthft_devx2:rural.ses.med2 1.00     2526     2134
## depbetray_mostthft_devx2:rural.ses.med3 1.00     2905     2880
## depbetray_mostthft_devx2:rural.ses.med4 1.00     2291     2415
## 
## Monotonic Simplex Parameters:
##                                             Estimate Est.Error l-95% CI
## depcantgo_mostthft_devx21[1]                    0.24      0.14     0.03
## depcantgo_mostthft_devx21[2]                    0.26      0.14     0.04
## depcantgo_mostthft_devx21[3]                    0.24      0.13     0.04
## depcantgo_mostthft_devx21[4]                    0.27      0.15     0.04
## depcantgo_mostthft_av12x21[1]                   0.12      0.08     0.02
## depcantgo_mostthft_av12x21[2]                   0.12      0.07     0.02
## depcantgo_mostthft_av12x21[3]                   0.11      0.07     0.02
## depcantgo_mostthft_av12x21[4]                   0.14      0.09     0.02
## depcantgo_mostthft_av12x21[5]                   0.14      0.08     0.02
## depcantgo_mostthft_av12x21[6]                   0.13      0.08     0.02
## depcantgo_mostthft_av12x21[7]                   0.12      0.08     0.01
## depcantgo_mostthft_av12x21[8]                   0.12      0.08     0.01
## depcantgo_mostthft_devx2:rural.ses.med21[1]     0.20      0.16     0.01
## depcantgo_mostthft_devx2:rural.ses.med21[2]     0.24      0.17     0.01
## depcantgo_mostthft_devx2:rural.ses.med21[3]     0.27      0.17     0.02
## depcantgo_mostthft_devx2:rural.ses.med21[4]     0.29      0.21     0.01
## depcantgo_mostthft_devx2:rural.ses.med31[1]     0.29      0.20     0.01
## depcantgo_mostthft_devx2:rural.ses.med31[2]     0.19      0.17     0.01
## depcantgo_mostthft_devx2:rural.ses.med31[3]     0.21      0.17     0.01
## depcantgo_mostthft_devx2:rural.ses.med31[4]     0.31      0.21     0.01
## depcantgo_mostthft_devx2:rural.ses.med41[1]     0.26      0.19     0.01
## depcantgo_mostthft_devx2:rural.ses.med41[2]     0.22      0.17     0.01
## depcantgo_mostthft_devx2:rural.ses.med41[3]     0.23      0.18     0.01
## depcantgo_mostthft_devx2:rural.ses.med41[4]     0.29      0.21     0.01
## depeffort_mostthft_devx21[1]                    0.26      0.15     0.04
## depeffort_mostthft_devx21[2]                    0.24      0.14     0.04
## depeffort_mostthft_devx21[3]                    0.24      0.14     0.03
## depeffort_mostthft_devx21[4]                    0.27      0.15     0.04
## depeffort_mostthft_av12x21[1]                   0.13      0.08     0.02
## depeffort_mostthft_av12x21[2]                   0.13      0.08     0.02
## depeffort_mostthft_av12x21[3]                   0.12      0.08     0.02
## depeffort_mostthft_av12x21[4]                   0.12      0.08     0.02
## depeffort_mostthft_av12x21[5]                   0.12      0.08     0.02
## depeffort_mostthft_av12x21[6]                   0.12      0.08     0.02
## depeffort_mostthft_av12x21[7]                   0.13      0.08     0.02
## depeffort_mostthft_av12x21[8]                   0.13      0.08     0.02
## depeffort_mostthft_devx2:rural.ses.med21[1]     0.24      0.18     0.01
## depeffort_mostthft_devx2:rural.ses.med21[2]     0.19      0.16     0.00
## depeffort_mostthft_devx2:rural.ses.med21[3]     0.27      0.20     0.01
## depeffort_mostthft_devx2:rural.ses.med21[4]     0.30      0.21     0.01
## depeffort_mostthft_devx2:rural.ses.med31[1]     0.27      0.20     0.01
## depeffort_mostthft_devx2:rural.ses.med31[2]     0.27      0.19     0.01
## depeffort_mostthft_devx2:rural.ses.med31[3]     0.21      0.16     0.01
## depeffort_mostthft_devx2:rural.ses.med31[4]     0.25      0.19     0.01
## depeffort_mostthft_devx2:rural.ses.med41[1]     0.26      0.19     0.01
## depeffort_mostthft_devx2:rural.ses.med41[2]     0.20      0.17     0.01
## depeffort_mostthft_devx2:rural.ses.med41[3]     0.21      0.17     0.01
## depeffort_mostthft_devx2:rural.ses.med41[4]     0.33      0.22     0.01
## deplonely_mostthft_devx21[1]                    0.17      0.12     0.02
## deplonely_mostthft_devx21[2]                    0.35      0.15     0.08
## deplonely_mostthft_devx21[3]                    0.22      0.12     0.04
## deplonely_mostthft_devx21[4]                    0.26      0.14     0.05
## deplonely_mostthft_av12x21[1]                   0.12      0.08     0.01
## deplonely_mostthft_av12x21[2]                   0.12      0.08     0.02
## deplonely_mostthft_av12x21[3]                   0.12      0.08     0.02
## deplonely_mostthft_av12x21[4]                   0.12      0.08     0.02
## deplonely_mostthft_av12x21[5]                   0.12      0.08     0.02
## deplonely_mostthft_av12x21[6]                   0.13      0.08     0.01
## deplonely_mostthft_av12x21[7]                   0.13      0.08     0.02
## deplonely_mostthft_av12x21[8]                   0.13      0.08     0.02
## deplonely_mostthft_devx2:rural.ses.med21[1]     0.22      0.18     0.01
## deplonely_mostthft_devx2:rural.ses.med21[2]     0.22      0.17     0.01
## deplonely_mostthft_devx2:rural.ses.med21[3]     0.24      0.19     0.01
## deplonely_mostthft_devx2:rural.ses.med21[4]     0.31      0.22     0.01
## deplonely_mostthft_devx2:rural.ses.med31[1]     0.26      0.18     0.01
## deplonely_mostthft_devx2:rural.ses.med31[2]     0.15      0.15     0.00
## deplonely_mostthft_devx2:rural.ses.med31[3]     0.21      0.17     0.01
## deplonely_mostthft_devx2:rural.ses.med31[4]     0.38      0.23     0.02
## deplonely_mostthft_devx2:rural.ses.med41[1]     0.26      0.21     0.01
## deplonely_mostthft_devx2:rural.ses.med41[2]     0.22      0.17     0.01
## deplonely_mostthft_devx2:rural.ses.med41[3]     0.22      0.18     0.01
## deplonely_mostthft_devx2:rural.ses.med41[4]     0.30      0.23     0.01
## depblues_mostthft_devx21[1]                     0.25      0.15     0.04
## depblues_mostthft_devx21[2]                     0.25      0.14     0.04
## depblues_mostthft_devx21[3]                     0.23      0.14     0.03
## depblues_mostthft_devx21[4]                     0.26      0.15     0.04
## depblues_mostthft_av12x21[1]                    0.14      0.09     0.02
## depblues_mostthft_av12x21[2]                    0.14      0.08     0.02
## depblues_mostthft_av12x21[3]                    0.13      0.08     0.02
## depblues_mostthft_av12x21[4]                    0.12      0.08     0.02
## depblues_mostthft_av12x21[5]                    0.11      0.07     0.01
## depblues_mostthft_av12x21[6]                    0.11      0.07     0.01
## depblues_mostthft_av12x21[7]                    0.12      0.08     0.02
## depblues_mostthft_av12x21[8]                    0.12      0.08     0.02
## depblues_mostthft_devx2:rural.ses.med21[1]      0.23      0.18     0.01
## depblues_mostthft_devx2:rural.ses.med21[2]      0.21      0.18     0.00
## depblues_mostthft_devx2:rural.ses.med21[3]      0.25      0.20     0.01
## depblues_mostthft_devx2:rural.ses.med21[4]      0.31      0.22     0.01
## depblues_mostthft_devx2:rural.ses.med31[1]      0.26      0.20     0.01
## depblues_mostthft_devx2:rural.ses.med31[2]      0.22      0.18     0.01
## depblues_mostthft_devx2:rural.ses.med31[3]      0.22      0.18     0.01
## depblues_mostthft_devx2:rural.ses.med31[4]      0.30      0.22     0.01
## depblues_mostthft_devx2:rural.ses.med41[1]      0.22      0.17     0.01
## depblues_mostthft_devx2:rural.ses.med41[2]      0.18      0.15     0.01
## depblues_mostthft_devx2:rural.ses.med41[3]      0.17      0.14     0.01
## depblues_mostthft_devx2:rural.ses.med41[4]      0.43      0.22     0.03
## depunfair_mostthft_devx21[1]                    0.26      0.15     0.04
## depunfair_mostthft_devx21[2]                    0.25      0.14     0.04
## depunfair_mostthft_devx21[3]                    0.23      0.14     0.04
## depunfair_mostthft_devx21[4]                    0.26      0.15     0.04
## depunfair_mostthft_av12x21[1]                   0.12      0.08     0.02
## depunfair_mostthft_av12x21[2]                   0.12      0.08     0.02
## depunfair_mostthft_av12x21[3]                   0.12      0.08     0.02
## depunfair_mostthft_av12x21[4]                   0.12      0.08     0.02
## depunfair_mostthft_av12x21[5]                   0.12      0.08     0.01
## depunfair_mostthft_av12x21[6]                   0.13      0.08     0.02
## depunfair_mostthft_av12x21[7]                   0.13      0.08     0.02
## depunfair_mostthft_av12x21[8]                   0.13      0.08     0.02
## depunfair_mostthft_devx2:rural.ses.med21[1]     0.26      0.19     0.01
## depunfair_mostthft_devx2:rural.ses.med21[2]     0.22      0.18     0.01
## depunfair_mostthft_devx2:rural.ses.med21[3]     0.20      0.17     0.01
## depunfair_mostthft_devx2:rural.ses.med21[4]     0.32      0.22     0.01
## depunfair_mostthft_devx2:rural.ses.med31[1]     0.23      0.16     0.01
## depunfair_mostthft_devx2:rural.ses.med31[2]     0.50      0.20     0.07
## depunfair_mostthft_devx2:rural.ses.med31[3]     0.08      0.09     0.00
## depunfair_mostthft_devx2:rural.ses.med31[4]     0.19      0.15     0.01
## depunfair_mostthft_devx2:rural.ses.med41[1]     0.22      0.17     0.01
## depunfair_mostthft_devx2:rural.ses.med41[2]     0.20      0.15     0.01
## depunfair_mostthft_devx2:rural.ses.med41[3]     0.35      0.19     0.03
## depunfair_mostthft_devx2:rural.ses.med41[4]     0.23      0.17     0.01
## depmistrt_mostthft_devx21[1]                    0.24      0.14     0.04
## depmistrt_mostthft_devx21[2]                    0.22      0.12     0.03
## depmistrt_mostthft_devx21[3]                    0.29      0.16     0.04
## depmistrt_mostthft_devx21[4]                    0.25      0.15     0.03
## depmistrt_mostthft_av12x21[1]                   0.13      0.08     0.02
## depmistrt_mostthft_av12x21[2]                   0.12      0.08     0.02
## depmistrt_mostthft_av12x21[3]                   0.12      0.08     0.02
## depmistrt_mostthft_av12x21[4]                   0.11      0.08     0.01
## depmistrt_mostthft_av12x21[5]                   0.12      0.08     0.01
## depmistrt_mostthft_av12x21[6]                   0.12      0.08     0.02
## depmistrt_mostthft_av12x21[7]                   0.14      0.09     0.02
## depmistrt_mostthft_av12x21[8]                   0.13      0.09     0.02
## depmistrt_mostthft_devx2:rural.ses.med21[1]     0.23      0.18     0.01
## depmistrt_mostthft_devx2:rural.ses.med21[2]     0.26      0.18     0.01
## depmistrt_mostthft_devx2:rural.ses.med21[3]     0.22      0.17     0.01
## depmistrt_mostthft_devx2:rural.ses.med21[4]     0.29      0.21     0.01
## depmistrt_mostthft_devx2:rural.ses.med31[1]     0.22      0.18     0.01
## depmistrt_mostthft_devx2:rural.ses.med31[2]     0.23      0.18     0.01
## depmistrt_mostthft_devx2:rural.ses.med31[3]     0.21      0.17     0.01
## depmistrt_mostthft_devx2:rural.ses.med31[4]     0.33      0.23     0.01
## depmistrt_mostthft_devx2:rural.ses.med41[1]     0.23      0.18     0.01
## depmistrt_mostthft_devx2:rural.ses.med41[2]     0.20      0.16     0.01
## depmistrt_mostthft_devx2:rural.ses.med41[3]     0.33      0.22     0.01
## depmistrt_mostthft_devx2:rural.ses.med41[4]     0.25      0.19     0.01
## depbetray_mostthft_devx21[1]                    0.26      0.15     0.04
## depbetray_mostthft_devx21[2]                    0.24      0.15     0.03
## depbetray_mostthft_devx21[3]                    0.24      0.14     0.04
## depbetray_mostthft_devx21[4]                    0.26      0.15     0.04
## depbetray_mostthft_av12x21[1]                   0.12      0.08     0.02
## depbetray_mostthft_av12x21[2]                   0.12      0.08     0.02
## depbetray_mostthft_av12x21[3]                   0.11      0.07     0.01
## depbetray_mostthft_av12x21[4]                   0.11      0.07     0.02
## depbetray_mostthft_av12x21[5]                   0.12      0.08     0.02
## depbetray_mostthft_av12x21[6]                   0.13      0.08     0.02
## depbetray_mostthft_av12x21[7]                   0.15      0.09     0.02
## depbetray_mostthft_av12x21[8]                   0.13      0.08     0.02
## depbetray_mostthft_devx2:rural.ses.med21[1]     0.17      0.15     0.00
## depbetray_mostthft_devx2:rural.ses.med21[2]     0.38      0.19     0.03
## depbetray_mostthft_devx2:rural.ses.med21[3]     0.18      0.14     0.01
## depbetray_mostthft_devx2:rural.ses.med21[4]     0.27      0.19     0.01
## depbetray_mostthft_devx2:rural.ses.med31[1]     0.18      0.15     0.00
## depbetray_mostthft_devx2:rural.ses.med31[2]     0.34      0.18     0.03
## depbetray_mostthft_devx2:rural.ses.med31[3]     0.26      0.16     0.02
## depbetray_mostthft_devx2:rural.ses.med31[4]     0.21      0.16     0.01
## depbetray_mostthft_devx2:rural.ses.med41[1]     0.25      0.19     0.01
## depbetray_mostthft_devx2:rural.ses.med41[2]     0.23      0.17     0.01
## depbetray_mostthft_devx2:rural.ses.med41[3]     0.28      0.20     0.01
## depbetray_mostthft_devx2:rural.ses.med41[4]     0.24      0.19     0.01
##                                             u-95% CI Rhat Bulk_ESS Tail_ESS
## depcantgo_mostthft_devx21[1]                    0.57 1.00     4990     2724
## depcantgo_mostthft_devx21[2]                    0.56 1.00     4872     2722
## depcantgo_mostthft_devx21[3]                    0.54 1.00     6444     3097
## depcantgo_mostthft_devx21[4]                    0.60 1.00     6770     2745
## depcantgo_mostthft_av12x21[1]                   0.31 1.00     7920     2641
## depcantgo_mostthft_av12x21[2]                   0.29 1.00     7153     2643
## depcantgo_mostthft_av12x21[3]                   0.29 1.00     7826     2677
## depcantgo_mostthft_av12x21[4]                   0.35 1.00     6911     2297
## depcantgo_mostthft_av12x21[5]                   0.34 1.00     6524     1787
## depcantgo_mostthft_av12x21[6]                   0.33 1.00     6452     2930
## depcantgo_mostthft_av12x21[7]                   0.31 1.00     6837     2332
## depcantgo_mostthft_av12x21[8]                   0.31 1.00     7081     2405
## depcantgo_mostthft_devx2:rural.ses.med21[1]     0.60 1.00     5283     3005
## depcantgo_mostthft_devx2:rural.ses.med21[2]     0.63 1.00     4539     2374
## depcantgo_mostthft_devx2:rural.ses.med21[3]     0.66 1.00     3607     2805
## depcantgo_mostthft_devx2:rural.ses.med21[4]     0.74 1.00     3506     2489
## depcantgo_mostthft_devx2:rural.ses.med31[1]     0.74 1.00     4124     2162
## depcantgo_mostthft_devx2:rural.ses.med31[2]     0.60 1.00     4295     2687
## depcantgo_mostthft_devx2:rural.ses.med31[3]     0.63 1.00     4959     2573
## depcantgo_mostthft_devx2:rural.ses.med31[4]     0.76 1.00     5142     2725
## depcantgo_mostthft_devx2:rural.ses.med41[1]     0.71 1.00     5638     2603
## depcantgo_mostthft_devx2:rural.ses.med41[2]     0.64 1.00     5407     1948
## depcantgo_mostthft_devx2:rural.ses.med41[3]     0.67 1.00     3820     3090
## depcantgo_mostthft_devx2:rural.ses.med41[4]     0.75 1.00     4377     2452
## depeffort_mostthft_devx21[1]                    0.61 1.00     6631     2902
## depeffort_mostthft_devx21[2]                    0.55 1.00     5710     2767
## depeffort_mostthft_devx21[3]                    0.55 1.00     6556     2694
## depeffort_mostthft_devx21[4]                    0.60 1.00     6022     2865
## depeffort_mostthft_av12x21[1]                   0.32 1.00     7131     2462
## depeffort_mostthft_av12x21[2]                   0.33 1.00     8238     2491
## depeffort_mostthft_av12x21[3]                   0.32 1.00     7229     1990
## depeffort_mostthft_av12x21[4]                   0.30 1.00     6459     3188
## depeffort_mostthft_av12x21[5]                   0.30 1.00     6290     2526
## depeffort_mostthft_av12x21[6]                   0.31 1.00     7026     3181
## depeffort_mostthft_av12x21[7]                   0.31 1.00     7257     3156
## depeffort_mostthft_av12x21[8]                   0.32 1.00     6547     2852
## depeffort_mostthft_devx2:rural.ses.med21[1]     0.66 1.00     4280     1800
## depeffort_mostthft_devx2:rural.ses.med21[2]     0.61 1.00     4740     2546
## depeffort_mostthft_devx2:rural.ses.med21[3]     0.72 1.00     4681     2699
## depeffort_mostthft_devx2:rural.ses.med21[4]     0.76 1.00     4717     2547
## depeffort_mostthft_devx2:rural.ses.med31[1]     0.71 1.00     4894     2717
## depeffort_mostthft_devx2:rural.ses.med31[2]     0.69 1.00     4074     1865
## depeffort_mostthft_devx2:rural.ses.med31[3]     0.61 1.00     4434     2455
## depeffort_mostthft_devx2:rural.ses.med31[4]     0.72 1.00     3673     1922
## depeffort_mostthft_devx2:rural.ses.med41[1]     0.71 1.00     6348     2269
## depeffort_mostthft_devx2:rural.ses.med41[2]     0.60 1.00     5944     2789
## depeffort_mostthft_devx2:rural.ses.med41[3]     0.64 1.00     5024     2377
## depeffort_mostthft_devx2:rural.ses.med41[4]     0.78 1.00     4550     2752
## deplonely_mostthft_devx21[1]                    0.46 1.00     4238     2598
## deplonely_mostthft_devx21[2]                    0.64 1.00     4788     2431
## deplonely_mostthft_devx21[3]                    0.48 1.00     5677     3137
## deplonely_mostthft_devx21[4]                    0.55 1.00     6821     2573
## deplonely_mostthft_av12x21[1]                   0.32 1.00     7354     2681
## deplonely_mostthft_av12x21[2]                   0.32 1.00     7891     2204
## deplonely_mostthft_av12x21[3]                   0.32 1.00     6121     2377
## deplonely_mostthft_av12x21[4]                   0.32 1.00     7284     2205
## deplonely_mostthft_av12x21[5]                   0.32 1.00     7541     2378
## deplonely_mostthft_av12x21[6]                   0.33 1.00     6964     2324
## deplonely_mostthft_av12x21[7]                   0.32 1.00     6904     3196
## deplonely_mostthft_av12x21[8]                   0.32 1.00     6325     2815
## deplonely_mostthft_devx2:rural.ses.med21[1]     0.66 1.00     4285     2338
## deplonely_mostthft_devx2:rural.ses.med21[2]     0.64 1.00     4498     2585
## deplonely_mostthft_devx2:rural.ses.med21[3]     0.68 1.00     4054     2827
## deplonely_mostthft_devx2:rural.ses.med21[4]     0.78 1.00     4012     2534
## deplonely_mostthft_devx2:rural.ses.med31[1]     0.66 1.00     5215     2692
## deplonely_mostthft_devx2:rural.ses.med31[2]     0.57 1.00     3597     2071
## deplonely_mostthft_devx2:rural.ses.med31[3]     0.62 1.00     4071     2544
## deplonely_mostthft_devx2:rural.ses.med31[4]     0.84 1.00     3834     2694
## deplonely_mostthft_devx2:rural.ses.med41[1]     0.73 1.00     3676     2735
## deplonely_mostthft_devx2:rural.ses.med41[2]     0.64 1.00     5742     2247
## deplonely_mostthft_devx2:rural.ses.med41[3]     0.64 1.00     4254     2868
## deplonely_mostthft_devx2:rural.ses.med41[4]     0.81 1.00     3132     2809
## depblues_mostthft_devx21[1]                     0.57 1.00     5926     2458
## depblues_mostthft_devx21[2]                     0.56 1.00     5953     2908
## depblues_mostthft_devx21[3]                     0.56 1.00     4889     2096
## depblues_mostthft_devx21[4]                     0.60 1.00     6853     2994
## depblues_mostthft_av12x21[1]                    0.35 1.00     6397     2236
## depblues_mostthft_av12x21[2]                    0.33 1.00     7684     2575
## depblues_mostthft_av12x21[3]                    0.33 1.00     5914     2366
## depblues_mostthft_av12x21[4]                    0.32 1.00     6108     2471
## depblues_mostthft_av12x21[5]                    0.28 1.00     5876     2470
## depblues_mostthft_av12x21[6]                    0.29 1.00     7835     2873
## depblues_mostthft_av12x21[7]                    0.30 1.00     7360     2839
## depblues_mostthft_av12x21[8]                    0.32 1.00     5785     2527
## depblues_mostthft_devx2:rural.ses.med21[1]      0.67 1.00     5813     2202
## depblues_mostthft_devx2:rural.ses.med21[2]      0.67 1.00     3864     2767
## depblues_mostthft_devx2:rural.ses.med21[3]      0.73 1.00     3613     2285
## depblues_mostthft_devx2:rural.ses.med21[4]      0.78 1.00     5712     2908
## depblues_mostthft_devx2:rural.ses.med31[1]      0.71 1.00     4328     2504
## depblues_mostthft_devx2:rural.ses.med31[2]      0.64 1.00     4453     2357
## depblues_mostthft_devx2:rural.ses.med31[3]      0.66 1.00     4621     2180
## depblues_mostthft_devx2:rural.ses.med31[4]      0.78 1.00     4330     2380
## depblues_mostthft_devx2:rural.ses.med41[1]      0.62 1.00     4617     2495
## depblues_mostthft_devx2:rural.ses.med41[2]      0.56 1.00     4888     2372
## depblues_mostthft_devx2:rural.ses.med41[3]      0.54 1.00     4937     2507
## depblues_mostthft_devx2:rural.ses.med41[4]      0.81 1.00     4634     2573
## depunfair_mostthft_devx21[1]                    0.59 1.00     5302     2405
## depunfair_mostthft_devx21[2]                    0.57 1.00     4461     2376
## depunfair_mostthft_devx21[3]                    0.55 1.00     5933     3109
## depunfair_mostthft_devx21[4]                    0.59 1.00     6347     3045
## depunfair_mostthft_av12x21[1]                   0.32 1.00     6058     2609
## depunfair_mostthft_av12x21[2]                   0.31 1.00     7198     2545
## depunfair_mostthft_av12x21[3]                   0.30 1.00     5958     2404
## depunfair_mostthft_av12x21[4]                   0.31 1.00     6255     2728
## depunfair_mostthft_av12x21[5]                   0.32 1.00     6107     2070
## depunfair_mostthft_av12x21[6]                   0.33 1.01     6294     2550
## depunfair_mostthft_av12x21[7]                   0.33 1.00     6107     2855
## depunfair_mostthft_av12x21[8]                   0.33 1.00     5448     2728
## depunfair_mostthft_devx2:rural.ses.med21[1]     0.69 1.00     5270     2305
## depunfair_mostthft_devx2:rural.ses.med21[2]     0.66 1.00     4540     2413
## depunfair_mostthft_devx2:rural.ses.med21[3]     0.62 1.00     4676     2742
## depunfair_mostthft_devx2:rural.ses.med21[4]     0.80 1.00     4681     2936
## depunfair_mostthft_devx2:rural.ses.med31[1]     0.61 1.00     4364     2430
## depunfair_mostthft_devx2:rural.ses.med31[2]     0.84 1.00     2701     1325
## depunfair_mostthft_devx2:rural.ses.med31[3]     0.32 1.00     3444     2147
## depunfair_mostthft_devx2:rural.ses.med31[4]     0.56 1.00     4678     2935
## depunfair_mostthft_devx2:rural.ses.med41[1]     0.63 1.00     4938     2387
## depunfair_mostthft_devx2:rural.ses.med41[2]     0.58 1.00     5714     2093
## depunfair_mostthft_devx2:rural.ses.med41[3]     0.75 1.00     4431     2767
## depunfair_mostthft_devx2:rural.ses.med41[4]     0.63 1.00     5959     2455
## depmistrt_mostthft_devx21[1]                    0.58 1.00     5087     2876
## depmistrt_mostthft_devx21[2]                    0.51 1.00     7196     2846
## depmistrt_mostthft_devx21[3]                    0.64 1.00     2661     2634
## depmistrt_mostthft_devx21[4]                    0.59 1.00     5202     2785
## depmistrt_mostthft_av12x21[1]                   0.32 1.00     6903     1854
## depmistrt_mostthft_av12x21[2]                   0.32 1.00     7020     2158
## depmistrt_mostthft_av12x21[3]                   0.31 1.00     7743     2359
## depmistrt_mostthft_av12x21[4]                   0.31 1.00     7262     2407
## depmistrt_mostthft_av12x21[5]                   0.32 1.00     6054     2347
## depmistrt_mostthft_av12x21[6]                   0.31 1.00     7138     2306
## depmistrt_mostthft_av12x21[7]                   0.34 1.00     6156     2598
## depmistrt_mostthft_av12x21[8]                   0.34 1.00     6339     2753
## depmistrt_mostthft_devx2:rural.ses.med21[1]     0.65 1.00     5689     2432
## depmistrt_mostthft_devx2:rural.ses.med21[2]     0.68 1.00     4709     2163
## depmistrt_mostthft_devx2:rural.ses.med21[3]     0.63 1.00     4637     3189
## depmistrt_mostthft_devx2:rural.ses.med21[4]     0.75 1.00     4633     2922
## depmistrt_mostthft_devx2:rural.ses.med31[1]     0.66 1.00     4352     2603
## depmistrt_mostthft_devx2:rural.ses.med31[2]     0.66 1.00     5937     2810
## depmistrt_mostthft_devx2:rural.ses.med31[3]     0.64 1.00     5231     3052
## depmistrt_mostthft_devx2:rural.ses.med31[4]     0.81 1.00     4463     2794
## depmistrt_mostthft_devx2:rural.ses.med41[1]     0.66 1.00     6355     2423
## depmistrt_mostthft_devx2:rural.ses.med41[2]     0.62 1.00     5235     2552
## depmistrt_mostthft_devx2:rural.ses.med41[3]     0.78 1.00     2682     2938
## depmistrt_mostthft_devx2:rural.ses.med41[4]     0.70 1.00     3934     2927
## depbetray_mostthft_devx21[1]                    0.61 1.00     5557     2838
## depbetray_mostthft_devx21[2]                    0.58 1.00     5196     2651
## depbetray_mostthft_devx21[3]                    0.54 1.00     5798     2685
## depbetray_mostthft_devx21[4]                    0.59 1.00     6391     3021
## depbetray_mostthft_av12x21[1]                   0.30 1.00     7472     2384
## depbetray_mostthft_av12x21[2]                   0.32 1.00     7347     2113
## depbetray_mostthft_av12x21[3]                   0.28 1.00     6345     1971
## depbetray_mostthft_av12x21[4]                   0.29 1.00     7631     3085
## depbetray_mostthft_av12x21[5]                   0.32 1.00     7235     2539
## depbetray_mostthft_av12x21[6]                   0.33 1.00     7050     2543
## depbetray_mostthft_av12x21[7]                   0.37 1.00     5657     2935
## depbetray_mostthft_av12x21[8]                   0.34 1.00     6322     2668
## depbetray_mostthft_devx2:rural.ses.med21[1]     0.55 1.00     4973     2580
## depbetray_mostthft_devx2:rural.ses.med21[2]     0.76 1.00     4034     2081
## depbetray_mostthft_devx2:rural.ses.med21[3]     0.52 1.00     3716     2676
## depbetray_mostthft_devx2:rural.ses.med21[4]     0.71 1.00     3837     2756
## depbetray_mostthft_devx2:rural.ses.med31[1]     0.55 1.00     4339     2023
## depbetray_mostthft_devx2:rural.ses.med31[2]     0.72 1.00     5077     2481
## depbetray_mostthft_devx2:rural.ses.med31[3]     0.63 1.00     4737     2655
## depbetray_mostthft_devx2:rural.ses.med31[4]     0.58 1.00     5951     2332
## depbetray_mostthft_devx2:rural.ses.med41[1]     0.68 1.00     5498     2387
## depbetray_mostthft_devx2:rural.ses.med41[2]     0.65 1.00     6608     2611
## depbetray_mostthft_devx2:rural.ses.med41[3]     0.72 1.00     4444     2822
## depbetray_mostthft_devx2:rural.ses.med41[4]     0.70 1.00     5539     2730
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.2.6.4 Prior summary
out.chg.alldepress.stthft.comm.fit[[2]]
##                              prior     class                           coef
##                             (flat)         b                               
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                       normal(0, 1)         b                               
##                   normal(0, 0.125)         b                mostthft_av12x2
##                    normal(0, 0.25)         b                 mostthft_devx2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostthft_devx2:rural.ses.med4
##                       normal(0, 1)         b                 rural.ses.med2
##                       normal(0, 1)         b                 rural.ses.med3
##                       normal(0, 1)         b                 rural.ses.med4
##                             (flat) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##                       normal(0, 2) Intercept                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##               student_t(3, 0, 2.5)        sd                               
##               student_t(3, 0, 2.5)        sd                      Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostthft_av12x21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostthft_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostthft_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##        depbetray                          user
##        depbetray                          user
##        depbetray                          user
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##         depblues                          user
##         depblues                          user
##         depblues                          user
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depeffort                          user
##        depeffort                          user
##        depeffort                          user
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        deplonely                          user
##        deplonely                          user
##        deplonely                          user
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depunfair                          user
##        depunfair                          user
##        depunfair                          user
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##                                        default
##        depbetray                          user
##         depblues                          user
##        depcantgo                          user
##        depeffort                          user
##        deplonely                          user
##        depmistrt                          user
##        depunfair                          user
##        depbetray             0         default
##         depblues             0         default
##        depcantgo             0         default
##        depeffort             0         default
##        deplonely             0         default
##        depmistrt             0         default
##        depunfair             0         default
##     id depbetray             0    (vectorized)
##     id depbetray             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depunfair             0    (vectorized)
##     id depunfair             0    (vectorized)
##        depbetray                          user
##        depbetray                       default
##        depbetray                       default
##        depbetray                       default
##        depbetray                          user
##         depblues                          user
##         depblues                       default
##         depblues                       default
##         depblues                       default
##         depblues                          user
##        depcantgo                          user
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                          user
##        depeffort                          user
##        depeffort                       default
##        depeffort                       default
##        depeffort                       default
##        depeffort                          user
##        deplonely                          user
##        deplonely                       default
##        deplonely                       default
##        deplonely                       default
##        deplonely                          user
##        depmistrt                          user
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                          user
##        depunfair                          user
##        depunfair                       default
##        depunfair                       default
##        depunfair                       default
##        depunfair                          user

8.1.2.7 Corr X Community: stmug & negative emotions

#Bivariate Change: negative emotions items ~ mo(stmug)
 
#Vectorize priors:

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names),
  set_prior('normal(0, 0.25)', class = 'b', coef = 'mostmug_devx2', 
                  resp = depdv_names), #norm(0,1)/4 thresholds
  set_prior('normal(0, 0.125)', class = 'b', coef = 'mostmug_av12x2', 
                  resp = depdv_names), #norm(0,1)/8 thresh
  set_prior('dirichlet(2, 2, 2, 2)', class = 'simo', coef = 'mostmug_devx21', 
                  resp = depdv_names),
  set_prior('dirichlet(2, 2, 2, 2, 2, 2, 2, 2)', class = 'simo', coef = 'mostmug_av12x21', 
                  resp = depdv_names)
  )

chg.alldepress.stmug.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + 
         rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id),   
      data = stress.long, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stmug_comm_fit",
      file_refit = "on_change"
  )


out.chg.alldepress.stmug.comm.fit <- ppchecks(chg.alldepress.stmug.comm.fit)
8.1.2.7.1 Coefficient plot (intervals)
out.chg.alldepress.stmug.comm.fit[[11]]

8.1.2.7.2 PPcheck (density)
p1 <- out.chg.alldepress.stmug.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stmug.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stmug.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stmug.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stmug.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stmug.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stmug.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

8.1.2.7.3 Fit summary
out.chg.alldepress.stmug.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          depeffort ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          deplonely ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          depblues ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          depunfair ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##          depbetray ~ 1 + mo(stmug_devx2) + mo(stmug_av12x2) + rural.ses.med + mo(stmug_devx2):rural.ses.med + (1 | id) 
##    Data: stress.long (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.31      0.20     0.01     0.71 1.00      529
## sd(depeffort_Intercept)     0.46      0.27     0.02     1.01 1.01      418
## sd(deplonely_Intercept)     0.40      0.23     0.02     0.86 1.01      469
## sd(depblues_Intercept)      0.73      0.32     0.08     1.30 1.00      499
## sd(depunfair_Intercept)     0.22      0.16     0.01     0.58 1.00      840
## sd(depmistrt_Intercept)     0.31      0.21     0.02     0.78 1.01      838
## sd(depbetray_Intercept)     0.47      0.27     0.03     1.04 1.01      512
##                         Tail_ESS
## sd(depcantgo_Intercept)     1245
## sd(depeffort_Intercept)     1306
## sd(deplonely_Intercept)      926
## sd(depblues_Intercept)       624
## sd(depunfair_Intercept)     1223
## sd(depmistrt_Intercept)     1546
## sd(depbetray_Intercept)     1427
## 
## Regression Coefficients:
##                                        Estimate Est.Error l-95% CI u-95% CI
## depcantgo_Intercept                       -0.71      0.39    -1.52     0.01
## depeffort_Intercept                       -2.09      0.40    -2.89    -1.28
## deplonely_Intercept                       -1.08      0.39    -1.78    -0.24
## depblues_Intercept                        -2.20      0.42    -3.07    -1.38
## depunfair_Intercept                       -1.54      0.35    -2.24    -0.86
## depmistrt_Intercept                       -2.06      0.44    -2.84    -1.15
## depbetray_Intercept                       -2.46      0.44    -3.30    -1.52
## depcantgo_rural.ses.med2                   0.06      0.67    -1.17     1.40
## depcantgo_rural.ses.med3                  -0.05      0.55    -1.24     1.00
## depcantgo_rural.ses.med4                   0.03      0.50    -0.99     1.02
## depeffort_rural.ses.med2                   0.60      0.56    -0.50     1.72
## depeffort_rural.ses.med3                   0.07      0.64    -1.34     1.21
## depeffort_rural.ses.med4                   0.45      0.57    -0.70     1.57
## deplonely_rural.ses.med2                  -0.95      0.46    -1.91    -0.11
## deplonely_rural.ses.med3                  -0.43      0.50    -1.36     0.71
## deplonely_rural.ses.med4                  -0.14      0.45    -1.07     0.71
## depblues_rural.ses.med2                    0.71      0.49    -0.31     1.68
## depblues_rural.ses.med3                    0.15      0.60    -1.15     1.32
## depblues_rural.ses.med4                    0.50      0.57    -0.65     1.65
## depunfair_rural.ses.med2                   0.35      0.50    -0.71     1.32
## depunfair_rural.ses.med3                   0.26      0.59    -1.12     1.27
## depunfair_rural.ses.med4                   0.48      0.55    -0.72     1.41
## depmistrt_rural.ses.med2                   0.55      0.54    -0.45     1.75
## depmistrt_rural.ses.med3                   0.85      0.54    -0.16     2.00
## depmistrt_rural.ses.med4                  -0.08      0.60    -1.45     0.94
## depbetray_rural.ses.med2                   0.41      0.59    -0.71     1.71
## depbetray_rural.ses.med3                  -0.02      0.61    -1.32     1.07
## depbetray_rural.ses.med4                   0.14      0.67    -1.33     1.27
## depcantgo_mostmug_devx2                    0.08      0.17    -0.26     0.41
## depcantgo_mostmug_av12x2                   0.02      0.04    -0.05     0.09
## depcantgo_mostmug_devx2:rural.ses.med2    -0.01      0.44    -1.13     0.54
## depcantgo_mostmug_devx2:rural.ses.med3     0.09      0.31    -0.44     0.85
## depcantgo_mostmug_devx2:rural.ses.med4     0.02      0.24    -0.45     0.53
## depeffort_mostmug_devx2                    0.07      0.18    -0.30     0.41
## depeffort_mostmug_av12x2                  -0.01      0.04    -0.10     0.08
## depeffort_mostmug_devx2:rural.ses.med2    -0.31      0.28    -0.86     0.26
## depeffort_mostmug_devx2:rural.ses.med3     0.16      0.32    -0.53     0.76
## depeffort_mostmug_devx2:rural.ses.med4     0.03      0.34    -0.75     0.60
## deplonely_mostmug_devx2                   -0.02      0.18    -0.37     0.32
## deplonely_mostmug_av12x2                   0.08      0.04     0.01     0.15
## deplonely_mostmug_devx2:rural.ses.med2     0.38      0.26    -0.11     0.92
## deplonely_mostmug_devx2:rural.ses.med3     0.23      0.29    -0.43     0.76
## deplonely_mostmug_devx2:rural.ses.med4     0.37      0.27    -0.12     0.94
## depblues_mostmug_devx2                    -0.05      0.18    -0.41     0.29
## depblues_mostmug_av12x2                   -0.00      0.05    -0.09     0.09
## depblues_mostmug_devx2:rural.ses.med2     -0.54      0.43    -1.49     0.22
## depblues_mostmug_devx2:rural.ses.med3      0.10      0.31    -0.55     0.72
## depblues_mostmug_devx2:rural.ses.med4      0.04      0.31    -0.65     0.60
## depunfair_mostmug_devx2                   -0.06      0.15    -0.36     0.24
## depunfair_mostmug_av12x2                   0.05      0.04    -0.03     0.13
## depunfair_mostmug_devx2:rural.ses.med2    -0.02      0.25    -0.52     0.47
## depunfair_mostmug_devx2:rural.ses.med3     0.28      0.36    -0.27     1.17
## depunfair_mostmug_devx2:rural.ses.med4     0.25      0.24    -0.23     0.72
## depmistrt_mostmug_devx2                   -0.09      0.18    -0.45     0.25
## depmistrt_mostmug_av12x2                   0.11      0.04     0.03     0.20
## depmistrt_mostmug_devx2:rural.ses.med2     0.02      0.26    -0.51     0.56
## depmistrt_mostmug_devx2:rural.ses.med3    -0.23      0.33    -1.00     0.33
## depmistrt_mostmug_devx2:rural.ses.med4     0.43      0.25    -0.04     0.95
## depbetray_mostmug_devx2                   -0.03      0.18    -0.42     0.30
## depbetray_mostmug_av12x2                   0.12      0.05     0.03     0.22
## depbetray_mostmug_devx2:rural.ses.med2     0.06      0.28    -0.54     0.57
## depbetray_mostmug_devx2:rural.ses.med3     0.38      0.28    -0.15     0.95
## depbetray_mostmug_devx2:rural.ses.med4     0.44      0.26    -0.05     0.98
##                                        Rhat Bulk_ESS Tail_ESS
## depcantgo_Intercept                    1.00     1506     2326
## depeffort_Intercept                    1.00     2361     2417
## deplonely_Intercept                    1.00     2020     2451
## depblues_Intercept                     1.00     2355     2530
## depunfair_Intercept                    1.00     3014     2895
## depmistrt_Intercept                    1.00     2564     2994
## depbetray_Intercept                    1.00     2764     2671
## depcantgo_rural.ses.med2               1.00     1206     2781
## depcantgo_rural.ses.med3               1.00     1998     2139
## depcantgo_rural.ses.med4               1.00     2374     2598
## depeffort_rural.ses.med2               1.00     2998     2676
## depeffort_rural.ses.med3               1.00     2768     2516
## depeffort_rural.ses.med4               1.00     2728     3059
## deplonely_rural.ses.med2               1.00     2852     2585
## deplonely_rural.ses.med3               1.00     1989     1498
## deplonely_rural.ses.med4               1.00     2660     2549
## depblues_rural.ses.med2                1.00     3245     2181
## depblues_rural.ses.med3                1.00     3156     2827
## depblues_rural.ses.med4                1.00     3253     3111
## depunfair_rural.ses.med2               1.00     2687     2354
## depunfair_rural.ses.med3               1.00     2843     2384
## depunfair_rural.ses.med4               1.00     2563     2550
## depmistrt_rural.ses.med2               1.00     2877     2711
## depmistrt_rural.ses.med3               1.00     3561     3214
## depmistrt_rural.ses.med4               1.00     3080     2577
## depbetray_rural.ses.med2               1.00     3053     2436
## depbetray_rural.ses.med3               1.00     3339     2752
## depbetray_rural.ses.med4               1.00     3098     2604
## depcantgo_mostmug_devx2                1.00     1345     2207
## depcantgo_mostmug_av12x2               1.00     6065     3055
## depcantgo_mostmug_devx2:rural.ses.med2 1.01     1064     1906
## depcantgo_mostmug_devx2:rural.ses.med3 1.00     1774     1998
## depcantgo_mostmug_devx2:rural.ses.med4 1.00     2134     2746
## depeffort_mostmug_devx2                1.00     2373     2508
## depeffort_mostmug_av12x2               1.00     6867     2719
## depeffort_mostmug_devx2:rural.ses.med2 1.00     2531     2431
## depeffort_mostmug_devx2:rural.ses.med3 1.00     2444     2081
## depeffort_mostmug_devx2:rural.ses.med4 1.00     2279     2028
## deplonely_mostmug_devx2                1.00     1870     2617
## deplonely_mostmug_av12x2               1.00     5943     2881
## deplonely_mostmug_devx2:rural.ses.med2 1.00     2164     2466
## deplonely_mostmug_devx2:rural.ses.med3 1.00     1764     1363
## deplonely_mostmug_devx2:rural.ses.med4 1.00     2418     2482
## depblues_mostmug_devx2                 1.00     2979     2647
## depblues_mostmug_av12x2                1.00     5063     3228
## depblues_mostmug_devx2:rural.ses.med2  1.00     2521     2151
## depblues_mostmug_devx2:rural.ses.med3  1.00     2811     2438
## depblues_mostmug_devx2:rural.ses.med4  1.00     2781     2164
## depunfair_mostmug_devx2                1.00     2825     2711
## depunfair_mostmug_av12x2               1.00     6420     3428
## depunfair_mostmug_devx2:rural.ses.med2 1.00     2584     2120
## depunfair_mostmug_devx2:rural.ses.med3 1.00     2388     2056
## depunfair_mostmug_devx2:rural.ses.med4 1.00     2800     2535
## depmistrt_mostmug_devx2                1.00     2638     2674
## depmistrt_mostmug_av12x2               1.00     5885     2849
## depmistrt_mostmug_devx2:rural.ses.med2 1.00     2547     2772
## depmistrt_mostmug_devx2:rural.ses.med3 1.00     2836     2171
## depmistrt_mostmug_devx2:rural.ses.med4 1.00     2948     2626
## depbetray_mostmug_devx2                1.00     2503     2690
## depbetray_mostmug_av12x2               1.00     5952     3166
## depbetray_mostmug_devx2:rural.ses.med2 1.00     2692     2898
## depbetray_mostmug_devx2:rural.ses.med3 1.00     2818     2615
## depbetray_mostmug_devx2:rural.ses.med4 1.00     2877     3015
## 
## Monotonic Simplex Parameters:
##                                            Estimate Est.Error l-95% CI u-95% CI
## depcantgo_mostmug_devx21[1]                    0.25      0.14     0.04     0.56
## depcantgo_mostmug_devx21[2]                    0.28      0.15     0.04     0.60
## depcantgo_mostmug_devx21[3]                    0.22      0.13     0.04     0.52
## depcantgo_mostmug_devx21[4]                    0.25      0.14     0.04     0.58
## depcantgo_mostmug_av12x21[1]                   0.12      0.07     0.02     0.30
## depcantgo_mostmug_av12x21[2]                   0.13      0.08     0.02     0.31
## depcantgo_mostmug_av12x21[3]                   0.13      0.08     0.02     0.31
## depcantgo_mostmug_av12x21[4]                   0.12      0.08     0.02     0.31
## depcantgo_mostmug_av12x21[5]                   0.12      0.08     0.02     0.30
## depcantgo_mostmug_av12x21[6]                   0.12      0.08     0.02     0.31
## depcantgo_mostmug_av12x21[7]                   0.13      0.08     0.02     0.34
## depcantgo_mostmug_av12x21[8]                   0.13      0.08     0.02     0.33
## depcantgo_mostmug_devx2:rural.ses.med21[1]     0.20      0.17     0.01     0.63
## depcantgo_mostmug_devx2:rural.ses.med21[2]     0.33      0.26     0.00     0.82
## depcantgo_mostmug_devx2:rural.ses.med21[3]     0.17      0.15     0.01     0.55
## depcantgo_mostmug_devx2:rural.ses.med21[4]     0.30      0.26     0.01     0.88
## depcantgo_mostmug_devx2:rural.ses.med31[1]     0.27      0.20     0.01     0.73
## depcantgo_mostmug_devx2:rural.ses.med31[2]     0.21      0.17     0.01     0.64
## depcantgo_mostmug_devx2:rural.ses.med31[3]     0.21      0.17     0.01     0.64
## depcantgo_mostmug_devx2:rural.ses.med31[4]     0.32      0.22     0.01     0.79
## depcantgo_mostmug_devx2:rural.ses.med41[1]     0.26      0.19     0.01     0.70
## depcantgo_mostmug_devx2:rural.ses.med41[2]     0.23      0.18     0.01     0.66
## depcantgo_mostmug_devx2:rural.ses.med41[3]     0.23      0.18     0.01     0.67
## depcantgo_mostmug_devx2:rural.ses.med41[4]     0.28      0.20     0.01     0.73
## depeffort_mostmug_devx21[1]                    0.25      0.14     0.04     0.58
## depeffort_mostmug_devx21[2]                    0.24      0.14     0.04     0.55
## depeffort_mostmug_devx21[3]                    0.26      0.15     0.04     0.59
## depeffort_mostmug_devx21[4]                    0.25      0.15     0.04     0.58
## depeffort_mostmug_av12x21[1]                   0.12      0.08     0.02     0.32
## depeffort_mostmug_av12x21[2]                   0.12      0.08     0.02     0.31
## depeffort_mostmug_av12x21[3]                   0.12      0.08     0.02     0.32
## depeffort_mostmug_av12x21[4]                   0.12      0.08     0.01     0.32
## depeffort_mostmug_av12x21[5]                   0.12      0.08     0.02     0.32
## depeffort_mostmug_av12x21[6]                   0.13      0.08     0.02     0.33
## depeffort_mostmug_av12x21[7]                   0.13      0.08     0.02     0.32
## depeffort_mostmug_av12x21[8]                   0.13      0.08     0.02     0.33
## depeffort_mostmug_devx2:rural.ses.med21[1]     0.22      0.17     0.01     0.64
## depeffort_mostmug_devx2:rural.ses.med21[2]     0.33      0.21     0.02     0.76
## depeffort_mostmug_devx2:rural.ses.med21[3]     0.21      0.17     0.01     0.61
## depeffort_mostmug_devx2:rural.ses.med21[4]     0.24      0.19     0.01     0.70
## depeffort_mostmug_devx2:rural.ses.med31[1]     0.25      0.19     0.01     0.70
## depeffort_mostmug_devx2:rural.ses.med31[2]     0.27      0.19     0.01     0.70
## depeffort_mostmug_devx2:rural.ses.med31[3]     0.20      0.17     0.01     0.64
## depeffort_mostmug_devx2:rural.ses.med31[4]     0.28      0.21     0.01     0.77
## depeffort_mostmug_devx2:rural.ses.med41[1]     0.24      0.19     0.01     0.69
## depeffort_mostmug_devx2:rural.ses.med41[2]     0.21      0.16     0.01     0.60
## depeffort_mostmug_devx2:rural.ses.med41[3]     0.26      0.20     0.01     0.71
## depeffort_mostmug_devx2:rural.ses.med41[4]     0.29      0.22     0.01     0.80
## deplonely_mostmug_devx21[1]                    0.27      0.15     0.04     0.59
## deplonely_mostmug_devx21[2]                    0.23      0.13     0.03     0.54
## deplonely_mostmug_devx21[3]                    0.24      0.14     0.04     0.56
## deplonely_mostmug_devx21[4]                    0.26      0.15     0.04     0.59
## deplonely_mostmug_av12x21[1]                   0.12      0.07     0.02     0.29
## deplonely_mostmug_av12x21[2]                   0.12      0.07     0.02     0.30
## deplonely_mostmug_av12x21[3]                   0.13      0.08     0.02     0.33
## deplonely_mostmug_av12x21[4]                   0.12      0.08     0.02     0.32
## deplonely_mostmug_av12x21[5]                   0.13      0.08     0.02     0.33
## deplonely_mostmug_av12x21[6]                   0.14      0.09     0.02     0.35
## deplonely_mostmug_av12x21[7]                   0.12      0.08     0.02     0.32
## deplonely_mostmug_av12x21[8]                   0.12      0.08     0.01     0.30
## deplonely_mostmug_devx2:rural.ses.med21[1]     0.18      0.16     0.01     0.59
## deplonely_mostmug_devx2:rural.ses.med21[2]     0.21      0.16     0.01     0.60
## deplonely_mostmug_devx2:rural.ses.med21[3]     0.28      0.18     0.02     0.69
## deplonely_mostmug_devx2:rural.ses.med21[4]     0.33      0.21     0.02     0.76
## deplonely_mostmug_devx2:rural.ses.med31[1]     0.21      0.17     0.01     0.66
## deplonely_mostmug_devx2:rural.ses.med31[2]     0.17      0.15     0.01     0.55
## deplonely_mostmug_devx2:rural.ses.med31[3]     0.36      0.21     0.01     0.77
## deplonely_mostmug_devx2:rural.ses.med31[4]     0.27      0.20     0.01     0.72
## deplonely_mostmug_devx2:rural.ses.med41[1]     0.19      0.16     0.01     0.59
## deplonely_mostmug_devx2:rural.ses.med41[2]     0.20      0.15     0.01     0.58
## deplonely_mostmug_devx2:rural.ses.med41[3]     0.30      0.19     0.02     0.71
## deplonely_mostmug_devx2:rural.ses.med41[4]     0.31      0.20     0.01     0.74
## depblues_mostmug_devx21[1]                     0.25      0.14     0.04     0.58
## depblues_mostmug_devx21[2]                     0.23      0.13     0.04     0.54
## depblues_mostmug_devx21[3]                     0.25      0.14     0.04     0.57
## depblues_mostmug_devx21[4]                     0.27      0.15     0.04     0.61
## depblues_mostmug_av12x21[1]                    0.12      0.08     0.02     0.32
## depblues_mostmug_av12x21[2]                    0.12      0.08     0.02     0.32
## depblues_mostmug_av12x21[3]                    0.12      0.08     0.02     0.32
## depblues_mostmug_av12x21[4]                    0.12      0.08     0.02     0.31
## depblues_mostmug_av12x21[5]                    0.13      0.08     0.02     0.33
## depblues_mostmug_av12x21[6]                    0.13      0.08     0.02     0.32
## depblues_mostmug_av12x21[7]                    0.13      0.08     0.02     0.33
## depblues_mostmug_av12x21[8]                    0.13      0.08     0.02     0.33
## depblues_mostmug_devx2:rural.ses.med21[1]      0.15      0.15     0.00     0.54
## depblues_mostmug_devx2:rural.ses.med21[2]      0.15      0.14     0.00     0.54
## depblues_mostmug_devx2:rural.ses.med21[3]      0.42      0.22     0.03     0.83
## depblues_mostmug_devx2:rural.ses.med21[4]      0.28      0.20     0.01     0.72
## depblues_mostmug_devx2:rural.ses.med31[1]      0.26      0.19     0.01     0.72
## depblues_mostmug_devx2:rural.ses.med31[2]      0.21      0.17     0.01     0.64
## depblues_mostmug_devx2:rural.ses.med31[3]      0.24      0.19     0.01     0.69
## depblues_mostmug_devx2:rural.ses.med31[4]      0.30      0.21     0.01     0.75
## depblues_mostmug_devx2:rural.ses.med41[1]      0.25      0.19     0.01     0.68
## depblues_mostmug_devx2:rural.ses.med41[2]      0.21      0.17     0.01     0.64
## depblues_mostmug_devx2:rural.ses.med41[3]      0.25      0.20     0.01     0.70
## depblues_mostmug_devx2:rural.ses.med41[4]      0.29      0.21     0.01     0.77
## depunfair_mostmug_devx21[1]                    0.26      0.14     0.04     0.58
## depunfair_mostmug_devx21[2]                    0.25      0.14     0.04     0.57
## depunfair_mostmug_devx21[3]                    0.23      0.14     0.03     0.56
## depunfair_mostmug_devx21[4]                    0.26      0.15     0.04     0.59
## depunfair_mostmug_av12x21[1]                   0.11      0.08     0.01     0.30
## depunfair_mostmug_av12x21[2]                   0.10      0.07     0.01     0.27
## depunfair_mostmug_av12x21[3]                   0.12      0.08     0.01     0.31
## depunfair_mostmug_av12x21[4]                   0.12      0.08     0.02     0.32
## depunfair_mostmug_av12x21[5]                   0.13      0.08     0.02     0.34
## depunfair_mostmug_av12x21[6]                   0.14      0.08     0.02     0.34
## depunfair_mostmug_av12x21[7]                   0.14      0.09     0.02     0.35
## depunfair_mostmug_av12x21[8]                   0.13      0.08     0.02     0.33
## depunfair_mostmug_devx2:rural.ses.med21[1]     0.26      0.20     0.01     0.72
## depunfair_mostmug_devx2:rural.ses.med21[2]     0.22      0.18     0.01     0.67
## depunfair_mostmug_devx2:rural.ses.med21[3]     0.23      0.18     0.01     0.68
## depunfair_mostmug_devx2:rural.ses.med21[4]     0.29      0.21     0.01     0.74
## depunfair_mostmug_devx2:rural.ses.med31[1]     0.27      0.20     0.01     0.71
## depunfair_mostmug_devx2:rural.ses.med31[2]     0.19      0.16     0.01     0.61
## depunfair_mostmug_devx2:rural.ses.med31[3]     0.20      0.17     0.01     0.62
## depunfair_mostmug_devx2:rural.ses.med31[4]     0.35      0.23     0.02     0.82
## depunfair_mostmug_devx2:rural.ses.med41[1]     0.29      0.20     0.01     0.73
## depunfair_mostmug_devx2:rural.ses.med41[2]     0.22      0.17     0.01     0.64
## depunfair_mostmug_devx2:rural.ses.med41[3]     0.26      0.19     0.01     0.70
## depunfair_mostmug_devx2:rural.ses.med41[4]     0.23      0.19     0.01     0.69
## depmistrt_mostmug_devx21[1]                    0.28      0.15     0.04     0.62
## depmistrt_mostmug_devx21[2]                    0.23      0.13     0.04     0.52
## depmistrt_mostmug_devx21[3]                    0.23      0.13     0.04     0.53
## depmistrt_mostmug_devx21[4]                    0.26      0.15     0.04     0.59
## depmistrt_mostmug_av12x21[1]                   0.15      0.09     0.02     0.34
## depmistrt_mostmug_av12x21[2]                   0.13      0.08     0.02     0.33
## depmistrt_mostmug_av12x21[3]                   0.10      0.06     0.01     0.26
## depmistrt_mostmug_av12x21[4]                   0.11      0.07     0.01     0.29
## depmistrt_mostmug_av12x21[5]                   0.12      0.07     0.01     0.30
## depmistrt_mostmug_av12x21[6]                   0.13      0.08     0.02     0.31
## depmistrt_mostmug_av12x21[7]                   0.14      0.09     0.02     0.35
## depmistrt_mostmug_av12x21[8]                   0.12      0.08     0.02     0.31
## depmistrt_mostmug_devx2:rural.ses.med21[1]     0.26      0.20     0.01     0.72
## depmistrt_mostmug_devx2:rural.ses.med21[2]     0.22      0.17     0.01     0.65
## depmistrt_mostmug_devx2:rural.ses.med21[3]     0.23      0.18     0.01     0.67
## depmistrt_mostmug_devx2:rural.ses.med21[4]     0.29      0.21     0.01     0.75
## depmistrt_mostmug_devx2:rural.ses.med31[1]     0.25      0.19     0.01     0.68
## depmistrt_mostmug_devx2:rural.ses.med31[2]     0.22      0.17     0.01     0.64
## depmistrt_mostmug_devx2:rural.ses.med31[3]     0.23      0.18     0.01     0.67
## depmistrt_mostmug_devx2:rural.ses.med31[4]     0.31      0.21     0.01     0.77
## depmistrt_mostmug_devx2:rural.ses.med41[1]     0.26      0.18     0.01     0.66
## depmistrt_mostmug_devx2:rural.ses.med41[2]     0.16      0.14     0.01     0.52
## depmistrt_mostmug_devx2:rural.ses.med41[3]     0.38      0.19     0.03     0.76
## depmistrt_mostmug_devx2:rural.ses.med41[4]     0.20      0.16     0.01     0.58
## depbetray_mostmug_devx21[1]                    0.27      0.15     0.03     0.60
## depbetray_mostmug_devx21[2]                    0.24      0.14     0.03     0.55
## depbetray_mostmug_devx21[3]                    0.24      0.14     0.04     0.56
## depbetray_mostmug_devx21[4]                    0.26      0.15     0.04     0.59
## depbetray_mostmug_av12x21[1]                   0.11      0.07     0.01     0.27
## depbetray_mostmug_av12x21[2]                   0.11      0.07     0.01     0.27
## depbetray_mostmug_av12x21[3]                   0.09      0.06     0.01     0.24
## depbetray_mostmug_av12x21[4]                   0.11      0.07     0.01     0.28
## depbetray_mostmug_av12x21[5]                   0.16      0.09     0.02     0.37
## depbetray_mostmug_av12x21[6]                   0.17      0.10     0.03     0.41
## depbetray_mostmug_av12x21[7]                   0.14      0.09     0.02     0.35
## depbetray_mostmug_av12x21[8]                   0.12      0.08     0.02     0.30
## depbetray_mostmug_devx2:rural.ses.med21[1]     0.25      0.20     0.01     0.73
## depbetray_mostmug_devx2:rural.ses.med21[2]     0.25      0.19     0.01     0.71
## depbetray_mostmug_devx2:rural.ses.med21[3]     0.23      0.18     0.01     0.65
## depbetray_mostmug_devx2:rural.ses.med21[4]     0.27      0.20     0.01     0.73
## depbetray_mostmug_devx2:rural.ses.med31[1]     0.23      0.18     0.01     0.66
## depbetray_mostmug_devx2:rural.ses.med31[2]     0.30      0.19     0.02     0.71
## depbetray_mostmug_devx2:rural.ses.med31[3]     0.21      0.16     0.01     0.59
## depbetray_mostmug_devx2:rural.ses.med31[4]     0.26      0.19     0.01     0.70
## depbetray_mostmug_devx2:rural.ses.med41[1]     0.30      0.19     0.02     0.71
## depbetray_mostmug_devx2:rural.ses.med41[2]     0.22      0.16     0.01     0.60
## depbetray_mostmug_devx2:rural.ses.med41[3]     0.29      0.17     0.02     0.67
## depbetray_mostmug_devx2:rural.ses.med41[4]     0.20      0.16     0.01     0.59
##                                            Rhat Bulk_ESS Tail_ESS
## depcantgo_mostmug_devx21[1]                1.00     5810     2690
## depcantgo_mostmug_devx21[2]                1.00     3132     2660
## depcantgo_mostmug_devx21[3]                1.00     5560     3108
## depcantgo_mostmug_devx21[4]                1.00     4465     2739
## depcantgo_mostmug_av12x21[1]               1.00     6186     2558
## depcantgo_mostmug_av12x21[2]               1.00     6117     2197
## depcantgo_mostmug_av12x21[3]               1.00     7576     2524
## depcantgo_mostmug_av12x21[4]               1.00     8494     2998
## depcantgo_mostmug_av12x21[5]               1.00     7347     2165
## depcantgo_mostmug_av12x21[6]               1.00     6423     2548
## depcantgo_mostmug_av12x21[7]               1.00     6695     2815
## depcantgo_mostmug_av12x21[8]               1.00     6510     3016
## depcantgo_mostmug_devx2:rural.ses.med21[1] 1.00     4438     2515
## depcantgo_mostmug_devx2:rural.ses.med21[2] 1.00     1354     1866
## depcantgo_mostmug_devx2:rural.ses.med21[3] 1.00     3881     2400
## depcantgo_mostmug_devx2:rural.ses.med21[4] 1.00     1505     2243
## depcantgo_mostmug_devx2:rural.ses.med31[1] 1.00     5294     2515
## depcantgo_mostmug_devx2:rural.ses.med31[2] 1.00     5488     2683
## depcantgo_mostmug_devx2:rural.ses.med31[3] 1.00     4204     2631
## depcantgo_mostmug_devx2:rural.ses.med31[4] 1.00     4330     3334
## depcantgo_mostmug_devx2:rural.ses.med41[1] 1.00     5029     2167
## depcantgo_mostmug_devx2:rural.ses.med41[2] 1.00     5823     2051
## depcantgo_mostmug_devx2:rural.ses.med41[3] 1.00     5776     2758
## depcantgo_mostmug_devx2:rural.ses.med41[4] 1.00     5716     2575
## depeffort_mostmug_devx21[1]                1.00     6710     2655
## depeffort_mostmug_devx21[2]                1.00     6630     2861
## depeffort_mostmug_devx21[3]                1.00     4443     3052
## depeffort_mostmug_devx21[4]                1.00     5092     2596
## depeffort_mostmug_av12x21[1]               1.00     8067     2207
## depeffort_mostmug_av12x21[2]               1.00     7570     2642
## depeffort_mostmug_av12x21[3]               1.00     7522     2670
## depeffort_mostmug_av12x21[4]               1.00     6477     2591
## depeffort_mostmug_av12x21[5]               1.00     8130     2672
## depeffort_mostmug_av12x21[6]               1.00     7404     2704
## depeffort_mostmug_av12x21[7]               1.00     6501     2613
## depeffort_mostmug_av12x21[8]               1.00     7199     2880
## depeffort_mostmug_devx2:rural.ses.med21[1] 1.00     5577     2309
## depeffort_mostmug_devx2:rural.ses.med21[2] 1.00     3773     1902
## depeffort_mostmug_devx2:rural.ses.med21[3] 1.00     5315     3055
## depeffort_mostmug_devx2:rural.ses.med21[4] 1.00     5863     2944
## depeffort_mostmug_devx2:rural.ses.med31[1] 1.00     5292     2257
## depeffort_mostmug_devx2:rural.ses.med31[2] 1.00     3932     2193
## depeffort_mostmug_devx2:rural.ses.med31[3] 1.00     4554     2783
## depeffort_mostmug_devx2:rural.ses.med31[4] 1.00     4251     2812
## depeffort_mostmug_devx2:rural.ses.med41[1] 1.00     5052     2171
## depeffort_mostmug_devx2:rural.ses.med41[2] 1.00     5642     2162
## depeffort_mostmug_devx2:rural.ses.med41[3] 1.00     3510     2899
## depeffort_mostmug_devx2:rural.ses.med41[4] 1.00     3038     2245
## deplonely_mostmug_devx21[1]                1.00     4839     2765
## deplonely_mostmug_devx21[2]                1.00     6956     2538
## deplonely_mostmug_devx21[3]                1.00     5526     2939
## deplonely_mostmug_devx21[4]                1.00     6363     2593
## deplonely_mostmug_av12x21[1]               1.00     6557     2314
## deplonely_mostmug_av12x21[2]               1.00     6974     2768
## deplonely_mostmug_av12x21[3]               1.00     6562     2000
## deplonely_mostmug_av12x21[4]               1.00     6278     2386
## deplonely_mostmug_av12x21[5]               1.00     8105     2578
## deplonely_mostmug_av12x21[6]               1.00     6869     2675
## deplonely_mostmug_av12x21[7]               1.00     7081     2882
## deplonely_mostmug_av12x21[8]               1.00     7897     2764
## deplonely_mostmug_devx2:rural.ses.med21[1] 1.00     4914     2714
## deplonely_mostmug_devx2:rural.ses.med21[2] 1.00     5483     1926
## deplonely_mostmug_devx2:rural.ses.med21[3] 1.00     3636     2673
## deplonely_mostmug_devx2:rural.ses.med21[4] 1.00     4099     2209
## deplonely_mostmug_devx2:rural.ses.med31[1] 1.00     3965     2664
## deplonely_mostmug_devx2:rural.ses.med31[2] 1.00     5719     2443
## deplonely_mostmug_devx2:rural.ses.med31[3] 1.00     2336     1986
## deplonely_mostmug_devx2:rural.ses.med31[4] 1.00     5093     2382
## deplonely_mostmug_devx2:rural.ses.med41[1] 1.00     4856     2598
## deplonely_mostmug_devx2:rural.ses.med41[2] 1.00     5326     2262
## deplonely_mostmug_devx2:rural.ses.med41[3] 1.00     4304     2454
## deplonely_mostmug_devx2:rural.ses.med41[4] 1.00     5281     2430
## depblues_mostmug_devx21[1]                 1.00     5637     2921
## depblues_mostmug_devx21[2]                 1.00     6768     2992
## depblues_mostmug_devx21[3]                 1.00     6749     2965
## depblues_mostmug_devx21[4]                 1.00     6605     2759
## depblues_mostmug_av12x21[1]                1.00     6956     2458
## depblues_mostmug_av12x21[2]                1.00     6165     2296
## depblues_mostmug_av12x21[3]                1.00     7007     2075
## depblues_mostmug_av12x21[4]                1.00     8005     2591
## depblues_mostmug_av12x21[5]                1.00     7086     2531
## depblues_mostmug_av12x21[6]                1.00     6349     2379
## depblues_mostmug_av12x21[7]                1.00     6485     2476
## depblues_mostmug_av12x21[8]                1.00     6507     2944
## depblues_mostmug_devx2:rural.ses.med21[1]  1.00     3395     2352
## depblues_mostmug_devx2:rural.ses.med21[2]  1.00     4871     2584
## depblues_mostmug_devx2:rural.ses.med21[3]  1.00     3609     2353
## depblues_mostmug_devx2:rural.ses.med21[4]  1.00     6183     2728
## depblues_mostmug_devx2:rural.ses.med31[1]  1.00     5296     2137
## depblues_mostmug_devx2:rural.ses.med31[2]  1.00     6640     2747
## depblues_mostmug_devx2:rural.ses.med31[3]  1.00     5652     2756
## depblues_mostmug_devx2:rural.ses.med31[4]  1.00     5429     3221
## depblues_mostmug_devx2:rural.ses.med41[1]  1.00     6463     2367
## depblues_mostmug_devx2:rural.ses.med41[2]  1.00     5935     2912
## depblues_mostmug_devx2:rural.ses.med41[3]  1.00     3693     3038
## depblues_mostmug_devx2:rural.ses.med41[4]  1.00     4234     2680
## depunfair_mostmug_devx21[1]                1.00     6054     2231
## depunfair_mostmug_devx21[2]                1.00     6406     3070
## depunfair_mostmug_devx21[3]                1.00     6050     2891
## depunfair_mostmug_devx21[4]                1.00     6858     2644
## depunfair_mostmug_av12x21[1]               1.00     5949     2365
## depunfair_mostmug_av12x21[2]               1.00     6641     2592
## depunfair_mostmug_av12x21[3]               1.00     6870     2103
## depunfair_mostmug_av12x21[4]               1.00     7035     2116
## depunfair_mostmug_av12x21[5]               1.00     8057     2164
## depunfair_mostmug_av12x21[6]               1.00     7000     2777
## depunfair_mostmug_av12x21[7]               1.00     5925     2647
## depunfair_mostmug_av12x21[8]               1.00     6447     2459
## depunfair_mostmug_devx2:rural.ses.med21[1] 1.00     5824     2648
## depunfair_mostmug_devx2:rural.ses.med21[2] 1.00     5448     2679
## depunfair_mostmug_devx2:rural.ses.med21[3] 1.00     5502     2662
## depunfair_mostmug_devx2:rural.ses.med21[4] 1.00     6225     2892
## depunfair_mostmug_devx2:rural.ses.med31[1] 1.00     4625     2650
## depunfair_mostmug_devx2:rural.ses.med31[2] 1.00     4928     2901
## depunfair_mostmug_devx2:rural.ses.med31[3] 1.00     4112     2052
## depunfair_mostmug_devx2:rural.ses.med31[4] 1.00     3722     2536
## depunfair_mostmug_devx2:rural.ses.med41[1] 1.00     3715     2155
## depunfair_mostmug_devx2:rural.ses.med41[2] 1.00     5101     2185
## depunfair_mostmug_devx2:rural.ses.med41[3] 1.00     5536     2844
## depunfair_mostmug_devx2:rural.ses.med41[4] 1.00     5400     3039
## depmistrt_mostmug_devx21[1]                1.00     5355     2710
## depmistrt_mostmug_devx21[2]                1.00     5907     2370
## depmistrt_mostmug_devx21[3]                1.00     6590     3135
## depmistrt_mostmug_devx21[4]                1.00     7007     2911
## depmistrt_mostmug_av12x21[1]               1.00     8033     2869
## depmistrt_mostmug_av12x21[2]               1.00     6498     2096
## depmistrt_mostmug_av12x21[3]               1.00     6238     2757
## depmistrt_mostmug_av12x21[4]               1.00     6651     2314
## depmistrt_mostmug_av12x21[5]               1.00     5407     2265
## depmistrt_mostmug_av12x21[6]               1.00     7764     2829
## depmistrt_mostmug_av12x21[7]               1.00     5577     2657
## depmistrt_mostmug_av12x21[8]               1.00     7534     2690
## depmistrt_mostmug_devx2:rural.ses.med21[1] 1.00     4829     2686
## depmistrt_mostmug_devx2:rural.ses.med21[2] 1.00     6202     1934
## depmistrt_mostmug_devx2:rural.ses.med21[3] 1.00     5340     2773
## depmistrt_mostmug_devx2:rural.ses.med21[4] 1.00     4880     2548
## depmistrt_mostmug_devx2:rural.ses.med31[1] 1.00     5545     2968
## depmistrt_mostmug_devx2:rural.ses.med31[2] 1.00     4768     2566
## depmistrt_mostmug_devx2:rural.ses.med31[3] 1.00     4312     2799
## depmistrt_mostmug_devx2:rural.ses.med31[4] 1.00     3920     2877
## depmistrt_mostmug_devx2:rural.ses.med41[1] 1.00     4621     2231
## depmistrt_mostmug_devx2:rural.ses.med41[2] 1.00     5134     2838
## depmistrt_mostmug_devx2:rural.ses.med41[3] 1.00     3619     2363
## depmistrt_mostmug_devx2:rural.ses.med41[4] 1.00     5568     2206
## depbetray_mostmug_devx21[1]                1.00     5247     2545
## depbetray_mostmug_devx21[2]                1.00     5269     2905
## depbetray_mostmug_devx21[3]                1.00     5606     2790
## depbetray_mostmug_devx21[4]                1.00     6546     2765
## depbetray_mostmug_av12x21[1]               1.00     6441     2552
## depbetray_mostmug_av12x21[2]               1.00     6894     2747
## depbetray_mostmug_av12x21[3]               1.00     5782     2360
## depbetray_mostmug_av12x21[4]               1.00     7348     2462
## depbetray_mostmug_av12x21[5]               1.00     7166     2533
## depbetray_mostmug_av12x21[6]               1.00     6495     2812
## depbetray_mostmug_av12x21[7]               1.00     6828     2970
## depbetray_mostmug_av12x21[8]               1.00     8165     2314
## depbetray_mostmug_devx2:rural.ses.med21[1] 1.00     4192     2656
## depbetray_mostmug_devx2:rural.ses.med21[2] 1.00     4629     2445
## depbetray_mostmug_devx2:rural.ses.med21[3] 1.00     5344     3012
## depbetray_mostmug_devx2:rural.ses.med21[4] 1.00     5800     2314
## depbetray_mostmug_devx2:rural.ses.med31[1] 1.00     4952     1924
## depbetray_mostmug_devx2:rural.ses.med31[2] 1.00     4208     2049
## depbetray_mostmug_devx2:rural.ses.med31[3] 1.00     4347     2566
## depbetray_mostmug_devx2:rural.ses.med31[4] 1.00     5226     2832
## depbetray_mostmug_devx2:rural.ses.med41[1] 1.00     4364     2665
## depbetray_mostmug_devx2:rural.ses.med41[2] 1.00     5220     2298
## depbetray_mostmug_devx2:rural.ses.med41[3] 1.00     4974     2748
## depbetray_mostmug_devx2:rural.ses.med41[4] 1.00     5274     2578
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
8.1.2.7.4 Prior summary
out.chg.alldepress.stmug.comm.fit[[2]]
##                              prior     class                          coef
##                             (flat)         b                              
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                       normal(0, 1)         b                              
##                   normal(0, 0.125)         b                mostmug_av12x2
##                    normal(0, 0.25)         b                 mostmug_devx2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med2
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med3
##                       normal(0, 1)         b  mostmug_devx2:rural.ses.med4
##                       normal(0, 1)         b                rural.ses.med2
##                       normal(0, 1)         b                rural.ses.med3
##                       normal(0, 1)         b                rural.ses.med4
##                             (flat) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##                       normal(0, 2) Intercept                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##               student_t(3, 0, 2.5)        sd                              
##               student_t(3, 0, 2.5)        sd                     Intercept
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  dirichlet(2, 2, 2, 2, 2, 2, 2, 2)      simo               mostmug_av12x21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med21
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med31
##                       dirichlet(1)      simo mostmug_devx2:rural.ses.med41
##              dirichlet(2, 2, 2, 2)      simo                mostmug_devx21
##  group      resp dpar nlpar lb ub       source
##                                        default
##        depbetray                          user
##        depbetray                          user
##        depbetray                          user
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##        depbetray                  (vectorized)
##         depblues                          user
##         depblues                          user
##         depblues                          user
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##         depblues                  (vectorized)
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                          user
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depcantgo                  (vectorized)
##        depeffort                          user
##        depeffort                          user
##        depeffort                          user
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        depeffort                  (vectorized)
##        deplonely                          user
##        deplonely                          user
##        deplonely                          user
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        deplonely                  (vectorized)
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                          user
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depmistrt                  (vectorized)
##        depunfair                          user
##        depunfair                          user
##        depunfair                          user
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##        depunfair                  (vectorized)
##                                        default
##        depbetray                          user
##         depblues                          user
##        depcantgo                          user
##        depeffort                          user
##        deplonely                          user
##        depmistrt                          user
##        depunfair                          user
##        depbetray             0         default
##         depblues             0         default
##        depcantgo             0         default
##        depeffort             0         default
##        deplonely             0         default
##        depmistrt             0         default
##        depunfair             0         default
##     id depbetray             0    (vectorized)
##     id depbetray             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id  depblues             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depcantgo             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id depeffort             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id deplonely             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depmistrt             0    (vectorized)
##     id depunfair             0    (vectorized)
##     id depunfair             0    (vectorized)
##        depbetray                          user
##        depbetray                       default
##        depbetray                       default
##        depbetray                       default
##        depbetray                          user
##         depblues                          user
##         depblues                       default
##         depblues                       default
##         depblues                       default
##         depblues                          user
##        depcantgo                          user
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                       default
##        depcantgo                          user
##        depeffort                          user
##        depeffort                       default
##        depeffort                       default
##        depeffort                       default
##        depeffort                          user
##        deplonely                          user
##        deplonely                       default
##        deplonely                       default
##        deplonely                       default
##        deplonely                          user
##        depmistrt                          user
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                       default
##        depmistrt                          user
##        depunfair                          user
##        depunfair                       default
##        depunfair                       default
##        depunfair                       default
##        depunfair                          user

9 Figure 4: Change correlations by community

(RMD FILE: BDK_2023_Stress_8_Chgcorr_comm_viz)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

9.1 Visualizing change correlations by community

9.1.1 Predictive Marginal Contrasts x Comm (Crim Intent)

load(here("1_Data_Files/Datasets/stress_long.Rdata"))

#load change by comm brms model fits 
# criminal intent
chg.prjcrime.stmony.comm.fit <- readRDS(here("Models/chg_prjcrime_stmony_comm_fit.rds")) 
chg.prjcrime.sttran.comm.fit <- readRDS(here("Models/chg_prjcrime_sttran_comm_fit.rds"))
chg.prjcrime.stresp.comm.fit <- readRDS(here("Models/chg_prjcrime_stresp_comm_fit.rds"))
chg.prjcrime.stfair.comm.fit <- readRDS(here("Models/chg_prjcrime_stfair_comm_fit.rds"))
chg.prjcrime.stjob.comm.fit <- readRDS(here("Models/chg_prjcrime_stjob_comm_fit.rds"))
chg.prjcrime.stthft.comm.fit <- readRDS(here("Models/chg_prjcrime_stthft_comm_fit.rds"))
chg.prjcrime.stmug.comm.fit <- readRDS(here("Models/chg_prjcrime_stmug_comm_fit.rds"))
chg.anyprjcrime.stmony.comm.fit <- readRDS(here("Models/chg_anyprjcrime_stmony_comm_fit.rds"))
chg.anyprjcrime.sttran.comm.fit <- readRDS(here("Models/chg_anyprjcrime_sttran_comm_fit.rds"))
chg.anyprjcrime.stresp.comm.fit <- readRDS(here("Models/chg_anyprjcrime_stresp_comm_fit.rds"))
chg.anyprjcrime.stfair.comm.fit <- readRDS(here("Models/chg_anyprjcrime_stfair_comm_fit.rds"))
chg.anyprjcrime.stjob.comm.fit <- readRDS(here("Models/chg_anyprjcrime_stjob_comm_fit.rds"))
chg.anyprjcrime.stthft.comm.fit <- readRDS(here("Models/chg_anyprjcrime_stthft_comm_fit.rds"))
chg.anyprjcrime.stmug.comm.fit <- readRDS(here("Models/chg_anyprjcrime_stmug_comm_fit.rds"))
# negative emotions
chg.alldepress.stmony.comm.fit <- readRDS(here("Models/chg_alldepress_stmony_comm_fit.rds"))
chg.alldepress.sttran.comm.fit <- readRDS(here("Models/chg_alldepress_sttran_comm_fit.rds"))
chg.alldepress.stresp.comm.fit <- readRDS(here("Models/chg_alldepress_stresp_comm_fit.rds"))
chg.alldepress.stfair.comm.fit <- readRDS(here("Models/chg_alldepress_stfair_comm_fit.rds"))
chg.alldepress.stjob.comm.fit <- readRDS(here("Models/chg_alldepress_stjob_comm_fit.rds"))
chg.alldepress.stthft.comm.fit <- readRDS(here("Models/chg_alldepress_stthft_comm_fit.rds"))
chg.alldepress.stmug.comm.fit <- readRDS(here("Models/chg_alldepress_stmug_comm_fit.rds"))

#T1 posterior PLME contrasts
# load(here("1_Data_Files/Datasets/twodif_combineddvs3.Rdata"))
# load(here("1_Data_Files/Datasets/twodif_combinedprj3.Rdata"))
# load(here("1_Data_Files/Datasets/twodif_combineddep3.Rdata"))
#Manually generate predictive margins data w/following generic structure:

# create new data grid for epred values
# newdata <- mylongdata %>%
#   data_grid(xdev, xbar, year) 
# 
# # generate epred draws (assuming two waves here)
# predmarg_data = epred_draws(mymodelfit,
#                 newdata = newdata,
#                 re_formula = NA) %>%
#   filter(xdev == -2 & year == 1 | 
#            xdev == 2 & year == 2) %>% 
#   group_by(.category, xdev, .draw) %>%      
#   summarise(`E[y|xdev]` = mean(`.epred`)) 
# 
# # calculate marginal effect contrasts
# margeff_contrast = predmarg_data %>% 
#   compare_levels(`E[y|xdev]`, by = xdev) %>%  # pairwise diffs in `E[y|x]`, by levels of x
#   rename(`difference in E[y|change in x (T2-T1)]` = `E[y|xdev]`) # more accurate column name


# create function to generate new data grid for epred values
gen_newdata_comm <- function(mylongdata, xdev, xave){
  mylongdata %>%
  data_grid({{xdev}}, {{xave}}, rural.ses.med, year) 
}

# create function to generate epred draws 
  # keeping only 2-unit increases from year 1 to year 2 (contrast 2_t2 - -2_t1)
gen_predmarg_data_comm <- function(mymodelfit, xdev){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  filter({{xdev}} == -2 & year == 1 | 
           {{xdev}} == 2 & year == 2) %>%
  group_by(.category, rural.ses.med, {{xdev}}, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`))
}

# generate epred draws 
newdata <- gen_newdata_comm(stress.long, stmony_devx2, stmony_av12x2)
predmarg_stmony_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.stmony.comm.fit, stmony_devx2)

newdata <- gen_newdata_comm(stress.long, sttran_devx2, sttran_av12x2)
predmarg_sttran_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.sttran.comm.fit, sttran_devx2)

newdata <- gen_newdata_comm(stress.long, stresp_devx2, stresp_av12x2)
predmarg_stresp_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.stresp.comm.fit, stresp_devx2)

newdata <- gen_newdata_comm(stress.long, stfair_devx2, stfair_av12x2)
predmarg_stfair_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.stfair.comm.fit, stfair_devx2)

newdata <- gen_newdata_comm(stress.long, stjob_devx2, stjob_av12x2)
predmarg_stjob_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.stjob.comm.fit, stjob_devx2)

newdata <- gen_newdata_comm(stress.long, stthft_devx2, stthft_av12x2)
predmarg_stthft_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.stthft.comm.fit, stthft_devx2)

newdata <- gen_newdata_comm(stress.long, stmug_devx2, stmug_av12x2)
predmarg_stmug_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.stmug.comm.fit, stmug_devx2)

  
gen_newdata_comm <- function(mylongdata, xdev, xave){
  mylongdata %>%
  data_grid({{xdev}}, {{xave}}, rural.ses.med, year) 
}


# create function to generate epred draws from "any crim intent" models 
  # keeping only 2-unit increases from year 1 to year 2 (contrast 2_t2 - -2_t1)
gen_predmarg_data_comm <- function(mymodelfit, xdev){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  filter({{xdev}} == -2 & year == 1 | 
           {{xdev}} == 2 & year == 2) %>%
  group_by(rural.ses.med, {{xdev}}, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`)) %>%
  ungroup() %>%
  mutate(.category="prjany")
}

# generate "any" epred data & merge with individual outcome item epred data
newdata <- gen_newdata_comm(stress.long, stmony_devx2, stmony_av12x2)
predmarg_stmony_anyprjcrim_chg_comm = 
  gen_predmarg_data_comm(chg.anyprjcrime.stmony.comm.fit, stmony_devx2)
predmarg_stmony_prjcrim_chg_comm <- bind_rows(predmarg_stmony_prjcrim_chg_comm, 
                                        predmarg_stmony_anyprjcrim_chg_comm)
rm(predmarg_stmony_anyprjcrim_chg_comm) #clean environment

newdata <- gen_newdata_comm(stress.long, sttran_devx2, sttran_av12x2)
predmarg_sttran_anyprjcrim_chg_comm = 
  gen_predmarg_data_comm(chg.anyprjcrime.sttran.comm.fit, sttran_devx2)
predmarg_sttran_prjcrim_chg_comm <- bind_rows(predmarg_sttran_prjcrim_chg_comm, 
                                        predmarg_sttran_anyprjcrim_chg_comm)
rm(predmarg_sttran_anyprjcrim_chg_comm) #clean environment

newdata <- gen_newdata_comm(stress.long, stresp_devx2, stresp_av12x2)
predmarg_stresp_anyprjcrim_chg_comm = 
  gen_predmarg_data_comm(chg.anyprjcrime.stresp.comm.fit, stresp_devx2)
predmarg_stresp_prjcrim_chg_comm <- bind_rows(predmarg_stresp_prjcrim_chg_comm, 
                                        predmarg_stresp_anyprjcrim_chg_comm)
rm(predmarg_stresp_anyprjcrim_chg_comm) #clean environment

newdata <- gen_newdata_comm(stress.long, stfair_devx2, stfair_av12x2)
predmarg_stfair_anyprjcrim_chg_comm = 
  gen_predmarg_data_comm(chg.anyprjcrime.stfair.comm.fit, stfair_devx2)
predmarg_stfair_prjcrim_chg_comm <- bind_rows(predmarg_stfair_prjcrim_chg_comm, 
                                        predmarg_stfair_anyprjcrim_chg_comm)
rm(predmarg_stfair_anyprjcrim_chg_comm) #clean environment

newdata <- gen_newdata_comm(stress.long, stjob_devx2, stjob_av12x2)
predmarg_stjob_anyprjcrim_chg_comm = 
  gen_predmarg_data_comm(chg.anyprjcrime.stjob.comm.fit, stjob_devx2)
predmarg_stjob_prjcrim_chg_comm <- bind_rows(predmarg_stjob_prjcrim_chg_comm, 
                                        predmarg_stjob_anyprjcrim_chg_comm)
rm(predmarg_stjob_anyprjcrim_chg_comm) #clean environment

newdata <- gen_newdata_comm(stress.long, stthft_devx2, stthft_av12x2)
predmarg_stthft_anyprjcrim_chg_comm = 
  gen_predmarg_data_comm(chg.anyprjcrime.stthft.comm.fit, stthft_devx2)
predmarg_stthft_prjcrim_chg_comm <- bind_rows(predmarg_stthft_prjcrim_chg_comm, 
                                        predmarg_stthft_anyprjcrim_chg_comm)
rm(predmarg_stthft_anyprjcrim_chg_comm) #clean environment

newdata <- gen_newdata_comm(stress.long, stmug_devx2, stmug_av12x2)
predmarg_stmug_anyprjcrim_chg_comm = 
  gen_predmarg_data_comm(chg.anyprjcrime.stmug.comm.fit, stmug_devx2)
predmarg_stmug_prjcrim_chg_comm <- bind_rows(predmarg_stmug_prjcrim_chg_comm, 
                                        predmarg_stmug_anyprjcrim_chg_comm)
rm(predmarg_stmug_anyprjcrim_chg_comm) #clean environment

#function to calculate mean difference contrasts (marginal effect contrast) 
calc_ME_chg_comm <- function(predmarg_data, xdev) {
  predmarg_data %>%
    compare_levels(`E[y|xdev]`, by = xdev) %>%  # pairwise diffs in `E[y|x]`, by levels of x
    group_by(rural.ses.med) %>% # generate community-specific marginal contrasts 
    rename(`PLME2chg` = `E[y|xdev]`) # easy colname reflecting ME 2-unit chg contrast 
}


#outputs community-specific predicted differences in E[y] 
# associated with 2-Likert category increase in stress (T2-T1) 
  #marg effect contrasts are marginalized over all person-level avg values of stress (AME)

#generate ME contrasts
PLME2_stmony_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stmony_prjcrim_chg_comm, "stmony_devx2") %>%
      mutate(stress_var = "Stress:\nMoney",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stmony_devx2)}, file="cache_8_1") 
PLME2_sttran_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_sttran_prjcrim_chg_comm, "sttran_devx2") %>%
      mutate(stress_var = "Stress:\nTransport",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = sttran_devx2)}, file="cache_8_2")
PLME2_stresp_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stresp_prjcrim_chg_comm, "stresp_devx2") %>%
      mutate(stress_var = "Stress:\nRespect",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stresp_devx2)}, file="cache_8_3")
PLME2_stfair_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stfair_prjcrim_chg_comm, "stfair_devx2") %>%
      mutate(stress_var = "Stress:\nFair Trtmt",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stfair_devx2)}, file="cache_8_4")
PLME2_stjob_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stjob_prjcrim_chg_comm, "stjob_devx2") %>%
      mutate(stress_var = "Stress:\nJob",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stjob_devx2)}, file="cache_8_5")
PLME2_stthft_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stthft_prjcrim_chg_comm, "stthft_devx2") %>%
      mutate(stress_var = "Stress:\nTheft Vctm",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stthft_devx2)}, file="cache_8_6")
PLME2_stmug_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stmug_prjcrim_chg_comm, "stmug_devx2") %>%
      mutate(stress_var = "Stress:\nAssault Vctm",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stmug_devx2)}, file="cache_8_7")

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
PLME2_combinedprjchg_comm <- bind_rows(
  PLME2_stmony_prjcrim_chg_comm,
  PLME2_sttran_prjcrim_chg_comm,
  PLME2_stresp_prjcrim_chg_comm,
  PLME2_stfair_prjcrim_chg_comm,
  PLME2_stjob_prjcrim_chg_comm,
  PLME2_stthft_prjcrim_chg_comm,
  PLME2_stmug_prjcrim_chg_comm) %>% 
  mutate (stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nAssault Vctm",
                                    "Stress:\nTheft Vctm", 
                                    "Stress:\nJob",
                                    "Stress:\nFair Trtmt",
                                    "Stress:\nRespect",
                                    "Stress:\nTransport",
                                    "Stress:\nMoney")
                           )
          )

9.1.2 Predictive Marginal Contrasts x Comm (Negative Emotions)

# create function to generate new data grid for epred values
gen_newdata_comm <- function(mylongdata, xdev, xave){
  mylongdata %>%
  data_grid({{xdev}}, {{xave}}, rural.ses.med, year) 
}

# create function to generate epred draws 
  # keeping only 2-unit increases from year 1 to year 2 (contrast 2_t2 - -2_t1)
gen_predmarg_data_comm <- function(mymodelfit, xdev){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  filter({{xdev}} == -2 & year == 1 | 
           {{xdev}} == 2 & year == 2) %>%
  group_by(.category, rural.ses.med, {{xdev}}, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`))
}

# generate epred draws using gen_newdata & gen_predmarg_data function
newdata <- gen_newdata_comm(stress.long, stmony_devx2, stmony_av12x2)
predmarg_stmony_dep_chg_comm = gen_predmarg_data_comm(chg.alldepress.stmony.comm.fit, stmony_devx2)

newdata <- gen_newdata_comm(stress.long, sttran_devx2, sttran_av12x2)
predmarg_sttran_dep_chg_comm = gen_predmarg_data_comm(chg.alldepress.sttran.comm.fit, sttran_devx2)

newdata <- gen_newdata_comm(stress.long, stresp_devx2, stresp_av12x2)
predmarg_stresp_dep_chg_comm = gen_predmarg_data_comm(chg.alldepress.stresp.comm.fit, stresp_devx2)

newdata <- gen_newdata_comm(stress.long, stfair_devx2, stfair_av12x2)
predmarg_stfair_dep_chg_comm = gen_predmarg_data_comm(chg.alldepress.stfair.comm.fit, stfair_devx2)

newdata <- gen_newdata_comm(stress.long, stjob_devx2, stjob_av12x2)
predmarg_stjob_dep_chg_comm = gen_predmarg_data_comm(chg.alldepress.stjob.comm.fit, stjob_devx2)

newdata <- gen_newdata_comm(stress.long, stthft_devx2, stthft_av12x2)
predmarg_stthft_dep_chg_comm = gen_predmarg_data_comm(chg.alldepress.stthft.comm.fit, stthft_devx2)

newdata <- gen_newdata_comm(stress.long, stmug_devx2, stmug_av12x2)
predmarg_stmug_dep_chg_comm = gen_predmarg_data_comm(chg.alldepress.stmug.comm.fit, stmug_devx2)

#outputs predicted difference in E[y] associated with 2-Likert category increase in stress (T2-T1) 
  #marg effect contrasts are marginalized over all person-level avg values of stress (AME)

#generate ME contrasts using calc_ME_chg function
PLME2_stmony_dep_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stmony_dep_chg_comm, "stmony_devx2") %>%
      mutate(stress_var = "Stress:\nMoney",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stmony_devx2)}, file="cache_8_8")
PLME2_sttran_dep_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_sttran_dep_chg_comm, "sttran_devx2") %>%
      mutate(stress_var = "Stress:\nTransport",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = sttran_devx2)}, file="cache_8_9")
PLME2_stresp_dep_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stresp_dep_chg_comm, "stresp_devx2") %>%
      mutate(stress_var = "Stress:\nRespect",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stresp_devx2)}, file="cache_8_10")
PLME2_stfair_dep_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stfair_dep_chg_comm, "stfair_devx2") %>%
      mutate(stress_var = "Stress:\nFair Trtmt",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stfair_devx2)}, file="cache_8_11")
PLME2_stjob_dep_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stjob_dep_chg_comm, "stjob_devx2") %>%
      mutate(stress_var = "Stress:\nJob",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stjob_devx2)}, file="cache_8_12")
PLME2_stthft_dep_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stthft_dep_chg_comm, "stthft_devx2") %>%
      mutate(stress_var = "Stress:\nTheft Vctm",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stthft_devx2)}, file="cache_8_13")
PLME2_stmug_dep_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stmug_dep_chg_comm, "stmug_devx2") %>%
      mutate(stress_var = "Stress:\nAssault Vctm",
             dif_label = "diff in E[y|stress change]") %>%
      rename(contrast = stmug_devx2)}, file="cache_8_14")

#Combine data sets w/"bind_rows" command (stacks on top of each other bc all have same vars)
PLME2_combineddepchg_comm <- bind_rows(
  PLME2_stmony_dep_chg_comm,
  PLME2_sttran_dep_chg_comm,
  PLME2_stresp_dep_chg_comm,
  PLME2_stfair_dep_chg_comm,
  PLME2_stjob_dep_chg_comm,
  PLME2_stthft_dep_chg_comm,
  PLME2_stmug_dep_chg_comm) %>% 
  mutate (stress_varf = factor(stress_var, ordered=TRUE,
                           levels=c("Stress:\nAssault Vctm",
                                    "Stress:\nTheft Vctm", 
                                    "Stress:\nJob",
                                    "Stress:\nFair Trtmt",
                                    "Stress:\nRespect",
                                    "Stress:\nTransport",
                                    "Stress:\nMoney")
                           )
          )

9.1.3 Fig4 versions: PLME Stress/Outcome Change X Community

#function to find & drop leading zeroes (used for x-axis label)
dropLeadingZero <- function(l){
  str_replace(l, '0(?=.)', '')
}

#wrangle PLME prj crime T2-T1 change estimates
PLMEprjchg_comm <- PLME2_combinedprjchg_comm %>% 
  rename(PLME = PLME2chg) %>%
  mutate(
    dif_label='diff in E[y|2-cat stress increase]'
  ) %>% 
  dplyr::select(-c(contrast)) %>%
  group_by(.category, stress_var, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = as.factor(if_else(p_gt0 >= .80, 1, 0)) 
  ) %>% 
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5", "prjthfgt5", "prjthreat",
                                "prjharm", "prjusedrg", "prjhack", 
                                "prjany"))
  )
  

#wrangle PLME neg emo T2-T1 change estimates
PLMEdepchg_comm <- PLME2_combineddepchg_comm %>% 
  rename(PLME = PLME2chg) %>%
  mutate(
    dif_label='diff in E[y|2-cat stress increase]' 
  ) %>% 
  dplyr::select(-c(contrast)) %>%
  group_by(.category, stress_var, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = as.factor(if_else(p_gt0 >= .80, 1, 0))
  )


prjlabs <- c(
  "prjthflt5"="Theft <5BAM", 
  "prjthfgt5"="Theft >5BAM", 
  "prjthreat"="Threaten", 
  "prjharm"="Phys. harm",
  "prjusedrg"="Use drugs",
  "prjhack"="Hack info",
  "prjany"="Any crime")
deplabs <- c(
  "depcantgo"="Can't go", 
  "depeffort"="Effort", 
  "deplonely"="Lonely", 
  "depblues"="Blues",
  "depunfair"="Unfair",
  "depmistrt"="Mistreated",
  "depbetray"="Betrayed")
stress_varlabs <- c(
  "Stress:\nMoney" = "Stress:\nMoney",
  "Stress:\nTransport" = "Stress:\nTransport",
  "Stress:\nRespect" = "Stress:\nRespect",
  "Stress:\nFair Trtmt" = "Stress:\nFair Trtmt",
  "Stress:\nJob" = "Stress:\nJob",
  "Stress:\nTheft Vctm" = "Stress:\nTheft",
  "Stress:\nAssault Vctm"   = "Stress:\nAssault")
numcommlabs <- c("1"="Rural/\nLow SES", 
              "2"="Rural/\nHigh SES", 
              "3"="Urban/\nLow SES", 
              "4"="Urban/\nHigh SES")

# Colors from viridis colorblind-friendly palette
# https://waldyrious.net/viridis-palette-generator/

prjcommplot <- ggplot(data = PLMEprjchg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(.category, desc(.category)), 
                                     color=rural.ses.med)) + 
  facet_wrap(~reorder(stress_varf, desc(stress_varf)), nrow=1,
             labeller = labeller(stress_varf= as_labeller(stress_varlabs))) +
    geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 1),
                     aes(x=PLME, y=reorder(.category, desc(.category)), 
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = .3), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 2),
                     aes(x=PLME, y=reorder(.category, desc(.category)),
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = .1), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 3),
                     aes(x=PLME, y=reorder(.category, desc(.category)),
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = -.1), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 4),
                     aes(x=PLME, y=reorder(.category, desc(.category)),
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = -.3), size=.5) +
  scale_color_manual(values=c("#bddf26","#7ad151", "#2a788e", "#440154"), 
                      labels=as_labeller(numcommlabs), name=NULL) +
  scale_alpha_discrete(range=c(.1,1), guide = "none") +
  coord_cartesian(xlim=c(-.11,.31)) + 
  scale_x_continuous(breaks=c(-.1,0,.1,.2), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=prjlabs) +
  theme(axis.title.y = element_blank(), 
        legend.position = "right",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) +
        guides(shape = guide_legend(override.aes = list(size = 0.5))) 

# prjcommplot

depcommplot <- ggplot(data = PLMEdepchg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(.category, desc(.category)), 
                                     color=rural.ses.med)) + 
  facet_wrap(~reorder(stress_varf, desc(stress_varf)), nrow=1,
             labeller = labeller(stress_varf= as_labeller(stress_varlabs))) +
    geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 1),
                     aes(x=PLME, y=reorder(.category, desc(.category)), 
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = .3), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 2),
                     aes(x=PLME, y=reorder(.category, desc(.category)),
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = .1), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 3),
                     aes(x=PLME, y=reorder(.category, desc(.category)),
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = -.1), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 4),
                     aes(x=PLME, y=reorder(.category, desc(.category)),
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = -.3), size=.5) +
  scale_color_manual(values=c("#bddf26","#7ad151", "#2a788e", "#440154"), 
                      labels=as_labeller(numcommlabs), name=NULL) +
  scale_alpha_discrete(range=c(.1,1), guide = "none") +
  coord_cartesian(xlim=c(-.51,.71)) + 
  scale_x_continuous(breaks=c(-.5,0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=deplabs) +
  theme(axis.title.y = element_blank(), 
        legend.position = "right",
        strip.background = element_blank(),
        strip.text.x = element_blank(), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) +
        guides(shape = guide_legend(override.aes = list(size = 0.5))) 

# depcommplot

design <- "
1113
2223
"    

# library(patchwork)
SuppFigure4a <- prjcommplot + depcommplot + guide_area() + 
  plot_layout(design=design, guides = 'collect', widths = c(4,.6)) + 
    plot_annotation(
    title = 'SUPPLEMENTAL FIGURE 4a\nMarginal Effects of 2-Category Change in Stress on Outcome Probabilities, by Community SES & Urban/Rural Location',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Estimates derived from 14 multivariate (using `brms::mvbind()`) and multilevel between-within Bayesian logistic regression models simultaneously regressing all six specific criminal intent outcomes (7 models) and all seven negative emotion outcomes (7 models) separately on each of the seven stress types, and seven separate models regressing "any criminal intent" on stress. Stress items were separated into a L2 cross-time average (Xbar_i) between-person predictor and a L1 within-person change (X_it - Xbar_i) "fixed effects" estimator. Both L1 and L2 stress variables were specified as monotonic ordinal predictors with a cumulative probit link function. Models also included a factor variable for community and a multiplicative interaction between L1 stress change (fixed effects estimator) and community. Models were estimated in brms with 4 chains and 4000 total post-warmup posterior draws per outcome and per community group. Marginal effect contrast distributions were estimated from the expectation of the posterior predictive distribution for each model as predicted probability difference distributions for 2-category stress increases (T1 to T2 change) by community, averaged over all between-person stress levels. Median posterior density estimates with 95% intervals displayed. Bold point-intervals indicate at least 80% of posterior estimates for the average marginal effect contrast are greater than zero.', width=180)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'right',
        legend.key.height = unit(1, 'cm'))

# SuppFigure4a

ggsave("SuppFigure4a.jpeg", width=9, height=6.5, path=here("Output"))


stress_varlabsalt <- c(
  "Stress:\nMoney" = "Stress: Money",
  "Stress:\nTransport" = "Stress: Transport",
  "Stress:\nRespect" = "Stress: Respect",
  "Stress:\nFair Trtmt" = "Stress: Fair Trtmt",
  "Stress:\nJob" = "Stress: Job",
  "Stress:\nTheft Vctm" = "Stress: Theft",
  "Stress:\nAssault Vctm"   = "Stress: Assault")

  
prjcommplotalt <- ggplot(data = PLMEprjchg_comm, 
                       mapping = aes(x = PLME, 
                                     y = stress_varf, 
                                     color=rural.ses.med)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(prjlabs))) +
    geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 1),
                     aes(x=PLME, y=stress_varf, 
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = .3), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 2),
                     aes(x=PLME, y=stress_varf,
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = .1), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 3),
                     aes(x=PLME, y=stress_varf,
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = -.1), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 4),
                     aes(x=PLME, y=stress_varf,
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = -.3), size=.5) +
  scale_color_manual(values=c("#bddf26","#7ad151", "#2a788e", "#440154"), 
                      labels=as_labeller(numcommlabs), name=NULL) +
  scale_alpha_discrete(range=c(.1,1), guide = "none") +
  coord_cartesian(xlim=c(-.11,.31)) + 
  scale_x_continuous(breaks=c(-.1,0,.1,.2), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=stress_varlabsalt) +
  theme(axis.title.y = element_blank(), 
        legend.position = "right",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) +
        guides(shape = guide_legend(override.aes = list(size = 0.5))) 

# prjcommplotalt

depcommplotalt <- ggplot(data = PLMEdepchg_comm, 
                       mapping = aes(x = PLME, 
                                     y = stress_varf, 
                                     color=rural.ses.med)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(deplabs))) +
    geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 1),
                     aes(x=PLME, y=stress_varf, 
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = .3), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 2),
                     aes(x=PLME, y=stress_varf, 
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = .1), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 3),
                     aes(x=PLME, y=stress_varf, 
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = -.1), size=.5) +
    stat_pointinterval(data=function(x) subset(x, rural.ses.med == 4),
                     aes(x=PLME, y=stress_varf, 
                         alpha=p80_gt0), .width = .95, 
                     position = position_nudge(y = -.3), size=.5) +
  scale_color_manual(values=c("#bddf26","#7ad151", "#2a788e", "#440154"), 
                      labels=as_labeller(numcommlabs), name=NULL) +
  scale_alpha_discrete(range=c(.1,1), guide = "none") +
  coord_cartesian(xlim=c(-.51,.71)) + 
  scale_x_continuous(breaks=c(-.5,0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=stress_varlabsalt) +
  theme(axis.title.y = element_blank(), 
        legend.position = "right",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) +
        guides(shape = guide_legend(override.aes = list(size = 0.5))) 

# depcommplotalt

design <- "
1113
2223
"    

# library(patchwork)
SuppFigure4b <- prjcommplotalt + depcommplotalt + guide_area() + 
  plot_layout(design=design, guides = 'collect', widths = c(4,.6)) + 
    plot_annotation(
    title = 'SUPPLEMENTAL FIGURE 4b\nMarginal Effects of 2-Category Change in Stress on Outcome Probabilities, by Community SES & Urban/Rural Location',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Estimates derived from 14 multivariate (using `brms::mvbind()`) and multilevel between-within Bayesian logistic regression models simultaneously regressing all six specific criminal intent outcomes (7 models) and all seven negative emotion outcomes (7 models) separately on each of the seven stress types, and seven separate models regressing "any criminal intent" on stress. Stress items were separated into a L2 cross-time average (Xbar_i) between-person predictor and a L1 within-person change (X_it - Xbar_i) "fixed effects" estimator. Both L1 and L2 stress variables were specified as monotonic ordinal predictors with a cumulative probit link function. Models also included a factor variable for community and a multiplicative interaction between L1 stress change (fixed effects estimator) and community. Models were estimated in brms with 4 chains and 4000 total post-warmup posterior draws per outcome and per community group. Marginal effect contrast distributions were estimated from the expectation of the posterior predictive distribution for each model as predicted probability difference distributions for 2-category stress increases (T1 to T2 change) by community, averaged over all between-person stress levels. Median posterior density estimates with 95% intervals displayed. Bold point-intervals indicate at least 80% of posterior estimates for the average marginal effect contrast are greater than zero.', width=180)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'right', 
        legend.key.height = unit(1, 'cm'))

# SuppFigure4b

ggsave("SuppFigure4b.jpeg", width=9, height=6.5, path=here("Output"))

9.1.3.1 Supp. Fig4a (Alt. groupings)

SuppFigure4a

9.1.3.2 Supp. Fig4b (Alt. groupings)

SuppFigure4b

9.2 FIGURE 4 - Stress Chg on Outcomes by Community

numcommlabs2 <- c("1"="Rural\nLowSES", 
              "2"="Rural\nHighSES", 
              "3"="Urban\nLowSES", 
              "4"="Urban\nHighSES")
prjlabs2 <- c(
  "prjthflt5"="Theft\n<5BAM", 
  "prjthfgt5"="Theft\n>5BAM", 
  "prjthreat"="Threat", 
  "prjharm"="Phys.\nharm",
  "prjusedrg"="Use\ndrugs",
  "prjhack"="Hack\ninfo",
  "prjany"="Any crime")
deplabs2 <- c(
  "depcantgo"="Can't\ngo", 
  "depeffort"="Effort", 
  "deplonely"="Lonely", 
  "depblues"="Blues",
  "depunfair"="Unfair",
  "depmistrt"="Mistreated",
  "depbetray"="Betrayed")

stress_varlabs <- c(
  "Stress:\nMoney" = "Money",
  "Stress:\nTransport" = "Transport",
  "Stress:\nRespect" = "Respect",
  "Stress:\nFair Trtmt" = "Fair Trtmt",
  "Stress:\nJob" = "Job",
  "Stress:\nTheft Vctm" = "Theft",
  "Stress:\nAssault Vctm"   = "Assault")

prjcommplotalt2 <- ggplot(data = PLMEprjchg_comm, 
                          mapping = aes(x = PLME,
                                        y = reorder(rural.ses.med, desc(rural.ses.med)),
                                        group=stress_varf,
                                        color=stress_varf)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(prjlabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLMEprjchg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med), 
                                           group_by=stress_varf),
                         alpha=p80_gt0),
                     .width = .95, size=.7,
                     position = position_dodge(width=.7)) +
  scale_color_viridis_d(labels=as_labeller(stress_varlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.25,.51)) + 
  scale_x_continuous(breaks=c(0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=numcommlabs2) +
  labs(subtitle='Criminal Intent\n___________________________________________________________') +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_text(size =8, angle=65),
        axis.text.y = element_text(size=10),
        plot.subtitle=element_text(size=8, hjust=0.5, face="italic"),
        legend.text = element_text(size = 10), 
        legend.title=element_text(size=10, face="italic")) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)),
               color = guide_legend(nrow=1, reverse = TRUE, title="Stress Item:"))

# prjcommplotalt2


depcommplotalt2 <- ggplot(data = PLMEdepchg_comm, 
                          mapping = aes(x = PLME,
                                        y = reorder(rural.ses.med, desc(rural.ses.med)),
                                        group=stress_varf,
                                        color=stress_varf)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(deplabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLMEdepchg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med), 
                                           group_by=stress_varf),
                         alpha=p80_gt0),
                     .width = .95, size=.7,
                     position = position_dodge(width=.7)) +
  scale_color_viridis_d(labels=as_labeller(stress_varlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.25,.71)) + 
  scale_x_continuous(breaks=c(0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=numcommlabs2) +
  labs(subtitle='Negative Emotions\n_____________________________________________________________') +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8, angle=65),
        axis.text.y=element_blank(), #remove y-axis labels
        axis.ticks.y=element_blank(), #remove y-axis ticks
        axis.line.y=element_blank(), #remove y-axis line
        plot.subtitle=element_text(size=8, hjust=0.5, face="italic"),
        legend.text = element_text(size = 10), 
        legend.title=element_text(size=10, face="italic")) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)),
               color = guide_legend(nrow=1, reverse = TRUE, title="Stress Item:"))

# depcommplotalt2




design <- "
12
33
"    

Figure4 <- prjcommplotalt2 + depcommplotalt2 + 
  guide_area() +
  plot_layout(design=design, guides = 'collect', heights = c(4,.1)) + 
    plot_annotation(
    title = 'FIGURE 4\nMarginal Effect of 2-Category Within-Person Increase in Stress on Change in Outcome Probabilities, by Community',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Each of the 392 intervals displayed represents the estimated marginal effect of a "practically large" 2-category increase in stress on an outcome probability derived from a fixed effects estimator in 98 distinct Bayesian multilevel between/within logistic regression models (98 models*4 estimates per community). Of these, 364 estimates are from 91 multivariate models simultaneously regressing (using `brms::mvbind()`) from multivariate models simultaneously regressing (using `brms:: mvbind()`) the six specific criminal intent outcomes or the seven negative emotions outcomes on each of the seven stress types (13*7=91 models). The other 28 estimates are from seven models regressing "any criminal intent" on each stress type.  Stress items were separated into a L2 cross-time average (Xbar_i) between-person predictor and a L1 within-person change (X_it - Xbar_i) "fixed effects" estimator. Both L1 and L2 stress variables were specified as monotonic ordinal predictors with a cumulative probit link function. Models also included a factor variable for community and a multiplicative interaction between L1 stress change (fixed effects estimator) and community. Models were estimated in brms with 4 chains and 4000 total post-warmup posterior draws per outcome and per community group. Marginal effect contrast distributions were estimated from the expectation of the posterior predictive distribution for each model as predicted probability difference distributions for 2-category stress increases (T1 to T2 change) by community, averaged over all between-person stress levels. Median posterior density estimates with 95% intervals displayed. Bold point-intervals indicate at least 80% of posterior estimates for the average marginal effect contrast are greater than zero.', width=195)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'bottom', 
        legend.key.height = unit(.5, 'cm'), 
        legend.margin = margin(0,0,0,0), 
        legend.spacing.y = unit(0, "mm"))

Figure4

ggsave("Figure4.jpeg", width=9, height=6.5, path=here("Output"))

As before, let’s pull all these plotted estimates into tables.

Again, we will specifically report some of the bold or “plausibly positive” (i.e., >=80% posterior probability of PLME > 0) in the text, so we make those easier to find by filtering to keep only those bold estimates. We will also report all estimates plotted in Figure 4 in separate tables.

9.2.1 Estimates plotted in Fig4

9.2.1.1 Bold crim intent (chg, >=80% ppd positive)

PLMEprjchg_comm %>% 
  mutate(
    rural.ses.med = if_else(
      rural.ses.med == "1", "Rural/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "2", "Rural/HighSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "3", "Urban/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "4", "Urban/HighSES", rural.ses.med)
  ) %>% 
  group_by(.category, stress_var, rural.ses.med) %>%
  mutate(
    n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests
    ) %>% 
  dplyr::filter(p_gt0 >= .80) %>% 
 # summarize PLME estimates across the MCMC draws
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (Chg) by Community PLME Estimates**"), 
    subtitle = md("Plotted in FIG4 (FIG5 in paper)")
  )
Criminal Intent (Chg) by Community PLME Estimates
Plotted in FIG4 (FIG5 in paper)
rural.ses.med m s ll ul
prjthflt5 - Stress: Assault Vctm
Urban/HighSES 0.034 0.096 -0.0354 0.34
prjthflt5 - Stress: Fair Trtmt
Urban/LowSES 0.021 0.057 -0.0113 0.17
prjthflt5 - Stress: Job
Urban/LowSES 0.021 0.064 -0.0089 0.22
prjthflt5 - Stress: Money
Urban/HighSES 0.089 0.159 0.0037 0.63
Urban/LowSES 0.028 0.093 -0.0045 0.32
prjthflt5 - Stress: Transport
Urban/HighSES 0.069 0.176 -0.0189 0.68
prjthfgt5 - Stress: Assault Vctm
Urban/HighSES 0.060 0.108 -0.0255 0.38
prjthfgt5 - Stress: Fair Trtmt
Urban/HighSES 0.062 0.121 -0.0223 0.46
Urban/LowSES 0.016 0.049 -0.0251 0.15
prjthfgt5 - Stress: Job
Urban/LowSES 0.033 0.072 -0.0088 0.26
prjthfgt5 - Stress: Money
Urban/HighSES 0.112 0.154 0.0088 0.61
Urban/LowSES 0.036 0.088 -0.0050 0.30
prjthfgt5 - Stress: Transport
Urban/HighSES 0.065 0.127 -0.0231 0.48
prjusedrg - Stress: Assault Vctm
Urban/HighSES 0.024 0.069 -0.0211 0.24
prjany - Stress: Assault Vctm
Urban/HighSES 0.182 0.198 -0.1462 0.65
prjany - Stress: Fair Trtmt
Urban/HighSES 0.209 0.189 -0.0619 0.68
Urban/LowSES 0.042 0.086 -0.0577 0.28
prjany - Stress: Job
Urban/LowSES 0.081 0.098 -0.0239 0.36
prjany - Stress: Money
Urban/HighSES 0.320 0.219 -0.0292 0.82
Urban/LowSES 0.105 0.140 -0.0211 0.56
prjany - Stress: Transport
Urban/HighSES 0.297 0.232 -0.0586 0.84

9.2.1.2 Bold neg emotions (chg, >=80% ppd positive)

PLMEdepchg_comm %>% 
  mutate(
    rural.ses.med = if_else(
      rural.ses.med == "1", "Rural/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "2", "Rural/HighSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "3", "Urban/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "4", "Urban/HighSES", rural.ses.med)
  ) %>% 
  group_by(.category, stress_var, rural.ses.med) %>%
  mutate(
    n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests
    ) %>% 
  dplyr::filter(p_gt0 >= .80) %>% 
   # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var, rural.ses.med) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (Chg) by Community PLME Estimates**"), 
    subtitle = md("Plotted in FIG4 (FIG5 in paper)")
  )
Negative Emotions (Chg) by Community PLME Estimates
Plotted in FIG4 (FIG5 in paper)
rural.ses.med m s ll ul
depcantgo - Stress: Fair Trtmt
Rural/HighSES 0.513 0.183 0.15217 0.85
Rural/LowSES 0.147 0.134 -0.10261 0.43
depcantgo - Stress: Job
Rural/HighSES 0.406 0.177 0.03778 0.73
Rural/LowSES 0.221 0.120 -0.03806 0.44
Urban/HighSES 0.269 0.228 -0.27323 0.63
depcantgo - Stress: Money
Rural/HighSES 0.203 0.217 -0.17191 0.70
Rural/LowSES 0.219 0.118 -0.00383 0.46
Urban/HighSES 0.301 0.218 -0.14792 0.74
depcantgo - Stress: Theft Vctm
Rural/HighSES 0.481 0.185 0.09190 0.81
Rural/LowSES 0.116 0.135 -0.16929 0.38
depcantgo - Stress: Transport
Rural/HighSES 0.481 0.182 0.10531 0.81
Rural/LowSES 0.176 0.109 -0.03484 0.38
Urban/HighSES 0.277 0.181 -0.09016 0.65
depeffort - Stress: Assault Vctm
Urban/LowSES 0.132 0.171 -0.18348 0.53
depeffort - Stress: Fair Trtmt
Rural/HighSES 0.128 0.163 -0.08649 0.59
Urban/LowSES 0.242 0.165 -0.01066 0.66
depeffort - Stress: Job
Urban/HighSES 0.181 0.207 -0.13394 0.68
depeffort - Stress: Money
Urban/HighSES 0.180 0.166 -0.14306 0.55
depeffort - Stress: Respect
Rural/HighSES 0.119 0.126 -0.07022 0.45
Urban/LowSES 0.134 0.139 -0.07376 0.48
depeffort - Stress: Theft Vctm
Urban/HighSES 0.133 0.169 -0.14109 0.53
Urban/LowSES 0.117 0.127 -0.14066 0.37
deplonely - Stress: Assault Vctm
Rural/HighSES 0.261 0.180 -0.05242 0.65
Urban/HighSES 0.306 0.192 -0.08557 0.67
Urban/LowSES 0.187 0.203 -0.25643 0.57
deplonely - Stress: Fair Trtmt
Rural/HighSES 0.162 0.160 -0.16396 0.49
deplonely - Stress: Job
Rural/LowSES 0.141 0.107 -0.06212 0.36
deplonely - Stress: Money
Urban/HighSES 0.428 0.205 0.05703 0.84
deplonely - Stress: Theft Vctm
Rural/HighSES 0.292 0.217 -0.07986 0.82
Rural/LowSES 0.201 0.120 -0.04916 0.43
Urban/HighSES 0.249 0.196 -0.13226 0.66
deplonely - Stress: Transport
Urban/HighSES 0.324 0.177 -0.04336 0.65
depblues - Stress: Theft Vctm
Urban/HighSES 0.392 0.199 0.07894 0.81
depunfair - Stress: Assault Vctm
Urban/HighSES 0.169 0.186 -0.20791 0.51
depunfair - Stress: Fair Trtmt
Rural/HighSES 0.316 0.172 0.00768 0.71
Rural/LowSES 0.116 0.086 -0.03856 0.31
Urban/HighSES 0.308 0.192 -0.09554 0.67
Urban/LowSES 0.157 0.158 -0.12547 0.50
depunfair - Stress: Job
Rural/HighSES 0.303 0.149 0.03667 0.63
Urban/HighSES 0.532 0.155 0.18758 0.79
depunfair - Stress: Money
Rural/HighSES 0.284 0.166 -0.02701 0.66
Rural/LowSES 0.140 0.082 -0.00579 0.32
Urban/HighSES 0.283 0.198 -0.17381 0.64
Urban/LowSES 0.173 0.177 -0.17580 0.55
depunfair - Stress: Respect
Rural/HighSES 0.388 0.145 0.15582 0.72
Urban/HighSES 0.253 0.157 -0.05980 0.55
Urban/LowSES 0.117 0.144 -0.15130 0.42
depunfair - Stress: Theft Vctm
Urban/HighSES 0.317 0.156 -0.00011 0.61
Urban/LowSES 0.310 0.136 0.05076 0.60
depunfair - Stress: Transport
Rural/HighSES 0.314 0.179 -0.10265 0.67
Rural/LowSES 0.130 0.080 -0.03927 0.28
Urban/HighSES 0.344 0.177 -0.04847 0.67
Urban/LowSES 0.249 0.169 -0.11300 0.60
depmistrt - Stress: Assault Vctm
Urban/HighSES 0.254 0.166 -0.06804 0.57
depmistrt - Stress: Fair Trtmt
Rural/HighSES 0.161 0.180 -0.10357 0.64
Urban/LowSES 0.159 0.124 -0.09339 0.40
depmistrt - Stress: Money
Urban/HighSES 0.262 0.230 -0.05523 0.84
depmistrt - Stress: Theft Vctm
Rural/HighSES 0.255 0.210 -0.07162 0.79
Urban/HighSES 0.153 0.155 -0.16415 0.45
depmistrt - Stress: Transport
Rural/LowSES 0.058 0.076 -0.09714 0.21
depbetray - Stress: Assault Vctm
Urban/HighSES 0.299 0.165 -0.03701 0.61
Urban/LowSES 0.213 0.179 -0.10479 0.63
depbetray - Stress: Fair Trtmt
Rural/HighSES 0.116 0.163 -0.11443 0.56
Urban/LowSES 0.112 0.130 -0.14435 0.37
depbetray - Stress: Job
Rural/HighSES 0.331 0.145 0.10439 0.68
depbetray - Stress: Money
Rural/HighSES 0.125 0.133 -0.11833 0.42
Urban/HighSES 0.154 0.182 -0.19427 0.56
depbetray - Stress: Theft Vctm
Rural/HighSES 0.261 0.215 -0.01388 0.86
Urban/LowSES 0.247 0.131 0.02634 0.55

9.2.1.3 All crim intent (chg)

PLMEprjchg_comm %>% 
  mutate(
    rural.ses.med = if_else(
      rural.ses.med == "1", "Rural/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "2", "Rural/HighSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "3", "Urban/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "4", "Urban/HighSES", rural.ses.med)
  ) %>%
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var, rural.ses.med) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (Chg) by Community PLME Estimates**"), 
    subtitle = md("Plotted in FIG4 (FIG5 in paper)")
  )
Criminal Intent (Chg) by Community PLME Estimates
Plotted in FIG4 (FIG5 in paper)
rural.ses.med m s ll ul
prjthflt5 - Stress: Assault Vctm
Rural/HighSES -0.00158094 0.0062 -0.0163 0.0011976
Rural/LowSES -0.00090159 0.0043 -0.0107 0.0061629
Urban/HighSES 0.03443182 0.0956 -0.0354 0.3385213
Urban/LowSES -0.00047146 0.0630 -0.0558 0.1197702
prjthflt5 - Stress: Fair Trtmt
Rural/HighSES -0.00163958 0.0072 -0.0177 0.0013682
Rural/LowSES -0.00047637 0.0043 -0.0094 0.0077465
Urban/HighSES 0.01669615 0.0860 -0.0621 0.2634245
Urban/LowSES 0.02050070 0.0565 -0.0113 0.1729251
prjthflt5 - Stress: Job
Rural/HighSES -0.00260125 0.0068 -0.0211 -0.0001487
Rural/LowSES -0.00107765 0.0036 -0.0100 0.0046447
Urban/HighSES 0.02572255 0.0897 -0.0554 0.2923601
Urban/LowSES 0.02113944 0.0645 -0.0089 0.2223953
prjthflt5 - Stress: Money
Rural/HighSES -0.00130638 0.0048 -0.0134 0.0002232
Rural/LowSES 0.00012116 0.0032 -0.0052 0.0074263
Urban/HighSES 0.08874325 0.1595 0.0037 0.6251763
Urban/LowSES 0.02827562 0.0934 -0.0045 0.3232879
prjthflt5 - Stress: Respect
Rural/HighSES -0.00275302 0.0071 -0.0220 0.0000521
Rural/LowSES -0.00279376 0.0054 -0.0178 0.0034116
Urban/HighSES 0.01346887 0.0666 -0.0674 0.1901647
Urban/LowSES -0.00816063 0.0241 -0.0699 0.0257236
prjthflt5 - Stress: Theft Vctm
Rural/HighSES -0.00317805 0.0104 -0.0326 0.0000317
Rural/LowSES -0.00211868 0.0055 -0.0174 0.0038382
Urban/HighSES 0.00528224 0.0565 -0.0858 0.1418435
Urban/LowSES 0.01102381 0.0885 -0.0303 0.2743924
prjthflt5 - Stress: Transport
Rural/HighSES -0.00169804 0.0059 -0.0192 0.0018803
Rural/LowSES -0.00076484 0.0041 -0.0095 0.0062063
Urban/HighSES 0.06862394 0.1758 -0.0189 0.6756410
Urban/LowSES 0.00557113 0.0683 -0.0413 0.1832424
prjthfgt5 - Stress: Assault Vctm
Rural/HighSES -0.00218675 0.0081 -0.0218 0.0010258
Rural/LowSES -0.00058844 0.0070 -0.0148 0.0135791
Urban/HighSES 0.05956849 0.1080 -0.0255 0.3838897
Urban/LowSES 0.00537067 0.0681 -0.0556 0.1827703
prjthfgt5 - Stress: Fair Trtmt
Rural/HighSES -0.00205920 0.0072 -0.0215 0.0013516
Rural/LowSES 0.00002924 0.0055 -0.0095 0.0118691
Urban/HighSES 0.06176543 0.1212 -0.0223 0.4646645
Urban/LowSES 0.01567591 0.0486 -0.0251 0.1479464
prjthfgt5 - Stress: Job
Rural/HighSES -0.00269774 0.0093 -0.0249 0.0013454
Rural/LowSES -0.00109126 0.0058 -0.0140 0.0099578
Urban/HighSES 0.02978770 0.0921 -0.0771 0.2885130
Urban/LowSES 0.03288692 0.0719 -0.0088 0.2599347
prjthfgt5 - Stress: Money
Rural/HighSES -0.00146022 0.0073 -0.0155 0.0012389
Rural/LowSES 0.00063480 0.0043 -0.0060 0.0121152
Urban/HighSES 0.11155557 0.1537 0.0088 0.6074268
Urban/LowSES 0.03578330 0.0877 -0.0050 0.2958762
prjthfgt5 - Stress: Respect
Rural/HighSES -0.00322876 0.0087 -0.0292 0.0004675
Rural/LowSES -0.00344126 0.0071 -0.0223 0.0055750
Urban/HighSES 0.01211397 0.0724 -0.0837 0.2046446
Urban/LowSES -0.01052425 0.0311 -0.0894 0.0363386
prjthfgt5 - Stress: Theft Vctm
Rural/HighSES -0.00578987 0.0161 -0.0510 -0.0001861
Rural/LowSES -0.00289224 0.0094 -0.0268 0.0110698
Urban/HighSES 0.02181668 0.0758 -0.0880 0.2108915
Urban/LowSES 0.01349434 0.0917 -0.0488 0.3023956
prjthfgt5 - Stress: Transport
Rural/HighSES -0.00260686 0.0094 -0.0295 0.0008443
Rural/LowSES -0.00072850 0.0064 -0.0144 0.0113500
Urban/HighSES 0.06536789 0.1272 -0.0231 0.4825420
Urban/LowSES -0.00008400 0.0643 -0.0627 0.1480932
prjthreat - Stress: Assault Vctm
Rural/HighSES -0.00089617 0.0061 -0.0124 0.0037547
Rural/LowSES -0.00084824 0.0033 -0.0085 0.0029524
Urban/HighSES -0.00573692 0.0255 -0.0657 0.0370181
Urban/LowSES -0.00147528 0.0266 -0.0248 0.0285686
prjthreat - Stress: Fair Trtmt
Rural/HighSES -0.00166048 0.0063 -0.0187 0.0010639
Rural/LowSES -0.00152362 0.0035 -0.0109 0.0011499
Urban/HighSES -0.00037942 0.0468 -0.0477 0.1125599
Urban/LowSES -0.00101389 0.0172 -0.0204 0.0238118
prjthreat - Stress: Job
Rural/HighSES -0.00091874 0.0115 -0.0122 0.0074216
Rural/LowSES -0.00055650 0.0031 -0.0079 0.0047030
Urban/HighSES 0.00762679 0.0449 -0.0410 0.1261608
Urban/LowSES 0.00093106 0.0153 -0.0154 0.0417247
prjthreat - Stress: Money
Rural/HighSES -0.00106683 0.0047 -0.0127 0.0014391
Rural/LowSES -0.00041019 0.0025 -0.0061 0.0035088
Urban/HighSES 0.00833897 0.0722 -0.0276 0.2143597
Urban/LowSES -0.00007177 0.0231 -0.0175 0.0381684
prjthreat - Stress: Respect
Rural/HighSES -0.00145201 0.0068 -0.0177 0.0031175
Rural/LowSES -0.00220404 0.0042 -0.0148 0.0005980
Urban/HighSES -0.00011453 0.0390 -0.0518 0.0903556
Urban/LowSES -0.00476666 0.0123 -0.0402 0.0059121
prjthreat - Stress: Theft Vctm
Rural/HighSES -0.00153573 0.0211 -0.0230 0.0090816
Rural/LowSES -0.00181583 0.0049 -0.0155 0.0026505
Urban/HighSES -0.00797705 0.0322 -0.0859 0.0423985
Urban/LowSES -0.00286577 0.0190 -0.0356 0.0210013
prjthreat - Stress: Transport
Rural/HighSES -0.00133909 0.0059 -0.0165 0.0008593
Rural/LowSES -0.00086240 0.0026 -0.0081 0.0024544
Urban/HighSES -0.00309687 0.0376 -0.0566 0.0708090
Urban/LowSES -0.00152914 0.0272 -0.0219 0.0237147
prjharm - Stress: Assault Vctm
Rural/HighSES 0.00029257 0.0287 -0.0094 0.0592233
Rural/LowSES -0.00045576 0.0040 -0.0087 0.0073557
Urban/HighSES -0.00037847 0.0221 -0.0325 0.0479820
Urban/LowSES -0.00277390 0.0185 -0.0315 0.0151167
prjharm - Stress: Fair Trtmt
Rural/HighSES -0.00161606 0.0103 -0.0191 0.0071763
Rural/LowSES -0.00143353 0.0038 -0.0117 0.0023154
Urban/HighSES -0.00750310 0.0233 -0.0592 0.0194579
Urban/LowSES -0.00033785 0.0203 -0.0158 0.0303686
prjharm - Stress: Job
Rural/HighSES -0.00127812 0.0077 -0.0164 0.0086614
Rural/LowSES -0.00011182 0.0038 -0.0076 0.0077997
Urban/HighSES -0.00295323 0.0254 -0.0419 0.0409323
Urban/LowSES -0.00165096 0.0106 -0.0211 0.0141202
prjharm - Stress: Money
Rural/HighSES -0.00122517 0.0081 -0.0161 0.0082017
Rural/LowSES -0.00047077 0.0032 -0.0074 0.0051510
Urban/HighSES 0.00292301 0.0545 -0.0249 0.1131868
Urban/LowSES -0.00082693 0.0217 -0.0218 0.0296146
prjharm - Stress: Respect
Rural/HighSES -0.00162800 0.0080 -0.0188 0.0050562
Rural/LowSES -0.00134174 0.0039 -0.0122 0.0030485
Urban/HighSES -0.00868173 0.0196 -0.0631 0.0064259
Urban/LowSES -0.00044546 0.0109 -0.0177 0.0223627
prjharm - Stress: Theft Vctm
Rural/HighSES -0.00346533 0.0145 -0.0402 0.0023111
Rural/LowSES -0.00262738 0.0060 -0.0216 0.0009913
Urban/HighSES -0.00706313 0.0223 -0.0624 0.0192608
Urban/LowSES -0.00332707 0.0130 -0.0336 0.0119253
prjharm - Stress: Transport
Rural/HighSES -0.00387007 0.0120 -0.0387 0.0000054
Rural/LowSES -0.00197644 0.0043 -0.0145 0.0018270
Urban/HighSES -0.01149533 0.0238 -0.0757 0.0090732
Urban/LowSES -0.00055698 0.0263 -0.0196 0.0437102
prjusedrg - Stress: Assault Vctm
Rural/HighSES -0.00082361 0.0134 -0.0147 0.0109883
Rural/LowSES -0.00045749 0.0055 -0.0116 0.0080974
Urban/HighSES 0.02448915 0.0688 -0.0211 0.2404848
Urban/LowSES -0.00154845 0.0162 -0.0193 0.0074088
prjusedrg - Stress: Fair Trtmt
Rural/HighSES -0.00282678 0.0122 -0.0266 0.0011003
Rural/LowSES -0.00176450 0.0040 -0.0136 0.0016870
Urban/HighSES 0.00924337 0.0648 -0.0375 0.1744457
Urban/LowSES -0.00195983 0.0077 -0.0206 0.0037780
prjusedrg - Stress: Job
Rural/HighSES -0.00094474 0.0120 -0.0169 0.0150446
Rural/LowSES -0.00028824 0.0044 -0.0089 0.0092898
Urban/HighSES 0.00382895 0.0520 -0.0596 0.1346532
Urban/LowSES -0.00174610 0.0075 -0.0195 0.0054332
prjusedrg - Stress: Money
Rural/HighSES -0.00091823 0.0175 -0.0177 0.0114634
Rural/LowSES -0.00092759 0.0037 -0.0097 0.0036332
Urban/HighSES 0.00374948 0.0726 -0.0529 0.1803764
Urban/LowSES -0.00165640 0.0089 -0.0184 0.0055722
prjusedrg - Stress: Respect
Rural/HighSES -0.00236949 0.0085 -0.0231 0.0041981
Rural/LowSES -0.00287318 0.0053 -0.0171 0.0005417
Urban/HighSES -0.00465803 0.0340 -0.0718 0.0620390
Urban/LowSES -0.00305129 0.0080 -0.0251 0.0015024
prjusedrg - Stress: Theft Vctm
Rural/HighSES -0.00092294 0.0265 -0.0151 0.0121010
Rural/LowSES -0.00075291 0.0034 -0.0093 0.0048510
Urban/HighSES 0.00087451 0.0316 -0.0516 0.0718913
Urban/LowSES -0.00163587 0.0061 -0.0175 0.0041290
prjusedrg - Stress: Transport
Rural/HighSES -0.00192269 0.0095 -0.0203 0.0034057
Rural/LowSES -0.00128741 0.0038 -0.0106 0.0036551
Urban/HighSES -0.00908540 0.0397 -0.0826 0.0538457
Urban/LowSES -0.00261160 0.0081 -0.0252 0.0014759
prjhack - Stress: Assault Vctm
Rural/HighSES -0.00520953 0.0246 -0.0578 0.0376390
Rural/LowSES 0.00000095 0.0192 -0.0335 0.0438488
Urban/HighSES -0.01130634 0.0654 -0.1451 0.1290772
Urban/LowSES 0.00366818 0.0726 -0.0692 0.1860251
prjhack - Stress: Fair Trtmt
Rural/HighSES -0.00805015 0.0306 -0.0775 0.0305239
Rural/LowSES -0.00890961 0.0165 -0.0504 0.0146669
Urban/HighSES -0.03254606 0.0630 -0.1665 0.0778911
Urban/LowSES -0.01579531 0.0383 -0.1002 0.0449155
prjhack - Stress: Job
Rural/HighSES -0.00534077 0.0242 -0.0555 0.0403825
Rural/LowSES 0.00327542 0.0170 -0.0261 0.0437748
Urban/HighSES -0.01127410 0.0530 -0.1041 0.1105256
Urban/LowSES -0.00948798 0.0283 -0.0690 0.0419329
prjhack - Stress: Money
Rural/HighSES -0.00399020 0.0268 -0.0512 0.0400320
Rural/LowSES 0.00183507 0.0153 -0.0246 0.0402821
Urban/HighSES 0.02836875 0.0899 -0.0735 0.2814083
Urban/LowSES -0.00462542 0.0516 -0.0771 0.1063139
prjhack - Stress: Respect
Rural/HighSES -0.00846566 0.0251 -0.0728 0.0238427
Rural/LowSES -0.00976495 0.0171 -0.0569 0.0137854
Urban/HighSES -0.02290337 0.0512 -0.1493 0.0655700
Urban/LowSES -0.02701212 0.0413 -0.1430 0.0142090
prjhack - Stress: Theft Vctm
Rural/HighSES -0.01201587 0.0384 -0.1014 0.0130728
Rural/LowSES -0.00835322 0.0182 -0.0527 0.0183392
Urban/HighSES -0.02395402 0.0662 -0.1622 0.1141607
Urban/LowSES -0.00230733 0.0432 -0.0769 0.1012141
prjhack - Stress: Transport
Rural/HighSES -0.01182366 0.0275 -0.0892 0.0099562
Rural/LowSES -0.00881672 0.0173 -0.0531 0.0166542
Urban/HighSES -0.05009037 0.0671 -0.2308 0.0383661
Urban/LowSES -0.00966014 0.0586 -0.1067 0.0942147
prjany - Stress: Assault Vctm
Rural/HighSES 0.00187526 0.0358 -0.0237 0.0870979
Rural/LowSES -0.00147053 0.0190 -0.0355 0.0436702
Urban/HighSES 0.18166602 0.1979 -0.1462 0.6529999
Urban/LowSES -0.03652088 0.0974 -0.2025 0.1739317
prjany - Stress: Fair Trtmt
Rural/HighSES -0.00935075 0.0219 -0.0699 0.0101260
Rural/LowSES -0.00346379 0.0146 -0.0360 0.0237269
Urban/HighSES 0.20902936 0.1893 -0.0619 0.6838385
Urban/LowSES 0.04205541 0.0863 -0.0577 0.2840469
prjany - Stress: Job
Rural/HighSES -0.00835722 0.0197 -0.0584 0.0124868
Rural/LowSES 0.00159856 0.0163 -0.0253 0.0416329
Urban/HighSES 0.09981052 0.2022 -0.2459 0.5728979
Urban/LowSES 0.08056247 0.0978 -0.0239 0.3609980
prjany - Stress: Money
Rural/HighSES -0.00408195 0.0178 -0.0399 0.0217676
Rural/LowSES 0.00728413 0.0171 -0.0125 0.0548368
Urban/HighSES 0.32012319 0.2186 -0.0292 0.8247629
Urban/LowSES 0.10544514 0.1400 -0.0211 0.5572340
prjany - Stress: Respect
Rural/HighSES -0.01109630 0.0215 -0.0731 0.0098086
Rural/LowSES -0.01401251 0.0173 -0.0601 0.0092845
Urban/HighSES 0.06799576 0.1602 -0.2328 0.4343151
Urban/LowSES -0.03191680 0.0634 -0.1808 0.0738670
prjany - Stress: Theft Vctm
Rural/HighSES -0.01545267 0.0352 -0.1096 0.0121142
Rural/LowSES -0.01502300 0.0207 -0.0699 0.0109002
Urban/HighSES 0.06093828 0.1698 -0.2546 0.4310546
Urban/LowSES 0.03213155 0.1270 -0.0990 0.4271599
prjany - Stress: Transport
Rural/HighSES -0.01378224 0.0284 -0.1001 0.0044937
Rural/LowSES -0.00153706 0.0158 -0.0321 0.0328138
Urban/HighSES 0.29678607 0.2322 -0.0586 0.8380301
Urban/LowSES 0.04425633 0.1262 -0.0865 0.4084651

9.2.1.4 All neg emotions (chg)

PLMEdepchg_comm %>% 
  mutate(
    rural.ses.med = if_else(
      rural.ses.med == "1", "Rural/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "2", "Rural/HighSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "3", "Urban/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "4", "Urban/HighSES", rural.ses.med)
  ) %>%
 # summarize PLME estimates across the MCMC draws
  group_by(.category, stress_var, rural.ses.med) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .025),
            ul = quantile(PLME, probs = .975)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (Chg) by Community PLME Estimates**"), 
    subtitle = md("Plotted in FIG4 (FIG5 in paper)")
  )
Negative Emotions (Chg) by Community PLME Estimates
Plotted in FIG4 (FIG5 in paper)
rural.ses.med m s ll ul
depcantgo - Stress: Assault Vctm
Rural/HighSES 0.15517 0.263 -0.49454 0.469
Rural/LowSES 0.08133 0.155 -0.23944 0.366
Urban/HighSES 0.09498 0.196 -0.29126 0.479
Urban/LowSES 0.13862 0.232 -0.27470 0.644
depcantgo - Stress: Fair Trtmt
Rural/HighSES 0.51254 0.183 0.15217 0.852
Rural/LowSES 0.14664 0.134 -0.10261 0.426
Urban/HighSES -0.02861 0.207 -0.43173 0.389
Urban/LowSES 0.09596 0.178 -0.24120 0.459
depcantgo - Stress: Job
Rural/HighSES 0.40649 0.177 0.03778 0.725
Rural/LowSES 0.22088 0.120 -0.03806 0.437
Urban/HighSES 0.26876 0.228 -0.27323 0.629
Urban/LowSES -0.10559 0.143 -0.37845 0.169
depcantgo - Stress: Money
Rural/HighSES 0.20286 0.217 -0.17191 0.699
Rural/LowSES 0.21879 0.118 -0.00383 0.460
Urban/HighSES 0.30094 0.218 -0.14792 0.740
Urban/LowSES 0.08431 0.195 -0.31618 0.460
depcantgo - Stress: Respect
Rural/HighSES 0.15166 0.182 -0.26863 0.456
Rural/LowSES 0.09172 0.127 -0.16588 0.340
Urban/HighSES -0.04478 0.180 -0.39454 0.319
Urban/LowSES 0.10659 0.162 -0.18675 0.455
depcantgo - Stress: Theft Vctm
Rural/HighSES 0.48063 0.185 0.09190 0.810
Rural/LowSES 0.11646 0.135 -0.16929 0.379
Urban/HighSES 0.12808 0.186 -0.22976 0.503
Urban/LowSES -0.02671 0.196 -0.47259 0.294
depcantgo - Stress: Transport
Rural/HighSES 0.48085 0.182 0.10531 0.815
Rural/LowSES 0.17558 0.109 -0.03484 0.383
Urban/HighSES 0.27680 0.181 -0.09016 0.650
Urban/LowSES -0.09814 0.190 -0.48148 0.246
depeffort - Stress: Assault Vctm
Rural/HighSES -0.09778 0.113 -0.33529 0.115
Rural/LowSES 0.03079 0.080 -0.12530 0.195
Urban/HighSES 0.07766 0.167 -0.24811 0.405
Urban/LowSES 0.13220 0.171 -0.18348 0.528
depeffort - Stress: Fair Trtmt
Rural/HighSES 0.12819 0.163 -0.08649 0.595
Rural/LowSES 0.05641 0.074 -0.08056 0.216
Urban/HighSES 0.05234 0.157 -0.26316 0.367
Urban/LowSES 0.24247 0.165 -0.01066 0.658
depeffort - Stress: Job
Rural/HighSES 0.07827 0.140 -0.13428 0.453
Rural/LowSES 0.03149 0.065 -0.09304 0.168
Urban/HighSES 0.18129 0.207 -0.13394 0.684
Urban/LowSES 0.06917 0.130 -0.19891 0.313
depeffort - Stress: Money
Rural/HighSES 0.00593 0.123 -0.22862 0.253
Rural/LowSES 0.04208 0.069 -0.09090 0.185
Urban/HighSES 0.18001 0.166 -0.14306 0.551
Urban/LowSES 0.07315 0.171 -0.19019 0.515
depeffort - Stress: Respect
Rural/HighSES 0.11890 0.126 -0.07022 0.447
Rural/LowSES 0.02989 0.067 -0.09365 0.177
Urban/HighSES -0.00812 0.130 -0.25650 0.254
Urban/LowSES 0.13392 0.139 -0.07376 0.484
depeffort - Stress: Theft Vctm
Rural/HighSES -0.06563 0.146 -0.33657 0.239
Rural/LowSES 0.00452 0.070 -0.12154 0.159
Urban/HighSES 0.13347 0.169 -0.14109 0.526
Urban/LowSES 0.11744 0.127 -0.14066 0.366
depeffort - Stress: Transport
Rural/HighSES 0.07507 0.152 -0.22164 0.409
Rural/LowSES 0.01702 0.071 -0.12072 0.164
Urban/HighSES 0.01373 0.188 -0.26800 0.529
Urban/LowSES -0.02394 0.150 -0.30059 0.292
deplonely - Stress: Assault Vctm
Rural/HighSES 0.26053 0.180 -0.05242 0.651
Rural/LowSES -0.01032 0.149 -0.31145 0.274
Urban/HighSES 0.30648 0.192 -0.08557 0.671
Urban/LowSES 0.18661 0.203 -0.25643 0.565
deplonely - Stress: Fair Trtmt
Rural/HighSES 0.16214 0.160 -0.16396 0.492
Rural/LowSES 0.06778 0.114 -0.14359 0.315
Urban/HighSES 0.08941 0.210 -0.31655 0.526
Urban/LowSES 0.02553 0.156 -0.24257 0.390
deplonely - Stress: Job
Rural/HighSES -0.04690 0.146 -0.32667 0.243
Rural/LowSES 0.14053 0.107 -0.06212 0.362
Urban/HighSES 0.13160 0.201 -0.27298 0.522
Urban/LowSES -0.04919 0.132 -0.31177 0.208
deplonely - Stress: Money
Rural/HighSES -0.00415 0.158 -0.31626 0.301
Rural/LowSES 0.09524 0.113 -0.16293 0.282
Urban/HighSES 0.42793 0.205 0.05703 0.845
Urban/LowSES -0.07479 0.173 -0.43808 0.240
deplonely - Stress: Respect
Rural/HighSES 0.08452 0.143 -0.18912 0.386
Rural/LowSES 0.01172 0.110 -0.20657 0.234
Urban/HighSES 0.11065 0.168 -0.22336 0.433
Urban/LowSES 0.08285 0.131 -0.17403 0.355
deplonely - Stress: Theft Vctm
Rural/HighSES 0.29179 0.217 -0.07986 0.824
Rural/LowSES 0.20108 0.120 -0.04916 0.433
Urban/HighSES 0.24941 0.196 -0.13226 0.656
Urban/LowSES -0.05123 0.182 -0.43265 0.270
deplonely - Stress: Transport
Rural/HighSES -0.05367 0.187 -0.45358 0.293
Rural/LowSES 0.06195 0.120 -0.19405 0.281
Urban/HighSES 0.32421 0.177 -0.04336 0.652
Urban/LowSES 0.02409 0.202 -0.30674 0.586
depblues - Stress: Assault Vctm
Rural/HighSES -0.15539 0.097 -0.34635 0.038
Rural/LowSES -0.01673 0.061 -0.13407 0.105
Urban/HighSES 0.00324 0.145 -0.28598 0.304
Urban/LowSES 0.01729 0.144 -0.22807 0.358
depblues - Stress: Fair Trtmt
Rural/HighSES -0.00702 0.123 -0.23369 0.254
Rural/LowSES -0.00514 0.057 -0.12436 0.102
Urban/HighSES 0.00509 0.146 -0.28738 0.303
Urban/LowSES 0.05317 0.102 -0.13393 0.280
depblues - Stress: Job
Rural/HighSES -0.00176 0.116 -0.22486 0.239
Rural/LowSES -0.04300 0.054 -0.15862 0.061
Urban/HighSES 0.01646 0.235 -0.29602 0.637
Urban/LowSES -0.02966 0.102 -0.22650 0.179
depblues - Stress: Money
Rural/HighSES -0.03989 0.161 -0.33111 0.337
Rural/LowSES -0.05444 0.062 -0.19728 0.050
Urban/HighSES -0.14868 0.158 -0.48413 0.158
Urban/LowSES 0.02934 0.132 -0.19808 0.350
depblues - Stress: Respect
Rural/HighSES -0.04802 0.122 -0.29800 0.197
Rural/LowSES -0.03253 0.057 -0.15323 0.076
Urban/HighSES 0.06375 0.141 -0.17069 0.399
Urban/LowSES -0.05085 0.097 -0.24542 0.141
depblues - Stress: Theft Vctm
Rural/HighSES 0.01317 0.160 -0.20905 0.421
Rural/LowSES 0.02284 0.056 -0.07962 0.150
Urban/HighSES 0.39201 0.199 0.07894 0.811
Urban/LowSES 0.03271 0.107 -0.16353 0.264
depblues - Stress: Transport
Rural/HighSES -0.09120 0.127 -0.34673 0.173
Rural/LowSES -0.02656 0.055 -0.13313 0.089
Urban/HighSES -0.04098 0.146 -0.26945 0.337
Urban/LowSES -0.05955 0.120 -0.27717 0.209
depunfair - Stress: Assault Vctm
Rural/HighSES -0.05113 0.155 -0.34942 0.258
Rural/LowSES -0.03228 0.092 -0.21292 0.146
Urban/HighSES 0.16922 0.186 -0.20791 0.515
Urban/LowSES 0.13916 0.250 -0.24452 0.746
depunfair - Stress: Fair Trtmt
Rural/HighSES 0.31600 0.172 0.00768 0.709
Rural/LowSES 0.11566 0.086 -0.03856 0.310
Urban/HighSES 0.30829 0.192 -0.09554 0.675
Urban/LowSES 0.15705 0.158 -0.12547 0.503
depunfair - Stress: Job
Rural/HighSES 0.30288 0.149 0.03667 0.631
Rural/LowSES 0.04858 0.087 -0.11276 0.225
Urban/HighSES 0.53203 0.155 0.18758 0.793
Urban/LowSES 0.00893 0.142 -0.26217 0.312
depunfair - Stress: Money
Rural/HighSES 0.28413 0.166 -0.02701 0.658
Rural/LowSES 0.14043 0.082 -0.00579 0.315
Urban/HighSES 0.28264 0.198 -0.17381 0.641
Urban/LowSES 0.17310 0.177 -0.17580 0.547
depunfair - Stress: Respect
Rural/HighSES 0.38780 0.145 0.15582 0.722
Rural/LowSES 0.05441 0.084 -0.12213 0.216
Urban/HighSES 0.25279 0.157 -0.05980 0.554
Urban/LowSES 0.11687 0.144 -0.15130 0.418
depunfair - Stress: Theft Vctm
Rural/HighSES 0.07794 0.214 -0.28526 0.615
Rural/LowSES -0.00423 0.092 -0.18235 0.182
Urban/HighSES 0.31708 0.156 -0.00011 0.605
Urban/LowSES 0.30982 0.136 0.05076 0.601
depunfair - Stress: Transport
Rural/HighSES 0.31401 0.179 -0.10265 0.668
Rural/LowSES 0.12964 0.080 -0.03927 0.285
Urban/HighSES 0.34396 0.177 -0.04847 0.674
Urban/LowSES 0.24949 0.169 -0.11300 0.603
depmistrt - Stress: Assault Vctm
Rural/HighSES -0.04336 0.167 -0.37194 0.298
Rural/LowSES -0.03986 0.094 -0.23885 0.132
Urban/HighSES 0.25391 0.166 -0.06804 0.568
Urban/LowSES -0.18619 0.169 -0.52511 0.143
depmistrt - Stress: Fair Trtmt
Rural/HighSES 0.16097 0.180 -0.10357 0.642
Rural/LowSES 0.00682 0.062 -0.12324 0.126
Urban/HighSES 0.04449 0.147 -0.23503 0.343
Urban/LowSES 0.15910 0.124 -0.09339 0.403
depmistrt - Stress: Job
Rural/HighSES 0.08660 0.147 -0.22960 0.364
Rural/LowSES 0.01066 0.076 -0.17374 0.139
Urban/HighSES 0.06661 0.177 -0.28131 0.443
Urban/LowSES -0.12286 0.140 -0.41723 0.132
depmistrt - Stress: Money
Rural/HighSES 0.09002 0.149 -0.21266 0.401
Rural/LowSES 0.03029 0.066 -0.08714 0.173
Urban/HighSES 0.26234 0.230 -0.05523 0.844
Urban/LowSES 0.02938 0.148 -0.25081 0.317
depmistrt - Stress: Respect
Rural/HighSES 0.16591 0.260 -0.15934 0.775
Rural/LowSES -0.02565 0.071 -0.17473 0.113
Urban/HighSES 0.09587 0.129 -0.15674 0.357
Urban/LowSES 0.05974 0.123 -0.16633 0.331
depmistrt - Stress: Theft Vctm
Rural/HighSES 0.25477 0.210 -0.07162 0.789
Rural/LowSES 0.03792 0.084 -0.13402 0.201
Urban/HighSES 0.15291 0.155 -0.16415 0.453
Urban/LowSES -0.07593 0.134 -0.34069 0.188
depmistrt - Stress: Transport
Rural/HighSES -0.02369 0.164 -0.37433 0.282
Rural/LowSES 0.05807 0.076 -0.09714 0.207
Urban/HighSES 0.07312 0.164 -0.30021 0.360
Urban/LowSES -0.04784 0.150 -0.37236 0.227
depbetray - Stress: Assault Vctm
Rural/HighSES 0.01982 0.153 -0.29884 0.328
Rural/LowSES -0.00783 0.078 -0.17837 0.135
Urban/HighSES 0.29867 0.165 -0.03701 0.611
Urban/LowSES 0.21316 0.179 -0.10479 0.625
depbetray - Stress: Fair Trtmt
Rural/HighSES 0.11612 0.163 -0.11443 0.562
Rural/LowSES 0.03138 0.057 -0.06563 0.156
Urban/HighSES 0.12412 0.181 -0.16638 0.569
Urban/LowSES 0.11192 0.130 -0.14435 0.375
depbetray - Stress: Job
Rural/HighSES 0.33146 0.145 0.10439 0.680
Rural/LowSES 0.03964 0.056 -0.06588 0.160
Urban/HighSES 0.03791 0.170 -0.27381 0.405
Urban/LowSES 0.03182 0.112 -0.18242 0.266
depbetray - Stress: Money
Rural/HighSES 0.12480 0.133 -0.11833 0.424
Rural/LowSES 0.01972 0.058 -0.09189 0.139
Urban/HighSES 0.15430 0.182 -0.19427 0.555
Urban/LowSES -0.14405 0.116 -0.36802 0.092
depbetray - Stress: Respect
Rural/HighSES 0.05355 0.117 -0.17730 0.282
Rural/LowSES 0.02559 0.057 -0.07907 0.152
Urban/HighSES 0.11071 0.145 -0.15930 0.416
Urban/LowSES -0.00397 0.120 -0.24591 0.236
depbetray - Stress: Theft Vctm
Rural/HighSES 0.26148 0.215 -0.01388 0.857
Rural/LowSES -0.00019 0.068 -0.14757 0.126
Urban/HighSES 0.11702 0.151 -0.19178 0.403
Urban/LowSES 0.24744 0.131 0.02634 0.551
depbetray - Stress: Transport
Rural/HighSES -0.09004 0.146 -0.39010 0.190
Rural/LowSES 0.01561 0.060 -0.10064 0.141
Urban/HighSES -0.00915 0.156 -0.28970 0.326
Urban/LowSES -0.01476 0.148 -0.27422 0.328

9.2.2 Median unweighted (meta-analytic avg) estimates from Fig 4

Similar to before, we can also summarize the median unweighted community-specific PLME estimates and 80% posterior interval ranges for these model estimates, this time grouped by community.

9.2.2.1 Crim intent (chg)

PLMEprjchg_comm %>% 
  ungroup() %>%
  mutate(
    rural.ses.med = if_else(
      rural.ses.med == "1", "Rural/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "2", "Rural/HighSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "3", "Urban/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "4", "Urban/HighSES", rural.ses.med)
  ) %>% 
  group_by(rural.ses.med) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .10),
            ul = quantile(PLME, probs = .90)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Criminal Intent (Chg) Median Unadj. PLME Estimate by Comm.**")
  )
Criminal Intent (Chg) Median Unadj. PLME Estimate by Comm.
rural.ses.med m s ll ul
Rural/HighSES -0.00244 0.019 -0.018 0.00081
Rural/LowSES -0.00125 0.011 -0.012 0.00453
Urban/HighSES 0.00625 0.133 -0.040 0.19256
Urban/LowSES -0.00062 0.068 -0.025 0.06248

9.2.2.2 Neg emotions (chg)

PLMEdepchg_comm %>% 
  ungroup() %>%
  mutate(
    rural.ses.med = if_else(
      rural.ses.med == "1", "Rural/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "2", "Rural/HighSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "3", "Urban/LowSES", rural.ses.med), 
    rural.ses.med = if_else(
      rural.ses.med == "4", "Urban/HighSES", rural.ses.med)
  ) %>% 
  group_by(rural.ses.med) %>%
  summarise(m = median(PLME),
            s = sd(PLME),
            ll = quantile(PLME, probs = .10),
            ul = quantile(PLME, probs = .90)) %>% 
  gt() %>% 
  tab_header(
    title = md("**Negative Emotions (Chg) Median Unadj. PLME Estimate by Comm.**")
  )
Negative Emotions (Chg) Median Unadj. PLME Estimate by Comm.
rural.ses.med m s ll ul
Rural/HighSES 0.102 0.24 -0.147 0.46
Rural/LowSES 0.034 0.11 -0.077 0.20
Urban/HighSES 0.144 0.23 -0.117 0.46
Urban/LowSES 0.046 0.19 -0.177 0.30

10 Appendix 1: Composite stress scales

(RMD FILE: BDK_2023_Stress_9_Append1_stress_scales)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

10.1 IRT/SUM STRESS SCALE VERSIONS

Below, we present measurement models for general stress scale with all seven stress items. We create composite stress scales (latent IRT theta scale; sum scale), run models, and plot contrasts. We anticipate a graded response IRT model will be unlikely to fit well and that a sum scale will better capture predictive information contained in stress items due to multidimensionality from different stress sources (e.g., financial; interpersonal) and potentially generate more replicable results (e.g., see here and here). Nonetheless, we will estimate models and plot marginal effects contrasts using IRT and sum scales to assess robustness and present results from both in the Appendix. Later, we will use the stress sum scale in mediation models to estimate direct and indirect effects of stress on criminal intent through criminogenic negative emotions.

load(here("1_Data_Files/Datasets/stress_long.Rdata"))
# https://hanhao23.github.io/project/irttutorial/irt-tutorial-in-r-with-mirt-package/
# https://philippmasur.de/2022/05/13/how-to-run-irt-analyses-in-r/
# https://bookdown.org/bean_jerry/using_r_for_social_work_research/item-response-theory.html
# https://journals.sagepub.com/doi/10.1177/09622802211043263
# https://stackoverflow.com/questions/63646722/mirt-package-r-how-to-create-a-independent-model-with-multigroup-function
# https://groups.google.com/g/mirt-package/c/TLv1JFq2tCg

# Estimate graded response IRT model with mirt & save theta scores for stress, 
# crim intent, dep symp, & crim emots

# https://rdrr.io/cran/mirt/man/multipleGroup.html
# https://rstudio-pubs-static.s3.amazonaws.com/357155_6674780326ef4afba5f009d17a85d4ae.html



# follow steps here:
# https://bookdown.org/bean_jerry/using_r_for_social_work_research/item-response-theory.html
# mod1 <- (mirt(scale, 1, verbose = FALSE, itemtype = 'graded', SE = TRUE))

#stress - year 1
irtstressy1 <- stress.long %>% 
  filter(year==1) %>%
  dplyr::select(id, stmony, sttran, stresp, stfair, stjob, stthft, stmug) 

#graded response IRT model
stscaley1 <- mirt(irtstressy1[-1], 1, verbose = FALSE, itemtype = 'graded')

#save IRT theta (factor) scores
irtstscorey1 <- fscores(stscaley1) 

#merge with T1 data    
irtstressy1 <- bind_cols(irtstressy1, irtstscorey1) %>% 
  rename("irtstress" = "F1") %>% 
  mutate(year="1") %>% 
  dplyr::select(c(id, year, irtstress))

10.1.1 Stress (chg)

10.1.1.1 Model fit

# https://bookdown.org/bean_jerry/using_r_for_social_work_research/item-response-theory.html

# "...we used the R mirt package to fit a graded response model (the recommended model for ordered polytomous response data) using a full-information maximum likelihood fitting function. In addition, we assessed model fit using an index, M2, which is specifically designed to assess the fit of item response models for ordinal data. We used the M2-based root mean square error of approximation as the primary fit index. We also used the standardized root mean square residual (SRMSR) and comparative fit index (CFI) to assess adequacy of model fit."

M2(stscaley1, type = "C2", calcNULL = FALSE) %>% gt()
M2 df p RMSEA RMSEA_5 RMSEA_95 SRMSR TLI CFI
414 14 0 0.24 0.22 0.26 0.19 0.5 0.67

10.1.1.2 Factor loadings

summary(stscaley1)
##            F1      h2
## stmony 0.1086 0.01178
## sttran 0.0548 0.00301
## stresp 0.9485 0.89957
## stfair 0.9852 0.97067
## stjob  0.4488 0.20142
## stthft 0.3232 0.10448
## stmug  0.4327 0.18720
## 
## SS loadings:  2.4 
## Proportion Var:  0.34 
## 
## Factor correlations: 
## 
##    F1
## F1  1

10.1.1.3 Item fit

itemfit(stscaley1) 
##     item S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1 stmony  136      64      0.048  0.000
## 2 sttran  132      63      0.047  0.000
## 3 stresp  339      33      0.138  0.000
## 4 stfair  314      32      0.134  0.000
## 5  stjob   96      57      0.038  0.001
## 6 stthft   85      56      0.033  0.007
## 7  stmug   78      45      0.039  0.002

10.1.1.4 Category characteristic curves

  plot(stscaley1, type='trace', which.item = c(1,2,3,4,5,6,7), facet_items=T, 
     as.table = TRUE, auto.key=list(points=F, lines=T, columns=4, space = 'top', cex = .8), 
              theta_lim = c(-3, 3), 
     main = "")

10.1.1.5 Item information curves

  plot(stscaley1, type='infotrace', which.item = c(1,2,3,4,5,6,7), facet_items=T, 
     as.table = TRUE, auto.key=list(points=F, lines=T, columns=1, space = 'right', cex = .8), 
              theta_lim = c(-3, 3), 
     main="")  #interpersonal items driving latent trait - virtually no info from other vars

10.1.1.6 Scale information & conditional SEs

  plot(stscaley1, type = 'infoSE', theta_lim = c(-3, 3), 
     main="") 

10.1.1.7 Conditional reliability

  plot(stscaley1, type = 'rxx', theta_lim = c(-3, 3), 
     main="" )  

10.1.1.8 Marginal reliability

marginal_rxx(stscaley1) #marginal reliability = .85
## [1] 0.85

10.1.1.9 Scale characteristic curve

plot(stscaley1, type = 'score', theta_lim = c(-3, 3), main = "") 

#maps latent theta scores to original scale score metric  

10.1.2 Stress (T2)

#stress - year 2
irtstressy2 <- stress.long %>% 
  filter(year==2) %>%
  dplyr::select(id, stmony, sttran, stresp, stfair, stjob, stthft, stmug) 

#graded response IRT model
stscaley2 <- mirt(irtstressy2[-1], 1, verbose = FALSE, itemtype = 'graded')

#save IRT theta (factor) scores
irtstscorey2 <- fscores(stscaley2)

#merge IRT theta scores with T2 data
irtstressy2 <- bind_cols(irtstressy2, irtstscorey2) %>%
  rename("irtstress" = "F1") %>%
  mutate(year="2") %>% 
  dplyr::select(c(id, year, irtstress))

#merge T1 & T2 data with IRT scales
tmpdat <- bind_rows(irtstressy1, irtstressy2) 
stress.long <- left_join(stress.long, tmpdat, by=c("id", "year"))
rm(tmpdat)

10.1.2.1 Model fit

# https://bookdown.org/bean_jerry/using_r_for_social_work_research/item-response-theory.html

# "...we used the R mirt package to fit a graded response model (the recommended model for ordered polytomous response data) using a full-information maximum likelihood fitting function. In addition, we assessed model fit using an index, M2, which is specifically designed to assess the fit of item response models for ordinal data. We used the M2-based root mean square error of approximation as the primary fit index. We also used the standardized root mean square residual (SRMSR) and comparative fit index (CFI) to assess adequacy of model fit."

M2(stscaley2, type = "C2", calcNULL = FALSE) %>% gt()
M2 df p RMSEA RMSEA_5 RMSEA_95 SRMSR TLI CFI
257 14 0 0.19 0.17 0.21 0.15 0.58 0.72

10.1.2.2 Factor loadings

summary(stscaley2)
##            F1      h2
## stmony 0.1612 0.02599
## sttran 0.0808 0.00653
## stresp 0.9254 0.85641
## stfair 0.9540 0.91004
## stjob  0.4760 0.22661
## stthft 0.1936 0.03747
## stmug  0.3088 0.09537
## 
## SS loadings:  2.2 
## Proportion Var:  0.31 
## 
## Factor correlations: 
## 
##    F1
## F1  1

10.1.2.3 Item fit

itemfit(stscaley2) 
##     item S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1 stmony  114      61      0.042  0.000
## 2 sttran   79      56      0.029  0.022
## 3 stresp  155      34      0.085  0.000
## 4 stfair  130      34      0.076  0.000
## 5  stjob   68      52      0.025  0.067
## 6 stthft   60      56      0.012  0.328
## 7  stmug   57      49      0.018  0.204

10.1.2.4 Category characteristic curves

  plot(stscaley2, type='trace', which.item = c(1,2,3,4,5,6,7), facet_items=T, 
     as.table = TRUE, auto.key=list(points=F, lines=T, columns=4, space = 'top', cex = .8), 
              theta_lim = c(-3, 3), 
     main = "")

10.1.2.5 Item information curves

  plot(stscaley2, type='infotrace', which.item = c(1,2,3,4,5,6,7), facet_items=T, 
     as.table = TRUE, auto.key=list(points=F, lines=T, columns=1, space = 'right', cex = .8), 
              theta_lim = c(-3, 3), 
     main="")  #interpersonal items driving latent trait - virtually no info from other vars

10.1.2.6 Scale information & conditional SEs

  plot(stscaley2, type = 'infoSE', theta_lim = c(-3, 3), 
     main="") 

10.1.2.7 Conditional reliability

  plot(stscaley2, type = 'rxx', theta_lim = c(-3, 3), 
     main="" )  

10.1.2.8 Marginal reliability

marginal_rxx(stscaley2) #marginal reliability = .85
## [1] 0.84

10.1.2.9 Scale characteristic curve

plot(stscaley2, type = 'score', theta_lim = c(-3, 3), main = "") 

#maps latent theta scores to original scale score metric  

As anticipated, IRT model suggests the stress items collectively exhibit poor measurement properties as a unidimensional scale; that is, the items do not coalesce well into single stress scale. RMSEA and SRMSR values indicate poor overall fit, while specific item loadings and information criteria indicate interpersonal items almost exclusively drive latent theta scores at each wave. Scale information, conditional SE, and conditional reliability plots indicate ranges where latent theta scores are most precise and exhibit highest scale reliability (T1: [-1.5,1]; T2: [-2,1]). Meanwhile, the overall marginal reliability for the IRT scale is relatively high (T1: 0.85; T2: 0.84).

These graded response IRT models confirm our suspicions that simply lumping stress items together into a single scale at each wave is inadvisable. Most items contributed very little information to the latent stress scale, while latent theta scores largely reflect information contributed by interpersonal stress items. An item-specific approach or perhaps examination of stress subscales by type (e.g., financial; interpersonal) is warranted.

If a general scale is needed (e.g., we will use one later for mediation analysis), then the equal unit weighting assumption underlying simple sum scaling may be better for capturing meaningful outcome-relevant variations in stress; latent scaling may better reflect an underlying unidimensional factor but at the cost of potentially arbitrarily up- or down-weighting component stress items that may vary in their relevance to outcomes of interest. However, either scaling approach purchases data reduction or parsimony at the potentially high cost of precision and interpretive clarity.

Since general scales are common in the field, we repeat the process of estimating between-within models and plotting estimated contrasts representing practically large marginal effects of general stress on outcomes using a latent IRT theta scale and a standardized sum scale.

10.1.3 Descriptives: Composite stress scales

# stdz sum stress scale 
# break irtstress & sumstress vars into btw-person means & w/in person changes

stress.long2 <- stress.long %>%
  mutate(
    sumstress = stmony + sttran + stresp + stfair + stjob + stthft + stmug, 
    sumstress = (sumstress - mean(sumstress)) / sd(sumstress)
    ) %>%
  group_by(id) %>%
  mutate( 
    irtstressav = mean(irtstress),
    sumstressav = mean(sumstress)
  ) %>% 
  ungroup() %>% 
  mutate(
    irtstresschg = irtstress - irtstressav,
    sumstresschg = sumstress - sumstressav
  )

10.1.3.1 Summary statistics

#corr btw irt stress scale & standardized sum stress scale
print("Corr: irtstress & sumstress")
## [1] "Corr: irtstress & sumstress"
cor(stress.long2$irtstress, stress.long2$sumstress)
## [1] 0.8
cat('\n')
#btw-person cross-time average stress items
print("Summary: IRT stress avg")
## [1] "Summary: IRT stress avg"
summary(stress.long2$irtstressav) 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   -2.10   -0.70    0.14    0.00    0.77    1.73
print("Summary: Sum stress avg")
## [1] "Summary: Sum stress avg"
summary(stress.long2$sumstressav)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   -2.47   -0.65    0.11    0.00    0.69    2.22
# sd(stress.long2$irtstressav)
# sd(stress.long2$sumstressav)
cat('\n')
#w/in-person over time change items
print("Summary: IRT stress chg")
## [1] "Summary: IRT stress chg"
summary(stress.long2$irtstresschg)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   -0.80   -0.15    0.00    0.00    0.15    0.80
print("Summary: Sum stress chg")
## [1] "Summary: Sum stress chg"
summary(stress.long2$sumstresschg)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   -0.86   -0.10    0.00    0.00    0.10    0.86
  # -.5/.5 change contrast = 1 unit (approx 1SD) change on IRT scale
# table(stress.long2$irtstresschg)

10.1.3.2 IRT stress avg (btw)

ggplot(stress.long2, aes(irtstressav)) + geom_histogram(fill="#E99D53")

10.1.3.3 Sum stress avg (btw)

ggplot(stress.long2, aes(sumstressav)) + geom_histogram(fill="#E99D53")

10.1.3.4 IRT stress chg (w/in)

ggplot(stress.long2, aes(irtstresschg)) + geom_histogram(fill="#883E3A")

10.1.3.5 Sum stress chg (w/in)

ggplot(stress.long2, aes(sumstresschg)) + geom_histogram(fill="#883E3A")

10.1.4 Corr X Community: irt stress & prj crime

#list of colnames for projected crime DVs  
prjdv_names <- noquote(c("prjthflt5", "prjthfgt5", "prjthreat", "prjharm", 
                         "prjusedrg", "prjhack"))


# Getting a few divergent transitions after warmup
# increased adapt_delta from 0.8 to 0.85

# Could consider priors that better reflect rarity of criminal intent 
# E.g., assume probability of each crime intent outcome is 0.1 
  # & 90% sure that each crime intent mean is less than 0.2

# use LearnBayes package (ProbBayes)
# LearnBayes::beta.select(list(x = 0.1, p = 0.5),
#             list(x = 0.2, p = 0.9))
#2.5 20.1

# With these assumptions, could set more informative logit priors:
# set.seed(8675309)
# p_sim <- rbeta(1000, 2.5, 20.1)
# theta_sim <- log(p_sim / (1 - p_sim))
# c(mean(theta_sim), sd(theta_sim))
#Priors: mean = -2.3 SD = .75

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names)
  ) 

chg.prjcrime.stirt.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 + 
    irtstresschg + irtstressav + rural.ses.med + 
    irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id),   
      data = stress.long2, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      adapt_delta = 0.85,
      file = "Models/chg_prjcrime_stirt_comm_fit",
      file_refit = "on_change"
  )

#Update function to call all ppchecks for bivar projected crime models
varlist <- c("^b_prjthflt5_irt","^b_prjthfgt5_irt", "^b_prjthreat_irt", 
             "^b_prjharm_irt", "^b_usedrg_irt", "^b_prjhack_irt") 
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="prjthflt5")
  ppcheckdv2 <-pp_check(modelfit, resp="prjthfgt5")
  ppcheckdv3 <-pp_check(modelfit, resp="prjthreat")
  ppcheckdv4 <-pp_check(modelfit, resp="prjharm")
  ppcheckdv5 <-pp_check(modelfit, resp="prjusedrg")
  ppcheckdv6 <-pp_check(modelfit, resp="prjhack")
  plotcoefs2 <- mcmc_plot(modelfit, variable = varlist, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, 
                    ppcheckdv3, ppcheckdv4, ppcheckdv5, ppcheckdv6, plotcoefs2)
  return(allchecks)
}

out.chg.prjcrime.stirt.comm.fit <- ppchecks(chg.prjcrime.stirt.comm.fit)

10.1.4.1 Coefficient plot (intervals)

out.chg.prjcrime.stirt.comm.fit[[9]] 

10.1.4.2 PPcheck (density)

p1 <- out.chg.prjcrime.stirt.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stirt.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stirt.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stirt.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stirt.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stirt.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

10.1.4.3 Fit summary

out.chg.prjcrime.stirt.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          prjharm ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          prjhack ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##    Data: stress.long2 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.79      0.54     2.88     4.95 1.00     1253
## sd(prjthfgt5_Intercept)     3.24      0.47     2.41     4.24 1.00     1104
## sd(prjthreat_Intercept)     3.04      0.51     2.14     4.16 1.00     1130
## sd(prjharm_Intercept)       2.87      0.52     1.93     3.98 1.00     1177
## sd(prjusedrg_Intercept)     2.67      0.51     1.77     3.77 1.00     1155
## sd(prjhack_Intercept)       0.85      0.56     0.03     2.03 1.00      561
##                         Tail_ESS
## sd(prjthflt5_Intercept)     2190
## sd(prjthfgt5_Intercept)     2203
## sd(prjthreat_Intercept)     2263
## sd(prjharm_Intercept)       1992
## sd(prjusedrg_Intercept)     1733
## sd(prjhack_Intercept)       1228
## 
## Regression Coefficients:
##                                       Estimate Est.Error l-95% CI u-95% CI Rhat
## prjthflt5_Intercept                      -5.77      0.69    -7.22    -4.49 1.00
## prjthfgt5_Intercept                      -5.36      0.65    -6.73    -4.18 1.00
## prjthreat_Intercept                      -6.59      0.82    -8.36    -5.12 1.00
## prjharm_Intercept                        -6.29      0.82    -8.06    -4.82 1.00
## prjusedrg_Intercept                      -6.21      0.80    -7.93    -4.78 1.00
## prjhack_Intercept                        -4.58      0.62    -6.01    -3.57 1.00
## prjthflt5_irtstresschg                   -0.12      0.63    -1.34     1.14 1.00
## prjthflt5_irtstressav                     0.55      0.47    -0.35     1.52 1.00
## prjthflt5_rural.ses.med2                 -1.44      0.67    -2.79    -0.16 1.00
## prjthflt5_rural.ses.med3                  1.20      0.57     0.07     2.32 1.00
## prjthflt5_rural.ses.med4                  1.95      0.61     0.75     3.11 1.00
## prjthflt5_irtstresschg:rural.ses.med2    -0.33      0.90    -2.10     1.42 1.00
## prjthflt5_irtstresschg:rural.ses.med3     0.29      0.74    -1.16     1.72 1.00
## prjthflt5_irtstresschg:rural.ses.med4    -0.15      0.79    -1.69     1.41 1.00
## prjthflt5_irtstressav:rural.ses.med2      0.43      0.71    -0.92     1.83 1.00
## prjthflt5_irtstressav:rural.ses.med3      0.84      0.61    -0.37     2.07 1.00
## prjthflt5_irtstressav:rural.ses.med4      0.24      0.62    -0.94     1.44 1.00
## prjthfgt5_irtstresschg                    0.12      0.62    -1.12     1.37 1.00
## prjthfgt5_irtstressav                     0.28      0.45    -0.58     1.19 1.00
## prjthfgt5_rural.ses.med2                 -1.53      0.64    -2.77    -0.26 1.00
## prjthfgt5_rural.ses.med3                  1.23      0.53     0.19     2.30 1.00
## prjthfgt5_rural.ses.med4                  1.86      0.57     0.74     2.98 1.00
## prjthfgt5_irtstresschg:rural.ses.med2    -0.02      0.88    -1.72     1.73 1.00
## prjthfgt5_irtstresschg:rural.ses.med3    -0.09      0.74    -1.51     1.35 1.00
## prjthfgt5_irtstresschg:rural.ses.med4     0.21      0.78    -1.31     1.74 1.00
## prjthfgt5_irtstressav:rural.ses.med2      0.19      0.69    -1.16     1.52 1.00
## prjthfgt5_irtstressav:rural.ses.med3      0.51      0.58    -0.63     1.69 1.00
## prjthfgt5_irtstressav:rural.ses.med4      0.29      0.59    -0.88     1.48 1.00
## prjthreat_irtstresschg                   -0.44      0.68    -1.76     0.90 1.00
## prjthreat_irtstressav                     0.87      0.50    -0.08     1.90 1.00
## prjthreat_rural.ses.med2                 -0.84      0.70    -2.23     0.53 1.00
## prjthreat_rural.ses.med3                  0.37      0.63    -0.90     1.58 1.00
## prjthreat_rural.ses.med4                  1.61      0.60     0.45     2.82 1.00
## prjthreat_irtstresschg:rural.ses.med2     0.12      0.94    -1.75     1.97 1.00
## prjthreat_irtstresschg:rural.ses.med3     0.15      0.80    -1.42     1.75 1.00
## prjthreat_irtstresschg:rural.ses.med4    -0.13      0.82    -1.75     1.44 1.00
## prjthreat_irtstressav:rural.ses.med2     -0.60      0.72    -2.02     0.84 1.00
## prjthreat_irtstressav:rural.ses.med3      0.78      0.66    -0.50     2.10 1.00
## prjthreat_irtstressav:rural.ses.med4      0.29      0.63    -0.96     1.54 1.00
## prjharm_irtstresschg                     -0.29      0.69    -1.67     1.08 1.00
## prjharm_irtstressav                       0.29      0.47    -0.59     1.24 1.00
## prjharm_rural.ses.med2                   -0.55      0.67    -1.87     0.76 1.00
## prjharm_rural.ses.med3                    0.16      0.62    -1.05     1.36 1.00
## prjharm_rural.ses.med4                    1.04      0.62    -0.19     2.27 1.00
## prjharm_irtstresschg:rural.ses.med2      -0.04      0.93    -1.85     1.79 1.00
## prjharm_irtstresschg:rural.ses.med3       0.51      0.80    -1.06     2.05 1.00
## prjharm_irtstresschg:rural.ses.med4      -0.46      0.86    -2.19     1.19 1.00
## prjharm_irtstressav:rural.ses.med2       -0.71      0.64    -1.97     0.53 1.00
## prjharm_irtstressav:rural.ses.med3        0.79      0.64    -0.43     2.10 1.00
## prjharm_irtstressav:rural.ses.med4        0.12      0.64    -1.12     1.45 1.00
## prjusedrg_irtstresschg                   -0.57      0.68    -1.91     0.75 1.00
## prjusedrg_irtstressav                     0.69      0.49    -0.26     1.66 1.00
## prjusedrg_rural.ses.med2                 -0.57      0.66    -1.92     0.70 1.00
## prjusedrg_rural.ses.med3                 -0.74      0.66    -2.02     0.56 1.00
## prjusedrg_rural.ses.med4                  1.63      0.59     0.43     2.78 1.00
## prjusedrg_irtstresschg:rural.ses.med2    -0.24      0.89    -2.00     1.53 1.00
## prjusedrg_irtstresschg:rural.ses.med3    -0.01      0.88    -1.71     1.69 1.00
## prjusedrg_irtstresschg:rural.ses.med4     0.37      0.80    -1.18     1.97 1.00
## prjusedrg_irtstressav:rural.ses.med2     -0.89      0.68    -2.27     0.40 1.00
## prjusedrg_irtstressav:rural.ses.med3      0.50      0.68    -0.81     1.86 1.00
## prjusedrg_irtstressav:rural.ses.med4      0.39      0.63    -0.81     1.60 1.00
## prjhack_irtstresschg                     -0.43      0.69    -1.78     0.95 1.00
## prjhack_irtstressav                       0.56      0.45    -0.31     1.45 1.00
## prjhack_rural.ses.med2                   -0.93      0.67    -2.30     0.32 1.00
## prjhack_rural.ses.med3                    0.17      0.54    -0.90     1.24 1.00
## prjhack_rural.ses.med4                    0.56      0.56    -0.57     1.61 1.00
## prjhack_irtstresschg:rural.ses.med2       0.23      0.93    -1.59     2.03 1.00
## prjhack_irtstresschg:rural.ses.med3      -0.32      0.82    -1.89     1.29 1.00
## prjhack_irtstresschg:rural.ses.med4      -0.15      0.83    -1.77     1.48 1.00
## prjhack_irtstressav:rural.ses.med2       -0.45      0.68    -1.71     0.95 1.00
## prjhack_irtstressav:rural.ses.med3        0.01      0.58    -1.10     1.18 1.00
## prjhack_irtstressav:rural.ses.med4        0.50      0.58    -0.62     1.67 1.00
##                                       Bulk_ESS Tail_ESS
## prjthflt5_Intercept                       1570     2320
## prjthfgt5_Intercept                       1570     2211
## prjthreat_Intercept                       1657     2694
## prjharm_Intercept                         1643     2432
## prjusedrg_Intercept                       1515     2262
## prjhack_Intercept                         1059     1276
## prjthflt5_irtstresschg                    4061     3181
## prjthflt5_irtstressav                     2500     2831
## prjthflt5_rural.ses.med2                  3054     2649
## prjthflt5_rural.ses.med3                  2490     2625
## prjthflt5_rural.ses.med4                  2632     3167
## prjthflt5_irtstresschg:rural.ses.med2     5818     2903
## prjthflt5_irtstresschg:rural.ses.med3     4397     2803
## prjthflt5_irtstresschg:rural.ses.med4     4633     2727
## prjthflt5_irtstressav:rural.ses.med2      3411     2912
## prjthflt5_irtstressav:rural.ses.med3      2625     2722
## prjthflt5_irtstressav:rural.ses.med4      2794     2969
## prjthfgt5_irtstresschg                    3151     2793
## prjthfgt5_irtstressav                     2221     2714
## prjthfgt5_rural.ses.med2                  3002     2698
## prjthfgt5_rural.ses.med3                  2461     2694
## prjthfgt5_rural.ses.med4                  2396     2404
## prjthfgt5_irtstresschg:rural.ses.med2     6481     2787
## prjthfgt5_irtstresschg:rural.ses.med3     3716     2599
## prjthfgt5_irtstresschg:rural.ses.med4     4477     2762
## prjthfgt5_irtstressav:rural.ses.med2      3344     2917
## prjthfgt5_irtstressav:rural.ses.med3      2628     2964
## prjthfgt5_irtstressav:rural.ses.med4      2249     2406
## prjthreat_irtstresschg                    4232     3030
## prjthreat_irtstressav                     2595     2908
## prjthreat_rural.ses.med2                  3933     2361
## prjthreat_rural.ses.med3                  3370     2810
## prjthreat_rural.ses.med4                  2973     2595
## prjthreat_irtstresschg:rural.ses.med2     5066     3018
## prjthreat_irtstresschg:rural.ses.med3     5148     2773
## prjthreat_irtstresschg:rural.ses.med4     5404     3003
## prjthreat_irtstressav:rural.ses.med2      3671     2805
## prjthreat_irtstressav:rural.ses.med3      2951     2898
## prjthreat_irtstressav:rural.ses.med4      2189     2792
## prjharm_irtstresschg                      4513     2348
## prjharm_irtstressav                       2518     2861
## prjharm_rural.ses.med2                    3247     2937
## prjharm_rural.ses.med3                    3599     3006
## prjharm_rural.ses.med4                    3155     2872
## prjharm_irtstresschg:rural.ses.med2       6386     2312
## prjharm_irtstresschg:rural.ses.med3       4685     2788
## prjharm_irtstresschg:rural.ses.med4       5867     3343
## prjharm_irtstressav:rural.ses.med2        3123     3260
## prjharm_irtstressav:rural.ses.med3        3018     2648
## prjharm_irtstressav:rural.ses.med4        3270     3066
## prjusedrg_irtstresschg                    4263     3184
## prjusedrg_irtstressav                     3016     2557
## prjusedrg_rural.ses.med2                  3890     2925
## prjusedrg_rural.ses.med3                  4259     3125
## prjusedrg_rural.ses.med4                  3295     3066
## prjusedrg_irtstresschg:rural.ses.med2     5758     3097
## prjusedrg_irtstresschg:rural.ses.med3     5078     2698
## prjusedrg_irtstresschg:rural.ses.med4     4269     3140
## prjusedrg_irtstressav:rural.ses.med2      3222     2685
## prjusedrg_irtstressav:rural.ses.med3      3838     3027
## prjusedrg_irtstressav:rural.ses.med4      2817     2700
## prjhack_irtstresschg                      4262     2984
## prjhack_irtstressav                       2565     2556
## prjhack_rural.ses.med2                    5323     2987
## prjhack_rural.ses.med3                    4040     2805
## prjhack_rural.ses.med4                    4078     3103
## prjhack_irtstresschg:rural.ses.med2       4823     2855
## prjhack_irtstresschg:rural.ses.med3       4810     3015
## prjhack_irtstresschg:rural.ses.med4       4942     2892
## prjhack_irtstressav:rural.ses.med2        3774     3294
## prjhack_irtstressav:rural.ses.med3        2722     2459
## prjhack_irtstressav:rural.ses.med4        3262     2613
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

10.1.4.4 Prior summary

out.chg.prjcrime.stirt.comm.fit[[2]]
##                 prior     class                        coef group      resp
##                (flat)         b                                            
##          normal(0, 1)         b                                     prjhack
##          normal(0, 1)         b                 irtstressav         prjhack
##          normal(0, 1)         b  irtstressav:rural.ses.med2         prjhack
##          normal(0, 1)         b  irtstressav:rural.ses.med3         prjhack
##          normal(0, 1)         b  irtstressav:rural.ses.med4         prjhack
##          normal(0, 1)         b                irtstresschg         prjhack
##          normal(0, 1)         b irtstresschg:rural.ses.med2         prjhack
##          normal(0, 1)         b irtstresschg:rural.ses.med3         prjhack
##          normal(0, 1)         b irtstresschg:rural.ses.med4         prjhack
##          normal(0, 1)         b              rural.ses.med2         prjhack
##          normal(0, 1)         b              rural.ses.med3         prjhack
##          normal(0, 1)         b              rural.ses.med4         prjhack
##          normal(0, 1)         b                                     prjharm
##          normal(0, 1)         b                 irtstressav         prjharm
##          normal(0, 1)         b  irtstressav:rural.ses.med2         prjharm
##          normal(0, 1)         b  irtstressav:rural.ses.med3         prjharm
##          normal(0, 1)         b  irtstressav:rural.ses.med4         prjharm
##          normal(0, 1)         b                irtstresschg         prjharm
##          normal(0, 1)         b irtstresschg:rural.ses.med2         prjharm
##          normal(0, 1)         b irtstresschg:rural.ses.med3         prjharm
##          normal(0, 1)         b irtstresschg:rural.ses.med4         prjharm
##          normal(0, 1)         b              rural.ses.med2         prjharm
##          normal(0, 1)         b              rural.ses.med3         prjharm
##          normal(0, 1)         b              rural.ses.med4         prjharm
##          normal(0, 1)         b                                   prjthfgt5
##          normal(0, 1)         b                 irtstressav       prjthfgt5
##          normal(0, 1)         b  irtstressav:rural.ses.med2       prjthfgt5
##          normal(0, 1)         b  irtstressav:rural.ses.med3       prjthfgt5
##          normal(0, 1)         b  irtstressav:rural.ses.med4       prjthfgt5
##          normal(0, 1)         b                irtstresschg       prjthfgt5
##          normal(0, 1)         b irtstresschg:rural.ses.med2       prjthfgt5
##          normal(0, 1)         b irtstresschg:rural.ses.med3       prjthfgt5
##          normal(0, 1)         b irtstresschg:rural.ses.med4       prjthfgt5
##          normal(0, 1)         b              rural.ses.med2       prjthfgt5
##          normal(0, 1)         b              rural.ses.med3       prjthfgt5
##          normal(0, 1)         b              rural.ses.med4       prjthfgt5
##          normal(0, 1)         b                                   prjthflt5
##          normal(0, 1)         b                 irtstressav       prjthflt5
##          normal(0, 1)         b  irtstressav:rural.ses.med2       prjthflt5
##          normal(0, 1)         b  irtstressav:rural.ses.med3       prjthflt5
##          normal(0, 1)         b  irtstressav:rural.ses.med4       prjthflt5
##          normal(0, 1)         b                irtstresschg       prjthflt5
##          normal(0, 1)         b irtstresschg:rural.ses.med2       prjthflt5
##          normal(0, 1)         b irtstresschg:rural.ses.med3       prjthflt5
##          normal(0, 1)         b irtstresschg:rural.ses.med4       prjthflt5
##          normal(0, 1)         b              rural.ses.med2       prjthflt5
##          normal(0, 1)         b              rural.ses.med3       prjthflt5
##          normal(0, 1)         b              rural.ses.med4       prjthflt5
##          normal(0, 1)         b                                   prjthreat
##          normal(0, 1)         b                 irtstressav       prjthreat
##          normal(0, 1)         b  irtstressav:rural.ses.med2       prjthreat
##          normal(0, 1)         b  irtstressav:rural.ses.med3       prjthreat
##          normal(0, 1)         b  irtstressav:rural.ses.med4       prjthreat
##          normal(0, 1)         b                irtstresschg       prjthreat
##          normal(0, 1)         b irtstresschg:rural.ses.med2       prjthreat
##          normal(0, 1)         b irtstresschg:rural.ses.med3       prjthreat
##          normal(0, 1)         b irtstresschg:rural.ses.med4       prjthreat
##          normal(0, 1)         b              rural.ses.med2       prjthreat
##          normal(0, 1)         b              rural.ses.med3       prjthreat
##          normal(0, 1)         b              rural.ses.med4       prjthreat
##          normal(0, 1)         b                                   prjusedrg
##          normal(0, 1)         b                 irtstressav       prjusedrg
##          normal(0, 1)         b  irtstressav:rural.ses.med2       prjusedrg
##          normal(0, 1)         b  irtstressav:rural.ses.med3       prjusedrg
##          normal(0, 1)         b  irtstressav:rural.ses.med4       prjusedrg
##          normal(0, 1)         b                irtstresschg       prjusedrg
##          normal(0, 1)         b irtstresschg:rural.ses.med2       prjusedrg
##          normal(0, 1)         b irtstresschg:rural.ses.med3       prjusedrg
##          normal(0, 1)         b irtstresschg:rural.ses.med4       prjusedrg
##          normal(0, 1)         b              rural.ses.med2       prjusedrg
##          normal(0, 1)         b              rural.ses.med3       prjusedrg
##          normal(0, 1)         b              rural.ses.med4       prjusedrg
##                (flat) Intercept                                            
##          normal(0, 2) Intercept                                     prjhack
##          normal(0, 2) Intercept                                     prjharm
##          normal(0, 2) Intercept                                   prjthfgt5
##          normal(0, 2) Intercept                                   prjthflt5
##          normal(0, 2) Intercept                                   prjthreat
##          normal(0, 2) Intercept                                   prjusedrg
##  student_t(3, 0, 2.5)        sd                                     prjhack
##  student_t(3, 0, 2.5)        sd                                     prjharm
##  student_t(3, 0, 2.5)        sd                                   prjthfgt5
##  student_t(3, 0, 2.5)        sd                                   prjthflt5
##  student_t(3, 0, 2.5)        sd                                   prjthreat
##  student_t(3, 0, 2.5)        sd                                   prjusedrg
##  student_t(3, 0, 2.5)        sd                                id   prjhack
##  student_t(3, 0, 2.5)        sd                   Intercept    id   prjhack
##  student_t(3, 0, 2.5)        sd                                id   prjharm
##  student_t(3, 0, 2.5)        sd                   Intercept    id   prjharm
##  student_t(3, 0, 2.5)        sd                                id prjthfgt5
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthfgt5
##  student_t(3, 0, 2.5)        sd                                id prjthflt5
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthflt5
##  student_t(3, 0, 2.5)        sd                                id prjthreat
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthreat
##  student_t(3, 0, 2.5)        sd                                id prjusedrg
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)

10.1.5 Corr X Community: irt stress & any prj crime

# "Any crime" outcome & irt stress scale
prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept'),
  set_prior('normal(0, 1)', class = 'b')
  )

chg.anyprjcrime.stirt.comm.fit <- brm(prjany ~ 1 + 
    irtstresschg + irtstressav + rural.ses.med + 
    irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id),   
      data = stress.long2, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_anyprjcrime_stirt_comm_fit",
      file_refit = "on_change"
    )


#Update function to call all ppchecks for bivar projected crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit)
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^b_irt", regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, plotcoefs2)
  return(allchecks)
}

out.chg.anyprjcrime.stirt.comm.fit <- ppchecks(chg.anyprjcrime.stirt.comm.fit)

10.1.5.1 Coefficient plot (intervals)

out.chg.anyprjcrime.stirt.comm.fit[[4]] 

10.1.5.2 PPcheck (density)

out.chg.anyprjcrime.stirt.comm.fit[[3]] + labs(title = "Any Crime Intent (chg)") 

10.1.5.3 Fit summary

out.chg.anyprjcrime.stirt.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##    Data: stress.long2 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.02      0.40     2.28     3.86 1.00     1169     1877
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept                      -4.03      0.49    -5.07    -3.12 1.00     2074
## irtstresschg                   -0.10      0.56    -1.17     1.01 1.00     4336
## irtstressav                     0.51      0.41    -0.28     1.34 1.00     2752
## rural.ses.med2                 -1.06      0.54    -2.14    -0.01 1.00     2880
## rural.ses.med3                  1.01      0.49     0.06     1.98 1.00     2893
## rural.ses.med4                  2.16      0.51     1.18     3.20 1.00     2968
## irtstresschg:rural.ses.med2    -0.61      0.82    -2.21     1.02 1.00     5932
## irtstresschg:rural.ses.med3     0.29      0.68    -1.06     1.61 1.00     4242
## irtstresschg:rural.ses.med4     0.54      0.72    -0.87     1.94 1.00     5401
## irtstressav:rural.ses.med2     -0.48      0.57    -1.57     0.63 1.00     2988
## irtstressav:rural.ses.med3      0.67      0.52    -0.34     1.69 1.00     3167
## irtstressav:rural.ses.med4      0.39      0.55    -0.68     1.46 1.00     3097
##                             Tail_ESS
## Intercept                       1894
## irtstresschg                    2925
## irtstressav                     2605
## rural.ses.med2                  3019
## rural.ses.med3                  2861
## rural.ses.med4                  3195
## irtstresschg:rural.ses.med2     2908
## irtstresschg:rural.ses.med3     2728
## irtstresschg:rural.ses.med4     3066
## irtstressav:rural.ses.med2      2848
## irtstressav:rural.ses.med3      2695
## irtstressav:rural.ses.med4      2651
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

10.1.5.4 Prior summary

out.chg.anyprjcrime.stirt.comm.fit[[2]]
##                 prior     class                        coef group resp dpar
##          normal(0, 1)         b                                            
##          normal(0, 1)         b                 irtstressav                
##          normal(0, 1)         b  irtstressav:rural.ses.med2                
##          normal(0, 1)         b  irtstressav:rural.ses.med3                
##          normal(0, 1)         b  irtstressav:rural.ses.med4                
##          normal(0, 1)         b                irtstresschg                
##          normal(0, 1)         b irtstresschg:rural.ses.med2                
##          normal(0, 1)         b irtstresschg:rural.ses.med3                
##          normal(0, 1)         b irtstresschg:rural.ses.med4                
##          normal(0, 1)         b              rural.ses.med2                
##          normal(0, 1)         b              rural.ses.med3                
##          normal(0, 1)         b              rural.ses.med4                
##          normal(0, 2) Intercept                                            
##  student_t(3, 0, 2.5)        sd                                            
##  student_t(3, 0, 2.5)        sd                                id          
##  student_t(3, 0, 2.5)        sd                   Intercept    id          
##  nlpar lb ub       source
##                      user
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)

10.1.6 Corr X Community: irt stress & negative emotions

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

#Vectorize priors:
prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names)
  )

chg.alldepress.stirt.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + irtstresschg + irtstressav + 
         rural.ses.med + irtstresschg:rural.ses.med + 
         irtstressav:rural.ses.med + (1 | id),   
      data = stress.long2, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stirt_comm_fit",
      file_refit = "on_change"
  )

##Update function to call all ppchecks for bivar depressive symptom chg models
varlist1 <- c("^b_depcantgo_irt","^b_depeffort_irt", "^b_deplonely_irt", 
             "^b_depblues_irt") 
varlist2 <- c("^b_depunfair_irt", "^b_depmistrt_irt", "^b_depbetray_irt") 
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="depcantgo")
  ppcheckdv2 <-pp_check(modelfit, resp="depeffort")
  ppcheckdv3 <-pp_check(modelfit, resp="deplonely")
  ppcheckdv4 <-pp_check(modelfit, resp="depblues")
  ppcheckdv5 <-pp_check(modelfit, resp="depunfair")
  ppcheckdv6 <-pp_check(modelfit, resp="depmistrt")
  ppcheckdv7 <-pp_check(modelfit, resp="depbetray")
  plotcoefs1 <- mcmc_plot(modelfit, variable = varlist1, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients\nwith medians, 80%, and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = varlist2, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients\nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, ppcheckdv3, 
                    ppcheckdv4, ppcheckdv5, ppcheckdv6, ppcheckdv7, 
                    plotcoefs1, plotcoefs2)
  return(allchecks)
}

out.chg.alldepress.stirt.comm.fit <- ppchecks(chg.alldepress.stirt.comm.fit)

10.1.6.1 Coefficient plot (depressive symptoms)

out.chg.alldepress.stirt.comm.fit[[10]]

10.1.6.2 Coefficient plot (criminogenic emotions)

out.chg.alldepress.stirt.comm.fit[[11]]

10.1.6.3 PPcheck (density)

p1 <- out.chg.alldepress.stirt.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stirt.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stirt.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stirt.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stirt.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stirt.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stirt.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

10.1.6.4 Fit summary

out.chg.alldepress.stirt.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          depeffort ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          deplonely ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          depblues ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          depunfair ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##          depbetray ~ 1 + irtstresschg + irtstressav + rural.ses.med + irtstresschg:rural.ses.med + irtstressav:rural.ses.med + (1 | id) 
##    Data: stress.long2 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.33      0.20     0.02     0.72 1.00      705
## sd(depeffort_Intercept)     0.48      0.28     0.03     1.05 1.00      673
## sd(deplonely_Intercept)     0.44      0.24     0.03     0.90 1.01      697
## sd(depblues_Intercept)      0.61      0.31     0.05     1.21 1.01      510
## sd(depunfair_Intercept)     0.23      0.16     0.01     0.59 1.00     1071
## sd(depmistrt_Intercept)     0.33      0.22     0.02     0.83 1.00      779
## sd(depbetray_Intercept)     0.42      0.26     0.02     0.95 1.01      745
##                         Tail_ESS
## sd(depcantgo_Intercept)     1591
## sd(depeffort_Intercept)     1610
## sd(deplonely_Intercept)     1355
## sd(depblues_Intercept)       931
## sd(depunfair_Intercept)     1719
## sd(depmistrt_Intercept)      976
## sd(depbetray_Intercept)     1333
## 
## Regression Coefficients:
##                                       Estimate Est.Error l-95% CI u-95% CI Rhat
## depcantgo_Intercept                      -0.50      0.14    -0.77    -0.23 1.00
## depeffort_Intercept                      -2.00      0.22    -2.47    -1.59 1.00
## deplonely_Intercept                      -1.03      0.17    -1.35    -0.72 1.00
## depblues_Intercept                       -2.28      0.25    -2.80    -1.81 1.00
## depunfair_Intercept                      -1.57      0.17    -1.92    -1.23 1.00
## depmistrt_Intercept                      -2.08      0.21    -2.50    -1.68 1.00
## depbetray_Intercept                      -2.27      0.23    -2.75    -1.85 1.00
## depcantgo_irtstresschg                   -0.04      0.44    -0.88     0.82 1.00
## depcantgo_irtstressav                    -0.16      0.16    -0.48     0.16 1.00
## depcantgo_rural.ses.med2                  0.32      0.19    -0.06     0.70 1.00
## depcantgo_rural.ses.med3                  0.12      0.19    -0.25     0.49 1.00
## depcantgo_rural.ses.med4                  0.09      0.20    -0.30     0.48 1.00
## depcantgo_irtstresschg:rural.ses.med2     0.52      0.59    -0.63     1.67 1.00
## depcantgo_irtstresschg:rural.ses.med3     0.02      0.54    -1.05     1.10 1.00
## depcantgo_irtstresschg:rural.ses.med4    -0.30      0.59    -1.47     0.83 1.00
## depcantgo_irtstressav:rural.ses.med2      0.24      0.21    -0.18     0.65 1.00
## depcantgo_irtstressav:rural.ses.med3     -0.05      0.21    -0.45     0.38 1.00
## depcantgo_irtstressav:rural.ses.med4      0.15      0.23    -0.31     0.61 1.00
## depeffort_irtstresschg                    0.14      0.49    -0.82     1.11 1.00
## depeffort_irtstressav                     0.03      0.23    -0.41     0.49 1.00
## depeffort_rural.ses.med2                 -0.02      0.28    -0.54     0.52 1.00
## depeffort_rural.ses.med3                  0.43      0.26    -0.08     0.94 1.00
## depeffort_rural.ses.med4                  0.51      0.28    -0.03     1.06 1.00
## depeffort_irtstresschg:rural.ses.med2     0.28      0.71    -1.08     1.67 1.00
## depeffort_irtstresschg:rural.ses.med3     0.23      0.59    -0.93     1.38 1.00
## depeffort_irtstresschg:rural.ses.med4     0.00      0.65    -1.21     1.31 1.00
## depeffort_irtstressav:rural.ses.med2     -0.17      0.30    -0.76     0.42 1.00
## depeffort_irtstressav:rural.ses.med3      0.32      0.29    -0.22     0.88 1.00
## depeffort_irtstressav:rural.ses.med4      0.12      0.31    -0.48     0.71 1.00
## deplonely_irtstresschg                   -0.24      0.43    -1.08     0.59 1.00
## deplonely_irtstressav                    -0.12      0.19    -0.48     0.25 1.00
## deplonely_rural.ses.med2                 -0.38      0.23    -0.83     0.07 1.00
## deplonely_rural.ses.med3                 -0.05      0.21    -0.45     0.37 1.00
## deplonely_rural.ses.med4                  0.42      0.23    -0.02     0.87 1.00
## deplonely_irtstresschg:rural.ses.med2     0.33      0.62    -0.90     1.53 1.00
## deplonely_irtstresschg:rural.ses.med3    -0.01      0.54    -1.11     1.03 1.00
## deplonely_irtstresschg:rural.ses.med4    -0.13      0.60    -1.26     1.06 1.00
## deplonely_irtstressav:rural.ses.med2      0.06      0.24    -0.44     0.53 1.00
## deplonely_irtstressav:rural.ses.med3      0.30      0.24    -0.17     0.77 1.00
## deplonely_irtstressav:rural.ses.med4      0.17      0.26    -0.35     0.67 1.00
## depblues_irtstresschg                     0.39      0.51    -0.58     1.41 1.00
## depblues_irtstressav                      0.04      0.25    -0.45     0.54 1.00
## depblues_rural.ses.med2                   0.05      0.30    -0.55     0.63 1.00
## depblues_rural.ses.med3                   0.24      0.29    -0.34     0.83 1.00
## depblues_rural.ses.med4                   0.47      0.30    -0.11     1.07 1.00
## depblues_irtstresschg:rural.ses.med2      0.42      0.71    -1.00     1.83 1.00
## depblues_irtstresschg:rural.ses.med3      0.23      0.62    -0.96     1.43 1.00
## depblues_irtstresschg:rural.ses.med4      0.21      0.66    -1.07     1.50 1.00
## depblues_irtstressav:rural.ses.med2      -0.68      0.32    -1.31    -0.06 1.00
## depblues_irtstressav:rural.ses.med3       0.55      0.32    -0.09     1.20 1.00
## depblues_irtstressav:rural.ses.med4       0.37      0.34    -0.29     1.02 1.00
## depunfair_irtstresschg                    0.84      0.46    -0.07     1.74 1.00
## depunfair_irtstressav                     0.27      0.21    -0.14     0.68 1.00
## depunfair_rural.ses.med2                  0.24      0.23    -0.21     0.70 1.00
## depunfair_rural.ses.med3                  0.69      0.21     0.29     1.12 1.00
## depunfair_rural.ses.med4                  0.90      0.23     0.46     1.35 1.00
## depunfair_irtstresschg:rural.ses.med2     0.68      0.64    -0.54     1.93 1.00
## depunfair_irtstresschg:rural.ses.med3    -0.36      0.56    -1.47     0.75 1.00
## depunfair_irtstresschg:rural.ses.med4    -0.18      0.60    -1.36     0.98 1.00
## depunfair_irtstressav:rural.ses.med2     -0.52      0.26    -1.03    -0.00 1.00
## depunfair_irtstressav:rural.ses.med3      0.02      0.25    -0.47     0.52 1.00
## depunfair_irtstressav:rural.ses.med4      0.04      0.27    -0.49     0.58 1.00
## depmistrt_irtstresschg                    0.22      0.49    -0.71     1.19 1.00
## depmistrt_irtstressav                     0.50      0.25     0.02     1.02 1.00
## depmistrt_rural.ses.med2                  0.58      0.26     0.07     1.09 1.00
## depmistrt_rural.ses.med3                  0.52      0.26     0.02     1.02 1.00
## depmistrt_rural.ses.med4                  0.51      0.28    -0.03     1.07 1.00
## depmistrt_irtstresschg:rural.ses.med2    -0.05      0.66    -1.33     1.26 1.00
## depmistrt_irtstresschg:rural.ses.med3     0.59      0.60    -0.62     1.77 1.00
## depmistrt_irtstresschg:rural.ses.med4    -0.20      0.64    -1.46     1.03 1.00
## depmistrt_irtstressav:rural.ses.med2     -0.22      0.30    -0.82     0.36 1.00
## depmistrt_irtstressav:rural.ses.med3     -0.08      0.30    -0.68     0.50 1.00
## depmistrt_irtstressav:rural.ses.med4      0.19      0.34    -0.47     0.87 1.00
## depbetray_irtstresschg                    0.60      0.49    -0.36     1.57 1.00
## depbetray_irtstressav                     0.45      0.26    -0.04     0.94 1.00
## depbetray_rural.ses.med2                  0.48      0.28    -0.07     1.01 1.00
## depbetray_rural.ses.med3                  0.76      0.26     0.26     1.29 1.00
## depbetray_rural.ses.med4                  0.77      0.30     0.19     1.36 1.00
## depbetray_irtstresschg:rural.ses.med2    -0.32      0.68    -1.64     1.02 1.00
## depbetray_irtstresschg:rural.ses.med3    -0.35      0.59    -1.52     0.78 1.00
## depbetray_irtstresschg:rural.ses.med4    -0.39      0.63    -1.60     0.88 1.00
## depbetray_irtstressav:rural.ses.med2     -0.33      0.31    -0.96     0.27 1.00
## depbetray_irtstressav:rural.ses.med3     -0.09      0.31    -0.69     0.51 1.00
## depbetray_irtstressav:rural.ses.med4      0.40      0.34    -0.26     1.08 1.00
##                                       Bulk_ESS Tail_ESS
## depcantgo_Intercept                       6015     3005
## depeffort_Intercept                       2918     2286
## deplonely_Intercept                       3490     3016
## depblues_Intercept                        1888     2519
## depunfair_Intercept                       5223     2977
## depmistrt_Intercept                       3945     2729
## depbetray_Intercept                       3678     2969
## depcantgo_irtstresschg                    4691     3135
## depcantgo_irtstressav                     3589     3178
## depcantgo_rural.ses.med2                  4971     2922
## depcantgo_rural.ses.med3                  5492     3424
## depcantgo_rural.ses.med4                  5530     3547
## depcantgo_irtstresschg:rural.ses.med2     5681     2948
## depcantgo_irtstresschg:rural.ses.med3     4910     3033
## depcantgo_irtstresschg:rural.ses.med4     4845     3220
## depcantgo_irtstressav:rural.ses.med2      3801     3433
## depcantgo_irtstressav:rural.ses.med3      3791     3087
## depcantgo_irtstressav:rural.ses.med4      4160     3663
## depeffort_irtstresschg                    4736     3329
## depeffort_irtstressav                     3432     3032
## depeffort_rural.ses.med2                  5146     3097
## depeffort_rural.ses.med3                  5301     3167
## depeffort_rural.ses.med4                  5018     2892
## depeffort_irtstresschg:rural.ses.med2     6493     3473
## depeffort_irtstresschg:rural.ses.med3     5949     3152
## depeffort_irtstresschg:rural.ses.med4     6043     3525
## depeffort_irtstressav:rural.ses.med2      3958     3241
## depeffort_irtstressav:rural.ses.med3      3421     3072
## depeffort_irtstressav:rural.ses.med4      3716     3403
## deplonely_irtstresschg                    4315     3248
## deplonely_irtstressav                     3763     3036
## deplonely_rural.ses.med2                  4513     3143
## deplonely_rural.ses.med3                  5318     3364
## deplonely_rural.ses.med4                  4809     2952
## deplonely_irtstresschg:rural.ses.med2     5539     3728
## deplonely_irtstresschg:rural.ses.med3     4676     3339
## deplonely_irtstresschg:rural.ses.med4     5669     3270
## deplonely_irtstressav:rural.ses.med2      4071     2852
## deplonely_irtstressav:rural.ses.med3      3868     3127
## deplonely_irtstressav:rural.ses.med4      4097     3337
## depblues_irtstresschg                     5045     2887
## depblues_irtstressav                      3797     2848
## depblues_rural.ses.med2                   4917     3151
## depblues_rural.ses.med3                   5459     2570
## depblues_rural.ses.med4                   5009     3075
## depblues_irtstresschg:rural.ses.med2      6633     3198
## depblues_irtstresschg:rural.ses.med3      5545     3520
## depblues_irtstresschg:rural.ses.med4      5991     2915
## depblues_irtstressav:rural.ses.med2       4005     3059
## depblues_irtstressav:rural.ses.med3       4097     3350
## depblues_irtstressav:rural.ses.med4       3806     3514
## depunfair_irtstresschg                    4034     3178
## depunfair_irtstressav                     3430     2766
## depunfair_rural.ses.med2                  5306     3478
## depunfair_rural.ses.med3                  5536     3850
## depunfair_rural.ses.med4                  5236     3175
## depunfair_irtstresschg:rural.ses.med2     5737     3324
## depunfair_irtstresschg:rural.ses.med3     4749     3271
## depunfair_irtstresschg:rural.ses.med4     4565     3376
## depunfair_irtstressav:rural.ses.med2      3229     3449
## depunfair_irtstressav:rural.ses.med3      3331     3025
## depunfair_irtstressav:rural.ses.med4      3655     3135
## depmistrt_irtstresschg                    4414     3276
## depmistrt_irtstressav                     3501     2822
## depmistrt_rural.ses.med2                  5271     3169
## depmistrt_rural.ses.med3                  5064     3047
## depmistrt_rural.ses.med4                  4863     3472
## depmistrt_irtstresschg:rural.ses.med2     5961     3147
## depmistrt_irtstresschg:rural.ses.med3     5102     2839
## depmistrt_irtstresschg:rural.ses.med4     6159     3161
## depmistrt_irtstressav:rural.ses.med2      3698     3257
## depmistrt_irtstressav:rural.ses.med3      3899     3172
## depmistrt_irtstressav:rural.ses.med4      3891     3443
## depbetray_irtstresschg                    4215     3106
## depbetray_irtstressav                     3658     2941
## depbetray_rural.ses.med2                  4715     3549
## depbetray_rural.ses.med3                  5069     3475
## depbetray_rural.ses.med4                  5559     3336
## depbetray_irtstresschg:rural.ses.med2     5815     2945
## depbetray_irtstresschg:rural.ses.med3     5364     3443
## depbetray_irtstresschg:rural.ses.med4     5860     3296
## depbetray_irtstressav:rural.ses.med2      3943     3065
## depbetray_irtstressav:rural.ses.med3      4062     3168
## depbetray_irtstressav:rural.ses.med4      3998     3116
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

10.1.6.5 Prior summary

out.chg.alldepress.stirt.comm.fit[[2]]
##                 prior     class                        coef group      resp
##                (flat)         b                                            
##          normal(0, 1)         b                                   depbetray
##          normal(0, 1)         b                 irtstressav       depbetray
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depbetray
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depbetray
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depbetray
##          normal(0, 1)         b                irtstresschg       depbetray
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depbetray
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depbetray
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depbetray
##          normal(0, 1)         b              rural.ses.med2       depbetray
##          normal(0, 1)         b              rural.ses.med3       depbetray
##          normal(0, 1)         b              rural.ses.med4       depbetray
##          normal(0, 1)         b                                    depblues
##          normal(0, 1)         b                 irtstressav        depblues
##          normal(0, 1)         b  irtstressav:rural.ses.med2        depblues
##          normal(0, 1)         b  irtstressav:rural.ses.med3        depblues
##          normal(0, 1)         b  irtstressav:rural.ses.med4        depblues
##          normal(0, 1)         b                irtstresschg        depblues
##          normal(0, 1)         b irtstresschg:rural.ses.med2        depblues
##          normal(0, 1)         b irtstresschg:rural.ses.med3        depblues
##          normal(0, 1)         b irtstresschg:rural.ses.med4        depblues
##          normal(0, 1)         b              rural.ses.med2        depblues
##          normal(0, 1)         b              rural.ses.med3        depblues
##          normal(0, 1)         b              rural.ses.med4        depblues
##          normal(0, 1)         b                                   depcantgo
##          normal(0, 1)         b                 irtstressav       depcantgo
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depcantgo
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depcantgo
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depcantgo
##          normal(0, 1)         b                irtstresschg       depcantgo
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depcantgo
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depcantgo
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depcantgo
##          normal(0, 1)         b              rural.ses.med2       depcantgo
##          normal(0, 1)         b              rural.ses.med3       depcantgo
##          normal(0, 1)         b              rural.ses.med4       depcantgo
##          normal(0, 1)         b                                   depeffort
##          normal(0, 1)         b                 irtstressav       depeffort
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depeffort
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depeffort
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depeffort
##          normal(0, 1)         b                irtstresschg       depeffort
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depeffort
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depeffort
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depeffort
##          normal(0, 1)         b              rural.ses.med2       depeffort
##          normal(0, 1)         b              rural.ses.med3       depeffort
##          normal(0, 1)         b              rural.ses.med4       depeffort
##          normal(0, 1)         b                                   deplonely
##          normal(0, 1)         b                 irtstressav       deplonely
##          normal(0, 1)         b  irtstressav:rural.ses.med2       deplonely
##          normal(0, 1)         b  irtstressav:rural.ses.med3       deplonely
##          normal(0, 1)         b  irtstressav:rural.ses.med4       deplonely
##          normal(0, 1)         b                irtstresschg       deplonely
##          normal(0, 1)         b irtstresschg:rural.ses.med2       deplonely
##          normal(0, 1)         b irtstresschg:rural.ses.med3       deplonely
##          normal(0, 1)         b irtstresschg:rural.ses.med4       deplonely
##          normal(0, 1)         b              rural.ses.med2       deplonely
##          normal(0, 1)         b              rural.ses.med3       deplonely
##          normal(0, 1)         b              rural.ses.med4       deplonely
##          normal(0, 1)         b                                   depmistrt
##          normal(0, 1)         b                 irtstressav       depmistrt
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depmistrt
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depmistrt
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depmistrt
##          normal(0, 1)         b                irtstresschg       depmistrt
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depmistrt
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depmistrt
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depmistrt
##          normal(0, 1)         b              rural.ses.med2       depmistrt
##          normal(0, 1)         b              rural.ses.med3       depmistrt
##          normal(0, 1)         b              rural.ses.med4       depmistrt
##          normal(0, 1)         b                                   depunfair
##          normal(0, 1)         b                 irtstressav       depunfair
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depunfair
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depunfair
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depunfair
##          normal(0, 1)         b                irtstresschg       depunfair
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depunfair
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depunfair
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depunfair
##          normal(0, 1)         b              rural.ses.med2       depunfair
##          normal(0, 1)         b              rural.ses.med3       depunfair
##          normal(0, 1)         b              rural.ses.med4       depunfair
##                (flat) Intercept                                            
##          normal(0, 2) Intercept                                   depbetray
##          normal(0, 2) Intercept                                    depblues
##          normal(0, 2) Intercept                                   depcantgo
##          normal(0, 2) Intercept                                   depeffort
##          normal(0, 2) Intercept                                   deplonely
##          normal(0, 2) Intercept                                   depmistrt
##          normal(0, 2) Intercept                                   depunfair
##  student_t(3, 0, 2.5)        sd                                   depbetray
##  student_t(3, 0, 2.5)        sd                                    depblues
##  student_t(3, 0, 2.5)        sd                                   depcantgo
##  student_t(3, 0, 2.5)        sd                                   depeffort
##  student_t(3, 0, 2.5)        sd                                   deplonely
##  student_t(3, 0, 2.5)        sd                                   depmistrt
##  student_t(3, 0, 2.5)        sd                                   depunfair
##  student_t(3, 0, 2.5)        sd                                id depbetray
##  student_t(3, 0, 2.5)        sd                   Intercept    id depbetray
##  student_t(3, 0, 2.5)        sd                                id  depblues
##  student_t(3, 0, 2.5)        sd                   Intercept    id  depblues
##  student_t(3, 0, 2.5)        sd                                id depcantgo
##  student_t(3, 0, 2.5)        sd                   Intercept    id depcantgo
##  student_t(3, 0, 2.5)        sd                                id depeffort
##  student_t(3, 0, 2.5)        sd                   Intercept    id depeffort
##  student_t(3, 0, 2.5)        sd                                id deplonely
##  student_t(3, 0, 2.5)        sd                   Intercept    id deplonely
##  student_t(3, 0, 2.5)        sd                                id depmistrt
##  student_t(3, 0, 2.5)        sd                   Intercept    id depmistrt
##  student_t(3, 0, 2.5)        sd                                id depunfair
##  student_t(3, 0, 2.5)        sd                   Intercept    id depunfair
##  dpar nlpar lb ub       source
##                        default
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)

10.1.7 Corr X Community: stdz sum stress & binary outcomes

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names)
  )

chg.prjcrime.stsum.comm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 + 
    sumstresschg + sumstressav + rural.ses.med + 
    sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id),   
      data = stress.long2, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      adapt_delta = 0.85,
      seed = 8675309, 
      file = "Models/chg_prjcrime_stsum_comm_fit",
      file_refit = "on_change"
  )

#Update function to call all ppchecks for bivar projected crime models
varlist <- c("^b_prjthflt5_sum","^b_prjthfgt5_sum", "^b_prjthreat_sum", 
             "^b_prjharm_sum", "^b_usedrg_sum", "^b_prjhack_sum") 
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="prjthflt5")
  ppcheckdv2 <-pp_check(modelfit, resp="prjthfgt5")
  ppcheckdv3 <-pp_check(modelfit, resp="prjthreat")
  ppcheckdv4 <-pp_check(modelfit, resp="prjharm")
  ppcheckdv5 <-pp_check(modelfit, resp="prjusedrg")
  ppcheckdv6 <-pp_check(modelfit, resp="prjhack")
  plotcoefs2 <- mcmc_plot(modelfit, variable = varlist, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for sum stress scale coefficients\nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, 
                    ppcheckdv3, ppcheckdv4, ppcheckdv5, ppcheckdv6, plotcoefs2)
  return(allchecks)
}

out.chg.prjcrime.stsum.comm.fit <- ppchecks(chg.prjcrime.stsum.comm.fit)

10.1.7.1 Coefficient plot (intervals)

out.chg.prjcrime.stsum.comm.fit[[9]] 

10.1.7.2 PPcheck (density)

p1 <- out.chg.prjcrime.stsum.comm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stsum.comm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stsum.comm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stsum.comm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stsum.comm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stsum.comm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

10.1.7.3 Fit summary

out.chg.prjcrime.stsum.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          prjthfgt5 ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          prjthreat ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          prjharm ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          prjusedrg ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          prjhack ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##    Data: stress.long2 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.76      0.54     2.81     4.94 1.01      953
## sd(prjthfgt5_Intercept)     3.33      0.49     2.45     4.40 1.00      969
## sd(prjthreat_Intercept)     3.15      0.53     2.17     4.26 1.00     1002
## sd(prjharm_Intercept)       3.01      0.54     2.08     4.18 1.00     1019
## sd(prjusedrg_Intercept)     2.76      0.51     1.85     3.84 1.00     1034
## sd(prjhack_Intercept)       0.83      0.55     0.04     1.97 1.00      435
##                         Tail_ESS
## sd(prjthflt5_Intercept)     1521
## sd(prjthfgt5_Intercept)     1665
## sd(prjthreat_Intercept)     1462
## sd(prjharm_Intercept)       2073
## sd(prjusedrg_Intercept)     1728
## sd(prjhack_Intercept)        789
## 
## Regression Coefficients:
##                                       Estimate Est.Error l-95% CI u-95% CI Rhat
## prjthflt5_Intercept                      -5.72      0.70    -7.16    -4.45 1.00
## prjthfgt5_Intercept                      -5.44      0.68    -6.86    -4.24 1.00
## prjthreat_Intercept                      -6.66      0.83    -8.43    -5.19 1.00
## prjharm_Intercept                        -6.49      0.86    -8.29    -4.93 1.00
## prjusedrg_Intercept                      -6.27      0.83    -8.04    -4.79 1.00
## prjhack_Intercept                        -4.51      0.61    -5.91    -3.49 1.00
## prjthflt5_sumstresschg                    0.52      0.63    -0.75     1.73 1.00
## prjthflt5_sumstressav                     0.47      0.46    -0.39     1.41 1.00
## prjthflt5_rural.ses.med2                 -1.43      0.67    -2.77    -0.11 1.00
## prjthflt5_rural.ses.med3                  1.06      0.60    -0.11     2.21 1.00
## prjthflt5_rural.ses.med4                  2.08      0.59     0.95     3.26 1.00
## prjthflt5_sumstresschg:rural.ses.med2    -0.49      0.91    -2.26     1.27 1.00
## prjthflt5_sumstresschg:rural.ses.med3     0.12      0.77    -1.42     1.67 1.00
## prjthflt5_sumstresschg:rural.ses.med4    -0.26      0.80    -1.81     1.33 1.00
## prjthflt5_sumstressav:rural.ses.med2      0.70      0.71    -0.69     2.13 1.00
## prjthflt5_sumstressav:rural.ses.med3      0.69      0.61    -0.50     1.89 1.00
## prjthflt5_sumstressav:rural.ses.med4     -0.28      0.58    -1.45     0.85 1.00
## prjthfgt5_sumstresschg                    0.85      0.65    -0.46     2.10 1.00
## prjthfgt5_sumstressav                     0.34      0.42    -0.45     1.16 1.00
## prjthfgt5_rural.ses.med2                 -1.53      0.65    -2.87    -0.25 1.00
## prjthfgt5_rural.ses.med3                  1.04      0.55    -0.03     2.19 1.00
## prjthfgt5_rural.ses.med4                  1.89      0.57     0.79     3.03 1.00
## prjthfgt5_sumstresschg:rural.ses.med2    -0.23      0.90    -2.00     1.57 1.00
## prjthfgt5_sumstresschg:rural.ses.med3    -0.12      0.79    -1.67     1.44 1.00
## prjthfgt5_sumstresschg:rural.ses.med4     0.21      0.82    -1.40     1.86 1.00
## prjthfgt5_sumstressav:rural.ses.med2      0.32      0.69    -1.03     1.73 1.00
## prjthfgt5_sumstressav:rural.ses.med3      0.59      0.55    -0.49     1.70 1.00
## prjthfgt5_sumstressav:rural.ses.med4      0.06      0.53    -0.95     1.09 1.00
## prjthreat_sumstresschg                   -0.44      0.72    -1.85     0.99 1.00
## prjthreat_sumstressav                     0.82      0.48    -0.10     1.81 1.00
## prjthreat_rural.ses.med2                 -0.88      0.71    -2.31     0.51 1.00
## prjthreat_rural.ses.med3                  0.40      0.64    -0.90     1.62 1.00
## prjthreat_rural.ses.med4                  1.46      0.63     0.21     2.72 1.00
## prjthreat_sumstresschg:rural.ses.med2     0.39      0.92    -1.42     2.21 1.00
## prjthreat_sumstresschg:rural.ses.med3    -0.16      0.83    -1.87     1.46 1.00
## prjthreat_sumstresschg:rural.ses.med4    -1.00      0.88    -2.71     0.71 1.00
## prjthreat_sumstressav:rural.ses.med2     -0.52      0.74    -1.94     0.94 1.00
## prjthreat_sumstressav:rural.ses.med3      0.23      0.63    -1.01     1.44 1.00
## prjthreat_sumstressav:rural.ses.med4      0.40      0.60    -0.78     1.55 1.00
## prjharm_sumstresschg                     -0.62      0.71    -2.01     0.77 1.00
## prjharm_sumstressav                       0.23      0.45    -0.63     1.14 1.00
## prjharm_rural.ses.med2                   -0.57      0.68    -1.89     0.73 1.00
## prjharm_rural.ses.med3                    0.21      0.63    -1.05     1.45 1.00
## prjharm_rural.ses.med4                    0.92      0.63    -0.34     2.13 1.00
## prjharm_sumstresschg:rural.ses.med2       0.08      0.88    -1.63     1.78 1.00
## prjharm_sumstresschg:rural.ses.med3       0.13      0.87    -1.55     1.81 1.00
## prjharm_sumstresschg:rural.ses.med4      -1.15      0.86    -2.81     0.59 1.00
## prjharm_sumstressav:rural.ses.med2       -0.74      0.66    -2.02     0.59 1.00
## prjharm_sumstressav:rural.ses.med3        0.37      0.63    -0.87     1.58 1.00
## prjharm_sumstressav:rural.ses.med4        0.41      0.61    -0.78     1.61 1.00
## prjusedrg_sumstresschg                   -0.26      0.75    -1.72     1.24 1.00
## prjusedrg_sumstressav                     0.50      0.48    -0.40     1.47 1.00
## prjusedrg_rural.ses.med2                 -0.62      0.67    -1.92     0.68 1.00
## prjusedrg_rural.ses.med3                 -0.59      0.66    -1.90     0.66 1.00
## prjusedrg_rural.ses.med4                  1.44      0.61     0.25     2.62 1.00
## prjusedrg_sumstresschg:rural.ses.med2     0.29      0.91    -1.51     2.07 1.00
## prjusedrg_sumstresschg:rural.ses.med3    -0.09      0.87    -1.80     1.63 1.00
## prjusedrg_sumstresschg:rural.ses.med4    -0.75      0.84    -2.37     0.93 1.00
## prjusedrg_sumstressav:rural.ses.med2     -0.78      0.67    -2.14     0.56 1.00
## prjusedrg_sumstressav:rural.ses.med3     -0.10      0.67    -1.39     1.21 1.00
## prjusedrg_sumstressav:rural.ses.med4      0.72      0.61    -0.45     1.91 1.00
## prjhack_sumstresschg                     -0.20      0.73    -1.59     1.24 1.00
## prjhack_sumstressav                       0.56      0.43    -0.24     1.42 1.00
## prjhack_rural.ses.med2                   -0.96      0.67    -2.33     0.30 1.00
## prjhack_rural.ses.med3                    0.20      0.53    -0.81     1.22 1.00
## prjhack_rural.ses.med4                    0.34      0.58    -0.79     1.46 1.00
## prjhack_sumstresschg:rural.ses.med2       0.45      0.94    -1.38     2.32 1.00
## prjhack_sumstresschg:rural.ses.med3      -0.12      0.84    -1.74     1.55 1.00
## prjhack_sumstresschg:rural.ses.med4      -1.06      0.86    -2.75     0.64 1.00
## prjhack_sumstressav:rural.ses.med2       -0.43      0.67    -1.72     0.87 1.00
## prjhack_sumstressav:rural.ses.med3       -0.36      0.55    -1.41     0.77 1.00
## prjhack_sumstressav:rural.ses.med4        0.55      0.55    -0.52     1.65 1.00
##                                       Bulk_ESS Tail_ESS
## prjthflt5_Intercept                       1297     2015
## prjthfgt5_Intercept                       1134     2247
## prjthreat_Intercept                       1326     2353
## prjharm_Intercept                         1249     2060
## prjusedrg_Intercept                       1306     2205
## prjhack_Intercept                          891     1049
## prjthflt5_sumstresschg                    3787     3066
## prjthflt5_sumstressav                     1439     2095
## prjthflt5_rural.ses.med2                  2403     2859
## prjthflt5_rural.ses.med3                  1753     2189
## prjthflt5_rural.ses.med4                  1800     2370
## prjthflt5_sumstresschg:rural.ses.med2     4729     2930
## prjthflt5_sumstresschg:rural.ses.med3     3886     3002
## prjthflt5_sumstresschg:rural.ses.med4     4236     2973
## prjthflt5_sumstressav:rural.ses.med2      1613     2122
## prjthflt5_sumstressav:rural.ses.med3      1684     1686
## prjthflt5_sumstressav:rural.ses.med4      1652     2288
## prjthfgt5_sumstresschg                    3207     3119
## prjthfgt5_sumstressav                     1655     2523
## prjthfgt5_rural.ses.med2                  2884     2849
## prjthfgt5_rural.ses.med3                  2035     2726
## prjthfgt5_rural.ses.med4                  2054     2602
## prjthfgt5_sumstresschg:rural.ses.med2     4606     2974
## prjthfgt5_sumstresschg:rural.ses.med3     3941     2727
## prjthfgt5_sumstresschg:rural.ses.med4     4059     3061
## prjthfgt5_sumstressav:rural.ses.med2      3088     2779
## prjthfgt5_sumstressav:rural.ses.med3      1605     2559
## prjthfgt5_sumstressav:rural.ses.med4      1672     2380
## prjthreat_sumstresschg                    3658     2958
## prjthreat_sumstressav                     2154     2492
## prjthreat_rural.ses.med2                  3403     2913
## prjthreat_rural.ses.med3                  2506     2695
## prjthreat_rural.ses.med4                  2290     2450
## prjthreat_sumstresschg:rural.ses.med2     4082     2874
## prjthreat_sumstresschg:rural.ses.med3     3886     2788
## prjthreat_sumstresschg:rural.ses.med4     3739     3015
## prjthreat_sumstressav:rural.ses.med2      3262     3187
## prjthreat_sumstressav:rural.ses.med3      2058     2755
## prjthreat_sumstressav:rural.ses.med4      2071     2593
## prjharm_sumstresschg                      3249     2811
## prjharm_sumstressav                       1740     2279
## prjharm_rural.ses.med2                    2534     2500
## prjharm_rural.ses.med3                    2347     2701
## prjharm_rural.ses.med4                    2387     2764
## prjharm_sumstresschg:rural.ses.med2       4190     3191
## prjharm_sumstresschg:rural.ses.med3       4641     2992
## prjharm_sumstresschg:rural.ses.med4       3611     3079
## prjharm_sumstressav:rural.ses.med2        2584     2868
## prjharm_sumstressav:rural.ses.med3        2545     2986
## prjharm_sumstressav:rural.ses.med4        2414     2808
## prjusedrg_sumstresschg                    4567     2994
## prjusedrg_sumstressav                     2077     2683
## prjusedrg_rural.ses.med2                  3262     2664
## prjusedrg_rural.ses.med3                  2710     2876
## prjusedrg_rural.ses.med4                  2559     2707
## prjusedrg_sumstresschg:rural.ses.med2     5259     2838
## prjusedrg_sumstresschg:rural.ses.med3     4787     2934
## prjusedrg_sumstresschg:rural.ses.med4     4537     2881
## prjusedrg_sumstressav:rural.ses.med2      2617     2899
## prjusedrg_sumstressav:rural.ses.med3      2849     2907
## prjusedrg_sumstressav:rural.ses.med4      1985     2727
## prjhack_sumstresschg                      3883     2969
## prjhack_sumstressav                       1596     2533
## prjhack_rural.ses.med2                    3970     2736
## prjhack_rural.ses.med3                    3179     3126
## prjhack_rural.ses.med4                    2718     2612
## prjhack_sumstresschg:rural.ses.med2       4637     3205
## prjhack_sumstresschg:rural.ses.med3       4003     2750
## prjhack_sumstresschg:rural.ses.med4       3796     2729
## prjhack_sumstressav:rural.ses.med2        2991     2913
## prjhack_sumstressav:rural.ses.med3        1994     2258
## prjhack_sumstressav:rural.ses.med4        1601     2091
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

10.1.7.4 Prior summary

out.chg.prjcrime.stsum.comm.fit[[2]]
##                 prior     class                        coef group      resp
##                (flat)         b                                            
##          normal(0, 1)         b                                     prjhack
##          normal(0, 1)         b              rural.ses.med2         prjhack
##          normal(0, 1)         b              rural.ses.med3         prjhack
##          normal(0, 1)         b              rural.ses.med4         prjhack
##          normal(0, 1)         b                 sumstressav         prjhack
##          normal(0, 1)         b  sumstressav:rural.ses.med2         prjhack
##          normal(0, 1)         b  sumstressav:rural.ses.med3         prjhack
##          normal(0, 1)         b  sumstressav:rural.ses.med4         prjhack
##          normal(0, 1)         b                sumstresschg         prjhack
##          normal(0, 1)         b sumstresschg:rural.ses.med2         prjhack
##          normal(0, 1)         b sumstresschg:rural.ses.med3         prjhack
##          normal(0, 1)         b sumstresschg:rural.ses.med4         prjhack
##          normal(0, 1)         b                                     prjharm
##          normal(0, 1)         b              rural.ses.med2         prjharm
##          normal(0, 1)         b              rural.ses.med3         prjharm
##          normal(0, 1)         b              rural.ses.med4         prjharm
##          normal(0, 1)         b                 sumstressav         prjharm
##          normal(0, 1)         b  sumstressav:rural.ses.med2         prjharm
##          normal(0, 1)         b  sumstressav:rural.ses.med3         prjharm
##          normal(0, 1)         b  sumstressav:rural.ses.med4         prjharm
##          normal(0, 1)         b                sumstresschg         prjharm
##          normal(0, 1)         b sumstresschg:rural.ses.med2         prjharm
##          normal(0, 1)         b sumstresschg:rural.ses.med3         prjharm
##          normal(0, 1)         b sumstresschg:rural.ses.med4         prjharm
##          normal(0, 1)         b                                   prjthfgt5
##          normal(0, 1)         b              rural.ses.med2       prjthfgt5
##          normal(0, 1)         b              rural.ses.med3       prjthfgt5
##          normal(0, 1)         b              rural.ses.med4       prjthfgt5
##          normal(0, 1)         b                 sumstressav       prjthfgt5
##          normal(0, 1)         b  sumstressav:rural.ses.med2       prjthfgt5
##          normal(0, 1)         b  sumstressav:rural.ses.med3       prjthfgt5
##          normal(0, 1)         b  sumstressav:rural.ses.med4       prjthfgt5
##          normal(0, 1)         b                sumstresschg       prjthfgt5
##          normal(0, 1)         b sumstresschg:rural.ses.med2       prjthfgt5
##          normal(0, 1)         b sumstresschg:rural.ses.med3       prjthfgt5
##          normal(0, 1)         b sumstresschg:rural.ses.med4       prjthfgt5
##          normal(0, 1)         b                                   prjthflt5
##          normal(0, 1)         b              rural.ses.med2       prjthflt5
##          normal(0, 1)         b              rural.ses.med3       prjthflt5
##          normal(0, 1)         b              rural.ses.med4       prjthflt5
##          normal(0, 1)         b                 sumstressav       prjthflt5
##          normal(0, 1)         b  sumstressav:rural.ses.med2       prjthflt5
##          normal(0, 1)         b  sumstressav:rural.ses.med3       prjthflt5
##          normal(0, 1)         b  sumstressav:rural.ses.med4       prjthflt5
##          normal(0, 1)         b                sumstresschg       prjthflt5
##          normal(0, 1)         b sumstresschg:rural.ses.med2       prjthflt5
##          normal(0, 1)         b sumstresschg:rural.ses.med3       prjthflt5
##          normal(0, 1)         b sumstresschg:rural.ses.med4       prjthflt5
##          normal(0, 1)         b                                   prjthreat
##          normal(0, 1)         b              rural.ses.med2       prjthreat
##          normal(0, 1)         b              rural.ses.med3       prjthreat
##          normal(0, 1)         b              rural.ses.med4       prjthreat
##          normal(0, 1)         b                 sumstressav       prjthreat
##          normal(0, 1)         b  sumstressav:rural.ses.med2       prjthreat
##          normal(0, 1)         b  sumstressav:rural.ses.med3       prjthreat
##          normal(0, 1)         b  sumstressav:rural.ses.med4       prjthreat
##          normal(0, 1)         b                sumstresschg       prjthreat
##          normal(0, 1)         b sumstresschg:rural.ses.med2       prjthreat
##          normal(0, 1)         b sumstresschg:rural.ses.med3       prjthreat
##          normal(0, 1)         b sumstresschg:rural.ses.med4       prjthreat
##          normal(0, 1)         b                                   prjusedrg
##          normal(0, 1)         b              rural.ses.med2       prjusedrg
##          normal(0, 1)         b              rural.ses.med3       prjusedrg
##          normal(0, 1)         b              rural.ses.med4       prjusedrg
##          normal(0, 1)         b                 sumstressav       prjusedrg
##          normal(0, 1)         b  sumstressav:rural.ses.med2       prjusedrg
##          normal(0, 1)         b  sumstressav:rural.ses.med3       prjusedrg
##          normal(0, 1)         b  sumstressav:rural.ses.med4       prjusedrg
##          normal(0, 1)         b                sumstresschg       prjusedrg
##          normal(0, 1)         b sumstresschg:rural.ses.med2       prjusedrg
##          normal(0, 1)         b sumstresschg:rural.ses.med3       prjusedrg
##          normal(0, 1)         b sumstresschg:rural.ses.med4       prjusedrg
##                (flat) Intercept                                            
##          normal(0, 2) Intercept                                     prjhack
##          normal(0, 2) Intercept                                     prjharm
##          normal(0, 2) Intercept                                   prjthfgt5
##          normal(0, 2) Intercept                                   prjthflt5
##          normal(0, 2) Intercept                                   prjthreat
##          normal(0, 2) Intercept                                   prjusedrg
##  student_t(3, 0, 2.5)        sd                                     prjhack
##  student_t(3, 0, 2.5)        sd                                     prjharm
##  student_t(3, 0, 2.5)        sd                                   prjthfgt5
##  student_t(3, 0, 2.5)        sd                                   prjthflt5
##  student_t(3, 0, 2.5)        sd                                   prjthreat
##  student_t(3, 0, 2.5)        sd                                   prjusedrg
##  student_t(3, 0, 2.5)        sd                                id   prjhack
##  student_t(3, 0, 2.5)        sd                   Intercept    id   prjhack
##  student_t(3, 0, 2.5)        sd                                id   prjharm
##  student_t(3, 0, 2.5)        sd                   Intercept    id   prjharm
##  student_t(3, 0, 2.5)        sd                                id prjthfgt5
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthfgt5
##  student_t(3, 0, 2.5)        sd                                id prjthflt5
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthflt5
##  student_t(3, 0, 2.5)        sd                                id prjthreat
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthreat
##  student_t(3, 0, 2.5)        sd                                id prjusedrg
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)

10.1.8 Corr X Community: stdz sum stress & any prj crime

# "Any crime" outcome & sum stress scale
prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept'),
  set_prior('normal(0, 1)', class = 'b')
  )

chg.anyprjcrime.stsum.comm.fit <- brm(prjany ~ 1 + 
    sumstresschg + sumstressav + rural.ses.med + 
    sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id),   
      data = stress.long2, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/chg_anyprjcrime_stsum_comm_fit",
      file_refit = "on_change"
    )

#Update function to call all ppchecks for bivar projected crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit)
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^b_sum", regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, plotcoefs2)
  return(allchecks)
}

out.chg.anyprjcrime.stsum.comm.fit <- ppchecks(chg.anyprjcrime.stsum.comm.fit)

10.1.8.1 Coefficient plot (intervals)

out.chg.anyprjcrime.stsum.comm.fit[[4]] 

10.1.8.2 PPcheck (density)

out.chg.anyprjcrime.stsum.comm.fit[[3]] + labs(title = "Any Crime Intent (chg)") 

10.1.8.3 Fit summary

out.chg.anyprjcrime.stsum.comm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##    Data: stress.long2 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.11      0.42     2.36     4.00 1.00      952     1756
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept                      -4.03      0.49    -5.05    -3.13 1.00     1635
## sumstresschg                    0.70      0.57    -0.43     1.83 1.00     3797
## sumstressav                     0.46      0.39    -0.29     1.23 1.00     1751
## rural.ses.med2                 -1.12      0.55    -2.21    -0.06 1.00     2579
## rural.ses.med3                  0.91      0.48    -0.03     1.84 1.00     2247
## rural.ses.med4                  2.25      0.52     1.25     3.31 1.00     2142
## sumstresschg:rural.ses.med2    -0.46      0.81    -2.11     1.16 1.00     5110
## sumstresschg:rural.ses.med3    -0.16      0.72    -1.60     1.29 1.00     4227
## sumstresschg:rural.ses.med4    -0.46      0.76    -1.93     1.04 1.00     3981
## sumstressav:rural.ses.med2     -0.31      0.56    -1.39     0.77 1.00     2271
## sumstressav:rural.ses.med3      0.31      0.50    -0.64     1.32 1.00     2016
## sumstressav:rural.ses.med4      0.03      0.49    -0.93     1.01 1.00     2045
##                             Tail_ESS
## Intercept                       2215
## sumstresschg                    2810
## sumstressav                     2452
## rural.ses.med2                  2742
## rural.ses.med3                  2777
## rural.ses.med4                  2579
## sumstresschg:rural.ses.med2     2371
## sumstresschg:rural.ses.med3     3077
## sumstresschg:rural.ses.med4     2967
## sumstressav:rural.ses.med2      2693
## sumstressav:rural.ses.med3      2713
## sumstressav:rural.ses.med4      2454
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

10.1.8.4 Prior summary

out.chg.anyprjcrime.stsum.comm.fit[[2]]
##                 prior     class                        coef group resp dpar
##          normal(0, 1)         b                                            
##          normal(0, 1)         b              rural.ses.med2                
##          normal(0, 1)         b              rural.ses.med3                
##          normal(0, 1)         b              rural.ses.med4                
##          normal(0, 1)         b                 sumstressav                
##          normal(0, 1)         b  sumstressav:rural.ses.med2                
##          normal(0, 1)         b  sumstressav:rural.ses.med3                
##          normal(0, 1)         b  sumstressav:rural.ses.med4                
##          normal(0, 1)         b                sumstresschg                
##          normal(0, 1)         b sumstresschg:rural.ses.med2                
##          normal(0, 1)         b sumstresschg:rural.ses.med3                
##          normal(0, 1)         b sumstresschg:rural.ses.med4                
##          normal(0, 2) Intercept                                            
##  student_t(3, 0, 2.5)        sd                                            
##  student_t(3, 0, 2.5)        sd                                id          
##  student_t(3, 0, 2.5)        sd                   Intercept    id          
##  nlpar lb ub       source
##                      user
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)

10.1.9 Corr X Community: stdz sum stress & negative emotions

#Vectorize priors:
prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names)
  )

chg.alldepress.stsum.comm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 + sumstresschg + sumstressav + 
         rural.ses.med + sumstresschg:rural.ses.med + 
         sumstressav:rural.ses.med + (1 | id),   
      data = stress.long2, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/chg_alldepress_stsum_comm_fit",
      file_refit = "on_change"
  )

##Update function to call all ppchecks for bivar neg emotions chg models
varlist1 <- c("^b_depcantgo_sum","^b_depeffort_sum", "^b_deplonely_sum", 
             "^b_depblues_sum") 
varlist2 <- c("^b_depunfair_sum", "^b_depmistrt_sum", "^b_depbetray_sum") 
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="depcantgo")
  ppcheckdv2 <-pp_check(modelfit, resp="depeffort")
  ppcheckdv3 <-pp_check(modelfit, resp="deplonely")
  ppcheckdv4 <-pp_check(modelfit, resp="depblues")
  ppcheckdv5 <-pp_check(modelfit, resp="depunfair")
  ppcheckdv6 <-pp_check(modelfit, resp="depmistrt")
  ppcheckdv7 <-pp_check(modelfit, resp="depbetray")
  plotcoefs1 <- mcmc_plot(modelfit, variable = varlist1, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients\nwith medians, 80%, and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = varlist2, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients\nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, ppcheckdv3, 
                    ppcheckdv4, ppcheckdv5, ppcheckdv6, ppcheckdv7, 
                    plotcoefs1, plotcoefs2)
  return(allchecks)
}

out.chg.alldepress.stsum.comm.fit <- ppchecks(chg.alldepress.stsum.comm.fit)

10.1.9.1 Coefficient plot (depressive symptoms)

out.chg.alldepress.stsum.comm.fit[[10]]

10.1.9.2 Coefficient plot (criminogenic emotions)

out.chg.alldepress.stsum.comm.fit[[11]]

10.1.9.3 PPcheck (density)

p1 <- out.chg.alldepress.stsum.comm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stsum.comm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stsum.comm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stsum.comm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stsum.comm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stsum.comm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stsum.comm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

10.1.9.4 Fit summary

out.chg.alldepress.stsum.comm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          depeffort ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          deplonely ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          depblues ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          depunfair ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          depmistrt ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##          depbetray ~ 1 + sumstresschg + sumstressav + rural.ses.med + sumstresschg:rural.ses.med + sumstressav:rural.ses.med + (1 | id) 
##    Data: stress.long2 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.38      0.21     0.03     0.79 1.00      538
## sd(depeffort_Intercept)     0.49      0.29     0.02     1.05 1.01      462
## sd(deplonely_Intercept)     0.48      0.26     0.03     0.97 1.02      378
## sd(depblues_Intercept)      0.67      0.32     0.05     1.26 1.01      466
## sd(depunfair_Intercept)     0.26      0.18     0.01     0.67 1.01      659
## sd(depmistrt_Intercept)     0.34      0.21     0.03     0.80 1.00      796
## sd(depbetray_Intercept)     0.41      0.25     0.02     0.94 1.00      650
##                         Tail_ESS
## sd(depcantgo_Intercept)     1295
## sd(depeffort_Intercept)      778
## sd(deplonely_Intercept)      875
## sd(depblues_Intercept)       882
## sd(depunfair_Intercept)     1550
## sd(depmistrt_Intercept)     1781
## sd(depbetray_Intercept)     1190
## 
## Regression Coefficients:
##                                       Estimate Est.Error l-95% CI u-95% CI Rhat
## depcantgo_Intercept                      -0.54      0.15    -0.84    -0.24 1.00
## depeffort_Intercept                      -2.08      0.23    -2.56    -1.65 1.00
## deplonely_Intercept                      -1.06      0.17    -1.41    -0.73 1.00
## depblues_Intercept                       -2.33      0.27    -2.88    -1.85 1.01
## depunfair_Intercept                      -1.57      0.18    -1.92    -1.23 1.00
## depmistrt_Intercept                      -2.02      0.22    -2.46    -1.61 1.00
## depbetray_Intercept                      -2.24      0.24    -2.73    -1.80 1.00
## depcantgo_sumstresschg                    1.42      0.45     0.53     2.31 1.00
## depcantgo_sumstressav                    -0.14      0.16    -0.45     0.16 1.00
## depcantgo_rural.ses.med2                  0.37      0.21    -0.04     0.77 1.00
## depcantgo_rural.ses.med3                  0.18      0.20    -0.20     0.56 1.00
## depcantgo_rural.ses.med4                  0.09      0.21    -0.34     0.51 1.00
## depcantgo_sumstresschg:rural.ses.med2     0.48      0.61    -0.73     1.69 1.00
## depcantgo_sumstresschg:rural.ses.med3    -1.26      0.56    -2.33    -0.17 1.00
## depcantgo_sumstresschg:rural.ses.med4    -0.21      0.66    -1.55     1.08 1.00
## depcantgo_sumstressav:rural.ses.med2      0.37      0.22    -0.05     0.79 1.00
## depcantgo_sumstressav:rural.ses.med3     -0.02      0.21    -0.44     0.39 1.00
## depcantgo_sumstressav:rural.ses.med4      0.23      0.21    -0.18     0.65 1.00
## depeffort_sumstresschg                    0.95      0.50    -0.03     1.94 1.00
## depeffort_sumstressav                    -0.15      0.20    -0.54     0.25 1.00
## depeffort_rural.ses.med2                  0.07      0.29    -0.49     0.64 1.00
## depeffort_rural.ses.med3                  0.51      0.27    -0.02     1.06 1.00
## depeffort_rural.ses.med4                  0.55      0.28    -0.00     1.13 1.00
## depeffort_sumstresschg:rural.ses.med2    -0.20      0.70    -1.59     1.12 1.00
## depeffort_sumstresschg:rural.ses.med3    -0.14      0.62    -1.36     1.10 1.00
## depeffort_sumstresschg:rural.ses.med4    -0.12      0.71    -1.54     1.22 1.00
## depeffort_sumstressav:rural.ses.med2      0.25      0.29    -0.33     0.82 1.00
## depeffort_sumstressav:rural.ses.med3      0.20      0.27    -0.33     0.72 1.00
## depeffort_sumstressav:rural.ses.med4      0.35      0.27    -0.18     0.88 1.00
## deplonely_sumstresschg                    0.94      0.45     0.09     1.84 1.00
## deplonely_sumstressav                    -0.08      0.16    -0.41     0.22 1.00
## deplonely_rural.ses.med2                 -0.39      0.23    -0.86     0.06 1.00
## deplonely_rural.ses.med3                 -0.06      0.22    -0.49     0.37 1.00
## deplonely_rural.ses.med4                  0.41      0.23    -0.02     0.87 1.00
## deplonely_sumstresschg:rural.ses.med2     0.29      0.64    -0.93     1.60 1.00
## deplonely_sumstresschg:rural.ses.med3    -0.66      0.56    -1.75     0.42 1.00
## deplonely_sumstresschg:rural.ses.med4     0.79      0.65    -0.47     2.07 1.00
## deplonely_sumstressav:rural.ses.med2      0.04      0.24    -0.42     0.52 1.00
## deplonely_sumstressav:rural.ses.med3      0.25      0.23    -0.19     0.71 1.00
## deplonely_sumstressav:rural.ses.med4      0.18      0.22    -0.25     0.62 1.00
## depblues_sumstresschg                    -0.22      0.53    -1.26     0.84 1.00
## depblues_sumstressav                     -0.08      0.23    -0.52     0.37 1.00
## depblues_rural.ses.med2                   0.10      0.31    -0.51     0.68 1.00
## depblues_rural.ses.med3                   0.25      0.30    -0.35     0.84 1.00
## depblues_rural.ses.med4                   0.50      0.31    -0.10     1.12 1.00
## depblues_sumstresschg:rural.ses.med2     -0.28      0.71    -1.67     1.10 1.00
## depblues_sumstresschg:rural.ses.med3      0.20      0.65    -1.13     1.45 1.00
## depblues_sumstresschg:rural.ses.med4      0.25      0.73    -1.16     1.68 1.00
## depblues_sumstressav:rural.ses.med2      -0.50      0.32    -1.13     0.12 1.00
## depblues_sumstressav:rural.ses.med3       0.53      0.30    -0.06     1.10 1.00
## depblues_sumstressav:rural.ses.med4       0.51      0.31    -0.10     1.11 1.00
## depunfair_sumstresschg                    1.84      0.47     0.94     2.77 1.00
## depunfair_sumstressav                     0.20      0.19    -0.18     0.58 1.00
## depunfair_rural.ses.med2                  0.26      0.23    -0.19     0.72 1.00
## depunfair_rural.ses.med3                  0.62      0.22     0.19     1.06 1.00
## depunfair_rural.ses.med4                  0.89      0.23     0.45     1.36 1.00
## depunfair_sumstresschg:rural.ses.med2     0.47      0.66    -0.83     1.74 1.00
## depunfair_sumstresschg:rural.ses.med3    -0.87      0.57    -1.97     0.24 1.00
## depunfair_sumstresschg:rural.ses.med4     0.73      0.69    -0.64     2.15 1.00
## depunfair_sumstressav:rural.ses.med2     -0.08      0.26    -0.58     0.42 1.00
## depunfair_sumstressav:rural.ses.med3      0.13      0.24    -0.36     0.60 1.00
## depunfair_sumstressav:rural.ses.med4      0.07      0.24    -0.39     0.55 1.00
## depmistrt_sumstresschg                    0.94      0.52    -0.09     1.96 1.00
## depmistrt_sumstressav                     0.38      0.23    -0.05     0.84 1.00
## depmistrt_rural.ses.med2                  0.53      0.27     0.01     1.06 1.00
## depmistrt_rural.ses.med3                  0.41      0.27    -0.12     0.94 1.00
## depmistrt_rural.ses.med4                  0.46      0.30    -0.12     1.04 1.00
## depmistrt_sumstresschg:rural.ses.med2    -0.12      0.67    -1.41     1.18 1.00
## depmistrt_sumstresschg:rural.ses.med3    -0.85      0.64    -2.10     0.41 1.00
## depmistrt_sumstresschg:rural.ses.med4     0.44      0.72    -0.97     1.85 1.00
## depmistrt_sumstressav:rural.ses.med2      0.05      0.30    -0.53     0.62 1.00
## depmistrt_sumstressav:rural.ses.med3      0.00      0.29    -0.58     0.57 1.00
## depmistrt_sumstressav:rural.ses.med4      0.19      0.30    -0.38     0.77 1.00
## depbetray_sumstresschg                    1.26      0.52     0.23     2.30 1.00
## depbetray_sumstressav                     0.32      0.24    -0.13     0.80 1.00
## depbetray_rural.ses.med2                  0.44      0.29    -0.12     1.00 1.00
## depbetray_rural.ses.med3                  0.62      0.28     0.06     1.17 1.00
## depbetray_rural.ses.med4                  0.68      0.30     0.07     1.27 1.00
## depbetray_sumstresschg:rural.ses.med2     0.18      0.70    -1.22     1.54 1.00
## depbetray_sumstresschg:rural.ses.med3    -0.70      0.63    -1.95     0.56 1.00
## depbetray_sumstresschg:rural.ses.med4    -0.23      0.69    -1.57     1.12 1.00
## depbetray_sumstressav:rural.ses.med2      0.03      0.31    -0.60     0.64 1.00
## depbetray_sumstressav:rural.ses.med3      0.14      0.30    -0.46     0.70 1.00
## depbetray_sumstressav:rural.ses.med4      0.51      0.31    -0.08     1.12 1.00
##                                       Bulk_ESS Tail_ESS
## depcantgo_Intercept                       3413     2586
## depeffort_Intercept                       2135     2694
## deplonely_Intercept                       2425     2948
## depblues_Intercept                        1459     2707
## depunfair_Intercept                       3099     2843
## depmistrt_Intercept                       2694     2748
## depbetray_Intercept                       2824     2736
## depcantgo_sumstresschg                    3561     3045
## depcantgo_sumstressav                     2349     2364
## depcantgo_rural.ses.med2                  3742     3180
## depcantgo_rural.ses.med3                  3659     2692
## depcantgo_rural.ses.med4                  4078     3089
## depcantgo_sumstresschg:rural.ses.med2     4126     2952
## depcantgo_sumstresschg:rural.ses.med3     4258     3664
## depcantgo_sumstresschg:rural.ses.med4     5247     3357
## depcantgo_sumstressav:rural.ses.med2      2692     2950
## depcantgo_sumstressav:rural.ses.med3      2590     2737
## depcantgo_sumstressav:rural.ses.med4      3142     2748
## depeffort_sumstresschg                    3564     2755
## depeffort_sumstressav                     1925     2028
## depeffort_rural.ses.med2                  3611     2657
## depeffort_rural.ses.med3                  3775     2905
## depeffort_rural.ses.med4                  3585     2941
## depeffort_sumstresschg:rural.ses.med2     5705     2837
## depeffort_sumstresschg:rural.ses.med3     4136     3008
## depeffort_sumstresschg:rural.ses.med4     5588     2668
## depeffort_sumstressav:rural.ses.med2      2800     2965
## depeffort_sumstressav:rural.ses.med3      2169     2684
## depeffort_sumstressav:rural.ses.med4      2082     2420
## deplonely_sumstresschg                    3337     3018
## deplonely_sumstressav                     2288     2742
## deplonely_rural.ses.med2                  3851     3588
## deplonely_rural.ses.med3                  3918     2887
## deplonely_rural.ses.med4                  4023     3299
## deplonely_sumstresschg:rural.ses.med2     5073     3045
## deplonely_sumstresschg:rural.ses.med3     4146     3237
## deplonely_sumstresschg:rural.ses.med4     4518     3233
## deplonely_sumstressav:rural.ses.med2      3221     3416
## deplonely_sumstressav:rural.ses.med3      2754     2921
## deplonely_sumstressav:rural.ses.med4      2798     2969
## depblues_sumstresschg                     3593     2882
## depblues_sumstressav                      2505     2886
## depblues_rural.ses.med2                   3302     2820
## depblues_rural.ses.med3                   3225     3348
## depblues_rural.ses.med4                   3196     3051
## depblues_sumstresschg:rural.ses.med2      6058     3143
## depblues_sumstresschg:rural.ses.med3      4774     2986
## depblues_sumstresschg:rural.ses.med4      4978     3068
## depblues_sumstressav:rural.ses.med2       2944     3154
## depblues_sumstressav:rural.ses.med3       2964     2927
## depblues_sumstressav:rural.ses.med4       2964     3206
## depunfair_sumstresschg                    3698     3133
## depunfair_sumstressav                     2197     2770
## depunfair_rural.ses.med2                  4083     3156
## depunfair_rural.ses.med3                  3803     3241
## depunfair_rural.ses.med4                  3541     3268
## depunfair_sumstresschg:rural.ses.med2     5329     3347
## depunfair_sumstresschg:rural.ses.med3     3549     3157
## depunfair_sumstresschg:rural.ses.med4     5318     3403
## depunfair_sumstressav:rural.ses.med2      2948     3016
## depunfair_sumstressav:rural.ses.med3      2609     3024
## depunfair_sumstressav:rural.ses.med4      2580     2811
## depmistrt_sumstresschg                    3414     2816
## depmistrt_sumstressav                     3004     3112
## depmistrt_rural.ses.med2                  3375     2785
## depmistrt_rural.ses.med3                  3091     2739
## depmistrt_rural.ses.med4                  3599     2684
## depmistrt_sumstresschg:rural.ses.med2     4784     3045
## depmistrt_sumstresschg:rural.ses.med3     4214     3062
## depmistrt_sumstresschg:rural.ses.med4     5671     3286
## depmistrt_sumstressav:rural.ses.med2      3300     3184
## depmistrt_sumstressav:rural.ses.med3      3480     3580
## depmistrt_sumstressav:rural.ses.med4      3517     3191
## depbetray_sumstresschg                    3746     2974
## depbetray_sumstressav                     2212     2542
## depbetray_rural.ses.med2                  4004     3251
## depbetray_rural.ses.med3                  3911     3015
## depbetray_rural.ses.med4                  4060     3272
## depbetray_sumstresschg:rural.ses.med2     5151     3107
## depbetray_sumstresschg:rural.ses.med3     4685     3132
## depbetray_sumstresschg:rural.ses.med4     6072     3353
## depbetray_sumstressav:rural.ses.med2      2537     3147
## depbetray_sumstressav:rural.ses.med3      2749     2709
## depbetray_sumstressav:rural.ses.med4      2716     3140
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

10.1.9.5 Prior summary

out.chg.alldepress.stirt.comm.fit[[2]]
##                 prior     class                        coef group      resp
##                (flat)         b                                            
##          normal(0, 1)         b                                   depbetray
##          normal(0, 1)         b                 irtstressav       depbetray
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depbetray
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depbetray
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depbetray
##          normal(0, 1)         b                irtstresschg       depbetray
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depbetray
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depbetray
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depbetray
##          normal(0, 1)         b              rural.ses.med2       depbetray
##          normal(0, 1)         b              rural.ses.med3       depbetray
##          normal(0, 1)         b              rural.ses.med4       depbetray
##          normal(0, 1)         b                                    depblues
##          normal(0, 1)         b                 irtstressav        depblues
##          normal(0, 1)         b  irtstressav:rural.ses.med2        depblues
##          normal(0, 1)         b  irtstressav:rural.ses.med3        depblues
##          normal(0, 1)         b  irtstressav:rural.ses.med4        depblues
##          normal(0, 1)         b                irtstresschg        depblues
##          normal(0, 1)         b irtstresschg:rural.ses.med2        depblues
##          normal(0, 1)         b irtstresschg:rural.ses.med3        depblues
##          normal(0, 1)         b irtstresschg:rural.ses.med4        depblues
##          normal(0, 1)         b              rural.ses.med2        depblues
##          normal(0, 1)         b              rural.ses.med3        depblues
##          normal(0, 1)         b              rural.ses.med4        depblues
##          normal(0, 1)         b                                   depcantgo
##          normal(0, 1)         b                 irtstressav       depcantgo
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depcantgo
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depcantgo
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depcantgo
##          normal(0, 1)         b                irtstresschg       depcantgo
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depcantgo
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depcantgo
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depcantgo
##          normal(0, 1)         b              rural.ses.med2       depcantgo
##          normal(0, 1)         b              rural.ses.med3       depcantgo
##          normal(0, 1)         b              rural.ses.med4       depcantgo
##          normal(0, 1)         b                                   depeffort
##          normal(0, 1)         b                 irtstressav       depeffort
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depeffort
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depeffort
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depeffort
##          normal(0, 1)         b                irtstresschg       depeffort
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depeffort
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depeffort
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depeffort
##          normal(0, 1)         b              rural.ses.med2       depeffort
##          normal(0, 1)         b              rural.ses.med3       depeffort
##          normal(0, 1)         b              rural.ses.med4       depeffort
##          normal(0, 1)         b                                   deplonely
##          normal(0, 1)         b                 irtstressav       deplonely
##          normal(0, 1)         b  irtstressav:rural.ses.med2       deplonely
##          normal(0, 1)         b  irtstressav:rural.ses.med3       deplonely
##          normal(0, 1)         b  irtstressav:rural.ses.med4       deplonely
##          normal(0, 1)         b                irtstresschg       deplonely
##          normal(0, 1)         b irtstresschg:rural.ses.med2       deplonely
##          normal(0, 1)         b irtstresschg:rural.ses.med3       deplonely
##          normal(0, 1)         b irtstresschg:rural.ses.med4       deplonely
##          normal(0, 1)         b              rural.ses.med2       deplonely
##          normal(0, 1)         b              rural.ses.med3       deplonely
##          normal(0, 1)         b              rural.ses.med4       deplonely
##          normal(0, 1)         b                                   depmistrt
##          normal(0, 1)         b                 irtstressav       depmistrt
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depmistrt
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depmistrt
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depmistrt
##          normal(0, 1)         b                irtstresschg       depmistrt
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depmistrt
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depmistrt
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depmistrt
##          normal(0, 1)         b              rural.ses.med2       depmistrt
##          normal(0, 1)         b              rural.ses.med3       depmistrt
##          normal(0, 1)         b              rural.ses.med4       depmistrt
##          normal(0, 1)         b                                   depunfair
##          normal(0, 1)         b                 irtstressav       depunfair
##          normal(0, 1)         b  irtstressav:rural.ses.med2       depunfair
##          normal(0, 1)         b  irtstressav:rural.ses.med3       depunfair
##          normal(0, 1)         b  irtstressav:rural.ses.med4       depunfair
##          normal(0, 1)         b                irtstresschg       depunfair
##          normal(0, 1)         b irtstresschg:rural.ses.med2       depunfair
##          normal(0, 1)         b irtstresschg:rural.ses.med3       depunfair
##          normal(0, 1)         b irtstresschg:rural.ses.med4       depunfair
##          normal(0, 1)         b              rural.ses.med2       depunfair
##          normal(0, 1)         b              rural.ses.med3       depunfair
##          normal(0, 1)         b              rural.ses.med4       depunfair
##                (flat) Intercept                                            
##          normal(0, 2) Intercept                                   depbetray
##          normal(0, 2) Intercept                                    depblues
##          normal(0, 2) Intercept                                   depcantgo
##          normal(0, 2) Intercept                                   depeffort
##          normal(0, 2) Intercept                                   deplonely
##          normal(0, 2) Intercept                                   depmistrt
##          normal(0, 2) Intercept                                   depunfair
##  student_t(3, 0, 2.5)        sd                                   depbetray
##  student_t(3, 0, 2.5)        sd                                    depblues
##  student_t(3, 0, 2.5)        sd                                   depcantgo
##  student_t(3, 0, 2.5)        sd                                   depeffort
##  student_t(3, 0, 2.5)        sd                                   deplonely
##  student_t(3, 0, 2.5)        sd                                   depmistrt
##  student_t(3, 0, 2.5)        sd                                   depunfair
##  student_t(3, 0, 2.5)        sd                                id depbetray
##  student_t(3, 0, 2.5)        sd                   Intercept    id depbetray
##  student_t(3, 0, 2.5)        sd                                id  depblues
##  student_t(3, 0, 2.5)        sd                   Intercept    id  depblues
##  student_t(3, 0, 2.5)        sd                                id depcantgo
##  student_t(3, 0, 2.5)        sd                   Intercept    id depcantgo
##  student_t(3, 0, 2.5)        sd                                id depeffort
##  student_t(3, 0, 2.5)        sd                   Intercept    id depeffort
##  student_t(3, 0, 2.5)        sd                                id deplonely
##  student_t(3, 0, 2.5)        sd                   Intercept    id deplonely
##  student_t(3, 0, 2.5)        sd                                id depmistrt
##  student_t(3, 0, 2.5)        sd                   Intercept    id depmistrt
##  student_t(3, 0, 2.5)        sd                                id depunfair
##  student_t(3, 0, 2.5)        sd                   Intercept    id depunfair
##  dpar nlpar lb ub       source
##                        default
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)

10.1.10 Predictive Marginal Contrasts x Comm (IRT & Sum Stress / Crim Intent)

# generate new data grid for specific change contrasts (average over irtstressav)
  # keep only 1-unit IRT scale increases from year 1 to year 2 (contrast .5_t2 - -.5_t1)
newdata <- stress.long2 %>% 
  data_grid(irtstresschg = c(-.5, .5),
              irtstressav,
              rural.ses.med, 
              year) %>%     
  filter(irtstresschg == -0.5  & year == "1" |
           irtstresschg == 0.5 & year == "2")

# function to generate epred draws 
gen_predmarg_data_comm <- function(mymodelfit, xdev){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(.category, rural.ses.med, {{xdev}}, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`))
}

#use function to generate epred draws
predmarg_stirt_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.stirt.comm.fit, irtstresschg)
predmarg_stirt_negemots_chg_comm = gen_predmarg_data_comm(chg.alldepress.stirt.comm.fit, irtstresschg)

#generate epred draws for "any crime" outcome & merge w/prjcrm epred draws
predmarg_stirt_anyprjcrim_chg_comm = 
  epred_draws(chg.prjcrime.stirt.comm.fit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(rural.ses.med, irtstresschg, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`)) %>%
  ungroup() %>%
  mutate(.category="prjany")
predmarg_stirt_prjcrim_chg_comm <- bind_rows(predmarg_stirt_prjcrim_chg_comm, 
                                        predmarg_stirt_anyprjcrim_chg_comm)
rm(predmarg_stirt_anyprjcrim_chg_comm) #clean environment

#repeat with sum stress scale
newdata <- stress.long2 %>% 
  data_grid(sumstresschg = c(-.5, .5),
              sumstressav,
              rural.ses.med, 
              year) %>%     
  filter(sumstresschg == -0.5  & year == "1" |
           sumstresschg == 0.5 & year == "2")

predmarg_stsum_prjcrim_chg_comm = gen_predmarg_data_comm(chg.prjcrime.stsum.comm.fit, sumstresschg)
predmarg_stsum_negemots_chg_comm = gen_predmarg_data_comm(chg.alldepress.stsum.comm.fit, sumstresschg)

#generate epred draws for "any crime" outcome & merge w/prjcrm epred draws
predmarg_stsum_anyprjcrim_chg_comm = 
  epred_draws(chg.anyprjcrime.stsum.comm.fit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(rural.ses.med, sumstresschg, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`)) %>%
  ungroup() %>%
  mutate(.category="prjany")
predmarg_stsum_prjcrim_chg_comm <- bind_rows(predmarg_stsum_prjcrim_chg_comm, 
                                        predmarg_stsum_anyprjcrim_chg_comm)
rm(predmarg_stsum_anyprjcrim_chg_comm) #clean environment


# function to calculate marginal contrasts
calc_ME_chg_comm <- function(predmarg_data, xdev) {
  predmarg_data %>%
    compare_levels(`E[y|xdev]`, by = xdev) %>%  # pairwise diffs in `E[y|x]`, by levels of x
    group_by(rural.ses.med) %>% # generate community-specific marginal contrasts
    rename(`PLME` = `E[y|xdev]`) # easy colname reflecting ME 2-unit chg contrast
}


#outputs community-specific predicted differences in E[y] 
# associated with 1-IRT AVE scale increase in stress (T2-T1, -.5 to .5) 
  #marg effect contrasts are marginalized over all person-level avg values of stress (AME)

#generate ME contrasts & add alpha indicator
PLME2_stirt_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stirt_prjcrim_chg_comm, "irtstresschg") %>%
      mutate(stress_var = "IRT Stress:\nWithin Person\nChange",
             dif_label = "diff in E[y|stress diff or increase]",
             method="irtchg") %>%
      rename(contrast = irtstresschg)}, file="cache_9_1")

PLME2_stirt_prjcrim_chg_comm <- PLME2_stirt_prjcrim_chg_comm %>% 
  group_by(.category, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1"))) %>% 
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5", "prjthfgt5", "prjthreat",
                                "prjharm", "prjusedrg", "prjhack", 
                                "prjany"))
  )

PLME2_stirt_negemots_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stirt_negemots_chg_comm, "irtstresschg") %>%
      mutate(stress_var = "IRT Stress:\nWithin Person\nChange",
             dif_label = "diff in E[y|stress diff or increase]",
             method="irtchg") %>%
      rename(contrast = irtstresschg)}, file="cache_9_2")

PLME2_stirt_negemots_chg_comm <- PLME2_stirt_negemots_chg_comm %>%
  group_by(.category, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1"))) 

#repeat for sum stress scale
PLME2_stsum_prjcrim_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stsum_prjcrim_chg_comm, "sumstresschg") %>%
      mutate(stress_var = "Sum Stress:\nWithin Person\nChange",
             dif_label = "diff in E[y|stress diff or increase]",
             method="sumchg") %>%
      rename(contrast = sumstresschg)}, file="cache_9_3")

PLME2_stsum_prjcrim_chg_comm <- PLME2_stsum_prjcrim_chg_comm %>% 
  group_by(.category, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1"))) %>% 
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5", "prjthfgt5", "prjthreat",
                                "prjharm", "prjusedrg", "prjhack", 
                                "prjany"))
  )


PLME2_stsum_negemots_chg_comm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stsum_negemots_chg_comm, "sumstresschg") %>%
      mutate(stress_var = "Sum Stress:\nWithin Person\nChange",
             dif_label = "diff in E[y|stress diff or increase]",
             method="sumchg") %>%
      rename(contrast = sumstresschg)}, file="cache_9_4")

PLME2_stsum_negemots_chg_comm <- PLME2_stsum_negemots_chg_comm %>%
  group_by(.category, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1"))) 
# levels(PLME2_stsum_negemots_chg_comm$p80_gt0)
  # NOTE: specify factor level for p80_gt0 indicator 
  # using as.factor() w/out specifying results in reversed levels in this object


# REPEAT FOR BETWEEN-PERSON DIFF ESTIMATES
# marginalize btw-per 1-0 diff contrast estimates across values of w/in person change & year

# NOTE: base rate probs differ across irtstressav scale, so could collapse representative 
# contrasts across scale (-1 - -2, -.5 - -1.5, 0 - -1, .5 - -.5, 1 - 0, 1.5 - .5)
# attempted but too computationally intensive 

newdata <- stress.long2 %>% 
  data_grid(irtstressav = c(0,1),
              irtstresschg,
              rural.ses.med, 
              year) 

# function to generate epred draws 
gen_predmarg_data_comm <- function(mymodelfit, xdif){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(.category, rural.ses.med, {{xdif}}, .draw) %>%
  summarise(`E[y|xdif]` = mean(`.epred`))
}

#use function to generate epred draws
predmarg_stirt_prjcrim_av_comm = gen_predmarg_data_comm(chg.prjcrime.stirt.comm.fit, irtstressav)
predmarg_stirt_negemots_av_comm = gen_predmarg_data_comm(chg.alldepress.stirt.comm.fit, irtstressav)

#generate epred draws for "any crime" outcome & merge w/prjcrm epred draws
predmarg_stirt_anyprjcrim_av_comm = 
  epred_draws(chg.anyprjcrime.stirt.comm.fit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(rural.ses.med, irtstressav, .draw) %>%
  summarise(`E[y|xdif]` = mean(`.epred`)) %>%
  ungroup() %>%
  mutate(.category="prjany")

predmarg_stirt_prjcrim_av_comm <- bind_rows(predmarg_stirt_prjcrim_av_comm, 
                                        predmarg_stirt_anyprjcrim_av_comm)
rm(predmarg_stirt_anyprjcrim_av_comm) #clean environment

#repeat with sum scale 
newdata <- stress.long2 %>% 
  data_grid(sumstressav = c(0,1),
              sumstresschg,
              rural.ses.med, 
              year) 

predmarg_stsum_prjcrim_av_comm = gen_predmarg_data_comm(chg.prjcrime.stsum.comm.fit, sumstressav)
predmarg_stsum_negemots_av_comm = gen_predmarg_data_comm(chg.alldepress.stsum.comm.fit, sumstressav)

#generate epred draws for "any crime" outcome & merge w/prjcrm epred draws
predmarg_stsum_anyprjcrim_av_comm = 
  epred_draws(chg.anyprjcrime.stsum.comm.fit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(rural.ses.med, sumstressav, .draw) %>%
  summarise(`E[y|xdif]` = mean(`.epred`)) %>%
  ungroup() %>%
  mutate(.category="prjany")

predmarg_stsum_prjcrim_av_comm <- bind_rows(predmarg_stsum_prjcrim_av_comm, 
                                        predmarg_stsum_anyprjcrim_av_comm)
rm(predmarg_stsum_anyprjcrim_av_comm) #clean environment


calc_ME_diff_comm <- function(predmarg_data, xdif) {
  predmarg_data %>%
    compare_levels(`E[y|xdif]`, by = xdif) %>%  # pairwise diffs in `E[y|x]`, by levels of x
    group_by(rural.ses.med) %>% # generate community-specific marginal contrasts
    rename(`PLME` = `E[y|xdif]`) # easy colname reflecting ME 2-unit chg contrast
}

#generate ME contrasts & add alpha indicator 
PLME2_stirt_prjcrim_av_comm = xfun::cache_rds({calc_ME_diff_comm(predmarg_stirt_prjcrim_av_comm, "irtstressav") %>%
      mutate(stress_var = "IRT Stress:\nBetween Person\nDifference",
             dif_label = "diff in E[y|stress diff or increase]",
             method="irtav") %>%
      rename(contrast = irtstressav)}, file="cache_9_5")

PLME2_stirt_prjcrim_av_comm <- PLME2_stirt_prjcrim_av_comm %>%
  group_by(.category, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1"))) %>% 
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5", "prjthfgt5", "prjthreat",
                                "prjharm", "prjusedrg", "prjhack", 
                                "prjany"))
  )


PLME2_stirt_negemots_av_comm = xfun::cache_rds({calc_ME_diff_comm(predmarg_stirt_negemots_av_comm, "irtstressav") %>%
      mutate(stress_var = "IRT Stress:\nBetween Person\nDifference",
             dif_label = "diff in E[y|stress diff or increase]",
             method="irtav") %>%
      rename(contrast = irtstressav)}, file="cache_9_6")

PLME2_stirt_negemots_av_comm <- PLME2_stirt_negemots_av_comm %>%
  group_by(.category, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1"))) 


#repeat for sum scale 
PLME2_stsum_prjcrim_av_comm = xfun::cache_rds({calc_ME_diff_comm(predmarg_stsum_prjcrim_av_comm, "sumstressav") %>%
      mutate(stress_var = "Sum Stress:\nBetween Person\nDifference",
             dif_label = "diff in E[y|stress diff or increase]",
             method="sumav") %>%
      rename(contrast = sumstressav)}, file="cache_9_7")

PLME2_stsum_prjcrim_av_comm <- PLME2_stsum_prjcrim_av_comm %>%
  group_by(.category, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1"))) %>% 
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5", "prjthfgt5", "prjthreat",
                                "prjharm", "prjusedrg", "prjhack", 
                                "prjany"))
  )

PLME2_stsum_negemots_av_comm = xfun::cache_rds({calc_ME_diff_comm(predmarg_stsum_negemots_av_comm, "sumstressav") %>%
      mutate(stress_var = "Sum Stress:\nBetween Person\nDifference",
             dif_label = "diff in E[y|stress diff or increase]",
             method="sumav") %>%
      rename(contrast = sumstressav)}, file="cache_9_8")

PLME2_stsum_negemots_av_comm <- PLME2_stsum_negemots_av_comm %>%
  group_by(.category, rural.ses.med) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1"))) 

10.2 APPENDIX 1: PLME Composite Stress Scales/Outcome Change X Community

#function to find & drop leading zeroes (used for x-axis label)
dropLeadingZero <- function(l){
  str_replace(l, '0(?=.)', '')
}

numcommlabs2 <- c("1"="Rural\nLowSES", 
              "2"="Rural\nHighSES", 
              "3"="Urban\nLowSES", 
              "4"="Urban\nHighSES")
prjlabs2 <- c(
  "prjthflt5"="Theft\n<5BAM", 
  "prjthfgt5"="Theft\n>5BAM", 
  "prjthreat"="Threat", 
  "prjharm"="Phys.\nharm",
  "prjusedrg"="Use\ndrugs",
  "prjhack"="Hack\ninfo", 
  "prjany"="Any crime")
deplabs2 <- c(
  "depcantgo"="Can't\ngo", 
  "depeffort"="Effort", 
  "deplonely"="Lonely", 
  "depblues"="Blues",
  "depunfair"="Unfair",
  "depmistrt"="Mistreated",
  "depbetray"="Betrayed")

methodlabs <- c(
  "irtav"="Between-Person Difference\nEstimator (IRT Scale)", 
  "irtchg"="Within-Person Change\nEstimator (IRT Scale)", 
  "sumav"="Between-Person Difference\nEstimator (Sum Scale)", 
  "sumchg"="Within-Person Change\nEstimator (Sum Scale)")


irtprjcommplot <- ggplot(data = PLME2_stirt_prjcrim_chg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.med, desc(rural.ses.med)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(prjlabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stirt_prjcrim_chg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  stat_pointinterval(data=PLME2_stirt_prjcrim_av_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  scale_color_manual(values=c("#E99D53","#883E3A"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  # coord_cartesian(xlim=c(-.06,.11)) + 
  # scale_x_continuous(breaks=c(0,.1), labels = dropLeadingZero) +
  coord_cartesian(xlim=c(-.055,.355)) + #plot on half scale as neg emotions 
  scale_x_continuous(breaks=c(0,.25), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  labs(subtitle='Criminal Intent\n___________________________________________________________') +
  scale_y_discrete(labels=numcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8, angle=65),
        axis.line.x = element_blank(), #remove x-axis for top plots
        axis.ticks.x = element_blank(), #remove x-axis for top plots
        axis.text.x = element_blank(), #remove x-axis for top plots
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.subtitle=element_text(size=8, hjust=0.5, face="italic"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# irtprjcommplot


irtdepcommplot <- ggplot(data = PLME2_stirt_negemots_chg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.med, desc(rural.ses.med)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(deplabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stirt_negemots_chg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  stat_pointinterval(data=PLME2_stirt_negemots_av_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  scale_color_manual(values=c("#E99D53","#883E3A"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.11,.71)) + 
  scale_x_continuous(breaks=c(0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  labs(subtitle='Negative Emotions\n____________________________________________________________') +
  # scale_y_discrete(labels=numcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8, angle=65),
        axis.line.x = element_blank(), #remove x-axis for top plots
        axis.ticks.x = element_blank(), #remove x-axis for top plots
        axis.text.x = element_blank(), #remove x-axis for top plots
        axis.text.y=element_blank(), #remove y-axis labels
        axis.ticks.y=element_blank(), #remove y-axis ticks
        axis.line.y=element_blank(), #remove y-axis line
        plot.title = element_text(size=10, face="bold"),
        plot.subtitle=element_text(size=8, hjust=0.5, face="italic"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# irtdepcommplot


sumprjcommplot <- ggplot(data = PLME2_stsum_prjcrim_chg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.med, desc(rural.ses.med)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(prjlabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_chg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_av_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  scale_color_manual(values=c("#7ad151", "#440154"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  # coord_cartesian(xlim=c(-.06,.11)) + 
  # scale_x_continuous(breaks=c(0,.1), labels = dropLeadingZero) +
  coord_cartesian(xlim=c(-.055,.355)) + #plot on half scale as neg emotions 
  scale_x_continuous(breaks=c(0,.25), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=numcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_blank(), #remove facet (outcome) labels 
        # strip.text.x = element_text(size = 8), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumprjcommplot


sumdepcommplot <- ggplot(data = PLME2_stsum_negemots_chg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.med, desc(rural.ses.med)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(deplabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_negemots_chg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  stat_pointinterval(data=PLME2_stsum_negemots_av_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  scale_color_manual(values=c("#7ad151", "#440154"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.11,.71)) + 
  scale_x_continuous(breaks=c(0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=numcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_blank(), 
        # strip.text.x = element_text(size = 8), 
        axis.text.y=element_blank(), #remove y-axis labels
        axis.ticks.y=element_blank(), #remove y-axis ticks
        axis.line.y=element_blank(), #remove y-axis line
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumdepcommplot




design <- "
12
34
55
"    

# library(patchwork)
AppendixFig1 <- irtprjcommplot + irtdepcommplot + 
  sumprjcommplot + sumdepcommplot + 
  guide_area() +
  plot_layout(design=design, guides = 'collect', heights = c(2,2,.1)) + 
    plot_annotation(
    title = 'Appendix 1: Marginal Effects of Stress Scale Increase on Outcome Probabilities, by Estimator, Scaling Method, & Community',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Estimates derived from multivariate (using `brms::mvbind()`) and multilevel between/within Bayesian logistic regression models simultaneously regressing all criminal intent outcomes (6*2=12 models) and all negative emotion outcomes (7*2=14 models) separately on a latent IRT and a standardized sum stress scale, and two separate models regressing "any criminal intent" on each stress scale. Both stress scales were separated into L2 cross-time average (Xbar_i) between-person and L1 within-person change (X_it - Xbar_i) "fixed effects" estimators. Models also included a factor variable for community and multiplicative interactions between community and both L1/L2 stress estimators. Models were estimated in brms with 4 chains and 4000 total post-warmup posterior draws per outcome and per community group. Marginal effect contrast distributions were estimated from the expectation of the posterior predictive distribution for each model as community-specific predicted probability difference distributions averaged over all 1-unit increases on the stress scale (within) or for a 1SD increase from mean (between; "0" vs "1") on initial IRT or standardized latent scale, averaged over the alternative (between or within) stress estimator levels. Median posterior density estimates with 95% intervals displayed. Bold point-intervals indicate at least 80% of posterior estimates for the average marginal effect contrast are greater than zero.', width=195)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'bottom', 
        legend.key.height = unit(.5, 'cm'), 
        legend.margin = margin(0,0,0,0), 
        legend.spacing.y = unit(0, "mm"))

AppendixFig1

ggsave("Appendix1.jpeg", width=9, height=6.5, path=here("Output"))
save(stress.long2, file = here("1_Data_Files/Datasets/stress_long2.Rdata"))

saveRDS(PLME2_stsum_prjcrim_chg_comm, file = here("Models/PLME2_stsum_prjcrim_chg_comm.rds"))
saveRDS(PLME2_stsum_prjcrim_av_comm, file = here("Models/PLME2_stsum_prjcrim_av_comm.rds"))
saveRDS(PLME2_stsum_negemots_chg_comm, file = here("Models/PLME2_stsum_negemots_chg_comm.rds"))
saveRDS(PLME2_stsum_negemots_av_comm, file = here("Models/PLME2_stsum_negemots_av_comm.rds"))

11 Appendix 2: Robustness of SES Median Split

(RMD FILE: BDK_2023_Stress_10_Append2_median_split)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

11.1 ROBUSTNESS CHECK ON COMMUNITY SES MEDIAN SPLIT

In this section, we re-estimate and plot composite stress scale models to assess robustness of findings to decision to use community-level (L2) SES median split for community identification. Models will include three-way interactions between rural residence, standardized L2 SES, and each stress estimator (between & within). The standardized sum stress scale is used rather than IRT scale because sum scale results more closely summarize those observed in item-specific analysis; as expected, the IRT scale heavily weights one dimension - interpersonal stress - while down-weighting others; thus, results using IRT scale primarily align only with previous findings from item-specific interpersonal stress models (see Appendix 1). Here, the goal is to use a composite measure that adequately captures “overall stress” differences or increases, which the unweighted standardized sum scale appears to do better than the IRT scale.

load(here("1_Data_Files/Datasets/stress_long2.Rdata"))

PLME2_stsum_prjcrim_chg_comm <- readRDS(
  file = here("Models/PLME2_stsum_prjcrim_chg_comm.rds"))
PLME2_stsum_prjcrim_av_comm <- readRDS(
  file = here("Models/PLME2_stsum_prjcrim_av_comm.rds"))
PLME2_stsum_negemots_chg_comm <- readRDS(
  file = here("Models/PLME2_stsum_negemots_chg_comm.rds"))
PLME2_stsum_negemots_av_comm <- readRDS(
  file = here("Models/PLME2_stsum_negemots_av_comm.rds"))

11.1.1 Standardize L2 SES (T1) variable

stress.long3 <- stress.long2 %>% 
  group_by(year) %>%
  mutate(
    L2sesw1z = (L2sesw1 - mean(L2sesw1))/sd(L2sesw1)
  ) %>%
  ungroup()

11.1.1.1 L2sesw1 distribution

ggplot(stress.long2, aes(L2sesw1)) + geom_histogram(fill="#E99D53")

11.1.1.2 L2sesw1z distribution

ggplot(stress.long3, aes(L2sesw1z)) + geom_histogram(fill="#E99D53")

11.1.2 Corr X Robust Community: stdz sum stress & prj crime

#list of colnames for projected crime DVs  
prjdv_names <- noquote(c("prjthflt5", "prjthfgt5", "prjthreat", "prjharm", 
                         "prjusedrg", "prjhack"))

#Vectorize priors:
prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = prjdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = prjdv_names)
  )

chg.prjcrime.stsum.rbstcomm.fit <- brm(
  mvbind(prjthflt5, prjthfgt5, prjthreat, prjharm, prjusedrg, prjhack) ~ 1 + 
    sumstresschg + sumstressav + rural + L2sesw1z +
    sumstresschg:rural + sumstressav:rural + 
    sumstresschg:L2sesw1z + sumstressav:L2sesw1z + 
    sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + 
    (1 | id),   
      data = stress.long3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      adapt_delta = 0.85,
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/chg_prjcrime_stsum_rbstcomm_fit",
      file_refit = "on_change"
  )

#Update function to call all ppchecks for bivar projected crime models
varlist <- c("^b_prjthflt5_sum","^b_prjthfgt5_sum", "^b_prjthreat_sum", 
             "^b_prjharm_sum", "^b_usedrg_sum", "^b_prjhack_sum") 
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="prjthflt5")
  ppcheckdv2 <-pp_check(modelfit, resp="prjthfgt5")
  ppcheckdv3 <-pp_check(modelfit, resp="prjthreat")
  ppcheckdv4 <-pp_check(modelfit, resp="prjharm")
  ppcheckdv5 <-pp_check(modelfit, resp="prjusedrg")
  ppcheckdv6 <-pp_check(modelfit, resp="prjhack")
  plotcoefs2 <- mcmc_plot(modelfit, variable = varlist, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, 
                    ppcheckdv3, ppcheckdv4, ppcheckdv5, ppcheckdv6, plotcoefs2)
  return(allchecks)
}

out.chg.prjcrime.stsum.rbstcomm.fit <- ppchecks(chg.prjcrime.stsum.rbstcomm.fit)

11.1.2.1 Coefficient plot (intervals)

out.chg.prjcrime.stsum.rbstcomm.fit[[9]] 

11.1.2.2 PPcheck (density)

p1 <- out.chg.prjcrime.stsum.rbstcomm.fit[[3]] + labs(title = "Theft <5BAM Intent (chg)") 
p2 <- out.chg.prjcrime.stsum.rbstcomm.fit[[4]] + labs(title = "Theft >5BAM Intent (chg)")
p3 <- out.chg.prjcrime.stsum.rbstcomm.fit[[5]] + labs(title = "Threat Intent (chg)")
p4 <- out.chg.prjcrime.stsum.rbstcomm.fit[[6]] + labs(title = "Harm Intent (chg)")
p5 <- out.chg.prjcrime.stsum.rbstcomm.fit[[7]] + labs(title = "Use Drugs Intent (chg)")
p6 <- out.chg.prjcrime.stsum.rbstcomm.fit[[8]] + labs(title = "Hack Intent (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6)

11.1.2.3 Fit summary

out.chg.prjcrime.stsum.rbstcomm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: prjthflt5 ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          prjthfgt5 ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          prjthreat ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          prjharm ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          prjusedrg ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          prjhack ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##    Data: stress.long3 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(prjthflt5_Intercept)     3.94      0.55     2.95     5.13 1.00     1263
## sd(prjthfgt5_Intercept)     3.36      0.49     2.51     4.41 1.00     1030
## sd(prjthreat_Intercept)     3.25      0.54     2.27     4.40 1.00      939
## sd(prjharm_Intercept)       3.02      0.54     2.05     4.15 1.00     1125
## sd(prjusedrg_Intercept)     2.92      0.52     2.00     3.99 1.00     1242
## sd(prjhack_Intercept)       0.95      0.56     0.05     2.10 1.00      508
##                         Tail_ESS
## sd(prjthflt5_Intercept)     1909
## sd(prjthfgt5_Intercept)     1220
## sd(prjthreat_Intercept)     2101
## sd(prjharm_Intercept)       1916
## sd(prjusedrg_Intercept)     1915
## sd(prjhack_Intercept)        896
## 
## Regression Coefficients:
##                                       Estimate Est.Error l-95% CI u-95% CI Rhat
## prjthflt5_Intercept                      -4.23      0.62    -5.56    -3.17 1.00
## prjthfgt5_Intercept                      -3.98      0.55    -5.13    -3.05 1.00
## prjthreat_Intercept                      -5.78      0.79    -7.43    -4.42 1.00
## prjharm_Intercept                        -5.89      0.81    -7.60    -4.47 1.00
## prjusedrg_Intercept                      -6.05      0.83    -7.81    -4.59 1.00
## prjhack_Intercept                        -4.33      0.59    -5.71    -3.40 1.00
## prjthflt5_sumstresschg                    0.41      0.57    -0.71     1.53 1.00
## prjthflt5_sumstressav                     0.64      0.36    -0.03     1.35 1.00
## prjthflt5_rural                          -2.55      0.54    -3.64    -1.49 1.00
## prjthflt5_L2sesw1z                        0.27      0.27    -0.26     0.82 1.00
## prjthflt5_sumstresschg:rural              0.37      0.82    -1.26     1.93 1.00
## prjthflt5_sumstressav:rural              -0.03      0.55    -1.12     1.07 1.00
## prjthflt5_sumstresschg:L2sesw1z          -0.40      0.51    -1.43     0.57 1.00
## prjthflt5_sumstressav:L2sesw1z           -0.27      0.29    -0.85     0.31 1.00
## prjthflt5_sumstresschg:rural:L2sesw1z    -0.95      0.90    -2.65     0.80 1.00
## prjthflt5_sumstressav:rural:L2sesw1z      0.98      0.66    -0.34     2.26 1.00
## prjthfgt5_sumstresschg                    0.77      0.57    -0.35     1.85 1.00
## prjthfgt5_sumstressav                     0.64      0.32     0.05     1.27 1.01
## prjthfgt5_rural                          -2.42      0.49    -3.39    -1.46 1.00
## prjthfgt5_L2sesw1z                        0.16      0.24    -0.33     0.64 1.00
## prjthfgt5_sumstresschg:rural              0.48      0.83    -1.14     2.12 1.00
## prjthfgt5_sumstressav:rural              -0.34      0.53    -1.38     0.70 1.00
## prjthfgt5_sumstresschg:L2sesw1z          -0.03      0.53    -1.07     1.03 1.00
## prjthfgt5_sumstressav:L2sesw1z           -0.14      0.27    -0.70     0.40 1.00
## prjthfgt5_sumstresschg:rural:L2sesw1z    -1.01      0.88    -2.78     0.74 1.00
## prjthfgt5_sumstressav:rural:L2sesw1z      0.91      0.66    -0.39     2.21 1.00
## prjthreat_sumstresschg                   -0.68      0.66    -2.00     0.60 1.00
## prjthreat_sumstressav                     1.03      0.39     0.30     1.84 1.00
## prjthreat_rural                          -1.57      0.56    -2.67    -0.49 1.00
## prjthreat_L2sesw1z                        0.23      0.31    -0.37     0.84 1.00
## prjthreat_sumstresschg:rural              0.70      0.90    -1.06     2.47 1.00
## prjthreat_sumstressav:rural              -0.26      0.62    -1.51     0.95 1.00
## prjthreat_sumstresschg:L2sesw1z          -0.76      0.62    -1.99     0.42 1.00
## prjthreat_sumstressav:L2sesw1z            0.17      0.33    -0.50     0.83 1.00
## prjthreat_sumstresschg:rural:L2sesw1z     0.05      0.98    -1.83     1.98 1.00
## prjthreat_sumstressav:rural:L2sesw1z     -0.54      0.72    -1.96     0.89 1.00
## prjharm_sumstresschg                     -0.84      0.69    -2.16     0.52 1.00
## prjharm_sumstressav                       0.55      0.37    -0.15     1.29 1.00
## prjharm_rural                            -0.96      0.57    -2.10     0.13 1.00
## prjharm_L2sesw1z                          0.21      0.29    -0.37     0.77 1.00
## prjharm_sumstresschg:rural                0.35      0.86    -1.29     2.09 1.00
## prjharm_sumstressav:rural                -0.66      0.57    -1.76     0.45 1.00
## prjharm_sumstresschg:L2sesw1z            -0.54      0.65    -1.82     0.72 1.00
## prjharm_sumstressav:L2sesw1z              0.01      0.34    -0.63     0.70 1.00
## prjharm_sumstresschg:rural:L2sesw1z       0.14      0.93    -1.63     1.96 1.00
## prjharm_sumstressav:rural:L2sesw1z       -0.27      0.67    -1.58     1.03 1.00
## prjusedrg_sumstresschg                   -0.42      0.72    -1.78     1.02 1.00
## prjusedrg_sumstressav                     0.82      0.40     0.05     1.64 1.00
## prjusedrg_rural                          -0.84      0.56    -1.99     0.28 1.00
## prjusedrg_L2sesw1z                        0.71      0.30     0.14     1.31 1.00
## prjusedrg_sumstresschg:rural              0.58      0.87    -1.13     2.21 1.00
## prjusedrg_sumstressav:rural              -0.51      0.59    -1.69     0.64 1.00
## prjusedrg_sumstresschg:L2sesw1z          -0.52      0.68    -1.83     0.82 1.00
## prjusedrg_sumstressav:L2sesw1z            0.32      0.34    -0.36     0.99 1.00
## prjusedrg_sumstresschg:rural:L2sesw1z     0.10      0.95    -1.76     1.97 1.00
## prjusedrg_sumstressav:rural:L2sesw1z     -0.75      0.65    -2.04     0.52 1.00
## prjhack_sumstresschg                     -0.56      0.69    -1.89     0.86 1.00
## prjhack_sumstressav                       0.72      0.30     0.15     1.33 1.00
## prjhack_rural                            -0.69      0.50    -1.67     0.26 1.00
## prjhack_L2sesw1z                         -0.20      0.25    -0.73     0.26 1.00
## prjhack_sumstresschg:rural                0.88      0.90    -0.90     2.63 1.00
## prjhack_sumstressav:rural                -0.20      0.52    -1.19     0.82 1.00
## prjhack_sumstresschg:L2sesw1z            -0.52      0.61    -1.72     0.67 1.00
## prjhack_sumstressav:L2sesw1z              0.30      0.26    -0.19     0.84 1.00
## prjhack_sumstresschg:rural:L2sesw1z       0.05      0.98    -1.85     1.96 1.00
## prjhack_sumstressav:rural:L2sesw1z       -0.49      0.63    -1.74     0.74 1.00
##                                       Bulk_ESS Tail_ESS
## prjthflt5_Intercept                       1353     2015
## prjthfgt5_Intercept                       1128     1688
## prjthreat_Intercept                       1063     2266
## prjharm_Intercept                         1340     2294
## prjusedrg_Intercept                       1500     2350
## prjhack_Intercept                          796     1269
## prjthflt5_sumstresschg                    4823     3305
## prjthflt5_sumstressav                     1676     1914
## prjthflt5_rural                           2355     2766
## prjthflt5_L2sesw1z                        1763     2437
## prjthflt5_sumstresschg:rural              5026     2956
## prjthflt5_sumstressav:rural               2133     2839
## prjthflt5_sumstresschg:L2sesw1z           5236     2809
## prjthflt5_sumstressav:L2sesw1z            1823     2330
## prjthflt5_sumstresschg:rural:L2sesw1z     5177     2544
## prjthflt5_sumstressav:rural:L2sesw1z      2522     2141
## prjthfgt5_sumstresschg                    5266     2964
## prjthfgt5_sumstressav                     1626     2129
## prjthfgt5_rural                           3001     2948
## prjthfgt5_L2sesw1z                        2273     2890
## prjthfgt5_sumstresschg:rural              5494     2933
## prjthfgt5_sumstressav:rural               2520     2423
## prjthfgt5_sumstresschg:L2sesw1z           4993     2890
## prjthfgt5_sumstressav:L2sesw1z            2109     2227
## prjthfgt5_sumstresschg:rural:L2sesw1z     5767     2748
## prjthfgt5_sumstressav:rural:L2sesw1z      2674     2728
## prjthreat_sumstresschg                    5332     3089
## prjthreat_sumstressav                     2067     2403
## prjthreat_rural                           2923     2599
## prjthreat_L2sesw1z                        2506     2556
## prjthreat_sumstresschg:rural              4620     2831
## prjthreat_sumstressav:rural               3065     2882
## prjthreat_sumstresschg:L2sesw1z           5261     3135
## prjthreat_sumstressav:L2sesw1z            2697     2719
## prjthreat_sumstresschg:rural:L2sesw1z     6367     2568
## prjthreat_sumstressav:rural:L2sesw1z      3915     2724
## prjharm_sumstresschg                      5575     3334
## prjharm_sumstressav                       2599     2918
## prjharm_rural                             2644     2490
## prjharm_L2sesw1z                          2823     3002
## prjharm_sumstresschg:rural                5924     2592
## prjharm_sumstressav:rural                 3144     2826
## prjharm_sumstresschg:L2sesw1z             4076     2689
## prjharm_sumstressav:L2sesw1z              2741     2311
## prjharm_sumstresschg:rural:L2sesw1z       4514     2547
## prjharm_sumstressav:rural:L2sesw1z        2958     2686
## prjusedrg_sumstresschg                    4769     2736
## prjusedrg_sumstressav                     2327     2353
## prjusedrg_rural                           3336     2909
## prjusedrg_L2sesw1z                        2649     2493
## prjusedrg_sumstresschg:rural              5583     3158
## prjusedrg_sumstressav:rural               2762     2302
## prjusedrg_sumstresschg:L2sesw1z           5311     2717
## prjusedrg_sumstressav:L2sesw1z            2740     2788
## prjusedrg_sumstresschg:rural:L2sesw1z     6518     2737
## prjusedrg_sumstressav:rural:L2sesw1z      3174     2808
## prjhack_sumstresschg                      5550     3195
## prjhack_sumstressav                       2328     2040
## prjhack_rural                             2976     2820
## prjhack_L2sesw1z                          3215     2651
## prjhack_sumstresschg:rural                6377     2885
## prjhack_sumstressav:rural                 3073     2854
## prjhack_sumstresschg:L2sesw1z             5375     2662
## prjhack_sumstressav:L2sesw1z              2851     2848
## prjhack_sumstresschg:rural:L2sesw1z       5260     3101
## prjhack_sumstressav:rural:L2sesw1z        3436     2417
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

11.1.2.4 Prior summary

out.chg.prjcrime.stsum.rbstcomm.fit[[2]]
##                 prior     class                        coef group      resp
##                (flat)         b                                            
##          normal(0, 1)         b                                     prjhack
##          normal(0, 1)         b                    L2sesw1z         prjhack
##          normal(0, 1)         b                       rural         prjhack
##          normal(0, 1)         b                 sumstressav         prjhack
##          normal(0, 1)         b        sumstressav:L2sesw1z         prjhack
##          normal(0, 1)         b           sumstressav:rural         prjhack
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z         prjhack
##          normal(0, 1)         b                sumstresschg         prjhack
##          normal(0, 1)         b       sumstresschg:L2sesw1z         prjhack
##          normal(0, 1)         b          sumstresschg:rural         prjhack
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z         prjhack
##          normal(0, 1)         b                                     prjharm
##          normal(0, 1)         b                    L2sesw1z         prjharm
##          normal(0, 1)         b                       rural         prjharm
##          normal(0, 1)         b                 sumstressav         prjharm
##          normal(0, 1)         b        sumstressav:L2sesw1z         prjharm
##          normal(0, 1)         b           sumstressav:rural         prjharm
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z         prjharm
##          normal(0, 1)         b                sumstresschg         prjharm
##          normal(0, 1)         b       sumstresschg:L2sesw1z         prjharm
##          normal(0, 1)         b          sumstresschg:rural         prjharm
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z         prjharm
##          normal(0, 1)         b                                   prjthfgt5
##          normal(0, 1)         b                    L2sesw1z       prjthfgt5
##          normal(0, 1)         b                       rural       prjthfgt5
##          normal(0, 1)         b                 sumstressav       prjthfgt5
##          normal(0, 1)         b        sumstressav:L2sesw1z       prjthfgt5
##          normal(0, 1)         b           sumstressav:rural       prjthfgt5
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       prjthfgt5
##          normal(0, 1)         b                sumstresschg       prjthfgt5
##          normal(0, 1)         b       sumstresschg:L2sesw1z       prjthfgt5
##          normal(0, 1)         b          sumstresschg:rural       prjthfgt5
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       prjthfgt5
##          normal(0, 1)         b                                   prjthflt5
##          normal(0, 1)         b                    L2sesw1z       prjthflt5
##          normal(0, 1)         b                       rural       prjthflt5
##          normal(0, 1)         b                 sumstressav       prjthflt5
##          normal(0, 1)         b        sumstressav:L2sesw1z       prjthflt5
##          normal(0, 1)         b           sumstressav:rural       prjthflt5
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       prjthflt5
##          normal(0, 1)         b                sumstresschg       prjthflt5
##          normal(0, 1)         b       sumstresschg:L2sesw1z       prjthflt5
##          normal(0, 1)         b          sumstresschg:rural       prjthflt5
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       prjthflt5
##          normal(0, 1)         b                                   prjthreat
##          normal(0, 1)         b                    L2sesw1z       prjthreat
##          normal(0, 1)         b                       rural       prjthreat
##          normal(0, 1)         b                 sumstressav       prjthreat
##          normal(0, 1)         b        sumstressav:L2sesw1z       prjthreat
##          normal(0, 1)         b           sumstressav:rural       prjthreat
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       prjthreat
##          normal(0, 1)         b                sumstresschg       prjthreat
##          normal(0, 1)         b       sumstresschg:L2sesw1z       prjthreat
##          normal(0, 1)         b          sumstresschg:rural       prjthreat
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       prjthreat
##          normal(0, 1)         b                                   prjusedrg
##          normal(0, 1)         b                    L2sesw1z       prjusedrg
##          normal(0, 1)         b                       rural       prjusedrg
##          normal(0, 1)         b                 sumstressav       prjusedrg
##          normal(0, 1)         b        sumstressav:L2sesw1z       prjusedrg
##          normal(0, 1)         b           sumstressav:rural       prjusedrg
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       prjusedrg
##          normal(0, 1)         b                sumstresschg       prjusedrg
##          normal(0, 1)         b       sumstresschg:L2sesw1z       prjusedrg
##          normal(0, 1)         b          sumstresschg:rural       prjusedrg
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       prjusedrg
##                (flat) Intercept                                            
##          normal(0, 2) Intercept                                     prjhack
##          normal(0, 2) Intercept                                     prjharm
##          normal(0, 2) Intercept                                   prjthfgt5
##          normal(0, 2) Intercept                                   prjthflt5
##          normal(0, 2) Intercept                                   prjthreat
##          normal(0, 2) Intercept                                   prjusedrg
##  student_t(3, 0, 2.5)        sd                                     prjhack
##  student_t(3, 0, 2.5)        sd                                     prjharm
##  student_t(3, 0, 2.5)        sd                                   prjthfgt5
##  student_t(3, 0, 2.5)        sd                                   prjthflt5
##  student_t(3, 0, 2.5)        sd                                   prjthreat
##  student_t(3, 0, 2.5)        sd                                   prjusedrg
##  student_t(3, 0, 2.5)        sd                                id   prjhack
##  student_t(3, 0, 2.5)        sd                   Intercept    id   prjhack
##  student_t(3, 0, 2.5)        sd                                id   prjharm
##  student_t(3, 0, 2.5)        sd                   Intercept    id   prjharm
##  student_t(3, 0, 2.5)        sd                                id prjthfgt5
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthfgt5
##  student_t(3, 0, 2.5)        sd                                id prjthflt5
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthflt5
##  student_t(3, 0, 2.5)        sd                                id prjthreat
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjthreat
##  student_t(3, 0, 2.5)        sd                                id prjusedrg
##  student_t(3, 0, 2.5)        sd                   Intercept    id prjusedrg
##  dpar nlpar lb ub       source
##                        default
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)

11.1.3 Corr X Robust Community: stdz sum stress & any prj crime

#repeat community robustness model for "any criminal intent" outcome
prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept'),
  set_prior('normal(0, 1)', class = 'b')
  )

chg.anyprjcrime.stsum.rbstcomm.fit <- brm(prjany ~ 1 + 
    sumstresschg + sumstressav + rural + L2sesw1z +
    sumstresschg:rural + sumstressav:rural + 
    sumstresschg:L2sesw1z + sumstressav:L2sesw1z + 
    sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + 
    (1 | id),   
      data = stress.long3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      adapt_delta = 0.85, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/chg_anyprjcrime_stsum_rbstcomm_fit",
      file_refit = "on_change"
    )

#Update function to call all ppchecks for bivar projected crime models
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit)
  plotcoefs2 <- mcmc_plot(modelfit, variable = "^b_sum", regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients \nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, plotcoefs2)
  return(allchecks)
}


out.chg.anyprjcrime.stsum.rbstcomm.fit <- ppchecks(chg.anyprjcrime.stsum.rbstcomm.fit)

11.1.3.1 Coefficient plot (intervals)

out.chg.anyprjcrime.stsum.rbstcomm.fit[[4]] 

11.1.3.2 PPcheck (density)

out.chg.anyprjcrime.stsum.rbstcomm.fit[[3]] + labs(title = "Any Crime Intent (chg)") 

11.1.3.3 Fit summary

out.chg.anyprjcrime.stsum.rbstcomm.fit[[1]]
##  Family: bernoulli 
##   Links: mu = logit 
## Formula: prjany ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##    Data: stress.long3 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)     3.25      0.42     2.50     4.16 1.00     1305     2226
## 
## Regression Coefficients:
##                             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept                      -2.52      0.39    -3.37    -1.83 1.00     2380
## sumstresschg                    0.31      0.51    -0.71     1.31 1.00     7915
## sumstressav                     0.59      0.28     0.04     1.14 1.00     3184
## rural                          -2.35      0.45    -3.25    -1.45 1.00     3970
## L2sesw1z                        0.39      0.22    -0.03     0.82 1.00     3273
## sumstresschg:rural              0.75      0.75    -0.73     2.21 1.00     7933
## sumstressav:rural              -0.28      0.45    -1.15     0.61 1.00     3865
## sumstresschg:L2sesw1z          -0.42      0.48    -1.37     0.50 1.00     8578
## sumstressav:L2sesw1z           -0.07      0.24    -0.54     0.40 1.00     3696
## sumstresschg:rural:L2sesw1z    -0.98      0.85    -2.63     0.65 1.00    10513
## sumstressav:rural:L2sesw1z     -0.01      0.55    -1.07     1.07 1.00     4394
##                             Tail_ESS
## Intercept                       2942
## sumstresschg                    3016
## sumstressav                     3078
## rural                           3133
## L2sesw1z                        3051
## sumstresschg:rural              3119
## sumstressav:rural               3310
## sumstresschg:L2sesw1z           3072
## sumstressav:L2sesw1z            2948
## sumstresschg:rural:L2sesw1z     2626
## sumstressav:rural:L2sesw1z      2694
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

11.1.3.4 Prior summary

out.chg.anyprjcrime.stsum.rbstcomm.fit[[2]]
##                 prior     class                        coef group resp dpar
##          normal(0, 1)         b                                            
##          normal(0, 1)         b                    L2sesw1z                
##          normal(0, 1)         b                       rural                
##          normal(0, 1)         b                 sumstressav                
##          normal(0, 1)         b        sumstressav:L2sesw1z                
##          normal(0, 1)         b           sumstressav:rural                
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z                
##          normal(0, 1)         b                sumstresschg                
##          normal(0, 1)         b       sumstresschg:L2sesw1z                
##          normal(0, 1)         b          sumstresschg:rural                
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z                
##          normal(0, 2) Intercept                                            
##  student_t(3, 0, 2.5)        sd                                            
##  student_t(3, 0, 2.5)        sd                                id          
##  student_t(3, 0, 2.5)        sd                   Intercept    id          
##  nlpar lb ub       source
##                      user
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##              (vectorized)
##                      user
##         0         default
##         0    (vectorized)
##         0    (vectorized)

11.1.4 Corr X Robust Community: stdz sum stress & negative emotions

depdv_names <- noquote(c("depcantgo", "depeffort", "deplonely", "depblues", 
                           "depunfair", "depmistrt", "depbetray"))

#Vectorize priors:
prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = depdv_names),
  set_prior('normal(0, 1)', class = 'b', resp = depdv_names)
  )

chg.alldepress.stsum.rbstcomm.fit <- brm(
  mvbind(depcantgo, depeffort, deplonely, depblues, depunfair, depmistrt,
         depbetray) ~ 1 +
         sumstresschg + sumstressav + rural + L2sesw1z +
         sumstresschg:rural + sumstressav:rural + 
         sumstresschg:L2sesw1z + sumstressav:L2sesw1z + 
         sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + 
         (1 | id),   
      data = stress.long3, 
      family = "bernoulli",
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/chg_alldepress_stsum_rbstcomm_fit",
      file_refit = "on_change"
  )

##Update function to call all ppchecks for bivar neg emotions chg models
varlist1 <- c("^b_depcantgo_sum","^b_depeffort_sum", "^b_deplonely_sum", 
             "^b_depblues_sum") 
varlist2 <- c("^b_depunfair_sum", "^b_depmistrt_sum", "^b_depbetray_sum") 
ppchecks <- function(modelfit) {
  fitsummary <- summary(modelfit)
  priorsummary <- prior_summary(modelfit)
  ppcheckdv1 <- pp_check(modelfit, resp="depcantgo")
  ppcheckdv2 <-pp_check(modelfit, resp="depeffort")
  ppcheckdv3 <-pp_check(modelfit, resp="deplonely")
  ppcheckdv4 <-pp_check(modelfit, resp="depblues")
  ppcheckdv5 <-pp_check(modelfit, resp="depunfair")
  ppcheckdv6 <-pp_check(modelfit, resp="depmistrt")
  ppcheckdv7 <-pp_check(modelfit, resp="depbetray")
  plotcoefs1 <- mcmc_plot(modelfit, variable = varlist1, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients\nwith medians, 80%, and 95% intervals")
  plotcoefs2 <- mcmc_plot(modelfit, variable = varlist2, regex = TRUE,  
                          prob = 0.80, prob_outer = 0.95) + 
        labs(title = "Coefficient plot", 
             subtitle = "Posterior intervals for irt stress scale coefficients\nwith medians, 80%, and 95% intervals")
  allchecks <- list(fitsummary, priorsummary, ppcheckdv1, ppcheckdv2, ppcheckdv3, 
                    ppcheckdv4, ppcheckdv5, ppcheckdv6, ppcheckdv7, 
                    plotcoefs1, plotcoefs2)
  return(allchecks)
}

out.chg.alldepress.stsum.rbstcomm.fit <- ppchecks(chg.alldepress.stsum.rbstcomm.fit)

11.1.4.1 Coefficient plot (depressive symptoms)

out.chg.alldepress.stsum.rbstcomm.fit[[10]]

11.1.4.2 Coefficient plot (criminogenic emotions)

out.chg.alldepress.stsum.rbstcomm.fit[[11]]

11.1.4.3 PPcheck (density)

p1 <- out.chg.alldepress.stsum.rbstcomm.fit[[3]] + labs(title = "Can't Get Going (chg)") 
p2 <- out.chg.alldepress.stsum.rbstcomm.fit[[4]] + labs(title = "Everything Effort (chg)")
p3 <- out.chg.alldepress.stsum.rbstcomm.fit[[5]] + labs(title = "Lonely (chg)")
p4 <- out.chg.alldepress.stsum.rbstcomm.fit[[6]] + labs(title = "Can't Shake Blues (chg)")
p5 <- out.chg.alldepress.stsum.rbstcomm.fit[[7]] + labs(title = "Felt Life Unfair (chg)")
p6 <- out.chg.alldepress.stsum.rbstcomm.fit[[8]] + labs(title = "Felt Mistreated (chg)")
p7 <- out.chg.alldepress.stsum.rbstcomm.fit[[9]] + labs(title = "Felt Betrayed (chg)")

(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())

11.1.4.4 Fit summary

out.chg.alldepress.stsum.rbstcomm.fit[[1]]
##  Family: MV(bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli, bernoulli) 
##   Links: mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit
##          mu = logit 
## Formula: depcantgo ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          depeffort ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          deplonely ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          depblues ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          depunfair ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          depmistrt ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##          depbetray ~ 1 + sumstresschg + sumstressav + rural + L2sesw1z + sumstresschg:rural + sumstressav:rural + sumstresschg:L2sesw1z + sumstressav:L2sesw1z + sumstresschg:rural:L2sesw1z + sumstressav:rural:L2sesw1z + (1 | id) 
##    Data: stress.long3 (Number of observations: 978) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~id (Number of levels: 489) 
##                         Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## sd(depcantgo_Intercept)     0.40      0.22     0.02     0.83 1.00      635
## sd(depeffort_Intercept)     0.49      0.29     0.02     1.08 1.00      595
## sd(deplonely_Intercept)     0.51      0.26     0.03     0.99 1.00      509
## sd(depblues_Intercept)      0.59      0.31     0.04     1.21 1.01      602
## sd(depunfair_Intercept)     0.28      0.19     0.01     0.70 1.00      958
## sd(depmistrt_Intercept)     0.34      0.23     0.01     0.85 1.01      748
## sd(depbetray_Intercept)     0.44      0.27     0.02     0.98 1.01      563
##                         Tail_ESS
## sd(depcantgo_Intercept)     1293
## sd(depeffort_Intercept)     1526
## sd(deplonely_Intercept)     1097
## sd(depblues_Intercept)      1454
## sd(depunfair_Intercept)     1911
## sd(depmistrt_Intercept)     1821
## sd(depbetray_Intercept)     1650
## 
## Regression Coefficients:
##                                       Estimate Est.Error l-95% CI u-95% CI Rhat
## depcantgo_Intercept                      -0.39      0.10    -0.60    -0.19 1.00
## depeffort_Intercept                      -1.55      0.15    -1.88    -1.28 1.00
## deplonely_Intercept                      -0.91      0.12    -1.16    -0.68 1.00
## depblues_Intercept                       -1.94      0.19    -2.35    -1.60 1.00
## depunfair_Intercept                      -0.82      0.11    -1.04    -0.61 1.00
## depmistrt_Intercept                      -1.57      0.14    -1.87    -1.30 1.00
## depbetray_Intercept                      -1.57      0.15    -1.90    -1.30 1.00
## depcantgo_sumstresschg                    0.47      0.34    -0.19     1.13 1.00
## depcantgo_sumstressav                    -0.04      0.10    -0.24     0.15 1.00
## depcantgo_rural                           0.05      0.15    -0.24     0.35 1.00
## depcantgo_L2sesw1z                        0.01      0.07    -0.13     0.16 1.00
## depcantgo_sumstresschg:rural              1.56      0.50     0.59     2.54 1.00
## depcantgo_sumstressav:rural               0.10      0.15    -0.19     0.41 1.00
## depcantgo_sumstresschg:L2sesw1z           0.16      0.29    -0.40     0.73 1.00
## depcantgo_sumstressav:L2sesw1z            0.10      0.09    -0.07     0.27 1.00
## depcantgo_sumstresschg:rural:L2sesw1z    -0.42      0.61    -1.58     0.79 1.00
## depcantgo_sumstressav:rural:L2sesw1z      0.07      0.20    -0.32     0.47 1.00
## depeffort_sumstresschg                    0.72      0.42    -0.11     1.52 1.00
## depeffort_sumstressav                     0.14      0.13    -0.12     0.39 1.00
## depeffort_rural                          -0.50      0.20    -0.90    -0.13 1.00
## depeffort_L2sesw1z                       -0.06      0.10    -0.25     0.13 1.00
## depeffort_sumstresschg:rural              0.44      0.62    -0.75     1.66 1.00
## depeffort_sumstressav:rural              -0.17      0.21    -0.56     0.25 1.00
## depeffort_sumstresschg:L2sesw1z           0.06      0.36    -0.66     0.76 1.00
## depeffort_sumstressav:L2sesw1z           -0.12      0.11    -0.34     0.08 1.00
## depeffort_sumstresschg:rural:L2sesw1z    -0.81      0.72    -2.19     0.65 1.00
## depeffort_sumstressav:rural:L2sesw1z      0.28      0.26    -0.25     0.79 1.00
## deplonely_sumstresschg                    0.87      0.38     0.14     1.63 1.00
## deplonely_sumstressav                     0.13      0.11    -0.09     0.35 1.00
## deplonely_rural                          -0.38      0.16    -0.72    -0.05 1.00
## deplonely_L2sesw1z                        0.12      0.08    -0.04     0.29 1.00
## deplonely_sumstresschg:rural              0.32      0.56    -0.76     1.42 1.00
## deplonely_sumstressav:rural              -0.23      0.17    -0.58     0.10 1.00
## deplonely_sumstresschg:L2sesw1z           0.69      0.32     0.07     1.32 1.00
## deplonely_sumstressav:L2sesw1z            0.06      0.09    -0.13     0.24 1.00
## deplonely_sumstresschg:rural:L2sesw1z    -0.49      0.65    -1.72     0.79 1.00
## deplonely_sumstressav:rural:L2sesw1z      0.20      0.22    -0.23     0.63 1.00
## depblues_sumstresschg                    -0.01      0.42    -0.83     0.83 1.00
## depblues_sumstressav                      0.42      0.15     0.14     0.73 1.00
## depblues_rural                           -0.36      0.22    -0.79     0.06 1.00
## depblues_L2sesw1z                         0.20      0.10     0.00     0.40 1.00
## depblues_sumstresschg:rural              -0.50      0.63    -1.72     0.74 1.00
## depblues_sumstressav:rural               -0.75      0.22    -1.20    -0.33 1.00
## depblues_sumstresschg:L2sesw1z           -0.11      0.38    -0.83     0.65 1.00
## depblues_sumstressav:L2sesw1z             0.01      0.12    -0.22     0.24 1.00
## depblues_sumstresschg:rural:L2sesw1z      0.24      0.72    -1.16     1.65 1.00
## depblues_sumstressav:rural:L2sesw1z      -0.50      0.27    -1.03     0.04 1.00
## depunfair_sumstresschg                    1.46      0.36     0.75     2.19 1.00
## depunfair_sumstressav                     0.30      0.11     0.09     0.51 1.00
## depunfair_rural                          -0.64      0.17    -0.97    -0.31 1.00
## depunfair_L2sesw1z                        0.03      0.08    -0.13     0.18 1.00
## depunfair_sumstresschg:rural              1.03      0.56    -0.06     2.15 1.00
## depunfair_sumstressav:rural              -0.12      0.17    -0.46     0.21 1.00
## depunfair_sumstresschg:L2sesw1z           0.33      0.31    -0.27     0.96 1.00
## depunfair_sumstressav:L2sesw1z           -0.08      0.09    -0.26     0.10 1.00
## depunfair_sumstresschg:rural:L2sesw1z    -0.57      0.64    -1.84     0.69 1.00
## depunfair_sumstressav:rural:L2sesw1z     -0.08      0.23    -0.55     0.35 1.00
## depmistrt_sumstresschg                    0.56      0.40    -0.23     1.34 1.00
## depmistrt_sumstressav                     0.47      0.13     0.22     0.73 1.00
## depmistrt_rural                          -0.17      0.19    -0.52     0.20 1.00
## depmistrt_L2sesw1z                        0.06      0.09    -0.12     0.24 1.00
## depmistrt_sumstresschg:rural              0.64      0.61    -0.55     1.81 1.00
## depmistrt_sumstressav:rural               0.00      0.20    -0.39     0.41 1.00
## depmistrt_sumstresschg:L2sesw1z           0.56      0.35    -0.11     1.25 1.00
## depmistrt_sumstressav:L2sesw1z            0.02      0.11    -0.20     0.24 1.00
## depmistrt_sumstresschg:rural:L2sesw1z    -0.78      0.67    -2.10     0.50 1.00
## depmistrt_sumstressav:rural:L2sesw1z     -0.20      0.26    -0.68     0.30 1.00
## depbetray_sumstresschg                    0.66      0.40    -0.13     1.45 1.00
## depbetray_sumstressav                     0.62      0.14     0.36     0.89 1.00
## depbetray_rural                          -0.48      0.20    -0.87    -0.08 1.00
## depbetray_L2sesw1z                        0.05      0.10    -0.15     0.24 1.00
## depbetray_sumstresschg:rural              1.29      0.63     0.04     2.51 1.00
## depbetray_sumstressav:rural              -0.24      0.22    -0.67     0.19 1.00
## depbetray_sumstresschg:L2sesw1z           0.13      0.36    -0.58     0.83 1.00
## depbetray_sumstressav:L2sesw1z            0.13      0.12    -0.10     0.36 1.00
## depbetray_sumstresschg:rural:L2sesw1z    -1.00      0.73    -2.48     0.42 1.00
## depbetray_sumstressav:rural:L2sesw1z     -0.31      0.28    -0.85     0.24 1.00
##                                       Bulk_ESS Tail_ESS
## depcantgo_Intercept                       7574     2833
## depeffort_Intercept                       1707     2349
## deplonely_Intercept                       2408     2739
## depblues_Intercept                        1536     2021
## depunfair_Intercept                       5153     3028
## depmistrt_Intercept                       3543     2728
## depbetray_Intercept                       2274     2429
## depcantgo_sumstresschg                    7217     3028
## depcantgo_sumstressav                     7150     2816
## depcantgo_rural                           9284     3137
## depcantgo_L2sesw1z                       10574     3058
## depcantgo_sumstresschg:rural              6512     3031
## depcantgo_sumstressav:rural               7149     3353
## depcantgo_sumstresschg:L2sesw1z           7754     2937
## depcantgo_sumstressav:L2sesw1z            6704     3278
## depcantgo_sumstresschg:rural:L2sesw1z     7671     3183
## depcantgo_sumstressav:rural:L2sesw1z      7367     3208
## depeffort_sumstresschg                    7002     2892
## depeffort_sumstressav                     5921     3449
## depeffort_rural                           7674     2905
## depeffort_L2sesw1z                        8377     2890
## depeffort_sumstresschg:rural              7336     3421
## depeffort_sumstressav:rural               7198     3385
## depeffort_sumstresschg:L2sesw1z           8136     2871
## depeffort_sumstressav:L2sesw1z            6552     2918
## depeffort_sumstresschg:rural:L2sesw1z     8980     3154
## depeffort_sumstressav:rural:L2sesw1z      8360     3419
## deplonely_sumstresschg                    5867     3128
## deplonely_sumstressav                     6741     3130
## deplonely_rural                           7936     3051
## deplonely_L2sesw1z                        7018     2839
## deplonely_sumstresschg:rural              7466     2826
## deplonely_sumstressav:rural               7177     3252
## deplonely_sumstresschg:L2sesw1z           8353     2775
## deplonely_sumstressav:L2sesw1z            6962     3126
## deplonely_sumstresschg:rural:L2sesw1z     8400     3229
## deplonely_sumstressav:rural:L2sesw1z      6245     3475
## depblues_sumstresschg                     7318     3155
## depblues_sumstressav                      5691     3128
## depblues_rural                            8229     3044
## depblues_L2sesw1z                         6221     3265
## depblues_sumstresschg:rural               7622     2917
## depblues_sumstressav:rural                5080     2936
## depblues_sumstresschg:L2sesw1z            8217     3339
## depblues_sumstressav:L2sesw1z             6239     2929
## depblues_sumstresschg:rural:L2sesw1z      8440     3396
## depblues_sumstressav:rural:L2sesw1z       6329     3494
## depunfair_sumstresschg                    7397     2882
## depunfair_sumstressav                     6215     2927
## depunfair_rural                           8721     3015
## depunfair_L2sesw1z                        8371     3088
## depunfair_sumstresschg:rural              7071     2886
## depunfair_sumstressav:rural               7079     3054
## depunfair_sumstresschg:L2sesw1z           7235     2902
## depunfair_sumstressav:L2sesw1z            8690     3345
## depunfair_sumstresschg:rural:L2sesw1z     8618     3325
## depunfair_sumstressav:rural:L2sesw1z      7619     3179
## depmistrt_sumstresschg                    7654     3389
## depmistrt_sumstressav                     6114     2525
## depmistrt_rural                           8251     3216
## depmistrt_L2sesw1z                        9277     3133
## depmistrt_sumstresschg:rural              7430     2756
## depmistrt_sumstressav:rural               7441     3415
## depmistrt_sumstresschg:L2sesw1z           9058     3055
## depmistrt_sumstressav:L2sesw1z            7263     3396
## depmistrt_sumstresschg:rural:L2sesw1z     9467     3806
## depmistrt_sumstressav:rural:L2sesw1z      7687     3175
## depbetray_sumstresschg                    7800     2861
## depbetray_sumstressav                     6058     2554
## depbetray_rural                           7394     3333
## depbetray_L2sesw1z                        7190     3210
## depbetray_sumstresschg:rural              8189     3080
## depbetray_sumstressav:rural               7292     3416
## depbetray_sumstresschg:L2sesw1z           9421     3233
## depbetray_sumstressav:L2sesw1z            7061     3249
## depbetray_sumstresschg:rural:L2sesw1z     8430     3102
## depbetray_sumstressav:rural:L2sesw1z      6818     3395
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

11.1.4.5 Prior summary

out.chg.alldepress.stsum.rbstcomm.fit[[2]]
##                 prior     class                        coef group      resp
##                (flat)         b                                            
##          normal(0, 1)         b                                   depbetray
##          normal(0, 1)         b                    L2sesw1z       depbetray
##          normal(0, 1)         b                       rural       depbetray
##          normal(0, 1)         b                 sumstressav       depbetray
##          normal(0, 1)         b        sumstressav:L2sesw1z       depbetray
##          normal(0, 1)         b           sumstressav:rural       depbetray
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       depbetray
##          normal(0, 1)         b                sumstresschg       depbetray
##          normal(0, 1)         b       sumstresschg:L2sesw1z       depbetray
##          normal(0, 1)         b          sumstresschg:rural       depbetray
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       depbetray
##          normal(0, 1)         b                                    depblues
##          normal(0, 1)         b                    L2sesw1z        depblues
##          normal(0, 1)         b                       rural        depblues
##          normal(0, 1)         b                 sumstressav        depblues
##          normal(0, 1)         b        sumstressav:L2sesw1z        depblues
##          normal(0, 1)         b           sumstressav:rural        depblues
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z        depblues
##          normal(0, 1)         b                sumstresschg        depblues
##          normal(0, 1)         b       sumstresschg:L2sesw1z        depblues
##          normal(0, 1)         b          sumstresschg:rural        depblues
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z        depblues
##          normal(0, 1)         b                                   depcantgo
##          normal(0, 1)         b                    L2sesw1z       depcantgo
##          normal(0, 1)         b                       rural       depcantgo
##          normal(0, 1)         b                 sumstressav       depcantgo
##          normal(0, 1)         b        sumstressav:L2sesw1z       depcantgo
##          normal(0, 1)         b           sumstressav:rural       depcantgo
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       depcantgo
##          normal(0, 1)         b                sumstresschg       depcantgo
##          normal(0, 1)         b       sumstresschg:L2sesw1z       depcantgo
##          normal(0, 1)         b          sumstresschg:rural       depcantgo
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       depcantgo
##          normal(0, 1)         b                                   depeffort
##          normal(0, 1)         b                    L2sesw1z       depeffort
##          normal(0, 1)         b                       rural       depeffort
##          normal(0, 1)         b                 sumstressav       depeffort
##          normal(0, 1)         b        sumstressav:L2sesw1z       depeffort
##          normal(0, 1)         b           sumstressav:rural       depeffort
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       depeffort
##          normal(0, 1)         b                sumstresschg       depeffort
##          normal(0, 1)         b       sumstresschg:L2sesw1z       depeffort
##          normal(0, 1)         b          sumstresschg:rural       depeffort
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       depeffort
##          normal(0, 1)         b                                   deplonely
##          normal(0, 1)         b                    L2sesw1z       deplonely
##          normal(0, 1)         b                       rural       deplonely
##          normal(0, 1)         b                 sumstressav       deplonely
##          normal(0, 1)         b        sumstressav:L2sesw1z       deplonely
##          normal(0, 1)         b           sumstressav:rural       deplonely
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       deplonely
##          normal(0, 1)         b                sumstresschg       deplonely
##          normal(0, 1)         b       sumstresschg:L2sesw1z       deplonely
##          normal(0, 1)         b          sumstresschg:rural       deplonely
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       deplonely
##          normal(0, 1)         b                                   depmistrt
##          normal(0, 1)         b                    L2sesw1z       depmistrt
##          normal(0, 1)         b                       rural       depmistrt
##          normal(0, 1)         b                 sumstressav       depmistrt
##          normal(0, 1)         b        sumstressav:L2sesw1z       depmistrt
##          normal(0, 1)         b           sumstressav:rural       depmistrt
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       depmistrt
##          normal(0, 1)         b                sumstresschg       depmistrt
##          normal(0, 1)         b       sumstresschg:L2sesw1z       depmistrt
##          normal(0, 1)         b          sumstresschg:rural       depmistrt
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       depmistrt
##          normal(0, 1)         b                                   depunfair
##          normal(0, 1)         b                    L2sesw1z       depunfair
##          normal(0, 1)         b                       rural       depunfair
##          normal(0, 1)         b                 sumstressav       depunfair
##          normal(0, 1)         b        sumstressav:L2sesw1z       depunfair
##          normal(0, 1)         b           sumstressav:rural       depunfair
##          normal(0, 1)         b  sumstressav:rural:L2sesw1z       depunfair
##          normal(0, 1)         b                sumstresschg       depunfair
##          normal(0, 1)         b       sumstresschg:L2sesw1z       depunfair
##          normal(0, 1)         b          sumstresschg:rural       depunfair
##          normal(0, 1)         b sumstresschg:rural:L2sesw1z       depunfair
##                (flat) Intercept                                            
##          normal(0, 2) Intercept                                   depbetray
##          normal(0, 2) Intercept                                    depblues
##          normal(0, 2) Intercept                                   depcantgo
##          normal(0, 2) Intercept                                   depeffort
##          normal(0, 2) Intercept                                   deplonely
##          normal(0, 2) Intercept                                   depmistrt
##          normal(0, 2) Intercept                                   depunfair
##  student_t(3, 0, 2.5)        sd                                   depbetray
##  student_t(3, 0, 2.5)        sd                                    depblues
##  student_t(3, 0, 2.5)        sd                                   depcantgo
##  student_t(3, 0, 2.5)        sd                                   depeffort
##  student_t(3, 0, 2.5)        sd                                   deplonely
##  student_t(3, 0, 2.5)        sd                                   depmistrt
##  student_t(3, 0, 2.5)        sd                                   depunfair
##  student_t(3, 0, 2.5)        sd                                id depbetray
##  student_t(3, 0, 2.5)        sd                   Intercept    id depbetray
##  student_t(3, 0, 2.5)        sd                                id  depblues
##  student_t(3, 0, 2.5)        sd                   Intercept    id  depblues
##  student_t(3, 0, 2.5)        sd                                id depcantgo
##  student_t(3, 0, 2.5)        sd                   Intercept    id depcantgo
##  student_t(3, 0, 2.5)        sd                                id depeffort
##  student_t(3, 0, 2.5)        sd                   Intercept    id depeffort
##  student_t(3, 0, 2.5)        sd                                id deplonely
##  student_t(3, 0, 2.5)        sd                   Intercept    id deplonely
##  student_t(3, 0, 2.5)        sd                                id depmistrt
##  student_t(3, 0, 2.5)        sd                   Intercept    id depmistrt
##  student_t(3, 0, 2.5)        sd                                id depunfair
##  student_t(3, 0, 2.5)        sd                   Intercept    id depunfair
##  dpar nlpar lb ub       source
##                        default
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                           user
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                   (vectorized)
##                        default
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##                           user
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0         default
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)
##              0    (vectorized)

11.1.5 Predictive Marginal Contrasts x Robust Comm (Stdz Sum Stress & Crim Intent)

Let’s compare marginal effect contrasts from models with the standardized sum stress scale and four discretely measured communities above to an alternative model that instead includes a rural/urban binary indicator and a continuous standardized community level SES variable in three-way interactions with the same stress variable.

# generate new data grid for specific change contrasts (average over sumstressav)
  # keep only 1-unit Stdz sum scale increases from year 1 to year 2 (contrast .5_t2 - -.5_t1)
  # generate data for rural/urban & for -1/1 SD L2sesw1z 
newdata <- stress.long3 %>% 
  data_grid(sumstresschg = c(-.5, .5),
              sumstressav,
              rural, 
              L2sesw1z = c(-1,1),
              year) %>%     
  filter(sumstresschg == -0.5  & year == "1" |
           sumstresschg == 0.5 & year == "2")

# function to generate epred draws 
gen_predmarg_data_comm <- function(mymodelfit, xdev){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(.category, rural, L2sesw1z, {{xdev}}, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`))
}

#generate epred draws
predmarg_stsum_prjcrim_chg_rbstcomm = gen_predmarg_data_comm(chg.prjcrime.stsum.rbstcomm.fit, sumstresschg)
predmarg_stsum_negemots_chg_rbstcomm = gen_predmarg_data_comm(chg.alldepress.stsum.rbstcomm.fit, sumstresschg)

#generate epred draws for "any crim intent" & merge with prjcrime
predmarg_stsum_anyprjcrim_chg_rbstcomm =
  epred_draws(chg.anyprjcrime.stsum.rbstcomm.fit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(rural, L2sesw1z, sumstresschg, .draw) %>%
  summarise(`E[y|xdev]` = mean(`.epred`)) %>% 
  ungroup() %>%
  mutate(.category="prjany")
predmarg_stsum_prjcrim_chg_rbstcomm <- bind_rows(predmarg_stsum_prjcrim_chg_rbstcomm, 
                                        predmarg_stsum_anyprjcrim_chg_rbstcomm)
rm(predmarg_stsum_anyprjcrim_chg_rbstcomm) #clean environment
  
# function to calculate marginal contrasts
calc_ME_chg_comm <- function(predmarg_data, xdev) {
  predmarg_data %>%
    compare_levels(`E[y|xdev]`, by = xdev) %>%  # pairwise diffs in `E[y|x]`, by levels of x
    group_by(rural, L2sesw1z) %>% # generate community-specific marginal contrasts
    rename(`PLME` = `E[y|xdev]`) # easy colname reflecting ME 2-unit chg contrast
}

# outputs community-specific predicted differences in E[y] 
# associated with 1-Sum AVE scale increase in stress (T2-T1, -.5 to .5) 
  # marg effect contrasts are marginalized over all person-level avg values of stress (AME)

#generate ME contrasts & add alpha indicator
PLME2_stsum_prjcrim_chg_rbstcomm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stsum_prjcrim_chg_rbstcomm, "sumstresschg") %>%
      mutate(stress_var = "Sum Stress:\nWithin Person\nChange",
             dif_label = "diff in E[y|stress diff or increase]",
             method="rbstcommchg") %>%
      rename(contrast = sumstresschg)}, file="cache_10_1")

PLME2_stsum_prjcrim_chg_rbstcomm <- PLME2_stsum_prjcrim_chg_rbstcomm %>% 
  group_by(.category, rural, L2sesw1z) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1")),
         rural.ses.rbst = if_else(rural==1 & L2sesw1z==-1, 1, 0),
         rural.ses.rbst = if_else(rural==1 & L2sesw1z==1, 2, rural.ses.rbst),
         rural.ses.rbst = if_else(rural==0 & L2sesw1z==-1, 3, rural.ses.rbst),
         rural.ses.rbst = if_else(rural==0 & L2sesw1z==1, 4, rural.ses.rbst),
         rural.ses.rbst = factor(rural.ses.rbst, levels = c("1", "2", "3", "4"))
         ) %>%
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5", "prjthfgt5", "prjthreat",
                                "prjharm", "prjusedrg", "prjhack", 
                                "prjany"))
  )
  

PLME2_stsum_negemots_chg_rbstcomm = xfun::cache_rds({calc_ME_chg_comm(predmarg_stsum_negemots_chg_rbstcomm, "sumstresschg") %>%
      mutate(stress_var = "Sum Stress:\nWithin Person\nChange",
             dif_label = "diff in E[y|stress diff or increase]",
             method="rbstcommchg") %>%
      rename(contrast = sumstresschg)}, file="cache_10_2")

PLME2_stsum_negemots_chg_rbstcomm <- PLME2_stsum_negemots_chg_rbstcomm %>%
  group_by(.category, rural, L2sesw1z) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1")),
         rural.ses.rbst = if_else(rural==1 & L2sesw1z==-1, 1, 0),
         rural.ses.rbst = if_else(rural==1 & L2sesw1z==1, 2, rural.ses.rbst),
         rural.ses.rbst = if_else(rural==0 & L2sesw1z==-1, 3, rural.ses.rbst),
         rural.ses.rbst = if_else(rural==0 & L2sesw1z==1, 4, rural.ses.rbst),
         rural.ses.rbst = factor(rural.ses.rbst, levels = c("1", "2", "3", "4"))
         ) 


# REPEAT FOR BETWEEN-PERSON DIFF ESTIMATES
# marginalize btw-per 1-0 diff contrast estimates across values of w/in person change & year

# NOTE: base rate probs differ across sumstressav scale, so could collapse representative 
# contrasts across scale (-1 - -2, -.5 - -1.5, 0 - -1, .5 - -.5, 1 - 0, 1.5 - .5)
# attempted but too computationally intensive 

newdata <- stress.long3 %>% 
  data_grid(sumstressav = c(0,1),
              sumstresschg,
              rural, 
              L2sesw1z = c(-1,1),
              year)     

# function to generate epred draws 
gen_predmarg_data_comm <- function(mymodelfit, xdif){
  epred_draws(mymodelfit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(.category, rural, L2sesw1z, {{xdif}}, .draw) %>%
  summarise(`E[y|xdif]` = mean(`.epred`))
}

#use function to generate epred draws
predmarg_stsum_prjcrim_av_rbstcomm = gen_predmarg_data_comm(chg.prjcrime.stsum.rbstcomm.fit, sumstressav)
predmarg_stsum_negemots_av_rbstcomm = gen_predmarg_data_comm(chg.alldepress.stsum.rbstcomm.fit, sumstressav)

#generate epred draws for "any crim intent" & merge with prjcrime
predmarg_stsum_anyprjcrim_av_rbstcomm =
  epred_draws(chg.anyprjcrime.stsum.rbstcomm.fit,
                newdata = newdata,
                re_formula = NA) %>%
  group_by(rural, L2sesw1z, sumstressav, .draw) %>%
  summarise(`E[y|xdif]` = mean(`.epred`)) %>%
  ungroup() %>%
  mutate(.category="prjany")
predmarg_stsum_prjcrim_av_rbstcomm <- bind_rows(predmarg_stsum_prjcrim_av_rbstcomm, 
                                        predmarg_stsum_anyprjcrim_av_rbstcomm)
rm(predmarg_stsum_anyprjcrim_av_rbstcomm) #clean environment



calc_ME_diff_comm <- function(predmarg_data, xdif) {
  predmarg_data %>%
    compare_levels(`E[y|xdif]`, by = xdif) %>%  # pairwise diffs in `E[y|x]`, by levels of x
    group_by(rural, L2sesw1z) %>% # generate community-specific marginal contrasts
    rename(`PLME` = `E[y|xdif]`) # easy colname reflecting ME 2-unit chg contrast
}

#generate ME contrasts & add alpha indicator & rural.ses.rbst
PLME2_stsum_prjcrim_av_rbstcomm = xfun::cache_rds({calc_ME_diff_comm(predmarg_stsum_prjcrim_av_rbstcomm, "sumstressav") %>%
      mutate(stress_var = "Sum Stress:\nBetween Person\nDifference",
             dif_label = "diff in E[y|stress diff or increase]",
             method="rbstcommav") %>%
      rename(contrast = sumstressav)}, file="cache_10_3")

PLME2_stsum_prjcrim_av_rbstcomm <- PLME2_stsum_prjcrim_av_rbstcomm %>%
  group_by(.category, rural, L2sesw1z) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1")),
         rural.ses.rbst = if_else(rural==1 & L2sesw1z==-1, 1, 0),
         rural.ses.rbst = if_else(rural==1 & L2sesw1z==1, 2, rural.ses.rbst),
         rural.ses.rbst = if_else(rural==0 & L2sesw1z==-1, 3, rural.ses.rbst),
         rural.ses.rbst = if_else(rural==0 & L2sesw1z==1, 4, rural.ses.rbst),
         rural.ses.rbst = factor(rural.ses.rbst, levels = c("1", "2", "3", "4"))
         ) %>%
  ungroup() %>% 
  mutate(
    .category = factor(.category, 
                       levels=c("prjthflt5", "prjthfgt5", "prjthreat",
                                "prjharm", "prjusedrg", "prjhack", 
                                "prjany"))
  )

PLME2_stsum_negemots_av_rbstcomm = xfun::cache_rds({calc_ME_diff_comm(predmarg_stsum_negemots_av_rbstcomm, "sumstressav") %>%
      mutate(stress_var = "Sum Stress:\nBetween Person\nDifference",
             dif_label = "diff in E[y|stress diff or increase]",
             method="rbstcommav") %>%
      rename(contrast = sumstressav)}, file="cache_10_4")

PLME2_stsum_negemots_av_rbstcomm <- PLME2_stsum_negemots_av_rbstcomm %>%
  group_by(.category, rural, L2sesw1z) %>%
  mutate(n_ests = n(),
         n_gt0 = sum(PLME>0),
         p_gt0 = n_gt0 / n_ests,
         p80_gt0 = if_else(p_gt0 >= .80, 1, 0),
         p80_gt0 = factor(p80_gt0, levels=c("0","1")),
         rural.ses.rbst = if_else(rural==1 & L2sesw1z==-1, 1, 0),
         rural.ses.rbst = if_else(rural==1 & L2sesw1z==1, 2, rural.ses.rbst),
         rural.ses.rbst = if_else(rural==0 & L2sesw1z==-1, 3, rural.ses.rbst),
         rural.ses.rbst = if_else(rural==0 & L2sesw1z==1, 4, rural.ses.rbst),
         rural.ses.rbst = factor(rural.ses.rbst, levels = c("1", "2", "3", "4"))
         ) 

11.2 APPENDIX 2: PLME Stress/Outcome Change X Community

#function to find & drop leading zeroes (used for x-axis label)
dropLeadingZero <- function(l){
  str_replace(l, '0(?=.)', '')
}

numcommlabs2 <- c("1"="Rural\nLowSES", 
              "2"="Rural\nHighSES", 
              "3"="Urban\nLowSES", 
              "4"="Urban\nHighSES")
numrbstcommlabs2 <- c("1"="Rural\nLowSES", 
              "2"="Rural\nHighSES", 
              "3"="Urban\nLowSES", 
              "4"="Urban\nHighSES")
prjlabs2 <- c(
  "prjthflt5"="Theft\n<5BAM", 
  "prjthfgt5"="Theft\n>5BAM", 
  "prjthreat"="Threat", 
  "prjharm"="Phys.\nharm",
  "prjusedrg"="Use\ndrugs",
  "prjhack"="Hack\ninfo",
  "prjany"="Any crime")
deplabs2 <- c(
  "depcantgo"="Can't\ngo", 
  "depeffort"="Effort", 
  "deplonely"="Lonely", 
  "depblues"="Blues",
  "depunfair"="Unfair",
  "depmistrt"="Mistreated",
  "depbetray"="Betrayed")

methodlabs <- c(
  "sumav"="Between-Person Difference\n(Discrete Communities)", 
  "sumchg"="Within-Person Change\n(Discrete Communities)",
  "rbstcommav"="Between-Person Difference\n(Continuous Communities)", 
  "rbstcommchg"="Within-Person Change\n(Continuous Communities)")


sumprjcommplot2 <- ggplot(data = PLME2_stsum_prjcrim_chg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.med, desc(rural.ses.med)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(prjlabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_chg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_av_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  scale_color_manual(values=c("#7ad151", "#440154"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  # coord_cartesian(xlim=c(-.06,.11)) + 
  # scale_x_continuous(breaks=c(0,.1), labels = dropLeadingZero) +
  coord_cartesian(xlim=c(-.055,.355)) + #plot on half scale as neg emotions 
  scale_x_continuous(breaks=c(0,.25), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  labs(subtitle='Criminal Intent\n___________________________________________________________') +
  scale_y_discrete(labels=numcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8, angle=65),
        axis.line.x = element_blank(), #remove x-axis for top plots
        axis.ticks.x = element_blank(), #remove x-axis for top plots
        axis.text.x = element_blank(), #remove x-axis for top plots
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.subtitle=element_text(size=8, hjust=0.5, face="italic"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumprjcommplot2


sumdepcommplot2 <- ggplot(data = PLME2_stsum_negemots_chg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.med, desc(rural.ses.med)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(deplabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_negemots_chg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  stat_pointinterval(data=PLME2_stsum_negemots_av_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  scale_color_manual(values=c("#7ad151", "#440154"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.11,.71)) + 
  scale_x_continuous(breaks=c(0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  labs(subtitle='Negative Emotions\n____________________________________________________________') +
  # scale_y_discrete(labels=numcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8, angle=65),
        axis.line.x = element_blank(), #remove x-axis for top plots
        axis.ticks.x = element_blank(), #remove x-axis for top plots
        axis.text.x = element_blank(), #remove x-axis for top plots
        axis.text.y=element_blank(), #remove y-axis labels
        axis.ticks.y=element_blank(), #remove y-axis ticks
        axis.line.y=element_blank(), #remove y-axis line
        plot.title = element_text(size=10, face="bold"),
        plot.subtitle=element_text(size=8, hjust=0.5, face="italic"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumdepcommplot2


sumprjrbstcommplot <- ggplot(data = PLME2_stsum_prjcrim_chg_rbstcomm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.rbst, desc(rural.ses.rbst)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(prjlabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_chg_rbstcomm,
                     aes(x=PLME, y=reorder(rural.ses.rbst, desc(rural.ses.rbst)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_av_rbstcomm,
                     aes(x=PLME, y=reorder(rural.ses.rbst, desc(rural.ses.rbst)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  scale_color_manual(values=c("#fcae12", "#a92e5e"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  # coord_cartesian(xlim=c(-.06,.11)) + 
  # scale_x_continuous(breaks=c(0,.1), labels = dropLeadingZero) +
  coord_cartesian(xlim=c(-.055,.355)) + #plot on half scale as neg emotions 
  scale_x_continuous(breaks=c(0,.25), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=numrbstcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_blank(), #remove facet (outcome) labels 
        # strip.text.x = element_text(size = 8), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumprjrbstcommplot


sumdeprbstcommplot <- ggplot(data = PLME2_stsum_negemots_chg_rbstcomm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.rbst, desc(rural.ses.rbst)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(deplabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_negemots_chg_rbstcomm,
                     aes(x=PLME, y=reorder(rural.ses.rbst, desc(rural.ses.rbst)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  stat_pointinterval(data=PLME2_stsum_negemots_av_rbstcomm,
                     aes(x=PLME, y=reorder(rural.ses.rbst, desc(rural.ses.rbst)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  scale_color_manual(values=c("#fcae12", "#a92e5e"), 
                      labels=as_labeller(methodlabs), name=NULL) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.11,.71)) + 
  scale_x_continuous(breaks=c(0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=numrbstcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_blank(), 
        # strip.text.x = element_text(size = 8), 
        axis.text.y=element_blank(), #remove y-axis labels
        axis.ticks.y=element_blank(), #remove y-axis ticks
        axis.line.y=element_blank(), #remove y-axis line
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumdeprbstcommplot




design <- "
12
34
55
"    

# library(patchwork)
SuppAppendix2a <- sumprjcommplot2 + sumdepcommplot2 +
  sumprjrbstcommplot + sumdeprbstcommplot + 
  guide_area() +
  plot_layout(design=design, guides = 'collect', heights = c(2,2,.1)) + 
    plot_annotation(
    title = 'SUPPLEMENTAL APPENDIX 2a\nMarginal Effects of 1-Unit Stress Scale Increase on Outcome Probabilities, Comparing Estimators by Discrete or Continuous Community',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Estimates derived from 4 multivariate (using `brms::mvbind()`) and multilevel between-within Bayesian logistic regression models simultaneously regressing  all criminal intent outcomes (2 models) and all negative emotion outcomes (2 models) on a standardized sum stress scale separated into L2 cross-time average (Xbar_i) between-person and L1 within-person change (X_it - Xbar_i) "fixed effects" estimators. Models summarized in top panel included a factor variable for community and multiplicative interactions  between community and both L1/L2 stress estimators. Models summarized in bottom panel included three-way interactions between stress, a rural/urban binary indicator, and a continuous standardized community level SES variable. Models were estimated in brms with 4 chains and 4000 total post-warmup posterior draws per outcome and per community group. Marginal effect contrast distributions were estimated from the expectation of the posterior predictive distribution for each model as community-specific predicted probability difference distributions averaged over all 1-unit increases on the stress scale (within) or for a 1SD increase from mean (between; "0" vs "1") on initial IRT or standardized latent scale, averaged over the alternative (between or within) stress estimator levels. In bottom panel, predicted contrasts were estimated for rural/urban communities with -1SD (low) and +1SD (high) continuous L2 SES levels. Median posterior density estimates with 95% intervals displayed. Bold point-intervals indicate at least 80% of posterior estimates for the average marginal effect contrast are greater than zero.', width=190)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'bottom', 
        legend.key.height = unit(1.5, 'cm'))

SuppAppendix2a

ggsave("SuppAppendix2a.jpeg", width=9, height=6.5, path=here("Output"))
numcommlabs2 <- c("1"="Rural\nLowSES", 
              "2"="Rural\nHighSES", 
              "3"="Urban\nLowSES", 
              "4"="Urban\nHighSES")
numrbstcommlabs2 <- c("1"="Rural\nLowSES", 
              "2"="Rural\nHighSES", 
              "3"="Urban\nLowSES", 
              "4"="Urban\nHighSES")
prjlabs2 <- c(
  "prjthflt5"="Theft\n<5BAM", 
  "prjthfgt5"="Theft\n>5BAM", 
  "prjthreat"="Threat", 
  "prjharm"="Phys.\nharm",
  "prjusedrg"="Use\ndrugs",
  "prjhack"="Hack\ninfo",
  "prjany"="Any crime")
deplabs2 <- c(
  "depcantgo"="Can't\ngo", 
  "depeffort"="Effort", 
  "deplonely"="Lonely", 
  "depblues"="Blues",
  "depunfair"="Unfair",
  "depmistrt"="Mistreated",
  "depbetray"="Betrayed")

methodlabs <- c(
  "sumav"="Between-Person Difference\n(Discrete Communities)", 
  "rbstcommav"="Between-Person Difference\n(Continuous Communities)", 
  "sumchg"="Within-Person Change\n(Discrete Communities)",
  "rbstcommchg"="Within-Person Change\n(Continuous Communities)")


sumprjwfecommplot2 <- ggplot(data = PLME2_stsum_prjcrim_chg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.med, desc(rural.ses.med)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(prjlabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_chg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_chg_rbstcomm,
                     aes(x=PLME, y=reorder(rural.ses.rbst, desc(rural.ses.rbst)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  scale_color_manual(values=c("#7ad151", "#440154"), 
                      labels=as_labeller(methodlabs), name=NULL, 
                     breaks=c('sumchg', 'rbstcommchg')) + #change order of legend items
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  # coord_cartesian(xlim=c(-.06,.11)) + 
  # scale_x_continuous(breaks=c(0,.1), labels = dropLeadingZero) +
  coord_cartesian(xlim=c(-.055,.355)) + #plot on half scale as neg emotions 
  scale_x_continuous(breaks=c(0,.25), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  labs(subtitle='Criminal Intent\n___________________________________________________________') +
  scale_y_discrete(labels=numcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8, angle=65),
        axis.line.x = element_blank(), #remove x-axis for top plots
        axis.ticks.x = element_blank(), #remove x-axis for top plots
        axis.text.x = element_blank(), #remove x-axis for top plots
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.subtitle=element_text(size=8, hjust=0.5, face="italic"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumprjwfecommplot2


sumdepwfecommplot2 <- ggplot(data = PLME2_stsum_negemots_chg_comm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.med, desc(rural.ses.med)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(deplabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_negemots_chg_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  stat_pointinterval(data=PLME2_stsum_negemots_chg_rbstcomm,
                     aes(x=PLME, y=reorder(rural.ses.rbst, desc(rural.ses.rbst)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  scale_color_manual(values=c("#7ad151", "#440154"), 
                      labels=as_labeller(methodlabs), name=NULL, 
                     breaks=c('sumchg', 'rbstcommchg')) + #change order of legend items
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.11,.71)) + 
  scale_x_continuous(breaks=c(0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  labs(subtitle='Negative Emotions\n____________________________________________________________') +
  # scale_y_discrete(labels=numcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_text(size = 8, angle=65),
        axis.line.x = element_blank(), #remove x-axis for top plots
        axis.ticks.x = element_blank(), #remove x-axis for top plots
        axis.text.x = element_blank(), #remove x-axis for top plots
        axis.text.y=element_blank(), #remove y-axis labels
        axis.ticks.y=element_blank(), #remove y-axis ticks
        axis.line.y=element_blank(), #remove y-axis line
        plot.title = element_text(size=10, face="bold"),
        plot.subtitle=element_text(size=8, hjust=0.5, face="italic"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumdepwfecommplot2


sumprjbtwcommplot <- ggplot(data = PLME2_stsum_prjcrim_chg_rbstcomm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.rbst, desc(rural.ses.rbst)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(prjlabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_av_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  stat_pointinterval(data=PLME2_stsum_prjcrim_av_rbstcomm,
                     aes(x=PLME, y=reorder(rural.ses.rbst, desc(rural.ses.rbst)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  scale_color_manual(values=c("#fcae12", "#a92e5e"), 
                      labels=as_labeller(methodlabs), name=NULL,
                     breaks=c('sumav', 'rbstcommav')) + #change order of legend items
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  # coord_cartesian(xlim=c(-.06,.11)) + 
  # scale_x_continuous(breaks=c(0,.1), labels = dropLeadingZero) +
  coord_cartesian(xlim=c(-.055,.355)) + #plot on half scale as neg emotions 
  scale_x_continuous(breaks=c(0,.25), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=numrbstcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_blank(), #remove facet (outcome) labels 
        # strip.text.x = element_text(size = 8), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumprjbtwcommplot


sumdepbtwcommplot <- ggplot(data = PLME2_stsum_negemots_chg_rbstcomm, 
                       mapping = aes(x = PLME, 
                                     y = reorder(rural.ses.rbst, desc(rural.ses.rbst)), 
                                     color=method)) + 
  facet_wrap(~.category, nrow=1,
             labeller = labeller(.category = as_labeller(deplabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  stat_pointinterval(data=PLME2_stsum_negemots_av_comm,
                     aes(x=PLME, y=reorder(rural.ses.med, desc(rural.ses.med)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = .15)) +
  stat_pointinterval(data=PLME2_stsum_negemots_av_rbstcomm,
                     aes(x=PLME, y=reorder(rural.ses.rbst, desc(rural.ses.rbst)),
                         alpha=p80_gt0),
                     .width = .95, size = .7,
                     position = position_nudge(y = -.15)) +
  scale_color_manual(values=c("#fcae12", "#a92e5e"), 
                      labels=as_labeller(methodlabs), name=NULL, 
                     breaks=c('sumav', 'rbstcommav')) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  coord_cartesian(xlim=c(-.11,.71)) + 
  scale_x_continuous(breaks=c(0,.5), labels = dropLeadingZero) +
  xlab(element_blank()) + 
  scale_y_discrete(labels=numrbstcommlabs2) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        # legend.direction="vertical",
        strip.background = element_blank(),
        strip.text.x = element_blank(), 
        # strip.text.x = element_text(size = 8), 
        axis.text.y=element_blank(), #remove y-axis labels
        axis.ticks.y=element_blank(), #remove y-axis ticks
        axis.line.y=element_blank(), #remove y-axis line
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), 
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)))

# sumdepbtwcommplot




design <- "
12
34
55
"    

# library(patchwork)
Appendix2 <- sumprjwfecommplot2 + sumdepwfecommplot2 +
  sumprjbtwcommplot + sumdepbtwcommplot + 
  guide_area() +
  plot_layout(design=design, guides = 'collect', heights = c(2,2,.1)) + 
    plot_annotation(
    title = 'APPENDIX 2\nMarginal Effects of Stress Scale Increase on Outcome Probabilities, by Estimator & Discrete or Continuous Community Measure',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Estimates derived from multivariate (using `brms::mvbind()`) and multilevel between-within Bayesian logistic regression models simultaneously regressing  all criminal intent outcomes (6*2=12 models) and all negative emotion outcomes (7*2=14 models) on a standardized sum stress scale separated into L2 cross-time average (Xbar_i) between-person and L1 within-person change (X_it - Xbar_i) "fixed effects" estimators. Two separate models also regressed "any criminal intent" on stress. "Discrete" community models included a factor variable for community and multiplicative interactions  between community and both L1/L2 stress estimators. "Continuous" community models included three- way interactions between stress, a rural/urban binary indicator, and a continuous standardized community level SES variable to assess robustness of results across community measurement. Models were estimated in brms with 4 chains and 4000 total post-warmup posterior draws per outcome and per community group. Marginal effect contrast distributions were estimated from the expectation of the posterior predictive distribution for each model as community-specific predicted probability difference distributions averaged over all 1-unit increases on the stress scale (within) or for a 1SD increase from mean (between; "0" vs "1") on initial IRT or standardized latent scale, averaged over the alternative (between or within) stress estimator levels. In bottom panel, predicted contrasts were estimated for rural/urban communities with -1SD (low) and +1SD (high) continuous L2 SES levels. Median posterior density estimates with 95% intervals displayed. Bold point-intervals indicate at least 80% of posterior estimates for the average marginal effect contrast are greater than zero.', width=190)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'bottom', 
        legend.key.height = unit(.5, 'cm'), 
        legend.margin = margin(0,0,0,0), 
        legend.spacing.y = unit(0, "mm"))

Appendix2

ggsave("Appendix2.jpeg", width=9, height=6.5, path=here("Output"))
save(stress.long3, file = here("1_Data_Files/Datasets/stress_long3.Rdata"))

12 Figure 5: Mediation models

(RMD FILE: BDK_2023_Stress_11_Fig5_mediate)

## [1] "T/F: Root 'here()' folder contains subfolder 'Models'"
## [1] TRUE

12.1 Mediation Modeling

General strain theory posits that stress causes negative emotions that, under certain conditions, cause criminal coping reactions, while certain stressors and resulting negative emotions are expected to be more “criminogenic” than others. For instance, theory and research suggests that individuals who experience “internalizing emotions” such as depressive symptoms in response to stressors are less likely to engage in aggressive or criminal coping behaviors. In contrast, stressors that invoke perceptions of unfair treatment, mistreatment, or betrayal presumably are more likely to result in “externalizing” responses such as criminal coping. Hence, we explore whether multivariate correlational patterns are consistent with the prediction that “criminogenic” emotions mediate stress-criminal intent associations.

Unfortunately, estimating mediation models with every multivariate combination of stress item, criminogenic emotion item, and criminal intent outcome item compounds the number of potential estimates, making summary and visualization even more untenable. Thus, for this exploratory analysis, we will reduce the number of potential estimates by, first, relying on our standardized sum stress composite scale and, second, collapsing our negative emotions items into a variety index.

The sum stress scale will permit estimation of the posited effects of between-person differences and within-person changes on criminogenic emotions and stress. Alternative scaling methods, such as factor-based or IRT scaling, typically enforce strong assumptions about the unidimensionality of an underlying latent construct and, by weighting items according to underlying theta or factor loadings, may overrepresent effect estimates corresponding to upweighted component items while suppressing those corresponding to down-weighted items. In this case, while a general “stressed” construct might be partly be driving reporting on each component stress item, multidimensionality cannot be ruled out - that is, one can imagine experiencing high financial stress, low relational stress, high job-related stress, and low victimization stress - or any other possible combination of stress levels. In such instances, weighted scales should be avoided altogether absent compelling theoretical reasoning and, if scaling is necessary, it should be conducted with caution and unweighted (e.g., simple sum) scales should be more effective in capturing and summarizing any effects of underlying components (see Appendix 1).

For similar reasons, we employ a simple variety index of the reported number of negative criminogenic emotions experienced, which permits us to estimate the change in the number of potentially criminogenic emotional “symptoms” associated with an increase in overall (sum) stress levels as well as the change in the probability of criminal intent associated with a one-symptom increase in criminogenic negative emotions. For robustness purposes, we also estimate (and present results below) mediation models using a sum scale for criminogenic emotions.

As for modeling, at this time, there is a lack of accessible options for multilevel mediation modeling - particularly if one wishes to generate between- and within-unit estimates or to specify a cumulative probit/logit function for ordinal predictors. Ultimately, we chose to estimate between/within models in brms similar to those estimated earlier, then we use easystats::mediate() function to estimate mediation pathway coefficients (e.g., direct and indirect effects). Since this package generates average causal mediation estimates from posterior distributions, the hope was that it would be flexible enough to apply to our models with ordinal predictors. Unfortunately, that did not work (see github issue). So, we instead settled for simpler mediation models by specifying X (stress) and M (emotions) as metric continuous variables (linear M models) and Y (criminal intent) as binary (logistic Y models). We supplemented estimates from these models with within-person X->M and X->Y effect plots generated using bmlm package, which is designed specifically to estimate within-unit mediation processes.

Ultimately, we present exploratory causal mediation estimates generated from these complementary approaches to assess whether these data plausibly might have been generated by the posited causal process - that is, whether evidence supports (among other plausible alternatives) the existence of indirect linear causal effects of differences or changes in stress (sum scale) on criminal intent (binary items) through differences or changes in “criminogenic” negative emotions items.

12.1.1 Data wrangling & summaries

load(here("1_Data_Files/Datasets/stress_wide4.Rdata"))
load(here("1_Data_Files/Datasets/stress_long3.Rdata"))
# summarytools::freq
# freq(stress.wide4$depunfairordw1)
# freq(stress.wide4$depunfairordw2)
# freq(stress.wide4$depmistrtordw1)
# freq(stress.wide4$depmistrtordw2)
# freq(stress.wide4$depbetrayordw1)
# freq(stress.wide4$depbetrayordw2)
# missing (NA) on one id for depunfairw1

# freq(stress.long3$depunfair) 
# freq(stress.long3$depmistrt) 
# freq(stress.long3$depbetray)


stress.long4 <- stress.long3 %>%
  mutate(
    indcrmemo = (as.numeric(depunfair) + as.numeric(depmistrt) + as.numeric(depbetray))-3,
    sumcrmemo = depunfairord + depmistrtord + depbetrayord,
    prjthflt5i = as.integer(recode(prjthflt5,
            "0" = 0, "1" = 1)),  # need binary y as integer for bmlm
    prjthfgt5i = as.integer(recode(prjthfgt5,
            "0" = 0, "1" = 1)),
    prjthreati = as.integer(recode(prjthreat,
            "0" = 0, "1" = 1)),
    prjharmi = as.integer(recode(prjharm,
            "0" = 0, "1" = 1)),
    prjusedrgi = as.integer(recode(prjusedrg,
            "0" = 0, "1" = 1)),
    prjhacki = as.integer(recode(prjhack,
            "0" = 0, "1" = 1)), 
    prjanyi = as.integer(recode(prjany,
            "0" = 0, "1" = 1)) 
    ) %>%
    drop_na(sumcrmemo) %>% # row for id w/missing unfairw1 obs dropped  
  group_by(id) %>%
  mutate(
    nobs = n() #count num observations by id to identify id w/missing row
  ) %>%
  ungroup() %>%
  filter(nobs ==2) %>%
  mutate(
    sumcrmemoz = (sumcrmemo - mean(sumcrmemo))/sd(sumcrmemo), #stdz sum crim emo var
    indcrmemoc = indcrmemo - mean(indcrmemo)
    ) %>%
  group_by(id) %>% #w2 row for id w/missing unfairw1 obs dropped 
  mutate( 
    sumcrmemozav = mean(sumcrmemoz), #create btw-person version of crim emo
    indcrmemoav = mean(indcrmemo),
    indcrmemocav = mean(indcrmemoc)
  ) %>% 
  ungroup() %>% 
  mutate(
    sumcrmemozchg = sumcrmemoz - sumcrmemozav, #create w/in-person version of crim emo
    indcrmemocchg = indcrmemoc - indcrmemocav, #create w/in-person version of crim emo
    indcrmemocchgi = as.integer(indcrmemocchg*2), #factor & integer versions (x2) for ordinal models
    indcrmemocchgf = factor(indcrmemocchgi, ordered=TRUE, levels = c(-3, -2, -1, 0, 1, 2, 3)), 
    indcrmemoavi = as.integer(indcrmemoav*2),
    indcrmemoavf = factor(indcrmemoavi, ordered=TRUE, levels = c(0, 1, 2, 3, 4, 5, 6)),
  ) %>%
  dplyr::select(-nobs)
# 976 obs from 488 ids (one id dropped)

12.1.1.1 Crim. Emotions (Sum)

ggplot(stress.long4, aes(sumcrmemo)) + geom_histogram(fill="#E99D53") + xlab("sumcrmemo (Crim Emotions Sum Score)")

12.1.1.2 Crim. Emotions (Stdz Sum)

ggplot(stress.long4, aes(sumcrmemoz)) + geom_histogram(fill="#E99D53") + xlab("sumcrmemo (Crim Emotions Std Sum Score)")

12.1.1.3 Crim. Emotions (Stdz Sum, Between)

ggplot(stress.long4, aes(sumcrmemozav)) + geom_histogram(fill="#E99D53") + xlab("sumcrmemo (Crim Emotions Std Sum Score; btw-id cross-time avg)")

12.1.1.4 Crim. Emotions (Stdz Sum, Within)

ggplot(stress.long4, aes(sumcrmemozchg)) + geom_histogram(fill="#E99D53") + xlab("sumcrmemo (Crim Emotions Sum Score; w/in-id chg)")

12.1.1.5 Crim. Emotions (Variety)

ggplot(stress.long4, aes(indcrmemo)) + geom_bar(fill="#E99D53") + xlab("sumcrmemo (Crim Emotions Variety Index)")

12.1.1.6 Crim. Emotions (Centered Variety)

ggplot(stress.long4, aes(indcrmemoc)) + geom_bar(fill="#E99D53") + xlab("sumcrmemo (Crim Emotions Centered Variety Index)")

12.1.1.7 Crim. Emotions (Centered Variety, Between)

ggplot(stress.long4, aes(indcrmemocav)) + geom_bar(fill="#E99D53") + xlab("sumcrmemo (Crim Emotions Centered Variety Index; btw-id avg)")

12.1.1.8 Crim. Emotions (Centered Variety, Within)

ggplot(stress.long4, aes(indcrmemocchg)) + geom_bar(fill="#E99D53") + xlab("sumcrmemo (Crim Emotions Centered Variety Index; w/in-id chg)")

12.1.1.9 Corr: Stdz Sum & Variety Crim. Emotions (Between)

cor(stress.long4$sumcrmemozav, stress.long4$indcrmemocav)
## [1] 0.81

12.1.1.10 Corr: Stdz Sum & Variety Crim. Emotions (Within)

cor(stress.long4$sumcrmemozchg, stress.long4$indcrmemocchg)
## [1] 0.81

12.2 B/W Mediation Models (brms; mediate)

12.2.1 X=stdz sum stress, M=crim emotions (variety index)

#Attempted to specify emotion mediators as ordinal
  # models estimate fine but mediation() throws errors 
  # raised issue here: https://github.com/easystats/bayestestR/issues/576


# f1.1o <- bf(prjthflt5 ~ 1 + sumstresschg + sumstressav +
#      mo(indcrmemoavf) + mo(indcrmemocchgf) + (1 | id),
#       family = "bernoulli")
# f1.2o <- bf(indcrmemocchgf ~ 1 + sumstressav + sumstresschg +
#      indcrmemocav + (1 | id),
#       family = cumulative("probit"))
# m1wo <- brm(f1.1o + f1.2o, set_rescor(FALSE),
#       data = stress.long4,
#       # prior = prior1,
#       cores = nCoresphys,
#       chains = 4,
#       backend = "cmdstanr",
#       seed = 8675309)
# summary(m1wo)
# 
# medy1wo <- mediation(m1wo,
#           treatment="sumstresschg",
#           mediator="indcrmemocchgf",
#           response=c(m="indcrmemocchgf", y="prjthflt5"),
#           ci=.95
#           )
# medy1wo


# "simple" mediation models treating X & M as metric & Y as binary (logistic)
  # default priors for M models, same Int & beta priors for Y models as before

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = "prjthflt5"),
  set_prior('normal(0, 1)', class = 'b', resp = "prjthflt5")
  )

fy1w <- bf(prjthflt5 ~ 1 + sumstresschg + sumstressav +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
fmw <- bf(indcrmemocchg ~ 1 + sumstressav + sumstresschg + 
     indcrmemocav + (1 | id),   
      family = "gaussian")
m1w <- brm(fy1w + fmw, set_rescor(FALSE), 
      data = stress.long4,
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/m1w",
      file_refit = "on_change"
      )

fy1b <- bf(prjthflt5 ~ 1 + sumstressav + sumstresschg +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
fmb <- bf(indcrmemocav ~ 1 + sumstressav + sumstresschg + 
     indcrmemocchg + (1 | id),   
      family = "gaussian")
m1b <- brm(fy1b + fmb, set_rescor(FALSE), 
      data = stress.long4, 
      prior = prior1,
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m1b",
      file_refit = "on_change"
      )


prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = "prjthfgt5"),
  set_prior('normal(0, 1)', class = 'b', resp = "prjthfgt5")
  )

fy2w <- bf(prjthfgt5 ~ 1 + sumstresschg + sumstressav +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m2w <- brm(fy2w + fmw, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/m2w",
      file_refit = "on_change"
      )

fy2b <- bf(prjthfgt5 ~ 1 + sumstressav + sumstresschg +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m2b <- brm(fy2b + fmb, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m2b",
      file_refit = "on_change"
      )

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = "prjthreat"),
  set_prior('normal(0, 1)', class = 'b', resp = "prjthreat")
  )

fy3w <- bf(prjthreat ~ 1 + sumstresschg + sumstressav +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m3w <- brm(fy3w + fmw, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m3w",
      file_refit = "on_change"
      )

fy3b <- bf(prjthreat ~ 1 + sumstressav + sumstresschg +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m3b <- brm(fy3b + fmb, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m3b",
      file_refit = "on_change"
      )

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = "prjharm"),
  set_prior('normal(0, 1)', class = 'b', resp = "prjharm")
  )

fy4w <- bf(prjharm ~ 1 + sumstresschg + sumstressav +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m4w <- brm(fy4w + fmw, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m4w",
      file_refit = "on_change"
      )

fy4b <- bf(prjharm ~ 1 + sumstressav + sumstresschg +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m4b <- brm(fy4b + fmb, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309, 
      file = "Models/m4b",
      file_refit = "on_change"
      )

prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = "prjusedrg"),
  set_prior('normal(0, 1)', class = 'b', resp = "prjusedrg")
  )

fy5w <- bf(prjusedrg ~ 1 + sumstresschg + sumstressav +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m5w <- brm(fy5w + fmw, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m5w",
      file_refit = "on_change"
      )

fy5b <- bf(prjusedrg ~ 1 + sumstressav + sumstresschg +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m5b <- brm(fy5b + fmb, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m5b",
      file_refit = "on_change"
      )


prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = "prjhack"),
  set_prior('normal(0, 1)', class = 'b', resp = "prjhack")
  )

fy6w <- bf(prjhack ~ 1 + sumstresschg + sumstressav +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m6w <- brm(fy6w + fmw, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m6w",
      file_refit = "on_change"
      )

fy6b <- bf(prjhack ~ 1 + sumstressav + sumstresschg +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m6b <- brm(fy6b + fmb, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m6b",
      file_refit = "on_change"
      )


prior1 <- c(
  set_prior('normal(0, 2)', class = 'Intercept', resp = "prjany"),
  set_prior('normal(0, 1)', class = 'b', resp = "prjany")
  )

fy7w <- bf(prjany ~ 1 + sumstresschg + sumstressav +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m7w <- brm(fy7w + fmw, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m7w",
      file_refit = "on_change"
      )

fy7b <- bf(prjany ~ 1 + sumstressav + sumstresschg +  
     indcrmemocav + indcrmemocchg + (1 | id),   
      family = "bernoulli")
m7b <- brm(fy7b + fmb, set_rescor(FALSE), 
      data = stress.long4, 
      cores = nCoresphys,
      chains = 4, 
      backend = "cmdstanr",
      seed = 8675309,
      file = "Models/m7b",
      file_refit = "on_change"
      )

12.2.1.1 Within-person mediation (x=chg, m=chg)

12.2.1.1.1 Theft <5BAM
medy1w <- mediation(m1w,
          treatment="sumstresschg",
          mediator="indcrmemocchg",
          ci=.95)
medy1w
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstresschg
##   Mediator : indcrmemocchg
##   Response : prjthflt5
## 
## Effect                 | Estimate |         95% ETI
## ---------------------------------------------------
## Direct Effect (ADE)    |    0.516 | [-0.687, 1.686]
## Indirect Effect (ACME) |   -0.044 | [-0.330, 0.233]
## Mediator Effect        |   -0.078 | [-0.554, 0.401]
## Total Effect           |    0.474 | [-0.688, 1.602]
## 
## Proportion mediated: -9.21% [-248.17%, 229.74%]
12.2.1.1.2 Theft >5BAM
medy2w <- mediation(m2w,
          treatment="sumstresschg",
          mediator="indcrmemocchg",
          ci=.95)
medy2w
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstresschg
##   Mediator : indcrmemocchg
##   Response : prjthfgt5
## 
## Effect                 | Estimate |         95% ETI
## ---------------------------------------------------
## Direct Effect (ADE)    |    1.586 | [ 0.018, 3.262]
## Indirect Effect (ACME) |   -0.083 | [-0.408, 0.217]
## Mediator Effect        |   -0.144 | [-0.681, 0.380]
## Total Effect           |    1.504 | [ 0.010, 3.094]
## 
## Proportion mediated: -5.51% [-48.81%, 37.79%]
12.2.1.1.3 Threat
medy3w <- mediation(m3w,
          treatment="sumstresschg",
          mediator="indcrmemocchg",
          ci=.95)
medy3w
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstresschg
##   Mediator : indcrmemocchg
##   Response : prjthreat
## 
## Effect                 | Estimate |         95% ETI
## ---------------------------------------------------
## Direct Effect (ADE)    |   -1.745 | [-4.178, 0.305]
## Indirect Effect (ACME) |    0.105 | [-0.276, 0.508]
## Mediator Effect        |    0.186 | [-0.478, 0.855]
## Total Effect           |   -1.646 | [-3.906, 0.302]
## 
## Proportion mediated: -6.39% [-75.98%, 63.20%]
12.2.1.1.4 Phys. Harm
medy4w <- mediation(m4w,
          treatment="sumstresschg",
          mediator="indcrmemocchg",
          ci=.95)
medy4w
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstresschg
##   Mediator : indcrmemocchg
##   Response : prjharm
## 
## Effect                 | Estimate |          95% ETI
## ----------------------------------------------------
## Direct Effect (ADE)    |   -2.262 | [-4.772, -0.187]
## Indirect Effect (ACME) |    0.338 | [-0.050,  0.842]
## Mediator Effect        |    0.593 | [-0.090,  1.434]
## Total Effect           |   -1.943 | [-4.257,  0.015]
## 
## Proportion mediated: -17.39% [-82.36%, 47.59%]
12.2.1.1.5 Use drugs
medy5w <- mediation(m5w,
          treatment="sumstresschg",
          mediator="indcrmemocchg",
          ci=.95)
medy5w
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstresschg
##   Mediator : indcrmemocchg
##   Response : prjusedrg
## 
## Effect                 | Estimate |         95% ETI
## ---------------------------------------------------
## Direct Effect (ADE)    |   -1.333 | [-3.807, 0.956]
## Indirect Effect (ACME) |    0.133 | [-0.234, 0.548]
## Mediator Effect        |    0.233 | [-0.416, 0.908]
## Total Effect           |   -1.207 | [-3.601, 1.008]
## 
## Proportion mediated: -11.05% [-150.09%, 127.98%]
12.2.1.1.6 Hack info.
medy6w <- mediation(m6w,
          treatment="sumstresschg",
          mediator="indcrmemocchg",
          ci=.95)
medy6w
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstresschg
##   Mediator : indcrmemocchg
##   Response : prjhack
## 
## Effect                 | Estimate |         95% ETI
## ---------------------------------------------------
## Direct Effect (ADE)    |   -0.911 | [-2.943, 1.042]
## Indirect Effect (ACME) |    0.131 | [-0.243, 0.530]
## Mediator Effect        |    0.231 | [-0.416, 0.876]
## Total Effect           |   -0.784 | [-2.690, 1.092]
## 
## Proportion mediated: -16.74% [-252.25%, 218.76%]
12.2.1.1.7 Any crime intent
medy7w <- mediation(m1w,
          treatment="sumstresschg",
          mediator="indcrmemocchg",
          ci=.95)
medy7w
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstresschg
##   Mediator : indcrmemocchg
##   Response : prjthflt5
## 
## Effect                 | Estimate |         95% ETI
## ---------------------------------------------------
## Direct Effect (ADE)    |    0.516 | [-0.687, 1.686]
## Indirect Effect (ACME) |   -0.044 | [-0.330, 0.233]
## Mediator Effect        |   -0.078 | [-0.554, 0.401]
## Total Effect           |    0.474 | [-0.688, 1.602]
## 
## Proportion mediated: -9.21% [-248.17%, 229.74%]

12.2.1.2 Between-person mediation (x=av, m=av)

12.2.1.2.1 Theft <5BAM
medy1b <- mediation(m1b,
          treatment="sumstressav",
          mediator="indcrmemocav",
          ci=.95)
medy1b
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstressav
##   Mediator : indcrmemocav
##   Response : prjthflt5
## 
## Effect                 | Estimate |        95% ETI
## --------------------------------------------------
## Direct Effect (ADE)    |    0.684 | [0.194, 1.233]
## Indirect Effect (ACME) |    0.202 | [0.150, 0.264]
## Mediator Effect        |    1.179 | [0.769, 1.518]
## Total Effect           |    0.839 | [0.438, 1.496]
## 
## Proportion mediated: 24.02% [3.64%, 44.40%]
12.2.1.2.2 Theft >5BAM
medy2b <- mediation(m2b,
          treatment="sumstressav",
          mediator="indcrmemocav",
          ci=.95)
medy2b
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstressav
##   Mediator : indcrmemocav
##   Response : prjthfgt5
## 
## Effect                 | Estimate |        95% ETI
## --------------------------------------------------
## Direct Effect (ADE)    |    0.956 | [0.287, 1.414]
## Indirect Effect (ACME) |    0.139 | [0.067, 0.312]
## Mediator Effect        |    0.909 | [0.471, 1.648]
## Total Effect           |    1.145 | [0.370, 1.608]
## 
## Proportion mediated: 12.11% [5.08%, 19.15%]
12.2.1.2.3 Threat
medy3b <- mediation(m3b,
          treatment="sumstressav",
          mediator="indcrmemocav",
          ci=.95)
medy3b
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstressav
##   Mediator : indcrmemocav
##   Response : prjthreat
## 
## Effect                 | Estimate |        95% ETI
## --------------------------------------------------
## Direct Effect (ADE)    |    1.173 | [1.013, 1.267]
## Indirect Effect (ACME) |    0.222 | [0.095, 0.485]
## Mediator Effect        |    1.194 | [0.578, 2.580]
## Total Effect           |    1.349 | [1.199, 1.752]
## 
## Proportion mediated: 16.47% [6.32%, 26.62%]
12.2.1.2.4 Phys. Harm
medy4b <- mediation(m4b,
          treatment="sumstressav",
          mediator="indcrmemocav",
          ci=.95)
medy4b
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstressav
##   Mediator : indcrmemocav
##   Response : prjharm
## 
## Effect                 | Estimate |         95% ETI
## ---------------------------------------------------
## Direct Effect (ADE)    |    0.113 | [-0.162, 0.875]
## Indirect Effect (ACME) |    0.205 | [ 0.152, 0.334]
## Mediator Effect        |    1.013 | [ 0.741, 1.862]
## Total Effect           |    0.356 | [ 0.022, 1.100]
## 
## Proportion mediated: 57.58% [-348.42%, 463.58%]
12.2.1.2.5 Use drugs
medy5b <- mediation(m5b,
          treatment="sumstressav",
          mediator="indcrmemocav",
          ci=.95)
medy5b
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstressav
##   Mediator : indcrmemocav
##   Response : prjusedrg
## 
## Effect                 | Estimate |        95% ETI
## --------------------------------------------------
## Direct Effect (ADE)    |    0.460 | [0.415, 0.894]
## Indirect Effect (ACME) |    0.210 | [0.152, 0.308]
## Mediator Effect        |    1.241 | [0.677, 1.634]
## Total Effect           |    0.670 | [0.567, 1.203]
## 
## Proportion mediated: 31.40% [27.00%, 35.80%]
12.2.1.2.6 Hack info.
medy6b <- mediation(m6b,
          treatment="sumstressav",
          mediator="indcrmemocav",
          ci=.95)
medy6b
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstressav
##   Mediator : indcrmemocav
##   Response : prjhack
## 
## Effect                 | Estimate |        95% ETI
## --------------------------------------------------
## Direct Effect (ADE)    |    0.731 | [0.373, 1.483]
## Indirect Effect (ACME) |    0.160 | [0.023, 0.224]
## Mediator Effect        |    0.801 | [0.103, 1.157]
## Total Effect           |    0.823 | [0.532, 1.707]
## 
## Proportion mediated: 19.41% [5.58%, 33.23%]
12.2.1.2.7 Any crime intent
medy7b <- mediation(m1b,
          treatment="sumstressav",
          mediator="indcrmemocav",
          ci=.95)
medy7b
## # Causal Mediation Analysis for Stan Model
## 
##   Treatment: sumstressav
##   Mediator : indcrmemocav
##   Response : prjthflt5
## 
## Effect                 | Estimate |        95% ETI
## --------------------------------------------------
## Direct Effect (ADE)    |    0.684 | [0.194, 1.233]
## Indirect Effect (ACME) |    0.202 | [0.150, 0.264]
## Mediator Effect        |    1.179 | [0.769, 1.518]
## Total Effect           |    0.839 | [0.438, 1.496]
## 
## Proportion mediated: 24.02% [3.64%, 44.40%]

12.3 Alt. Within-person Mediation Models (bmlm)

The models below present an alternative to between/within models for estimating within-person mediation effects using the bmlm package’s within-subjects mediation modeling. See here and here for more details.

12.3.1 X=stdz sum stress change, M=crim emotions (variety index)

# Within-subjects bayesian mediation models (bmlm)
  # X: stress change (sum scale)
  # M: criminogenic emotions (variety index)
  # Y: binary criminal intent items


# no built-in file save option, knitr & xfun cache options not working as desired during knitting
# instead, manual saving & loading bmlm models 

if (file.exists(here("Models","fit_med_1"))) {
   fit_med.1 <- readRDS("Models/fit_med_1")
 } else {
# mediation analysis - prjthflt5
fit_med.1 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "indcrmemocchg",
                 y = "prjthflt5i",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_med.1, file = "Models/fit_med_1")
}

# mediation model - prjthfgt5
if (file.exists(here("Models","fit_med_2"))) {
   fit_med.2 <- readRDS("Models/fit_med_2")
 } else {
fit_med.2 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "indcrmemocchg",
                 y = "prjthfgt5i",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_med.2, file = "Models/fit_med_2")
}

# mediation model - prjthreati
if (file.exists(here("Models","fit_med_3"))) {
   fit_med.3 <- readRDS("Models/fit_med_3")
 } else {
fit_med.3 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "indcrmemocchg",
                 y = "prjthreati",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_med.3, file = "Models/fit_med_3")
}

# mediation model - prjharmi
if (file.exists(here("Models","fit_med_4"))) {
   fit_med.4 <- readRDS("Models/fit_med_4")
 } else {
fit_med.4 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "indcrmemocchg",
                 y = "prjharmi",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_med.4, file = "Models/fit_med_4")
}

# mediation model - prjusedrgi
if (file.exists(here("Models","fit_med_5"))) {
   fit_med.5 <- readRDS("Models/fit_med_5")
 } else {
fit_med.5 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "indcrmemocchg",
                 y = "prjusedrgi",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_med.5, file = "Models/fit_med_5")
}

# mediation model - prjhacki
if (file.exists(here("Models","fit_med_6"))) {
   fit_med.6 <- readRDS("Models/fit_med_6")
 } else {
fit_med.6 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "indcrmemocchg",
                 y = "prjhacki",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_med.6, file = "Models/fit_med_6")
}

# mediation model - prjanyi
if (file.exists(here("Models","fit_med_7"))) {
   fit_med.7 <- readRDS("Models/fit_med_7")
 } else {
fit_med.7 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "indcrmemocchg",
                 y = "prjanyi",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_med.7, file = "Models/fit_med_7")
}


pars <- c("a", "b", "cp", "corrab")

# Diagnostic messages
# check_hmc_diagnostics(fit_med.1)
# check_hmc_diagnostics(fit_med.2)
# check_hmc_diagnostics(fit_med.3)
# check_hmc_diagnostics(fit_med.4)
# check_hmc_diagnostics(fit_med.5)
# check_hmc_diagnostics(fit_med.6)
# check_hmc_diagnostics(fit_med.7)

12.3.1.1 Theft <5BAM

12.3.1.1.1 Plot parameters (violin)
mlm_pars_plot(fit_med.1,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5))

12.3.1.1.2 Plot effects (pop-avg fitted values)
medplot1 <- mlm_spaghetti_plot(
  mod = fit_med.1,
  d = stress.long4,
  x = "sumstresschg", m = "indcrmemocchg", y = "prjthflt5i", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    medplot1[[1]] + labs(title="Path a (X -> M)"), 
    medplot1[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.1.1.3 Path diagram
mlm_path_plot(fit_med.1, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(variety)", 
              ylab = "Theft\n<5BAM")

  # grid.echo() #grab grid element (path plot)
  # path1 <- grid.grab() #save as grid object
12.3.1.1.4 Fit summary
#mediation model summary - prjthftlt5
mlm_summary(fit_med.1)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.78  0.19   0.78  0.41  1.15  7890    1
## 2         b -0.16  0.47  -0.16 -1.11  0.81   442    1
## 3        cp  1.01  1.60   0.98 -2.25  4.37   262    1
## 4        me -0.10  0.61  -0.09 -1.37  1.18   394    1
## 5         c  0.92  1.62   0.88 -2.35  4.27   245    1
## 6       pme -0.15 15.90   0.00 -4.19  3.91 19639    1
12.3.1.1.5 Trace plots
mcmc_trace(as.data.frame(fit_med.1), pars = pars)

12.3.1.2 Theft >5BAM

12.3.1.2.1 Plot parameters (violin)
mlm_pars_plot(fit_med.2,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5))

12.3.1.2.2 Plot effects (pop-avg fitted values)
medplot2 <- mlm_spaghetti_plot(
  mod = fit_med.2,
  d = stress.long4,
  x = "sumstresschg", m = "indcrmemocchg", y = "prjthfgt5i", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    medplot2[[1]] + labs(title="Path a (X -> M)"), 
    medplot2[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.1.2.3 Path diagram
mlm_path_plot(fit_med.2, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(variety)", 
              ylab = "Theft\n>5BAM")

  # grid.echo() #grab grid element (path plot)
  # path2 <- grid.grab() #save as grid object
12.3.1.2.4 Fit summary
#mediation model summary - prjthftgt5
mlm_summary(fit_med.2)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.78  0.19   0.78  0.41  1.16  8857    1
## 2         b -0.23  0.42  -0.22 -1.08  0.60   366    1
## 3        cp  1.43  1.50   1.46 -1.81  4.44   382    1
## 4        me -0.26  0.54  -0.23 -1.46  0.79   311    1
## 5         c  1.17  1.49   1.23 -2.12  4.08   355    1
## 6       pme  0.35 48.87  -0.08 -3.56  3.12 19958    1
12.3.1.2.5 Trace plots
mcmc_trace(as.data.frame(fit_med.2), pars = pars)

12.3.1.3 Threat

12.3.1.3.1 Plot parameters (violin)
mlm_pars_plot(fit_med.3,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5))

12.3.1.3.2 Plot effects (pop-avg fitted values)
medplot3 <- mlm_spaghetti_plot(
  mod = fit_med.3,
  d = stress.long4,
  x = "sumstresschg", m = "indcrmemocchg", y = "prjthreati", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    medplot3[[1]] + labs(title="Path a (X -> M)"), 
    medplot3[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.1.3.3 Path diagram
mlm_path_plot(fit_med.3, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(variety)", 
              ylab = "Threat")

  # grid.echo() #grab grid element (path plot)
  # path3 <- grid.grab() #save as grid object
12.3.1.3.4 Fit summary
#mediation model summary - prjthreat
mlm_summary(fit_med.3)
##   Parameter  Mean     SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.77   0.19   0.77  0.41  1.15 10000    1
## 2         b  0.12   0.53   0.12 -0.94  1.19   940    1
## 3        cp -1.10   1.85  -1.18 -4.62  2.91   830    1
## 4        me -0.31   0.66  -0.23 -1.82  0.83   602    1
## 5         c -1.41   1.86  -1.46 -5.08  2.61   795    1
## 6       pme  2.14 208.00   0.10 -2.78  2.79 20008    1
12.3.1.3.5 Trace plots
mcmc_trace(as.data.frame(fit_med.3), pars = pars)

12.3.1.4 Phys. Harm

12.3.1.4.1 Plot parameters (violin)
mlm_pars_plot(fit_med.4,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5)) 

12.3.1.4.2 Plot effects (pop-avg fitted values)
medplot4 <- mlm_spaghetti_plot(
  mod = fit_med.4,
  d = stress.long4,
  x = "sumstresschg", m = "indcrmemocchg", y = "prjharmi", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    medplot4[[1]] + labs(title="Path a (X -> M)"), 
    medplot4[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.1.4.3 Path diagram
mlm_path_plot(fit_med.4, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(variety)", 
              ylab = "Harm")

  # grid.echo() #grab grid element (path plot)
  # path4 <- grid.grab() #save as grid object
12.3.1.4.4 Fit summary
#mediation model summary - prjharm
mlm_summary(fit_med.4)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.78  0.19   0.78  0.40   1.1 13521    1
## 2         b  0.47  0.55   0.49 -0.68   1.6  1053    1
## 3        cp -1.85  2.11  -1.91 -6.05   2.7  1078    1
## 4        me  0.80  0.70   0.71 -0.38   2.4   698    1
## 5         c -1.05  2.15  -1.14 -5.21   3.6   991    1
## 6       pme  0.28 74.62  -0.19 -6.17   5.5 19888    1
12.3.1.4.5 Trace plots
mcmc_trace(as.data.frame(fit_med.4), pars = pars)

12.3.1.5 Use drugs

12.3.1.5.1 Plot parameters (violin)
mlm_pars_plot(fit_med.5,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5)) 

12.3.1.5.2 Plot effects (pop-avg fitted values)
medplot5 <- mlm_spaghetti_plot(
  mod = fit_med.5,
  d = stress.long4,
  x = "sumstresschg", m = "indcrmemocchg", y = "prjusedrgi", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    medplot5[[1]] + labs(title="Path a (X -> M)"), 
    medplot5[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.1.5.3 Path diagram
mlm_path_plot(fit_med.5, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(variety)", 
              ylab = "Use\nDrugs")

  # grid.echo() #grab grid element (path plot)
  # path5 <- grid.grab() #save as grid object
12.3.1.5.4 Fit summary
#mediation model summary - prjusedrg
mlm_summary(fit_med.5)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.81  0.19   0.81  0.44  1.19 11849    1
## 2         b  0.40  0.59   0.39 -0.76  1.60   905    1
## 3        cp -0.73  1.87  -0.81 -4.30  3.27   863    1
## 4        me -1.01  0.94  -0.92 -3.09  0.52   936    1
## 5         c -1.75  1.93  -1.74 -5.59  2.17  1065    1
## 6       pme  0.00 39.35   0.37 -4.08  4.82 20101    1
12.3.1.5.5 Trace plots
mcmc_trace(as.data.frame(fit_med.5), pars = pars)

12.3.1.6 Hack info.

12.3.1.6.1 Plot parameters (violin)
mlm_pars_plot(fit_med.6,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5)) 

12.3.1.6.2 Plot effects (pop-avg fitted values)
medplot6 <- mlm_spaghetti_plot(
  mod = fit_med.6,
  d = stress.long4,
  x = "sumstresschg", m = "indcrmemocchg", y = "prjhacki", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    medplot6[[1]] + labs(title="Path a (X -> M)"), 
    medplot6[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.1.6.3 Path diagram
mlm_path_plot(fit_med.6, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(variety)", 
              ylab = "Hack\nInfo")

  # grid.echo() #grab grid element (path plot)
  # path6 <- grid.grab() #save as grid object
12.3.1.6.4 Fit summary
#mediation model summary - prjhack
mlm_summary(fit_med.6)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.77  0.19   0.77  0.40   1.1  9072    1
## 2         b  0.21  0.43   0.20 -0.64   1.1  1988    1
## 3        cp -0.89  1.12  -0.88 -3.10   1.3  4840    1
## 4        me  0.34  0.67   0.30 -0.97   1.8   446    1
## 5         c -0.55  1.17  -0.56 -2.85   1.8  3420    1
## 6       pme -0.28 81.13   0.00 -7.61   7.4 19993    1
12.3.1.6.5 Trace plots
mcmc_trace(as.data.frame(fit_med.6), pars = pars)

12.3.1.7 Any crime intent

12.3.1.7.1 Plot parameters (violin)
mlm_pars_plot(fit_med.7,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5)) 

12.3.1.7.2 Plot effects (pop-avg fitted values)
medplot7 <- mlm_spaghetti_plot(
  mod = fit_med.7,
  d = stress.long4,
  x = "sumstresschg", m = "indcrmemocchg", y = "prjanyi", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    medplot7[[1]] + labs(title="Path a (X -> M)"), 
    medplot7[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.1.7.3 Path diagram
mlm_path_plot(fit_med.7, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(variety)", 
              ylab = "Any\nCrime")

  # grid.echo() #grab grid element (path plot)
  # path7 <- grid.grab() #save as grid object
12.3.1.7.4 Fit summary
#mediation model summary - prjany
mlm_summary(fit_med.7)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.79  0.19   0.79  0.42  1.16  8727    1
## 2         b  0.16  0.40   0.16 -0.67  0.96   418    1
## 3        cp  0.63  1.06   0.60 -1.48  2.84   512    1
## 4        me  0.16  0.54   0.15 -0.94  1.30   453    1
## 5         c  0.78  1.09   0.76 -1.38  3.02   335    1
## 6       pme -0.33 74.40   0.17 -4.40  4.89 19996    1
12.3.1.7.5 Trace plots
mcmc_trace(as.data.frame(fit_med.7), pars = pars)

12.3.1.8 Combine bmlm plots (variety M)

# Combine path plots
# grid.arrange(path1, path2, path3, path4, path5, path6, path7)
  # text does not scale properly

#Generate custom X->M & M->Y plots for Fig5

#function to find & drop leading zeroes (used for x-axis label)
dropLeadingZero <- function(l){
  str_replace(l, '0(?=.)', '')
}

#Function to generate custom X-M spaghetti plots
  # NOTE: same x->m plot for all models
xmplot <- function(){
testdat %>% 
  ggplot(
    aes(y=m_fitted_mean, x=sumstresschg, 
        ymin=m_fitted_lower, ymax=m_fitted_upper)
    ) + 
  geom_line(color="#883E3A") + 
  geom_ribbon(fill="#883E3A", alpha=.2) +
  scale_x_continuous(limits=c(-.51,.51),breaks=c(-.5,.5), 
                     labels = dropLeadingZero) + 
  scale_y_continuous(limits=c(-.6,.6),breaks=c(-.5,.5), 
                     labels = dropLeadingZero) + 
  ylab("\U25B3M") + 
  xlab("\U25B3X") + 
  theme(axis.title = element_blank(), 
        axis.text = element_blank())
}


#Function to generate custom M-Y spaghetti plots
medyplot <- function(){
testdat %>% 
  ggplot(
    aes(y=y_fitted_mean, x=indcrmemocchg, 
        ymin=y_fitted_lower, ymax=y_fitted_upper)
    ) + 
  geom_line(color="#883E3A") + 
  geom_ribbon(fill="#883E3A", alpha=.2) +
  scale_x_continuous(limits=c(-.6,.6),breaks=c(-.5,.5), 
                     labels = dropLeadingZero) + 
  scale_y_continuous(limits=c(-.01,.21),breaks=c(0,.2), 
                     labels = dropLeadingZero) + 
  ylab("\U25B3Y") + 
  xlab("\U25B3M") + 
  theme(axis.title = element_blank(), 
        axis.text = element_blank())
}

#Generate custom spaghetti plots

#prjthftlt5
testdat <- medplot1[[1]]$layer[[1]]$data 
med1xmplot <- xmplot()
testdat <- medplot1[[2]]$layer[[2]]$data 
med1myplot <- medyplot()

#prjthftgt5
testdat <- medplot2[[1]]$layer[[1]]$data 
med2xmplot <- xmplot()
testdat <- medplot2[[2]]$layer[[2]]$data 
med2myplot <- medyplot()

#prjthreat
testdat <- medplot3[[1]]$layer[[1]]$data 
  med3xmplot <- xmplot()
testdat <- medplot3[[2]]$layer[[2]]$data 
  med3myplot <- medyplot()

#prjharm
testdat <- medplot4[[1]]$layer[[1]]$data 
  med4xmplot <- xmplot()
testdat <- medplot4[[2]]$layer[[2]]$data 
  med4myplot <- medyplot()

#prjusedrg
testdat <- medplot5[[1]]$layer[[1]]$data 
  med5xmplot <- xmplot()
testdat <- medplot5[[2]]$layer[[2]]$data 
  med5myplot <- medyplot()

#prjhack
testdat <- medplot6[[1]]$layer[[1]]$data 
  med6xmplot <- xmplot()
testdat <- medplot6[[2]]$layer[[2]]$data 
  med6myplot <- medyplot()

#prjany
testdat <- medplot7[[1]]$layer[[1]]$data 
med7xmplot <- xmplot()
testdat <- medplot7[[2]]$layer[[2]]$data 
med7myplot <- medyplot()

# new approach = merge & facet_grid

medplot1xmdat <- medplot1[[1]]$layer[[1]]$data 
medplot1xmdat <- medplot1xmdat %>% mutate(yvar="prjthftlt5", plotvar="xm")
medplot1mydat <- medplot1[[2]]$layer[[2]]$data 
medplot1mydat <- medplot1mydat %>% mutate(yvar="prjthftlt5", plotvar="my")

medplot2xmdat <- medplot2[[1]]$layer[[1]]$data 
medplot2xmdat <- medplot2xmdat %>% mutate(yvar="prjthftgt5", plotvar="xm")
medplot2mydat <- medplot2[[2]]$layer[[2]]$data 
medplot2mydat <- medplot2mydat %>% mutate(yvar="prjthftgt5", plotvar="my")

medplot3xmdat <- medplot3[[1]]$layer[[1]]$data 
medplot3xmdat <- medplot3xmdat %>% mutate(yvar="prjthreat", plotvar="xm")
medplot3mydat <- medplot3[[2]]$layer[[2]]$data 
medplot3mydat <- medplot3mydat %>% mutate(yvar="prjthreat", plotvar="my")

medplot4xmdat <- medplot4[[1]]$layer[[1]]$data 
medplot4xmdat <- medplot4xmdat %>% mutate(yvar="prjharm", plotvar="xm")
medplot4mydat <- medplot4[[2]]$layer[[2]]$data 
medplot4mydat <- medplot4mydat %>% mutate(yvar="prjharm", plotvar="my")

medplot5xmdat <- medplot5[[1]]$layer[[1]]$data 
medplot5xmdat <- medplot5xmdat %>% mutate(yvar="prjusedrg", plotvar="xm")
medplot5mydat <- medplot5[[2]]$layer[[2]]$data 
medplot5mydat <- medplot5mydat %>% mutate(yvar="prjusedrg", plotvar="my")

medplot6xmdat <- medplot6[[1]]$layer[[1]]$data 
medplot6xmdat <- medplot6xmdat %>% mutate(yvar="prjhack", plotvar="xm")
medplot6mydat <- medplot6[[2]]$layer[[2]]$data 
medplot6mydat <- medplot6mydat %>% mutate(yvar="prjhack", plotvar="my")

medplot7xmdat <- medplot7[[1]]$layer[[1]]$data 
medplot7xmdat <- medplot7xmdat %>% mutate(yvar="prjany", plotvar="xm")
medplot7mydat <- medplot7[[2]]$layer[[2]]$data 
medplot7mydat <- medplot7mydat %>% mutate(yvar="prjany", plotvar="my")

medplotxmdat <- bind_rows(medplot1xmdat, medplot2xmdat, medplot3xmdat, 
                         medplot4xmdat, medplot5xmdat, medplot6xmdat, 
                         medplot7xmdat) %>% 
  mutate(yvar=factor(yvar, levels=c("prjthftlt5", "prjthftgt5", "prjthreat", 
                                    "prjharm", "prjusedrg", "prjhack", "prjany")))

medplotmydat <- bind_rows(medplot1mydat, medplot2mydat, medplot3mydat, 
                         medplot4mydat, medplot5mydat, medplot6mydat, 
                         medplot7mydat) %>% 
  mutate(yvar=factor(yvar, levels=c("prjthftlt5", "prjthftgt5", "prjthreat", 
                                    "prjharm", "prjusedrg", "prjhack", "prjany")))

12.3.2 Alt Med (X=stdz sum stress change, M=crim emotions sum scale)

As a robustness check, we re-estimated the bmlm within-person medition models above using a standardized sum scale instead of a variety “symptom” index for our mediating criminogenic negative emotions measure. As above, these models generate null within-person mediation effect estimates, due to near-zero associations between negative emotions and criminal intent (i.e., null “b” path or M-Y estimates).

# Within-subjects bayesian mediation models (bmlm)
  # X: stress change (sum scale)
  # M: criminogenic emotions (sum scale)
  # Y: binary criminal intent items


# no built-in file save option, knitr & xfun cache options not working as desired during knitting
# instead, manual saving & loading bmlm models 

if (file.exists(here("Models","fit_altmed_1"))) {
   fit_altmed.1 <- readRDS("Models/fit_altmed_1")
 } else {
# mediation analysis - prjthflt5
fit_altmed.1 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "sumcrmemozchg",
                 y = "prjthflt5i",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_altmed.1, file = "Models/fit_altmed_1")
}

# mediation model - prjthfgt5
if (file.exists(here("Models","fit_altmed_2"))) {
   fit_altmed.2 <- readRDS("Models/fit_altmed_2")
 } else {
fit_altmed.2 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "sumcrmemozchg",
                 y = "prjthfgt5i",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_altmed.2, file = "Models/fit_altmed_2")
}

# mediation model - prjthreati
if (file.exists(here("Models","fit_altmed_3"))) {
   fit_altmed.3 <- readRDS("Models/fit_altmed_3")
 } else {
fit_altmed.3 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "sumcrmemozchg",
                 y = "prjthreati",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_altmed.3, file = "Models/fit_altmed_3")
}

# mediation model - prjharmi
if (file.exists(here("Models","fit_altmed_4"))) {
   fit_altmed.4 <- readRDS("Models/fit_altmed_4")
 } else {
fit_altmed.4 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "sumcrmemozchg",
                 y = "prjharmi",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_altmed.4, file = "Models/fit_altmed_4")
}

# mediation model - prjusedrgi
if (file.exists(here("Models","fit_altmed_5"))) {
   fit_altmed.5 <- readRDS("Models/fit_altmed_5")
 } else {
fit_altmed.5 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "sumcrmemozchg",
                 y = "prjusedrgi",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_altmed.5, file = "Models/fit_altmed_5")
}

# mediation model - prjhacki
if (file.exists(here("Models","fit_altmed_6"))) {
   fit_altmed.6 <- readRDS("Models/fit_altmed_6")
 } else {
fit_altmed.6 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "sumcrmemozchg",
                 y = "prjhacki",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_altmed.6, file = "Models/fit_altmed_6")
}

# mediation model - prjanyi
if (file.exists(here("Models","fit_altmed_7"))) {
   fit_altmed.7 <- readRDS("Models/fit_altmed_7")
 } else {
fit_altmed.7 <- mlm(d = stress.long4,
                 id = "id",
                 x = "sumstresschg",
                 m = "sumcrmemozchg",
                 y = "prjanyi",
                 binary_y = TRUE,
                 priors = list(dy = 2, dm = 2, b = 1),
                 cores = 4,
                 iter = 10000,
                 seed = 8675309)
saveRDS(fit_altmed.7, file = "Models/fit_altmed_7")
}


pars <- c("a", "b", "cp", "corrab")

# Diagnostic messages
# check_hmc_diagnostics(fit_altmed.1)
# check_hmc_diagnostics(fit_altmed.2)
# check_hmc_diagnostics(fit_altmed.3)
# check_hmc_diagnostics(fit_altmed.4)
# check_hmc_diagnostics(fit_altmed.5)
# check_hmc_diagnostics(fit_altmed.6)
# check_hmc_diagnostics(fit_altmed.7)

12.3.2.1 Theft <5BAM

12.3.2.1.1 Plot parameters (violin)
mlm_pars_plot(fit_altmed.1,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5))

12.3.2.1.2 Plot effects (pop-avg fitted values)
altmedplot1 <- mlm_spaghetti_plot(
  mod = fit_altmed.1,
  d = stress.long4,
  x = "sumstresschg", m = "sumcrmemozchg", y = "prjthflt5i", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    altmedplot1[[1]] + labs(title="Path a (X -> M)"), 
    altmedplot1[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.2.1.3 Path diagram
mlm_path_plot(fit_altmed.1, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(sum scale)", 
              ylab = "Theft\n<5BAM")

  # grid.echo() #grab grid element (path plot)
  # altpath1 <- grid.grab() #save as grid object
12.3.2.1.4 Fit summary
#mediation model summary - prjthftlt5
mlm_summary(fit_altmed.1)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.94  0.19   0.94  0.57  1.32 16282    1
## 2         b -0.10  0.41  -0.09 -0.95  0.69   838    1
## 3        cp  0.73  1.65   0.70 -2.63  4.29   530    1
## 4        me  0.11  0.62   0.07 -1.06  1.47   615    1
## 5         c  0.84  1.66   0.83 -2.56  4.39   526    1
## 6       pme  0.10 27.60   0.08 -3.82  3.92 20010    1
12.3.2.1.5 Trace plots
mcmc_trace(as.data.frame(fit_altmed.1), pars = pars)

12.3.2.2 Theft >5BAM

12.3.2.2.1 Plot parameters (violin)
mlm_pars_plot(fit_altmed.2,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5))

12.3.2.2.2 Plot effects (pop-avg fitted values)
altmedplot2 <- mlm_spaghetti_plot(
  mod = fit_altmed.2,
  d = stress.long4,
  x = "sumstresschg", m = "sumcrmemozchg", y = "prjthfgt5i", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    altmedplot2[[1]] + labs(title="Path a (X -> M)"), 
    altmedplot2[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.2.2.3 Path diagram
mlm_path_plot(fit_altmed.2, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(sum scale)", 
              ylab = "Theft\n>5BAM")

  # grid.echo() #grab grid element (path plot)
  # altpath2 <- grid.grab() #save as grid object
12.3.2.2.4 Fit summary
#mediation model summary - prjthftgt5
mlm_summary(fit_altmed.2)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.95  0.19   0.95  0.56  1.32 17771    1
## 2         b -0.16  0.42  -0.15 -1.05  0.65   646    1
## 3        cp  1.40  1.51   1.40 -1.75  4.49   493    1
## 4        me  0.12  0.63   0.05 -0.98  1.58   500    1
## 5         c  1.52  1.53   1.53 -1.73  4.62   473    1
## 6       pme  0.45 44.49   0.05 -2.15  2.22 19962    1
12.3.2.2.5 Trace plots
mcmc_trace(as.data.frame(fit_altmed.2), pars = pars)

12.3.2.3 Threat

12.3.2.3.1 Plot parameters (violin)
mlm_pars_plot(fit_altmed.3,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5))

12.3.2.3.2 Plot effects (pop-avg fitted values)
altmedplot3 <- mlm_spaghetti_plot(
  mod = fit_altmed.3,
  d = stress.long4,
  x = "sumstresschg", m = "sumcrmemozchg", y = "prjthreati", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    altmedplot3[[1]] + labs(title="Path a (X -> M)"), 
    altmedplot3[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.2.3.3 Path diagram
mlm_path_plot(fit_altmed.3, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(sum scale)", 
              ylab = "Threat")

  # grid.echo() #grab grid element (path plot)
  # altpath3 <- grid.grab() #save as grid object
12.3.2.3.4 Fit summary
#mediation model summary - prjthreat
mlm_summary(fit_altmed.3)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.94  0.19   0.95  0.57   1.3 13804    1
## 2         b  0.03  0.53   0.04 -1.08   1.1  1032    1
## 3        cp -0.97  1.95  -1.09 -4.53   3.4   875    1
## 4        me -0.19  0.79  -0.13 -1.94   1.3   553    1
## 5         c -1.15  1.95  -1.23 -4.85   3.2   916    1
## 6       pme -0.20 46.37   0.07 -3.75   3.6 19961    1
12.3.2.3.5 Trace plots
mcmc_trace(as.data.frame(fit_altmed.3), pars = pars)

12.3.2.4 Phys. Harm

12.3.2.4.1 Plot parameters (violin)
mlm_pars_plot(fit_altmed.4,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5)) 

12.3.2.4.2 Plot effects (pop-avg fitted values)
altmedplot4 <- mlm_spaghetti_plot(
  mod = fit_altmed.4,
  d = stress.long4,
  x = "sumstresschg", m = "sumcrmemozchg", y = "prjharmi", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    altmedplot4[[1]] + labs(title="Path a (X -> M)"), 
    altmedplot4[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.2.4.3 Path diagram
mlm_path_plot(fit_altmed.4, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(sum scale)", 
              ylab = "Harm")

  # grid.echo() #grab grid element (path plot)
  # altpath4 <- grid.grab() #save as grid object
12.3.2.4.4 Fit summary
#mediation model summary - prjharm
mlm_summary(fit_altmed.4)
##   Parameter  Mean    SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.94  0.19   0.94  0.57   1.3 13056    1
## 2         b  0.19  0.61   0.18 -1.02   1.4  1512    1
## 3        cp -1.72  2.09  -1.78 -5.78   2.8  1013    1
## 4        me  0.88  1.06   0.76 -0.98   3.3   439    1
## 5         c -0.83  2.17  -0.94 -4.99   3.9  1021    1
## 6       pme  0.19 81.29  -0.10 -7.48   7.7 19993    1
12.3.2.4.5 Trace plots
mcmc_trace(as.data.frame(fit_altmed.4), pars = pars)

12.3.2.5 Use drugs

12.3.2.5.1 Plot parameters (violin)
mlm_pars_plot(fit_altmed.5,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5)) 

12.3.2.5.2 Plot effects (pop-avg fitted values)
altmedplot5 <- mlm_spaghetti_plot(
  mod = fit_altmed.5,
  d = stress.long4,
  x = "sumstresschg", m = "sumcrmemozchg", y = "prjusedrgi", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    altmedplot5[[1]] + labs(title="Path a (X -> M)"), 
    altmedplot5[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.2.5.3 Path diagram
mlm_path_plot(fit_altmed.5, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(sum scale)", 
              ylab = "Use\nDrugs")

  # grid.echo() #grab grid element (path plot)
  # altpath5 <- grid.grab() #save as grid object
12.3.2.5.4 Fit summary
#mediation model summary - prjusedrg
mlm_summary(fit_altmed.5)
##   Parameter  Mean     SE Median  2.5% 97.5% n_eff Rhat
## 1         a  0.95   0.19   0.95  0.58   1.3 15503    1
## 2         b  0.27   0.50   0.27 -0.73   1.3  1476    1
## 3        cp -0.71   1.76  -0.81 -3.99   3.1  1644    1
## 4        me -0.16   0.80  -0.06 -2.02   1.2   849    1
## 5         c -0.88   1.80  -0.92 -4.35   2.9  1473    1
## 6       pme -4.96 743.73   0.08 -3.88   4.2 20008    1
12.3.2.5.5 Trace plots
mcmc_trace(as.data.frame(fit_altmed.5), pars = pars)

12.3.2.6 Hack info.

12.3.2.6.1 Plot parameters (violin)
mlm_pars_plot(fit_altmed.6,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5)) 

12.3.2.6.2 Plot effects (pop-avg fitted values)
altmedplot6 <- mlm_spaghetti_plot(
  mod = fit_altmed.6,
  d = stress.long4,
  x = "sumstresschg", m = "sumcrmemozchg", y = "prjhacki", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    altmedplot6[[1]] + labs(title="Path a (X -> M)"), 
    altmedplot6[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.2.6.3 Path diagram
mlm_path_plot(fit_altmed.6, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(sum scale)", 
              ylab = "Hack\nInfo")

  # grid.echo() #grab grid element (path plot)
  # altpath6 <- grid.grab() #save as grid object
12.3.2.6.4 Fit summary
#altmediation model summary - prjhack
mlm_summary(fit_altmed.6)
##   Parameter  Mean     SE Median   2.5% 97.5% n_eff Rhat
## 1         a  0.93   0.19   0.93   0.56  1.31 10304    1
## 2         b  0.14   0.42   0.14  -0.72  0.98  2489    1
## 3        cp -1.08   1.16  -1.08  -3.36  1.20  3699    1
## 4        me  0.89   0.89   0.80  -0.62  2.82   314    1
## 5         c -0.19   1.22  -0.23  -2.49  2.33  1689    1
## 6       pme -0.19 150.21   0.03 -12.99 13.50 19767    1
12.3.2.6.5 Trace plots
mcmc_trace(as.data.frame(fit_altmed.6), pars = pars)

12.3.2.7 Any crime intent

12.3.2.7.1 Plot parameters (violin)
mlm_pars_plot(fit_altmed.7,
              type = "violin", 
              pars = c("a", "b", "cp", "c", "me")) +
  scale_y_continuous(breaks = seq(-50, 10, 5)) 

12.3.2.7.2 Plot effects (pop-avg fitted values)
altmedplot7 <- mlm_spaghetti_plot(
  mod = fit_altmed.7,
  d = stress.long4,
  x = "sumstresschg", m = "sumcrmemozchg", y = "prjanyi", id = "id",
  fixed = TRUE, random = FALSE, binary_y = TRUE, n = 20)

grid.arrange(
    altmedplot7[[1]] + labs(title="Path a (X -> M)"), 
    altmedplot7[[2]] + labs(title="Path b (M -> Y)") + 
        coord_cartesian(ylim=c(0,.05)),
    nrow=1)

12.3.2.7.3 Path diagram
mlm_path_plot(fit_altmed.7, 
              xlab = "Stress\nChange", 
              mlab = "Criminogenic\nEmotions\n(sum scale)", 
              ylab = "Any\nCrime")

  # grid.echo() #grab grid element (path plot)
  # altpath7 <- grid.grab() #save as grid object
12.3.2.7.4 Fit summary
#mediation model summary - prjany
mlm_summary(fit_altmed.7)
##   Parameter Mean     SE Median  2.5% 97.5% n_eff Rhat
## 1         a 0.95   0.19   0.95  0.57  1.32 14832    1
## 2         b 0.05   0.37   0.06 -0.74  0.76   563    1
## 3        cp 0.46   1.17   0.41 -1.75  3.06   228    1
## 4        me 0.65   0.67   0.56 -0.46  2.14   771    1
## 5         c 1.10   1.19   1.05 -1.14  3.71   225    1
## 6       pme 5.12 684.97   0.40 -4.09  5.17 20007    1
12.3.2.7.5 Trace plots
mcmc_trace(as.data.frame(fit_altmed.7), pars = pars)

12.4 FIGURE 5: Mediation

#wrangle mediation output - add yvar for merging & faceting
gen_meddata <- function(modname, yvarname){
  tibble(modname %>% 
  mutate(
    yvar = yvarname
  )
)}

#create a dummy indicator ==1 if lower 80% interval > 0
ci80gt0 <- function(modname, xvar, mvar){
  tibble(mediation(modname,
          treatment=xvar,
          mediator=mvar,
          ci=.80)) %>% 
  mutate(
    ci80gt0 = if_else(CI_low > 0, 1, 0)
    ) %>%
  dplyr::select(Effect, ci80gt0)
}


medy1w <- gen_meddata(medy1w, "prjthflt5") 
tempdat <- ci80gt0(m1w, "sumstresschg", "indcrmemocchg")
medy1w <- left_join(medy1w, tempdat)

medy2w <- gen_meddata(medy2w, "prjthfgt5") 
tempdat <- ci80gt0(m2w, "sumstresschg", "indcrmemocchg")
medy2w <- left_join(medy2w, tempdat)

medy3w <- gen_meddata(medy3w, "prjthreat") 
tempdat <- ci80gt0(m3w, "sumstresschg", "indcrmemocchg")
medy3w <- left_join(medy3w, tempdat)

medy4w <- gen_meddata(medy4w, "prjharm") 
tempdat <- ci80gt0(m4w, "sumstresschg", "indcrmemocchg")
medy4w <- left_join(medy4w, tempdat)

medy5w <- gen_meddata(medy5w, "prjusedrg") 
tempdat <- ci80gt0(m5w, "sumstresschg", "indcrmemocchg")
medy5w <- left_join(medy5w, tempdat)

medy6w <- gen_meddata(medy6w, "prjhack") 
tempdat <- ci80gt0(m6w, "sumstresschg", "indcrmemocchg")
medy6w <- left_join(medy6w, tempdat)

medy7w <- gen_meddata(medy7w, "prjany") 
tempdat <- ci80gt0(m6w, "sumstresschg", "indcrmemocchg")
medy7w <- left_join(medy7w, tempdat)

medy1b <- gen_meddata(medy1b, "prjthflt5") 
tempdat <- ci80gt0(m1b, "sumstressav", "indcrmemocav")
medy1b <- left_join(medy1b, tempdat)

medy2b <- gen_meddata(medy2b, "prjthfgt5") 
tempdat <- ci80gt0(m2b, "sumstressav", "indcrmemocav")
medy2b <- left_join(medy2b, tempdat)

medy3b <- gen_meddata(medy3b, "prjthreat") 
tempdat <- ci80gt0(m3b, "sumstressav", "indcrmemocav")
medy3b <- left_join(medy3b, tempdat)

medy4b <- gen_meddata(medy4b, "prjharm") 
tempdat <- ci80gt0(m4b, "sumstressav", "indcrmemocav")
medy4b <- left_join(medy4b, tempdat)

medy5b <- gen_meddata(medy5b, "prjusedrg")
tempdat <- ci80gt0(m5b, "sumstressav", "indcrmemocav")
medy5b <- left_join(medy5b, tempdat)

medy6b <- gen_meddata(medy6b, "prjhack") 
tempdat <- ci80gt0(m6b, "sumstressav", "indcrmemocav")
medy6b <- left_join(medy6b, tempdat)

medy7b <- gen_meddata(medy7b, "prjany") 
tempdat <- ci80gt0(m6b, "sumstressav", "indcrmemocav")
medy7b <- left_join(medy7b, tempdat)


meddataw <- bind_rows(medy1w, medy2w, medy3w, medy4w, medy5w, medy6w, medy7w) %>%
  mutate(
    yvar = factor(yvar, ordered=TRUE, 
                  levels = c("prjthflt5", "prjthfgt5", "prjthreat", 
                             "prjharm", "prjusedrg", "prjhack", "prjany")),
    ci80gt0 = factor(ci80gt0, levels=c(0,1)), 
    Effect = factor(Effect, levels=c("Direct Effect (ADE)", "Mediator Effect", 
                                     "Indirect Effect (ACME)", "Total Effect",  
                                     "Proportion Mediated")),
    method = "within"
    )
meddatab <- bind_rows(medy1b, medy2b, medy3b, medy4b, medy5b, medy6b, medy7b) %>%
  mutate(
    yvar = factor(yvar, ordered=TRUE, 
                  levels = c("prjthflt5", "prjthfgt5", "prjthreat", 
                             "prjharm", "prjusedrg", "prjhack", "prjany")),
    ci80gt0 = factor(ci80gt0, levels=c(0,1)),
    Effect = factor(Effect, levels=c("Direct Effect (ADE)", "Mediator Effect", 
                                     "Indirect Effect (ACME)", "Total Effect",  
                                     "Proportion Mediated")),
    method = "between"
    ) 
meddata <- bind_rows(meddataw, meddatab)

prjlabs3 <- c(
  "prjthflt5"="Theft\n<5BAM", 
  "prjthfgt5"="Theft\n>5BAM", 
  "prjthreat"="Threaten", 
  "prjharm"="Phys.\nharm",
  "prjusedrg"="Use\ndrugs",
  "prjhack"="Hack\ninfo",
  "prjany"="Any\ncrime")


effectlabs <- c(
  "Direct Effect (ADE)"="Direct\nEffect\n(ADE)\nX\U2192Y", 
  "Mediator Effect"=" \nMediator\nEffect\nM\U2192Y", 
  "Indirect Effect (ACME)"="Indirect\nEffect\n(ACME)\nX\U2192M\U2192Y", 
  "Total Effect"="Total Effect\nX\U2192Y\n+\nX\U2192M\U2192Y",
  "Proportion Mediated"=" \nProportion\nMediated\n(Ind/Total)")

methodlabs2 <- c(
  "between"="Between-Person Difference (Cross-Time Mean) Estimator", 
  "within"="Within-Person Change (T2-T1) \"Fixed Effects\" Estimator")


# Effect types have different scales, so changed to plot faceted by Effect 

# ggplot(meddataw, 
#        aes(y=reorder(Effect, desc(Effect)), x=Estimate)) + 
#   facet_wrap(~yvar, nrow=1, 
#              scales = "free_x",
#              labeller = labeller(yvar = as_labeller(prjlabs2))) +
#   geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
#   geom_pointrange(data=meddataw, 
#              aes(x=Estimate, xmin = CI_low, xmax = CI_high, alpha=ci80gt0), 
#              color="#883E3A", fill="#883E3A",
#              position = position_nudge(y=-.1)) + 
#   geom_pointrange(data=meddatab, 
#              aes(x=Estimate, xmin = CI_low, xmax = CI_high), color="#E99D53", fill="#E99D53",
#              position = position_nudge(y=.1)) + 
#   scale_y_discrete(labels=effectlabs) +
#   scale_alpha_discrete(range=c(.2,1), guide = "none") 

Fig5v1 <- ggplot(meddataw,
       aes(y=reorder(yvar, desc(yvar)), x=Estimate, color=method)) +
  facet_wrap(~Effect, nrow=1,
             scales = "free_x",
             labeller = labeller(Effect = as_labeller(effectlabs))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  geom_pointrangeh(data=meddataw, # use ggstance::geom_pointrangeh() for horiz lines in legend 
             aes(x=Estimate, xmin = CI_low, xmax = CI_high, alpha=ci80gt0), 
             # color="#883E3A", fill="#883E3A",
             position = position_nudge(y=-.1)) + 
  geom_pointrangeh(data=meddatab, 
             aes(x=Estimate, xmin = CI_low, xmax = CI_high, alpha=ci80gt0), 
             # color="#E99D53", fill="#E99D53",
             position = position_nudge(y=.1)) + 
  scale_y_discrete(labels=prjlabs3) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  scale_color_manual(values=c("#E99D53","#883E3A"), 
                      labels=as_labeller(methodlabs2), name=NULL) +
  xlab(element_blank()) + 
  facetted_pos_scales(
    x = list(
      Effect == "Proportion Mediated" ~
        scale_x_continuous(breaks=c(-1,-.5,0,.5,1), 
                           limits = c(-1.1,1.1), labels = dropLeadingZero)
      # Effect %in% c("depsymw1", "negemow1") ~
      #   scale_x_continuous(breaks=c(-.05,0,.05,.1, .15), 
      #                      limits = c(-.06,.16), labels = dropLeadingZero)
    ) ) +
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        strip.background = element_blank(),
        strip.text.x = element_text(size=8), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0),
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)),
               color = guide_legend(nrow=1, reverse = FALSE))

design <- "
11
22
"    


SuppFigure5 <- Fig5v1 + guide_area() +
  plot_layout(design=design, guides = 'collect', heights=c(30,.1)) +
    plot_annotation(
    title = 'SUPPLEMENTAL FIGURE 5\nEstimated Total, Direct, & Indirect Effects of Stress on Criminal Intent via Criminogenic Emotions, by Estimator',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. Estimates derived from 14 multivariate and multilevel between-within Bayesian regression models simultaneously regressing (using `brms`) each binary criminal intent outcome (six binary logistic models) and either a between-person or a within-person mediator model (two Gaussian models) predicting differences or changes in a variety index of the number of criminogenic emotions reported. All models included a standardized sum stress scale separated into L2 cross-time average (Xbar_i) between-person and L1 within-person change (X_it - Xbar_i) /"fixed effects"/ estimators. The outcome (criminal intent) models also included both L2 (between) and L1 (change) measures of criminogenic emotions. Mediation estimates reflect untransformed beta parameter estimates derived using `bayestestR::mediation()` R package. Median posterior density estimates with 95% equal-tailed (ETI) credible intervals displayed. Bold point-intervals indicate at least 80% of posterior estimates are greater than zero.', width=195)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'bottom', 
        legend.key.height = unit(.5, 'cm'), 
        legend.margin = margin(0,0,0,0), 
        legend.spacing.y = unit(0, "mm"))

SuppFigure5

# New version with BMLM plots 

meddatawsub <- meddataw %>% 
  filter(Effect != "Proportion Mediated") %>% 
  droplevels()
meddatabsub <- meddatab %>% 
  filter(Effect != "Proportion Mediated") %>% 
  droplevels()

effectlabs2 <- c(
  "Direct Effect (ADE)"="mediation()\nDirect Effect\n\"ADE\"\n(X\U2192Y)", 
  "Mediator Effect"=" mediation()\nMediator\nEffect\n(M\U2192Y)", 
  "Indirect Effect (ACME)"="mediation()\nIndirect Effect\n\"ACME\"\n(X\U2192M\U2192Y)", 
  "Total Effect"="mediation()\nTotal Effect\n(X\U2192Y) +\n(X\U2192M\U2192Y)")

Fig5 <- ggplot(meddatawsub,
       aes(y=reorder(yvar, desc(yvar)), x=Estimate, color=method)) +
  facet_wrap(~Effect, nrow=1,
             scales = "free_x",
             labeller = labeller(Effect = as_labeller(effectlabs2))) +
  geom_vline(xintercept = 0, linetype = "dashed", size=.5, alpha=.4) +
  geom_pointrangeh(data=meddatawsub, # use ggstance::geom_pointrangeh() for horiz lines in legend 
             aes(x=Estimate, xmin = CI_low, xmax = CI_high, alpha=ci80gt0), 
             # color="#883E3A", fill="#883E3A",
             position = position_nudge(y=-.1)) + 
  geom_pointrangeh(data=meddatabsub, 
             aes(x=Estimate, xmin = CI_low, xmax = CI_high, alpha=ci80gt0), 
             # color="#E99D53", fill="#E99D53",
             position = position_nudge(y=.1)) + 
  scale_y_discrete(labels=prjlabs3) +
  scale_alpha_discrete(range=c(.2,1), guide = "none") +
  scale_color_manual(values=c("#E99D53","#883E3A"), 
                      labels=as_labeller(methodlabs2), name=NULL) +
  xlab(element_blank()) + 
  theme(axis.title.y = element_blank(), 
        legend.position = "bottom",
        strip.background = element_blank(),
        strip.text.x = element_text(size=8), 
        axis.text.y = element_text(size=8),
        plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0),
        legend.text = element_text(size = 8)) + 
        guides(shape = guide_legend(override.aes = list(size = 0.5)),
               color = guide_legend(nrow=1, reverse = FALSE))


plotvarlabs<- c(
  "xm"="bmlm()\nWithin-\nPerson\n(\U25B3X\U2192\U25B3M)",
  "my"="bmlm()\nWithin-\nPerson\n(\U25B3M\U2192\U25B3Y)") 

#Custom X-M spaghetti plots
Fig5.2 <- medplotxmdat %>% 
  ggplot(
    aes(y=m_fitted_mean, x=sumstresschg, 
        ymin=m_fitted_lower, ymax=m_fitted_upper)
    ) + 
  facet_grid(yvar~plotvar, 
             labeller = labeller(plotvar = as_labeller(plotvarlabs))) +
  geom_line(color="#883E3A") + 
  geom_ribbon(fill="#883E3A", alpha=.3) +
  scale_x_continuous(breaks=c(-.5,.5), 
                     labels = dropLeadingZero) + 
  scale_y_continuous(breaks=c(-.5,.5), 
                     labels = dropLeadingZero) + 
  # ylab("\U25B3M") + 
  # xlab("\U25B3X") + 
  theme(
    legend.position = "none", 
    strip.text.y = element_blank(),
    strip.text.x = element_text(size=8),
    axis.title = element_blank(),
    axis.text = element_text(size=8))


#Custom M-Y spaghetti plots
Fig5.3 <- medplotmydat %>% 
  ggplot(
    aes(y=y_fitted_mean, x=indcrmemocchg, 
        ymin=y_fitted_lower, ymax=y_fitted_upper)
    ) + 
  facet_grid(yvar~plotvar, scales="free_y",
             labeller = labeller(plotvar = as_labeller(plotvarlabs))) +
  geom_line(color="#883E3A") + 
  geom_ribbon(fill="#883E3A", alpha=.3) +
  scale_x_continuous(breaks=c(-.5,.5),
                     labels = dropLeadingZero) +
  # scale_y_continuous(breaks=c(0,.02),
  #                    labels = dropLeadingZero) +
  # coord_cartesian(xlim=c(-.71,.71), expand=FALSE) +
  facetted_pos_scales(
    y = list(
      yvar == "prjany" ~
        scale_y_continuous(breaks=c(0,.04), 
                           limits = c(-.001,.05), labels = dropLeadingZero),
      yvar != "prjany" ~
        scale_y_continuous(breaks=c(0,.02),
                           limits = c(-.001,.035), labels = dropLeadingZero)
    ) ) +
  # ylab("\U25B3Y") + 
  # xlab("\U25B3M") + 
  theme(
    legend.position = "none", 
    strip.text.y = element_blank(),
    strip.text.x = element_text(size=8),
    axis.title = element_blank(),
    axis.text = element_text(size=8))

design <- "
123
444
"    

Figure5 <- Fig5 + Fig5.2 + Fig5.3 + guide_area() + 
  plot_layout(design=design, guides="collect",
              widths=c(4,.5,1), 
              heights=c(40,.1)) + 
    plot_annotation(
    title = 'FIGURE 5\nEstimated Total, Direct, & Indirect Effects of Stress on Criminal Intent via Criminogenic Emotions, by Estimator',
    #subtitle = 'Subtitle here',
    caption = str_wrap('Note: N=489 respondents participating at both survey waves. COLUMNS 1-4: Multilevel b/w Bayesian models predicted binary criminal intent outcomes (7 logistic "Y" models) and a between- or a within-person mediator (2 Gaussian "M" models). All models included a standardized sum stress scale separated into L2 between-person (Xbar_i) and L1 within-person change (X_it - Xbar_i) /"fixed effects"/ estimators ("X"). "Y" models also included both L2 (between) and L1 (change) measures of differences/changes in the number of criminogenic emotions reported. Untransformed posterior mediation estimates generated from fitted models using `bayestestR::mediation()` R package. Median posterior density estimates with 95% equal-tailed (ETI) credible intervals displayed. Bold point-intervals indicate at least 80% of posterior estimates are greater than zero. COLUMNS 5-6: Comparable within-person mediation models were fit using `bmlm::mlm()` R package to generate model-implied posterior effect estimates averaged over random effects for plotting in original item metrics. Column 5 (X\U2192M) displays estimated effect of changes in X (X=-.5 to X=.5 equates to 1 SD unit increase in stress) on changes in M (M=-.5 to M=.5 = equates to increase of 1 additional criminogenic emotion reported). Column 6 (M\U2192Y) displays estimated effect of changes in M on changes in the probability of Y (e.g., increase from Y=0 at M=-.5 to Y=0.02 at M=.5 would imply an increase of one reported emotion causes a 2-percentage-point increase in the probability of criminal intent). These estimates also reflect any indirect effect of X on Y through M, while x-axis range displays model-implied degree of change in M (emotions) caused by change in X (stress).', width=190)) &
  theme(plot.title = element_text(size=10, face="bold"),
        plot.caption = element_text(size=8, hjust = 0), #move caption to left of plot
        legend.position = 'bottom', 
        legend.key.height = unit(.5, 'cm'), 
        legend.margin = margin(0,0,0,0), 
        legend.spacing.y = unit(0, "mm"))

Figure5

ggsave("Figure5.jpeg", width=9, height=6.5, path=here("Output"))

13 Directed Acyclic Graphs (DAGS)

(RMD FILE: BDK_2023_Stress_12_DAG)

Our manuscript includes DAGs that communicate the simplistic causal assumptions underlying our analysis. You can think of them as communicating these as necessary beliefs if one wishes to make causal inferences from results that appear to support theoretical expectations. To be clear, I do not think these DAGs truly represent the complex causal processes generating our data. Rather, they represent a starting point for analysis and interpretation. We can improve future research by interrogating both our causal assumptions - these DAGs - and our results, identifying what we deem to be potential serious issues with the assumptions or design, and then develop more convincing DAGs and subsequent research designs intended to better identify (if possible) posited causal effects of interest.

13.1 Load Packages

13.2 DAGs

# DAG 1 (RQ2A)

DAG1 <- dagify(
  CrimIntent ~ Stress + Indiv + C,
  Stress ~ Indiv + C, 
  D ~ Stress + CrimIntent , 
  exposure = "Stress",
  outcome = "CrimIntent",
  coords=list(
    x=c(Stress=1, Indiv=1, CrimIntent=2, C=2, D=2),
    y=c(Stress=0, Indiv=1, CrimIntent=0, C=-1, D=1)
  )) %>% tidy_dagitty() %>% 
  dplyr::mutate(confound = if_else(name == "D",  
                                  "grey", "darkslategrey"), 
                confound = if_else(name %in% c("Indiv", "C"),  
                                  "maroon", confound)
                )

#function to shorten arrows - set percentage to shorten
DAG1p <- shorten_dag_arrows(DAG1, 0.2)

#create factor variable to isolate edge of interest, permits specifying edge color
testdat <- DAG1p %>% dplyr::mutate(
  myedge1 = if_else(DAG1p$data$name == "Indiv" |  
                      DAG1p$data$name == "C", 
                    "unblocked", "focal"),
  myedge1 = if_else(DAG1p$data$to == "D", 
                    "blocked", myedge1),
  modlinetype = ifelse(myedge1 == "unblocked", "solid", "dashed")
  ) 

DAG1p3 <- testdat %>% ggplot(aes(x=x, y=y, xend=xend, yend=yend)) +
  geom_dag_edges(aes(x = xstart, y = ystart, 
                     edge_color=myedge1, 
                     edge_linetype = modlinetype), show.legend = FALSE) +
  geom_dag_text(label=c("Time-varying\nconfounders",
                        "Criminal Intent\n(T1)",
                        "Colliders\n(common effects)",
                        "Time-stable\nconfounders", 
                        "Stress\n(T1)"), 
                aes(color = confound), size=4) +
  theme_dag() + 
  guides(fill = 'none', color = 'none', edge_color = 'none') +
  scale_color_manual(values = c("darkslategrey", "grey", "maroon")) +
  scale_edge_colour_manual(values=c("grey", "darkslategrey","maroon")) + 
  scale_x_continuous(expand=expansion(mult=c(0.3,0.3))) +
  scale_y_continuous(expand=expansion(mult=c(0.3,0.3))) +
  # ggtitle("DAG 1 (RQ2A: Between-person)") + 
  theme(plot.title = element_text(size = 10))




################
# DAG 2 (RQ2B)

DAG2 <- dagify(
  CrimIntent ~ Stress + Indiv + C,
  Stress ~ Indiv + C, 
  D ~ Stress + CrimIntent, 
  exposure = "Stress",
  outcome = "CrimIntent",
  coords=list(
    x=c(Stress=1, Indiv=1, CrimIntent=2, C=2, D=2),
    y=c(Stress=0, Indiv=1, CrimIntent=0, C=-1, D=1)
  )) %>% tidy_dagitty() %>% 
  dplyr::mutate(confound = if_else(name %in% c("Indiv","D"),  
                                  "grey", "darkslategrey"), 
                confound = if_else(name == "C",  
                                  "maroon", confound)
                )


#function to shorten arrows - set percentage to shorten
DAG2p <- shorten_dag_arrows(DAG2, 0.2)

#create factor variable to isolate edge of interest, permits specifying edge color
testdat <- DAG2p %>% dplyr::mutate(
  myedge1 = if_else(DAG2p$data$name == "Indiv" | 
                      DAG1p$data$to == "D", 
                    "blocked", "focal"), 
  myedge1 = if_else(DAG2p$data$name == "C", "unblocked", myedge1), 
  modlinetype = ifelse(myedge1 == "unblocked", "solid", "dashed")
  ) 

DAG2p3 <- testdat %>% ggplot(aes(x=x, y=y, xend=xend, yend=yend)) +
  geom_dag_edges(aes(x = xstart, y = ystart, 
                     edge_color=myedge1, 
                     edge_linetype = modlinetype), show.legend = FALSE) +
  geom_dag_text(label=c("Time-varying\nconfounders",
                        "Criminal Intent\n(change)", 
                        "Colliders\n(time-varying\ncommon effects)",
                        "Individual\n(time-stable\nconfounders)", 
                        "Stress\n(change)"), 
                aes(color = confound), size=4) +
  theme_dag() + 
  guides(fill = 'none', color = 'none', edge_color = 'none') +
  scale_color_manual(values = c("darkslategrey", "grey", "maroon")) +
  scale_edge_colour_manual(values=c("grey", "darkslategrey", "maroon")) + 
  scale_x_continuous(expand=expansion(mult=c(0.3,0.3))) +
  scale_y_continuous(expand=expansion(mult=c(0.3,0.3))) +
  # ggtitle("DAG 2 (RQ2B: Within-person)") + 
  theme(plot.title = element_text(size = 10))



################
# DAG 3 (RQ3)

DAG3 <- dagify(
  CrimIntent ~ Stress + Indiv + Community + C,
  Stress ~ Indiv + Community + C, 
  D ~ Stress + CrimIntent, 
  exposure = "Stress",
  outcome = "CrimIntent",
  coords=list(
    x=c(Stress=1, Community=1, Indiv=1, CrimIntent=2, C=2, D=2),
    y=c(Stress=0, Community=-1, Indiv=1, CrimIntent=0, C=-1, D=1)
  )) %>% tidy_dagitty() %>% 
  dplyr::mutate(confound = if_else(name %in% c("Indiv","Community", "D"),
                                  "grey", "darkslategrey"), 
                confound = if_else(name == "C",  
                                  "maroon", confound)
                )


#function to shorten arrows - set percentage to shorten
DAG3p <- shorten_dag_arrows(DAG3, 0.2)

#create factor variable to isolate edge of interest, permits specifying edge color
testdat <- DAG3p %>% dplyr::mutate(
  myedge1 = if_else(DAG3p$data$name %in% c("Indiv","Community")  | 
                      DAG3p$data$to == "D" , 
                    "blocked", "focal"), 
  myedge1 = if_else(DAG3p$data$name == "C", "unblocked", myedge1), 
  modlinetype = ifelse(myedge1 == "unblocked", "solid", "dashed")
  ) 


DAG3p3 <- testdat %>% ggplot(aes(x=x, y=y, xend=xend, yend=yend)) +
  geom_dag_edges(aes(x = xstart, y = ystart, 
                     edge_color=myedge1, 
                     edge_linetype = modlinetype), show.legend = FALSE) +
  geom_dag_text(label=c("Time-varying\nconfounders",
                        "Community\n(Rurality/SES)", 
                        "Criminal Intent\n(change)", 
                        "Colliders\n(time-varying\ncommon effects)",
                        "Individual\n(time-stable\nconfounders)", 
                        "Stress\n(change)"), 
                aes(color=confound), size=4) +
  theme_dag() + 
  guides(fill = 'none', color = 'none', edge_color = 'none') +
  scale_color_manual(values = c("darkslategrey","grey", "maroon")) +
  scale_edge_colour_manual(values=c("grey", "darkslategrey", "maroon")) + 
  scale_x_continuous(expand=expansion(mult=c(0.3,0.3))) +
  scale_y_continuous(expand=expansion(mult=c(0.3,0.3))) +
  # ggtitle("DAG 3 (RQ3: Effect heterogeneity)") + 
  theme(plot.title = element_text(size = 10))



################
# DAG 4 (RQ4)

DAG4 <- dagify(
  CrimIntent ~ Stress + Indiv + CrimEmots + C,
  CrimEmots ~ Stress + C, 
  Stress ~ Indiv + C, 
  D ~ Stress + CrimEmots + CrimIntent, 
  exposure = "Stress",
  outcome = "CrimIntent",
  coords=list(
    x=c(Stress=1, CrimEmots=1, Indiv=1, CrimIntent=2, C=2, D=2),
    y=c(Stress=0, CrimEmots=-1, Indiv=1, CrimIntent=0, C=-1, D=1)
  )) %>% tidy_dagitty() %>% 
  dplyr::mutate(confound = if_else(name %in% c("Indiv", "D"),  
                                  "grey", "darkslategrey"), 
                confound = if_else(name == "C",  
                                  "maroon", confound)
                )


#function to shorten arrows - set percentage to shorten
DAG4p <- shorten_dag_arrows(DAG4, 0.2)

#create factor variable to isolate edge of interest, permits specifying edge color
testdat <- DAG4p %>% dplyr::mutate(
  myedge1 = if_else(DAG4p$data$name == "Indiv" | 
                    DAG4p$data$to == "D" , 
                    "blocked", "focal"), 
  myedge1 = if_else(DAG4p$data$name == "C", "unblocked", myedge1), 
  modlinetype = ifelse(myedge1 == "unblocked", "solid", "dashed")
  ) 


DAG4p3 <- testdat %>% ggplot(aes(x=x, y=y, xend=xend, yend=yend)) +
  geom_dag_edges(aes(x = xstart, y = ystart, 
                     edge_color=myedge1, 
                     edge_linetype = modlinetype), show.legend = FALSE) +
  geom_dag_text(label=c("Time-varying\nconfounders",
                        "Criminogenic\nNeg. Emotions\n(change)", 
                        "Criminal Intent\n(change)", 
                        "Colliders\n(time-varying\ncommon effects)",
                        "Individual\n(time-stable\nconfounders)", 
                        "Stress\n(change)"), 
                aes(color=confound), size=4) +
  theme_dag() + 
  guides(fill = 'none', color = 'none', edge_color = 'none') +
  scale_color_manual(values = c("darkslategrey","grey", "maroon")) +
  scale_edge_colour_manual(values=c("grey", "darkslategrey", "maroon")) + 
  scale_x_continuous(expand=expansion(mult=c(0.3,0.3))) +
  scale_y_continuous(expand=expansion(mult=c(0.3,0.3))) +
  # ggtitle("DAG 4 (RQ4: Mediation)") + 
  theme(plot.title = element_text(size = 10))
# DAG1p3
# 
# DAG2p3
# 
# DAG3p3
# 
# DAG4p3

# ggsave("DAG1p3.jpg", DAG1p3)
# ggsave("DAG2p3.jpg", DAG2p3)
# ggsave("DAG3p3.jpg", DAG3p3)
# ggsave("DAG4p3.jpg", DAG4p3)
(DAG1p3 + DAG2p3) / (DAG3p3 + DAG4p3)

In these figures, the solid dark slate paths represent focal effects of interest. Maroon dashed arrows represent unblocked backdoor paths through which potentially biasing information might affect our estimates. The solid light grey arrows represent paths blocked by design or analysis. For instance, the within-person “fixed effects” estimate from “between-within” multilevel modeling designs adjust for time-stable confounders. I included colliders to note that they are adjusted by default without explicit stratification, whereas inclusion of covariates (“control variables”) without strong causal understanding of the underlying data-generating process (or selection in design/sampling phases) could open these backdoor paths and introduce collider bias.

The top row of DAGs communicate the simplistic causal assumptions underlying the between-person (top left) and within-person change (top right) estimates from our earlier models (e.g., see Figure 3 in supplement). In particular, comparison of these top two DAGs communicates the within-person change estimates’ adjustment by design for all “Individual” - measured or unmeasured - sources of time-stable, between-person confounding. Shout-out to Huntington-Klein here and here for inspiring this way of representing fixed effects in DAGs. From these DAGs, it should be clearer that the unadjusted between-person estimates are at greater risk of transmitting biasing information from these varied individual-specific sources of confounding. In the bottom row, explicit stratification on community blocks confounding (between-person; within-person already blocked) and permits assessment of effect heterogeneity across communities (RQ3), and “criminogenic” emotions are a posited mediator of the stress-crime relationship (RQ4).