Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. An interesting question about stratified sampling came up on X validated last week, namely how to optimise a Monte Carlo estimate based on two subsequent simulations, one, X, from a marginal and one or several Y from the corresponding conditional given X, when the costs of producing those two simulations significantly differ. When looking at the variance of the Monte Carlo estimate, this variance can be minimised in the number of simulations from the marginal under a computing budget. However, when the costs of producing x, y given or (x,y) are about the same, it does not pay to replicate simulations from y given x or x given y, because this increases the randomness of the estimator and induces positive correlation between some terms in the sum. Assuming that the conditional variances are always computable, we could envision an extension to the question where for each new value of a simulated x (or y), a variable number of conditionally simulated y (or x) could be produced. Or even when those conditional variances are unknown but can be replaced with empirical versions.

The illustration comes from a bivariate normal model with correlation, for a rather arbitrary function , but the pattern remains the same, namely that iid simulations of the pair (X,Y invariably leads to a smaller variance of the estimator compared with simulation with a 1:10 (10 Y’s for one X) or 10:1 ratio between x’s and y’s. Depending on the function and the relative variances, the 1:10 or 10:1 schemes may have a similar variability.

```zigma=c(9,1,-.9*sqrt(1*9))

geney=function(x,n=1){
return(rnorm(n,mean=zigma*x/zigma,sd=sqrt(zigma-
zigma^2/zigma)))}
genex=function(y,n=1){
return(rnorm(n,mean=zigma*y/zigma,sd=sqrt(zigma-
zigma*zigma/zigma)))}
targ=function(x,y){ log(x^2*y^4)+x^2*cos(x^2)/y*sin(y^2)}

T=1e4;N=1e3
vales=matrix(0,N,3)
for (i in 1:N){
xx=rnorm(T,sd=sqrt(zigma))
vales[i,1]=mean(targ(xx,geney(xx,n=T)))
xx=rep(rnorm(T/10,sd=sqrt(zigma)),10)
vales[i,2]=mean(targ(xx,geney(xx,n=T)))
yy=rep(rnorm(T/10,sd=sqrt(zigma)),10)
vales[i,3]=mean(targ(enex(yy,n=T),yy))}
```

Filed under: R, Statistics Tagged: conditional density, Cross Validation, Monte Carlo Statistical Methods, simulation, stratified sampling  