canlab / MediationToolbox

Single-level and multi-level mediation analyses for any kind of data, with bootstrap-based significance testing. Neuroimaging-oriented functions allow for mediation effect parametric mapping (mapping of mediation effects across the brain) and multivariate mediation.
https://canlabweb.colorado.edu/wiki/doku.php/help/mediation/m3_mediation_fmri_toolbox
83 stars 29 forks source link

Dimension not match Error when bootstrapping Joint PDM #17

Open hitrp opened 3 years ago

hitrp commented 3 years ago

There's one dimension not match error when running multivaraiteMediation function, and the error occurs in BootPDMJoint.m: worig = worig.*repmat(sign(torig(3,:)),p,1);

Here, I am using 10 PDMs, the dimensions info are: worig=#voxles 1, torig=510, p=10 #voxels. After this, I get worig=#voxels 1 and repmat(sign(torig(3,:)),p,1)=#voxels 10, they are not matched for . indeed. However, there's no error in previous steps, and I'm not sure about what happens here, and also not quite clear about the mathematics behind it, could you give me some idea?

torwager commented 3 years ago

Hi Peng,

I checked with Martin Lindquist, who says:

The value of p looks weird to me. It is defined as

p = size(Dt,2);

where Dt is the inverse weight projection matrix (B x voxels). Hence p should be #voxels, not 10*#voxels.......

Best,

Martin

On Dec 23, 2020, at 9:45 PM, Peng Ren notifications@github.com wrote:

There's one dimension not match error when running multivaraiteMediation function, and the error occurs in BootPDMJoint.m: worig = worig.*repmat(sign(torig(3,:)),p,1);

Here, I am using 10 PDMs, the dimensions info are: worig=#voxles1, torig=510, p=10#voxels. After this, I get worig=#voxels1 and repmat(sign(torig(3,:)),p,1)=#voxels10, they are not matched for . indeed. However, there's no error in previous steps, and I'm not sure about what happens here, and also not quite clear about the mathematics behind it, could you give me some idea?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/canlab/MediationToolbox/issues/17, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPY7LHRLQSXN573P26Q7I3SWKTLPANCNFSM4VHWB5EQ.

hitrp commented 3 years ago

Dear Prof.Wager,

Sorry for the mistake in my original description, P surely equals #voxels, and the error comes from worig = worig.*repmat(sign(torig(3,:)),p,1);

worig=#voxels 1, however, repmat(sign(torig(3,:)),p,1)=#voxels 10 cause sign(torig(3,:))=5 * 10.

I guess the original goal is to calculate the elementwise product between worig and each column of repmat(sign(torig(3,:)),p,1)=#voxels * 10, right? In this case, I find bsxfun(@times,worig,repmat(sign(torig(3,:)),p,1)) works.

Please forgive me if there's any mistake.

Best regards, Peng

hitrp commented 3 years ago

Dear Prof.Wager,

Just to make sure about the pipeline of Multivariate Mediation Analysis in your recent "Multiple Brain Networks Mediating Stimulus–Pain Relationships in Humans" article to avoid vital mistakes. These are the ideas I summarize from reading the article and emailing Prof.Lindquist. Any instruction would be much appreciated!

1) make sure a significant path c before I conduct multivariate mediation with multivariateMediation() and then get the number of PDMs used with PDM_toolbox, also the distribution of the PDMs and the a, b path coefficient but not p values of the paths 2) map the PDM to voxels using FDR correction 3) conduct a secondary mediation test to figure out if a specific PDM plays as the mediator, with the evaluation of the significance of their paths with mediation().

Is this the case? --The multivariateMediation() function seems to only find PDMs and a, b path, but not evaluate the significance of them. am I right? --and why does the coefficient of the path a and b for PDM1 in the secondary analysis (with mediation() in 1st figure below) differs so much from that from the first analysis (multivaraiteMediation() in 2nd figure below), could you give me some ideas? --What if I find no significant a and b path in secondary mediation analysis? Do I need to discard this PDM? just like in the 1st figure below.

image (1) image (2)

Seasons Greeting, Peng