As a part of a simulation, I need to sample from a large vector repeatedly.
For some reason sample() builds up the memory usage (> 500 MB for this
example) when used inside a for loop as illustrated here:
X <- 1:10
P <- runif(10)
for(i in 1:500) Xsamp <- sample(X,3,replace=TRUE,prob=P
As a part of a simulation, I need to sample from a large vector repeatedly.
For some reason sample() builds up the memory usage (> 500 MB for this
example) when used inside a for loop as illustrated here:
X <- 1:10
P <- runif(10)
for(i in 1:500) Xsamp <- sample(X,3,replace=TRUE,prob=P
As a part of a simulation, I need to sample from a large vector repeatedly.
For some reason sample() builds up the memory usage (> 500 MB for this
example) when used inside a for loop as illustrated here:
X <- 1:10
P <- runif(10)
for(i in 1:500) Xsamp <- sample(X,3,replace=TRUE,prob=P
Sorry to bother you about a S-Plus related problem, but I hope someone
can help.
I have tried to "translate" some code from R to S-Plus (I have colleague
that insists on using S-Plus. And yes, I have tried to make him change
to R...)
The following code works out fine in R, but in S-Plus (S-PLUS
Based on a rather complicated model I do parametric bootstrapping to obtain
bootstrap distributions of the parameters of interest. What is the proper
way to test whether the parameter estimates are significantly different (the
differences in parameter estimates are expected from including differ
You could try something like this.
Simulating with a large number of grid cells is however very RAM expensive.
library(MASS)
library(spatial)
x <- expand.grid(1:30, 1:30)
distances <- as.matrix(dist(x, diag=T, upper=T))
Sigma <- expcov(r=distances, d=10, se=1)
z <- mvrnorm(n = 1, mu=rep(0,900