search for: mylogdensity

Displaying 1 result from an estimated 1 matches for "mylogdensity".

Did you mean: logdensity
2005 Oct 25
0
Beginner question on apply()
...e Rejection Metropolis Sampling (function arms() from package HI) to draw values from p(x1,x2|x3,x4). My code is: ### Begin of function > myfunction <- function() { ### 1. Step: Definition of my log density log(p1(x1|x2,x3,x4)*p2(x2|x3,x4)), assuming values for (a1,a2,a3) and (b1,b2) > mylogdensity <- function(x){ + log(prod(dnorm(x[1], mean=0.1*x[2]+0.4*x3+0.9*x4), dnorm(x[2], mean=2*x3-3.1*x4)))} ### 2. Step: Drawing 1000 samples from this density > y <- arms(c(0,0), mylogdensity, function(x) crossprod(x)<=1e6, 1000) ### 3. Step: replacing the missing values by the sampled...