Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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[3]*x/zigma[1],sd=sqrt(zigma[2]- zigma[3]^2/zigma[1])))} genex=function(y,n=1){ return(rnorm(n,mean=zigma[3]*y/zigma[2],sd=sqrt(zigma[1]- zigma[3]*zigma[3]/zigma[2])))} 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[1])) vales[i,1]=mean(targ(xx,geney(xx,n=T))) xx=rep(rnorm(T/10,sd=sqrt(zigma[1])),10) vales[i,2]=mean(targ(xx,geney(xx,n=T))) yy=rep(rnorm(T/10,sd=sqrt(zigma[2])),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
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.