Displaying 2 results from an estimated 2 matches for "metroplis".
Did you mean:
metropolis
2013 Mar 01
2
using reserved words in R, and reuse variable names in different functions
...rnorm(t, mean=x, var=y)
return(val)
}
metropolis <- function(t, c, x, y){
den1 <- unnormalized(t, mean=x, sd=y)
den2 <- unnormalized(c, mean=x, sd=y)
if(den1 < den2)
return(a)
else
return(b)
}
for(i in 1: 100){
matrix <- c()
matrix[i] <- metroplis(1, 2, 3, 4)
}
Here, I reused letter "t" and "c", and the word "matrix". Could this cause
any potential problems?
Thanks in advance,
Mike
[[alternative HTML version deleted]]
2011 Nov 16
2
Error in random walk Metroplis-hasting
Hi R community,
I have some data set and construct the likelihood as follows
likelihood <- function(alpha,beta){
lh<-1
d<-0
p<-0
k<-NULL
data<-read.table("epidemic.txt",header = TRUE)
attach(data, warn.conflicts = F)
k <-which(inftime==1)
d <- (sqrt((x-x[k])^2+(y-y[k])^2))^(-beta)
p<-1 - exp(-alpha*d)
for(i in 1:100){