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

Categorical variable as predictor #35

Open
QDevignes opened this issue Jan 24, 2025 · 0 comments
Open

Categorical variable as predictor #35

QDevignes opened this issue Jan 24, 2025 · 0 comments

Comments

@QDevignes
Copy link

Hello,
I hope this message finds you well. First of all, thank you for sharing such an amazing toolbox! I have been willing to perform voxel-wise mediation analyses for a while, and your toolbox is exactly what I needed!
I have been trying to run a mediation analysis with a categorical variable. I defined my predictor X as categorical in matlab (with 3 conditions coded as 1, 2 and 3; for example, X = {1,1,1,2,3,1,2,3}, followed by X = categorical(X)). However, I got the following error message:

Error using mediation>setup_inputs
Expected input to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was categorical.
Error in mediation (line 183)
setup_inputs(X, Y, M, varargin);
Error in mediation_search (line 143)
[paths, stat] = mediation(X, Y, M(:,region), varargin{:}, 'persistent', extra_args{:}, 'pvals_for_boot', pvals_for_boot, 'arorder', arorder);
Error in mediation_brain/process_slice (line 314)
slice_results = mediation_search('M', X, Y, M(:,whvox), varargin{:});
Error in mediation_brain (line 276)
process_slice();

If I don't define X as categorical, the command runs just fine, but I am concerned that the regression models consider X as a continuous variable and not a categorical one (in the latter case, I would expect the regression command to create dummy variables and then run the regression). Therefore, my question is: how should I define the categorical predictor before running the mediation analysis?

Thank you for your help!
Best,
Quentin

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

1 participant