Can a prior be weighted?

Post Reply
User avatar
Matt J Dunn
Posts: 11
Joined: Thu Feb 24, 2022 3:34 am

Can a prior be weighted?

Post by Matt J Dunn »

When using PAL_AMPM(), can the values supplied for priors (priorAlphaRange, etc.) be weighted according to a distribution? For example, in a temporal order judgement task, I expect threshold to be somewhere around 30 ms. However, I am running the task on a group of people that could include some individuals with much longer thresholds. Therefore if I plot the threshold over a population, I expect a positively skewed distribution (peak at lower values, but a long tail).

What is the best way of informing PAL_AMPM() of this? I can think of three possible approaches:
  • Supply priorAlphaRange as a vector of values, with more elements in the lower part of the range (this is what we currently do)
  • Supply linearly-spaced values which are transformed in order to arrive at a flat distribution of expected threshold values (this might work but then you would need to untransform the values whenever using them - the code could get quite messy)
  • ...Or is there a native way to apply a distribution within Palamedes?
User avatar
Nick Prins
Site Admin
Posts: 28
Joined: Sun Feb 13, 2022 8:55 pm

Re: Can a prior be weighted?

Post by Nick Prins »

The recommended way to specify custom priors is demonstrated in the code below. It puts an ex-Gaussian prior on alpha (ex-Gaussian is often used to model skewed distributions including RTs) and puts a Normal prior on slopes. Strategy can be extended to put any custom prior on any of the PF's parameters. No idea whether specific choices (e.g., for the parameter values of the ex-Gaussian) I made in this example would be appropriate for any specific situation.

The code below produces this image of the prior (I rotated view though for clarity):

Image

Code: Select all

priorAlphaRange = linspace(0,200,201);
priorBetaRange = linspace(-2,2,101);    %log10 transformed values as usual
priorGammaRange = 0.5;
priorLambdaRange = .03;

%set up PM structure (with uniform prior for now):
PM = PAL_AMPM_setupPM('priorAlphaRange',priorAlphaRange,'priorBetaRange',priorBetaRange,'priorGammaRange',priorGammaRange,'priorLambdaRange',priorLambdaRange,'PF',@PAL_CumulativeNormal);

%PM.priorAlphas now has the same dimensions as the full prior/posterior
%distribution (i.e., 201 x 101) and contains, for each position in the array, 
% the value of the threshold parameter.

%PM.priorBetas now has the same dimensions as the full prior/posterior
%distribution (i.e., 201 x 101) and contains, for each position in the array, 
%the value of the slope parameter.

%similar for PM.priorGammas and PM.priorLambdas, but these will be constant
%in this example.

%Defining non-uniform prior across multi-dimensional parameter space is now 
%easy.
%The following puts an exGaussian density on threshold and a Gaussian 
%density on slopes:  
prior = PAL_pdfExGaussian(PM.priorAlphas,30,10,30).*PAL_pdfNormal(PM.priorBetas,0,.5);

%normalize:
prior = prior./sum(sum(prior));

%update PM structure with new prior (other previously defined settings are
%not affected by this):
PM = PAL_AMPM_setupPM(PM,'prior',prior);

%visualise prior
surf(priorBetaRange, priorAlphaRange,squeeze(PM.pdf))
xlabel('log10(slopes)');
ylabel('threshold');

Nick Prins, Administrator
Post Reply