This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
library(brms) # for the analysis
library(haven) # to load the SPSS .sav file
library(tidyverse) # needed for data manipulation.
library(RColorBrewer) # needed for some extra colours in one of the graphs
library(ggmcmc)
library(ggthemes)
library(ggridges)
\[Y = N(\mu, \sigma_{\epsilon}^{2})\] \[\mu = \alpha + \beta_{Tm}Tm + \beta_{TD}TD + \beta_{Sm}Sm+\beta_{Sd}Sd + \epsilon\] Where Tm, Td, Sm, and Sd are covariates.
Tm: Trait mean Td: Triat difference (uncon - con) Sm: State mean Sd: State difference (uncon - con)
\[N(0,100): \alpha\] \[N(0,100): \beta_{Tm}\] \[N(0,100): \beta_{Td}\] \[N(0,100): \beta_{Sm}\] \[N(0,100): \beta_{Sd}\] \[Cauchy(0,100): \sigma_{\epsilon}\]
setwd("C:/Users/Chirag/Box/Box/UMD/Project_UMD/eCON/RBA/uncon_v_con_rBNST_with_covariates")
df <- read.table('uncon_v_con_rBNST_with_covariates.txt',header=TRUE)
prior1 <- c(prior(normal(0,100),class=Intercept),
prior(normal(0,100),class=b, coef="TRAITmean"),
prior(normal(0,100),class=b, coef="TRAITdiff"),
prior(normal(0,100),class=b, coef="STATEmean"),
prior(normal(0,100),class=b, coef="STATEdiff"),
prior(cauchy(0,100),class=sigma)
)
bmod1 <- brm(Y ~ TRAITmean + TRAITdiff + STATEmean + STATEdiff,
data = df,
family = gaussian(),
prior = prior1,
warmup = 2000, iter = 5000,
chains = 4,
cores = 2)
Compiling the C++ model
recompiling to avoid crashing R session
Start sampling
summary(bmod1)
Family: gaussian
Links: mu = identity; sigma = identity
Formula: Y ~ TRAITmean + TRAITdiff + STATEmean + STATEdiff
Data: df (Number of observations: 61)
Samples: 4 chains, each with iter = 5000; warmup = 2000; thin = 1;
total post-warmup samples = 12000
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept 0.11 0.06 -0.01 0.23 1.00 15556 8385
TRAITmean -0.05 0.08 -0.21 0.11 1.00 11028 9079
TRAITdiff 0.07 0.06 -0.06 0.19 1.00 12712 8581
STATEmean 0.21 0.08 0.05 0.36 1.00 10850 9512
STATEdiff 0.05 0.06 -0.07 0.18 1.00 13098 8541
Family Specific Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sigma 0.48 0.05 0.40 0.58 1.00 13886 9365
Samples were drawn using sampling(NUTS). 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).