[R] sample function and memory usage

2007-05-08 Thread Victor Gravenholt
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

[R] sample() and memory usage

2007-05-08 Thread Victor Gravenholt
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

[R] sample() and memory usage

2007-05-08 Thread Victor Gravenholt
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

[R] Functions within functions in R and S-Plus

2005-06-07 Thread Victor Gravenholt
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

[R] testing for differences in parameter estimates from parametric bootstrapping

2004-10-08 Thread Victor Gravenholt
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

Re: [R] Simulating a landscape (matrix) in R

2004-06-03 Thread Victor Gravenholt
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