Warning: package 'tidyr' was built under R version 4.4.1
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(broom.mixed)
Warning: package 'broom.mixed' was built under R version 4.4.1
library(devtools)
Loading required package: usethis
library(brms)
Loading required package: Rcpp
Loading 'brms' package (version 2.21.0). Useful instructions
can be found by typing help('brms'). A more detailed introduction
to the package is available through vignette('brms_overview').
Attaching package: 'brms'
The following object is masked from 'package:stats':
ar
library(mascutils)
Attaching package: 'mascutils'
The following object is masked from 'package:tidyr':
expand_grid
The following object is masked from 'package:base':
mode
library(bayr)
Registered S3 methods overwritten by 'bayr':
method from
coef.brmsfit brms
knit_print.tbl_obs mascutils
predict.brmsfit brms
print.tbl_obs mascutils
Attaching package: 'bayr'
The following objects are masked from 'package:mascutils':
as_tbl_obs, discard_all_na, discard_redundant, expand_grid,
go_arrange, go_first, left_union, reorder_levels, rescale_centered,
rescale_unit, rescale_zero_one, update_by, z_score, z_trans
The following objects are masked from 'package:brms':
fixef, ranef
The following object is masked from 'package:tidyr':
expand_grid
library(readxl)
Warning: package 'readxl' was built under R version 4.4.1
library(ggplot2)library(effects)
Loading required package: carData
Warning: package 'carData' was built under R version 4.4.1
lattice theme set by effectsTheme()
See ?effectsTheme for details.
library(lme4)
Warning: package 'lme4' was built under R version 4.4.1
Loading required package: Matrix
Warning: package 'Matrix' was built under R version 4.4.1
Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':
expand, pack, unpack
Attaching package: 'lme4'
The following objects are masked from 'package:bayr':
fixef, ranef
The following object is masked from 'package:brms':
ngrps
library(haven)library(lattice)
Warning: package 'lattice' was built under R version 4.4.1
library(car)
Warning: package 'car' was built under R version 4.4.1
Attaching package: 'car'
The following object is masked from 'package:mascutils':
logit
The following object is masked from 'package:dplyr':
recode
The following object is masked from 'package:purrr':
some
library(knitr)
Warning: package 'knitr' was built under R version 4.4.1
library(reshape2)
Attaching package: 'reshape2'
The following object is masked from 'package:tidyr':
smiths
library(dplyr)library(forcats)library(DHARMa)
Warning: package 'DHARMa' was built under R version 4.4.1
This is DHARMa 0.4.7. For overview type '?DHARMa'. For recent changes, type news(package = 'DHARMa')
library(Hmisc)
Warning: package 'Hmisc' was built under R version 4.4.1
Attaching package: 'Hmisc'
The following objects are masked from 'package:dplyr':
src, summarize
The following objects are masked from 'package:base':
format.pval, units
library(phia)library(lsmeans)
Loading required package: emmeans
Warning: package 'emmeans' was built under R version 4.4.1
Welcome to emmeans.
Caution: You lose important information if you filter this package's results.
See '? untidy'
Attaching package: 'emmeans'
The following object is masked from 'package:devtools':
test
The 'lsmeans' package is now basically a front end for 'emmeans'.
Users are encouraged to switch the rest of the way.
See help('transition') for more information, including how to
convert old 'lsmeans' objects and scripts to work with 'emmeans'.
library(emmeans)library(multcomp)
Warning: package 'multcomp' was built under R version 4.4.1
Loading required package: mvtnorm
Loading required package: survival
Attaching package: 'survival'
The following object is masked from 'package:brms':
kidney
Loading required package: TH.data
Warning: package 'TH.data' was built under R version 4.4.1
Loading required package: MASS
Warning: package 'MASS' was built under R version 4.4.1
Attaching package: 'MASS'
The following object is masked from 'package:dplyr':
select
Attaching package: 'TH.data'
The following object is masked from 'package:MASS':
geyser
library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:MASS':
select
The following object is masked from 'package:Hmisc':
subplot
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
library(lmerTest)
Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':
lmer
The following object is masked from 'package:stats':
step
Attaching package: 'janitor'
The following objects are masked from 'package:stats':
chisq.test, fisher.test
library(magrittr)
Attaching package: 'magrittr'
The following object is masked from 'package:purrr':
set_names
The following object is masked from 'package:tidyr':
extract
Warning: package 'afex' was built under R version 4.4.1
************
Welcome to afex. For support visit: http://afex.singmann.science/
- Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
- Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
- 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
- Get and set global package options with: afex_options()
- Set sum-to-zero contrasts globally: set_sum_contrasts()
- For example analyses see: browseVignettes("afex")
************
Attaching package: 'afex'
The following object is masked from 'package:lme4':
lmer
Rows: 31968 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): procedure, feedback.CRESP, feedback.RESP, cue.OnsetTime, cue.OnsetD...
dbl (9): subject, session, sub.trial.number, feedback.ACC, feedback.RT, h, t...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Read the datasetdf <-read.csv("df.csv")# Convert trial.RT from milliseconds to secondsdf <- df %>%mutate(trial.RTS = trial.RT /1000)# Convert trial.ACC into a dummy variabledf <- df %>%mutate(trial.acc =ifelse(trial.acc ==1, 1, 0)) # 1 if correct, 0 otherwise# Aggregate data to have one row per trialdf_lc <- df %>%group_by(subject, session, trial) %>%summarise(trial.RT =mean(trial.RT, na.rm =TRUE), # Mean RT per trialtrial.RTS =mean(trial.RTS, na.rm =TRUE), # Mean RT in secondstrial.acc =mean(trial.acc, na.rm =TRUE) # Mean accuracy per trial (should remain binary) ) %>%ungroup()
`summarise()` has grouped output by 'subject', 'session'. You can override
using the `.groups` argument.
# Adjust trial numbers so that they continue across sessionsdf_lc <- df_lc %>%mutate(trial =case_when( session ==1~ trial, session ==2~ trial +48, session ==3~ trial +96 ))
# Save the modified datasetwrite.csv(df_lc, "df_lc.csv", row.names =FALSE)
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#Classic Learning curve model all 3 sessions
# ampl = possible amount of learning before diminishing returns# rate = how fast a person learns# asymptote = maximal learning (lowest RT)F_ary <-formula(trial.RTS ~ asym + ampl *exp(-rate * trial))# Base model only accounts for subject-level modelF_ary_ef_1 <-list(formula(ampl ~1|subject),formula(rate ~1|subject),formula(asym ~1|subject))# Priors (Weakly informative)F_ary_prior <-c(set_prior("normal(5, 100)", nlpar ="ampl", lb =0),set_prior("normal(.5, 3)", nlpar ="rate", lb =0),set_prior("normal(3, 20)", nlpar ="asym", lb =0))# Modeling at the subject level M_1 <- df_lc1 %>%brm(bf(F_ary,flist = F_ary_ef_1,nl = T), prior = F_ary_prior,family ="exgaussian",data = .,iter =5000, #2000 - #5000warmup =4000, #1000 - #4000save_pars =save_pars(all=TRUE))
Compiling Stan program...
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
using C compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.6)’
using SDK: ‘’
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_HAS_AUTO_PTR_ETC=0 -include '/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c foo.c -o foo.o
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/Core:19:
/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/src/Core/util/Macros.h:679:10: fatal error: 'cmath' file not found
679 | #include <cmath>
| ^~~~~~~
1 error generated.
make: *** [foo.o] Error 1
Start sampling
SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 0.0005 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 5 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: Iteration: 1 / 5000 [ 0%] (Warmup)
Chain 1: Iteration: 500 / 5000 [ 10%] (Warmup)
Chain 1: Iteration: 1000 / 5000 [ 20%] (Warmup)
Chain 1: Iteration: 1500 / 5000 [ 30%] (Warmup)
Chain 1: Iteration: 2000 / 5000 [ 40%] (Warmup)
Chain 1: Iteration: 2500 / 5000 [ 50%] (Warmup)
Chain 1: Iteration: 3000 / 5000 [ 60%] (Warmup)
Chain 1: Iteration: 3500 / 5000 [ 70%] (Warmup)
Chain 1: Iteration: 4000 / 5000 [ 80%] (Warmup)
Chain 1: Iteration: 4001 / 5000 [ 80%] (Sampling)
Chain 1: Iteration: 4500 / 5000 [ 90%] (Sampling)
Chain 1: Iteration: 5000 / 5000 [100%] (Sampling)
Chain 1:
Chain 1: Elapsed Time: 1681.92 seconds (Warm-up)
Chain 1: 281.4 seconds (Sampling)
Chain 1: 1963.32 seconds (Total)
Chain 1:
SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 0.000298 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 2.98 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 5000 [ 0%] (Warmup)
Chain 2: Iteration: 500 / 5000 [ 10%] (Warmup)
Chain 2: Iteration: 1000 / 5000 [ 20%] (Warmup)
Chain 2: Iteration: 1500 / 5000 [ 30%] (Warmup)
Chain 2: Iteration: 2000 / 5000 [ 40%] (Warmup)
Chain 2: Iteration: 2500 / 5000 [ 50%] (Warmup)
Chain 2: Iteration: 3000 / 5000 [ 60%] (Warmup)
Chain 2: Iteration: 3500 / 5000 [ 70%] (Warmup)
Chain 2: Iteration: 4000 / 5000 [ 80%] (Warmup)
Chain 2: Iteration: 4001 / 5000 [ 80%] (Sampling)
Chain 2: Iteration: 4500 / 5000 [ 90%] (Sampling)
Chain 2: Iteration: 5000 / 5000 [100%] (Sampling)
Chain 2:
Chain 2: Elapsed Time: 1118.65 seconds (Warm-up)
Chain 2: 285.292 seconds (Sampling)
Chain 2: 1403.94 seconds (Total)
Chain 2:
SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
Chain 3: Rejecting initial value:
Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
Chain 3: Stan can't start sampling from this initial value.
Chain 3:
Chain 3: Gradient evaluation took 0.000295 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 2.95 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
Chain 3: Iteration: 1 / 5000 [ 0%] (Warmup)
Chain 3: Iteration: 500 / 5000 [ 10%] (Warmup)
Chain 3: Iteration: 1000 / 5000 [ 20%] (Warmup)
Chain 3: Iteration: 1500 / 5000 [ 30%] (Warmup)
Chain 3: Iteration: 2000 / 5000 [ 40%] (Warmup)
Chain 3: Iteration: 2500 / 5000 [ 50%] (Warmup)
Chain 3: Iteration: 3000 / 5000 [ 60%] (Warmup)
Chain 3: Iteration: 3500 / 5000 [ 70%] (Warmup)
Chain 3: Iteration: 4000 / 5000 [ 80%] (Warmup)
Chain 3: Iteration: 4001 / 5000 [ 80%] (Sampling)
Chain 3: Iteration: 4500 / 5000 [ 90%] (Sampling)
Chain 3: Iteration: 5000 / 5000 [100%] (Sampling)
Chain 3:
Chain 3: Elapsed Time: 1061.67 seconds (Warm-up)
Chain 3: 296.707 seconds (Sampling)
Chain 3: 1358.38 seconds (Total)
Chain 3:
SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
Chain 4: Rejecting initial value:
Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
Chain 4: Stan can't start sampling from this initial value.
Chain 4: Rejecting initial value:
Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
Chain 4: Stan can't start sampling from this initial value.
Chain 4: Rejecting initial value:
Chain 4: Error evaluating the log probability at the initial value.
Chain 4: Exception: exp_mod_normal_lpdf: Location parameter[1193] is -inf, but must be finite! (in 'anon_model', line 104, column 4 to column 67)
Chain 4: Rejecting initial value:
Chain 4: Error evaluating the log probability at the initial value.
Chain 4: Exception: exp_mod_normal_lpdf: Location parameter[110] is -inf, but must be finite! (in 'anon_model', line 104, column 4 to column 67)
Chain 4: Rejecting initial value:
Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
Chain 4: Stan can't start sampling from this initial value.
Chain 4: Rejecting initial value:
Chain 4: Error evaluating the log probability at the initial value.
Chain 4: Exception: exp_mod_normal_lpdf: Location parameter[60] is inf, but must be finite! (in 'anon_model', line 104, column 4 to column 67)
Chain 4: Rejecting initial value:
Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
Chain 4: Stan can't start sampling from this initial value.
Chain 4: Rejecting initial value:
Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
Chain 4: Stan can't start sampling from this initial value.
Chain 4:
Chain 4: Gradient evaluation took 0.000299 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 2.99 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 5000 [ 0%] (Warmup)
Chain 4: Iteration: 500 / 5000 [ 10%] (Warmup)
Chain 4: Iteration: 1000 / 5000 [ 20%] (Warmup)
Chain 4: Iteration: 1500 / 5000 [ 30%] (Warmup)
Chain 4: Iteration: 2000 / 5000 [ 40%] (Warmup)
Chain 4: Iteration: 2500 / 5000 [ 50%] (Warmup)
Chain 4: Iteration: 3000 / 5000 [ 60%] (Warmup)
Chain 4: Iteration: 3500 / 5000 [ 70%] (Warmup)
Chain 4: Iteration: 4000 / 5000 [ 80%] (Warmup)
Chain 4: Iteration: 4001 / 5000 [ 80%] (Sampling)
Chain 4: Iteration: 4500 / 5000 [ 90%] (Sampling)
Chain 4: Iteration: 5000 / 5000 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 1119.07 seconds (Warm-up)
Chain 4: 297.726 seconds (Sampling)
Chain 4: 1416.79 seconds (Total)
Chain 4:
Warning: There were 67 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
Warning: There were 3839 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
Warning: Examine the pairs() plot to diagnose sampling problems
Warning: The largest R-hat is 2.05, indicating chains have not mixed.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#r-hat
Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
# Extract random effects for the "subject" grouping factorranef_df <-ranef(M_1)$subject %>%as.data.frame() %>%rownames_to_column(var ="subject") # Convert row names to a column# Rename columns for clarity (adjust based on `ranef(M_1)` output)colnames(ranef_df) <-c("subject", "term", "Estimate", "Q2.5", "Q97.5")# Convert subject to a factor for clear axis labelsranef_df$subject <-as.factor(ranef_df$subject)# Create a single plot with all subjectsggplot(ranef_df, aes(x = subject, y = Estimate, ymin = Q2.5, ymax = Q97.5)) +geom_crossbar(width =0.4, color ="blue", fill ="lightblue") +geom_point(size =3, color ="black") +# Highlight mean estimatestheme_minimal() +labs(title ="Subject-Level Random Effects",x ="Participant",y ="Random Effect Estimate") +theme(axis.text.x =element_text(angle =90, hjust =1)) # Rotate x-axis labels
`summarise()` has grouped output by 'session'. You can override using the
`.groups` argument.
# Plot estimated learning curves separately for each session with correct x-axisggplot(group_fitted, aes(x = trial, y = mean_Estimate, color =as.factor(session))) +geom_line(size =1) +# Estimated RT line per sessiongeom_ribbon(aes(ymin = lower_CI, ymax = upper_CI, fill =as.factor(session)), alpha =0.2) +# Confidence intervalfacet_wrap(~session, scales ="free_x") +# Adjust x-axis to match session trialsscale_x_continuous(breaks =seq(1, 144, by =5)) +# Show relevant trial numberslabs(title ="Session-Specific Estimated Learning Curves",x ="Trial Number",y ="Predicted Reaction Time (s)",color ="Session",fill ="Session") +theme_minimal()
#Models for each session individually
# Function to fit models for each sessionfit_model_for_session <-function(data, session_number) {brm(bf(F_ary, flist = F_ary_ef_1, nl =TRUE),prior = F_ary_prior,family ="exgaussian",data = data,iter =5000,warmup =4000,save_pars =save_pars(all =TRUE) )}# Fit models for each sessionM_session1 <-fit_model_for_session(df_lc1 %>%filter(session ==1), 1)
Compiling Stan program...
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
using C compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.6)’
using SDK: ‘’
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel/include/" -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_HAS_AUTO_PTR_ETC=0 -include '/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c foo.c -o foo.o
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/Core:19:
/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppEigen/include/Eigen/src/Core/util/Macros.h:679:10: fatal error: 'cmath' file not found
679 | #include <cmath>
| ^~~~~~~
1 error generated.
make: *** [foo.o] Error 1
Warning: There were 261 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
Warning: There were 2645 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
Warning: Examine the pairs() plot to diagnose sampling problems
Warning: The largest R-hat is 1.57, indicating chains have not mixed.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#r-hat
Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
Warning: There were 6 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
Warning: There were 997 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
Warning: Examine the pairs() plot to diagnose sampling problems
Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
# Save modelssave(M_session1, M_session2, M_session3, file ="tryout1")
# Save as CSV if neededwrite.csv(fixef_table, "fixef_table_full.csv", row.names =FALSE)
#Random effects for each session
#session1# Extract random effects for the "subject" grouping factorranef_ms1 <-ranef(M_session1)$subject %>%as.data.frame() %>%rownames_to_column(var ="subject") # Convert row names to a column# Rename columns for clarity (adjust based on `ranef(M_1)` output)colnames(ranef_ms1) <-c("subject", "term", "Estimate", "Q2.5", "Q97.5")# Convert subject to a factor for clear axis labelsranef_ms1$subject <-as.factor(ranef_ms1$subject)# Create a single plot with all subjectsggplot(ranef_ms1, aes(x = subject, y = Estimate, ymin = Q2.5, ymax = Q97.5)) +geom_crossbar(width =0.4, color ="blue", fill ="lightblue") +geom_point(size =3, color ="black") +# Highlight mean estimatestheme_minimal() +labs(title ="Subject-Level Random Effects",x ="Participant",y ="Random Effect Estimate") +theme(axis.text.x =element_text(angle =90, hjust =1)) # Rotate x-axis labels
#Session2# Extract random effects for the "subject" grouping factorranef_ms2 <-ranef(M_session2)$subject %>%as.data.frame() %>%rownames_to_column(var ="subject") # Convert row names to a column# Rename columns for clarity (adjust based on `ranef(M_1)` output)colnames(ranef_ms2) <-c("subject", "term", "Estimate", "Q2.5", "Q97.5")# Convert subject to a factor for clear axis labelsranef_ms2$subject <-as.factor(ranef_ms2$subject)# Create a single plot with all subjectsggplot(ranef_ms2, aes(x = subject, y = Estimate, ymin = Q2.5, ymax = Q97.5)) +geom_crossbar(width =0.4, color ="blue", fill ="lightblue") +geom_point(size =3, color ="black") +# Highlight mean estimatestheme_minimal() +labs(title ="Subject-Level Random Effects",x ="Participant",y ="Random Effect Estimate") +theme(axis.text.x =element_text(angle =90, hjust =1)) # Rotate x-axis labels
# Session3# Extract random effects for the "subject" grouping factorranef_ms3 <-ranef(M_session3)$subject %>%as.data.frame() %>%rownames_to_column(var ="subject") # Convert row names to a column# Rename columns for clarity (adjust based on `ranef(M_1)` output)colnames(ranef_ms3) <-c("subject", "term", "Estimate", "Q2.5", "Q97.5")# Convert subject to a factor for clear axis labelsranef_ms3$subject <-as.factor(ranef_ms3$subject)# Create a single plot with all subjectsggplot(ranef_ms3, aes(x = subject, y = Estimate, ymin = Q2.5, ymax = Q97.5)) +geom_crossbar(width =0.4, color ="blue", fill ="lightblue") +geom_point(size =3, color ="black") +# Highlight mean estimatestheme_minimal() +labs(title ="Subject-Level Random Effects",x ="Participant",y ="Random Effect Estimate") +theme(axis.text.x =element_text(angle =90, hjust =1)) # Rotate x-axis labels
# Create separate datasets for each sessiondf_session1 <- df_lc %>%filter(session ==1)df_session2 <- df_lc %>%filter(session ==2)df_session3 <- df_lc %>%filter(session ==3)# Save them as separate CSV fileswrite.csv(df_session1, "df_session1.csv", row.names =FALSE)write.csv(df_session2, "df_session2.csv", row.names =FALSE)write.csv(df_session3, "df_session3.csv", row.names =FALSE)
Warning: There were 132 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
Warning: There were 3633 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
Warning: Examine the pairs() plot to diagnose sampling problems
Warning: The largest R-hat is 1.57, indicating chains have not mixed.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#r-hat
Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
# Extract random effects for the "subject" grouping factorranef_M_inv_decay <-ranef(M_inv_decay)$subject %>%as.data.frame() %>%rownames_to_column(var ="subject") # Convert row names to a column# Rename columns for clarity (adjust based on `ranef(M_1)` output)colnames(ranef_M_inv_decay) <-c("subject", "term", "Estimate", "Q2.5", "Q97.5")# Convert subject to a factor for clear axis labelsranef_M_inv_decay$subject <-as.factor(ranef_M_inv_decay$subject)# Create a single plot with all subjectsggplot(ranef_M_inv_decay, aes(x = subject, y = Estimate, ymin = Q2.5, ymax = Q97.5)) +geom_crossbar(width =0.4, color ="blue", fill ="lightblue") +geom_point(size =3, color ="black") +# Highlight mean estimatestheme_minimal() +labs(title ="Subject-Level Random Effects",x ="Participant",y ="Random Effect Estimate") +theme(axis.text.x =element_text(angle =90, hjust =1)) # Rotate x-axis labels
Warning: There were 619 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
Warning: There were 1997 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
Warning: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See
https://mc-stan.org/misc/warnings.html#bfmi-low
Warning: Examine the pairs() plot to diagnose sampling problems
Warning: The largest R-hat is 2.48, indicating chains have not mixed.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#r-hat
Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
# Extract random effects for the "subject" grouping factorranef_M_logistic <-ranef(M_logistic)$subject %>%as.data.frame() %>%rownames_to_column(var ="subject") # Convert row names to a column# Rename columns for clarity (adjust based on `ranef(M_1)` output)colnames(ranef_M_logistic) <-c("subject", "term", "Estimate", "Q2.5", "Q97.5")# Convert subject to a factor for clear axis labelsranef_M_logistic$subject <-as.factor(ranef_M_logistic$subject)# Create a single plot with all subjectsggplot(ranef_M_logistic, aes(x = subject, y = Estimate, ymin = Q2.5, ymax = Q97.5)) +geom_crossbar(width =0.4, color ="blue", fill ="lightblue") +geom_point(size =3, color ="black") +# Highlight mean estimatestheme_minimal() +labs(title ="Subject-Level Random Effects",x ="Participant",y ="Random Effect Estimate") +theme(axis.text.x =element_text(angle =90, hjust =1)) # Rotate x-axis labels