Page 1 of 1
Single subject multiple condition demo
Posted: Thu May 25, 2023 12:16 pm
by Aoibheann
Hello,
I am new to Palamedes and I believe the data I have can work with the single subject multiple conditions demo. However I am changing the number of conditions. I see in the demo the function, PAL_PFHB_inspectParam is used for conditions 1 and 2. Do I need to add extra lines of this function if I am adding more conditions?
Many thanks
Aoibheann
Re: Single subject multiple condition demo
Posted: Thu May 25, 2023 12:54 pm
by Nick Prins
It all depends on what you're interested to see. The only thing needed to run the analysis itself is PAL_PFHB_fitModel. All the rest is essentially just visualization of results. PAL_PFHB_drawViolins is probably most useful to get a quick look at whether your location parameter (aka threshold, PSE, etc.) or slope parameter differs between conditions.
The line:
PAL_PFHB_inspectParam(pfhb,'a','condition',1,'a','condition',2);
is useful to compare the location parameter ('a') between conditions 1 and 2. Essentially a pairwise comparison. To compare location parameters between conditions 2 and 3 you would use:
PAL_PFHB_inspectParam(pfhb,'a','condition',2,'a','condition',3);
Make sure to check out
https://www.palamedestoolbox.org/hierar ... esian.html and the help in the functions. Type e.g., 'help PAL_PFHB_inspectParam' (without quotes) to learn more about what that function does.
Re: Single subject multiple condition demo
Posted: Fri May 26, 2023 7:55 am
by Manvi
Thank you for your reply.
We were trying to fit our data into the Single subject multiple condition demo and this is the error message we get:
Index in position 2 exceeds array bounds. Index must not exceed 3.
Error in PAL_PFHB_setupModel (line 382)
data.ac(contrast,data.c == cond) = model.a.cTtoP(contrast,cond);
Error in PAL_PFHB_fitModel (line 277)
pfhb = PAL_PFHB_setupModel(data, varargin{:});
Error in PAL_PFHB_SingleSubjectMultipleConditions_edited (line 77)
pfhb = PAL_PFHB_fitModel(data,'gammaEQlambda',true,'engine',engine,'a',M,'nsamples',10000);
We were also hoping to clarify how the 'M' values are decided and based on what parameters:
M = [1 1 1; -2 1 1; 0 -1 1] %Reparameterizes location parameters. E.g., pfhb.summStats.a.mean(1)
%will contain the mean of posterior on the sum of location parameters,
%pfhb.summStats.a.mean(2) will contain the mean of the posterior on
%the difference between location parameters.
%pfhb.summStats.a_actual.mean(1) will contain the mean
%of the posterior of the location parameter in
%condition 1. This posterior was not directly sampled
%but rather derived from reparameterized parameters.
Re: Single subject multiple condition demo
Posted: Sat May 27, 2023 11:18 am
by Nick Prins
By the time the error occurs, you have already modeled your data (using the first call to PAL_PFHB_fitModel in the demo). The crash you report happens during an alternative fit that uses a model matrix. The crash happens because the model matrix M is specific to a three-condition setup (and I gather you have more than three conditions in your data).
All that is required to perform a basic fit is this:
pfhb = PAL_PFHB_fitModel(data); %add arguments as needed
Then, to view the data plus fits for all conditions and subjects (if there are several):
PAL_PFHB_inspectFit(pfhb,’all’); %cycle through using ‘enter’
To visualise posterior and summary statistics for parameter estimates::
PAL_PFHB_drawViolins(pfhb);
Model matrices are quite useful to target specific research questions. A tutorial on model matrices and how to create model matrices that target specific research questions can be found here:
www.palamedestoolbox.org/modelmatrix.html