Open fontaine19100 opened 8 years ago
x is a vector not a matrix. The error means what it says. X[, 1] makes no sense. Think of the state of the Markov chain as a vector not a matrix (or anyother structured object).
On Wed, Jun 22, 2016 at 5:39 AM, fontaine19100 notifications@github.com wrote:
dear developpers,
I am quite new in sampling posterior distributions(so therefore Bayesian approach) using a MCMC technique based on Metropolis-Hastings algorithm. I am using the mcmc library in R for this. My distribution is multidimensional. In order to check if this metro algorithm works for multivaiate distribution I did it successfully on a student-t distribution (package mvtnorm, function dmvt).
Now I want to apply the same thing to my multivariate distribution (2 vars x and y) but it doesn't work; I get an error : Error in X[, 1] : incorrect number of dimensions
The code is available on : https://github.com/fontaine19100/MCMC_R/blob/master/try.R
So I tried to respect the same kind of format than for the MWE, but it doesn't work still as I got the error mentioned before. Another thing, is that applying logpost to X works perfectly.
Thanks in advance for your help, best
Jean-Philippe
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cjgeyer/mcmc/issues/1, or mute the thread https://github.com/notifications/unsubscribe/AAcdwDXF3jA7PBtKG0e_y9zDX8Uo_S4wks5qORDQgaJpZM4I7ou_ .
Dear professor, Thanks for your reply. In my case, the problem is that I have a multidimensionnal likelikood so I think I am obliged to pass an array or a matrix. Also as I mentionned, applying the metrop algorithm toa multivariate student t distribution works perfectly. For this I use the same object X which is a cbind of two vectors.
Thanks in advance, best regards Le 22 juin 2016 16:07, "Charles J. Geyer" notifications@github.com a écrit :
x is a vector not a matrix. The error means what it says. X[, 1] makes no sense. Think of the state of the Markov chain as a vector not a matrix (or anyother structured object).
On Wed, Jun 22, 2016 at 5:39 AM, fontaine19100 notifications@github.com wrote:
dear developpers,
I am quite new in sampling posterior distributions(so therefore Bayesian approach) using a MCMC technique based on Metropolis-Hastings algorithm. I am using the mcmc library in R for this. My distribution is multidimensional. In order to check if this metro algorithm works for multivaiate distribution I did it successfully on a student-t distribution (package mvtnorm, function dmvt).
Now I want to apply the same thing to my multivariate distribution (2 vars x and y) but it doesn't work; I get an error : Error in X[, 1] : incorrect number of dimensions
The code is available on : https://github.com/fontaine19100/MCMC_R/blob/master/try.R
So I tried to respect the same kind of format than for the MWE, but it doesn't work still as I got the error mentioned before. Another thing, is that applying logpost to X works perfectly.
Thanks in advance for your help, best
Jean-Philippe
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cjgeyer/mcmc/issues/1, or mute the thread < https://github.com/notifications/unsubscribe/AAcdwDXF3jA7PBtKG0e_y9zDX8Uo_S4wks5qORDQgaJpZM4I7ou_
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cjgeyer/mcmc/issues/1#issuecomment-227754555, or mute the thread https://github.com/notifications/unsubscribe/ARndfHmTs9Dgxra0QLUGmLL6tgADkm6aks5qOUGJgaJpZM4I7ou_ .
string out your matrix as a vector x <- as.vector(x) then put it back x <- matrix(x, ncol = 2) seems to be all you need in this case.
On Wed, Jun 22, 2016 at 9:12 AM, fontaine19100 notifications@github.com wrote:
Dear professor, Thanks for your reply. In my case, the problem is that I have a multidimensionnal likelikood so I think I am obliged to pass an array or a matrix. Also as I mentionned, applying the metrop algorithm toa multivariate student t distribution works perfectly. For this I use the same object X which is a cbind of two vectors.
Thanks in advance, best regards Le 22 juin 2016 16:07, "Charles J. Geyer" notifications@github.com a écrit :
x is a vector not a matrix. The error means what it says. X[, 1] makes no sense. Think of the state of the Markov chain as a vector not a matrix (or anyother structured object).
On Wed, Jun 22, 2016 at 5:39 AM, fontaine19100 <notifications@github.com
wrote:
dear developpers,
I am quite new in sampling posterior distributions(so therefore Bayesian approach) using a MCMC technique based on Metropolis-Hastings algorithm. I am using the mcmc library in R for this. My distribution is multidimensional. In order to check if this metro algorithm works for multivaiate distribution I did it successfully on a student-t distribution (package mvtnorm, function dmvt).
Now I want to apply the same thing to my multivariate distribution (2 vars x and y) but it doesn't work; I get an error : Error in X[, 1] : incorrect number of dimensions
The code is available on : https://github.com/fontaine19100/MCMC_R/blob/master/try.R
So I tried to respect the same kind of format than for the MWE, but it doesn't work still as I got the error mentioned before. Another thing, is that applying logpost to X works perfectly.
Thanks in advance for your help, best
Jean-Philippe
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cjgeyer/mcmc/issues/1, or mute the thread <
https://github.com/notifications/unsubscribe/AAcdwDXF3jA7PBtKG0e_y9zDX8Uo_S4wks5qORDQgaJpZM4I7ou_
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cjgeyer/mcmc/issues/1#issuecomment-227754555, or mute the thread < https://github.com/notifications/unsubscribe/ARndfHmTs9Dgxra0QLUGmLL6tgADkm6aks5qOUGJgaJpZM4I7ou_
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cjgeyer/mcmc/issues/1#issuecomment-227756301, or mute the thread https://github.com/notifications/unsubscribe/AAcdwHo-g4lhrUp24RlF7wmYybFjZq4uks5qOUK1gaJpZM4I7ou_ .
dear developpers,
I am quite new in sampling posterior distributions(so therefore Bayesian approach) using a MCMC technique based on Metropolis-Hastings algorithm. I am using the mcmc library in R for this. My distribution is multidimensional. In order to check if this metro algorithm works for multivaiate distribution I did it successfully on a student-t distribution (package mvtnorm, function dmvt).
Now I want to apply the same thing to my multivariate distribution (2 vars x and y) but it doesn't work; I get an error : Error in X[, 1] : incorrect number of dimensions
The code is available on : https://github.com/fontaine19100/MCMC_R/blob/master/try.R
So I tried to respect the same kind of format than for the MWE, but it doesn't work still as I got the error mentioned before. Another thing, is that applying logpost to X works perfectly.
Thanks in advance for your help, best
Jean-Philippe