Re: [R] Metropolis-Hastings in R

2012-03-14 Thread Michael Williams
Thanks, this isn't actually homework though. I'm researching MCMC methods but I've never really used R before so it's proved quite troublesome! my code is now: n=1 mu=0 sigma=1 lik<-function(theta) exp((-(theta-mu)^2)/2) alpha<-function(theta,phi) min(lik(phi)/lik(theta),1) theta1<-c(0,n) the

[R] Metropolis-Hastings in R

2012-03-14 Thread Michael Williams
Hi all, I'm trying to write a MH algorithm in R for a standard normal distribution, I've been trying for a good week or so now with multiple attempts and have finally given up trying to do it on my own as I'm beginning to run out of time for this, would somebody please tell me what is wrong with my