Skip to content

Instantly share code, notes, and snippets.

View benwhalley's full-sized avatar

Ben Whalley benwhalley

  • Plymouth University
View GitHub Profile
predictor mediator outcome
-0.5799569890194015 -2.386729068806458 0.16615007241450852
-0.9532787019469066 -1.8704045357635897 -2.365057031487532
-0.179428586945621 -0.7802502874626318 0.45227260237394107
1.0098082149443033 1.120252021425702 1.0126134245088094
0.023626614921408818 0.46469454732937937 1.85270396504268
-0.6490282195839006 -1.1446117023037912 -1.0069340694172548
-0.5043742220481909 0.4545346010968645 -1.9860277841931153
1.6143914954583631 2.107280493591184 2.3169539162841035
-0.446959811255663 -1.41170770556635 -0.23362692088530584
predictor mediator outcome
-1.2070657493854209 -0.18900934031772498 -0.9108482691338935
0.27742924211066 -0.33600385247403014 0.6381941682015424
1.084441176683056 0.6082140820459894 1.8781691743121023
-2.3456977026293493 -1.6753266337085408 -3.3202908207934287
0.42912468881105 -0.6114362427238106 0.12936947474859867
0.506055892157574 0.4200172258317707 1.686535479957183
-0.5747399601346488 -1.1836346063120828 0.08408905976092917
-0.546631855784187 -0.10513054023633653 0.46060044524207233
-0.564451999093283 0.07274226146821294 -0.45904578012362596
-1.2070657493854209 -0.18900934031772498 -0.9108482691338935
0.27742924211066 -0.33600385247403014 0.6381941682015424
1.084441176683056 0.6082140820459894 1.8781691743121023
-2.3456977026293493 -1.6753266337085408 -3.3202908207934287
0.42912468881105 -0.6114362427238106 0.12936947474859867
0.506055892157574 0.4200172258317707 1.686535479957183
-0.5747399601346488 -1.1836346063120828 0.08408905976092917
-0.546631855784187 -0.10513054023633653 0.46060044524207233
-0.564451999093283 0.07274226146821294 -0.45904578012362596
"mediationexample1.csv"
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
| predictor| mediator| outcome|
|----------:|----------:|----------:|
| -1.2070657| -0.1890093| -0.9108483|
| 0.2774292| -0.3360039| 0.6381942|
| 1.0844412| 0.6082141| 1.8781692|
| -2.3456977| -1.6753266| -3.3202908|
| 0.4291247| -0.6114362| 0.1293695|
| 0.5060559| 0.4200172| 1.6865355|
| -0.5747400| -1.1836346| 0.0840891|
| -0.5466319| -0.1051305| 0.4606004|
| predictor| mediator| outcome|
|----------:|----------:|----------:|
| -1.2070657| -0.1890093| -0.9108483|
| 0.2774292| -0.3360039| 0.6381942|
| 1.0844412| 0.6082141| 1.8781692|
| -2.3456977| -1.6753266| -3.3202908|
| 0.4291247| -0.6114362| 0.1293695|
| 0.5060559| 0.4200172| 1.6865355|
| -0.5747400| -1.1836346| 0.0840891|
| -0.5466319| -0.1051305| 0.4606004|
f.10 <- log.auc.positive ~ log(CueOrder)*Congruent + (1|Participant) + (0+log(CueOrder)*Congruent|Participant)
fit.10.stan <- stan_lmer(f.10, data=dftouse, iter=5000, chains=3)
summary(fit.10.stan)
fit.10.stan.preds <- posterior_linpred(fit.10.stan,
transform=F,
re.form=NA) %>%
-----------------------------------------------------------------------------------------------------------
Participant BlockNo CueOrder Congruent auc auc.positive log.auc log.auc.positive Trial
------------- --------- ---------- ----------- -------- -------------- --------- ------------------ -------
1 1 1 FALSE 0 0 0 0 1
1 1 2 TRUE 0 0 0 0 2
1 1 3 FALSE 0 0 0 0 3
require('dplyr')
require('rethinking')
dmode <- function(x) {
den <- density(x, kernel=c("gaussian"))
( den$x[den$y==max(den$y)] )
}
meanhpdi <- function(x, prob=.95) {
i <- rethinking::HPDI(x, prob=prob)
https://transfer.sh/B9DqM/5-cfa-part-2.pdf