Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Within Subject Factor Effect #8

Open
saurabhr opened this issue Mar 31, 2022 · 1 comment
Open

Within Subject Factor Effect #8

saurabhr opened this issue Mar 31, 2022 · 1 comment

Comments

@saurabhr
Copy link

Hi,
I was trying to use the package for modeling tree which has within-subject factor. As I have gone through the package's paper, you have given example to model between-subject factor. Should I model the 2htsm for each level of within-subject factor (which I think is wrong, but I do not see any other way as I don't understand how to specify that in treeBUGS package)?

@danheck
Copy link
Owner

danheck commented Apr 1, 2022

For within-subjects factors, it is necessary to extend the MPT model equations from one condition to multiple conditions manually. Essentially, it is necessary to define separate trees with separate category labels, as well as separate parameter names.

TreeBUGS also provides the function withinSubjectEQN to simplify this step. Here is an example:

library(TreeBUGS)
htm <- "
# Basic 2HTM for a single condition
Target    Hit    Do
Target    Hit    (1-Do)*g
Target    Miss   (1-Do)*(1-g)
Lure      FA     (1-Dn)*g
Lure      CR     (1-Dn)*(1-g)
Lure      CR     Dn
"
htm2 <- withinSubjectEQN(eqnfile = htm, 
                         labels = c("high","low"), 
                         constant=c("g"))
htm2

The extended model then looks like this:

          Tree  Category          Equation
1  high_Target  high_Hit           Do_high
2  high_Target  high_Hit     (1-Do_high)*g
3  high_Target high_Miss (1-Do_high)*(1-g)
4    high_Lure   high_FA     (1-Dn_high)*g
5    high_Lure   high_CR (1-Dn_high)*(1-g)
6    high_Lure   high_CR           Dn_high
7   low_Target   low_Hit            Do_low
8   low_Target   low_Hit      (1-Do_low)*g
9   low_Target  low_Miss  (1-Do_low)*(1-g)
10    low_Lure    low_FA      (1-Dn_low)*g
11    low_Lure    low_CR  (1-Dn_low)*(1-g)
12    low_Lure    low_CR            Dn_low

Once the model has been fitted, you can obtain the posterior distribution of the difference of the parameters at the group level:

# (requires a data set)
fit <- traitMPT(eqnfile = eqn, data = data)
tp <- transformedParameters(fittedModel = fit, 
                            transformedParameters = list("delta = Do_high - Do_low"))
summarizeMCMC(tp)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants