Problem using multiple chains in mhsample
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have set up code to use the mhsample function to estimate the posterior distribution for a complex problem with a large data set (which is confidential). As such I will not be able provide the entire coding since it is very long and will likely be more confusing. My proposal distribution and pdf is set up to take a row vector of a certain size and returns a row vector of the same size and a value for the posterior distribution, respectively. The function works when I set nchain to 1 but if I make it > 1 I get the following error message
??? Index exceeds matrix dimensions.
Error in ==> mhsample at 177 x0(acc,:) = y(acc,:); % preserves x's shape.
I have looked at the function and think I may have found the problem but am not sure how to fix it. It seems that it is attempting to access the number of rows = nchain for y the proposal values. The proposal function currently only puts out a single row vector so the values it it trying to access do not exist.
Do i need to change the proposal distribution so that it returns a matrix instead of just a row vector? If I do this I must then change it everytime that I want to try a different number if chains. Also I would need to change my pdf function to accept this matrix and then calculate separate values for the joint posterior distribution for each row. Is there a better way to deal with this problem?
Thank You Matt Vincent
0 Kommentare
Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!