I am trying to generate random fields on a square grid of size NXN using the 'RandomFields' package in R 4.1.0 with RStudio-1.5.192. Specifically, I am using the function 'RMgencauchy,' which takes two parameters: alpha and beta as inputs to obtain the the random fields. The code works for larger grid sizes for a particular combination of alpha and beta, for instance with N=100, alpha=1 and beta=1 the code works. However, for a different combination of alpha and beta with a grid of the same size, the R session gets terminated Here is a MWE:
################### my code ###############################################
rm(list=ls())
library(RandomFields)
library(pracma)
library(PracTools)
library(corTools)
meanv = 5
al = 1
bet = 0.2 #when 'bet' value is changed to 1, the code is executed without any issues
model <- RMgencauchy(var=1, alpha=al, beta=bet)+RMtrend(mean=5)
N = 100
step <- 1
x.seq <- seq(-((N-1)/2)*step, ((N-1)/2)*step, step)
y.seq <- seq(-((N-1)/2)*step, ((N-1)/2)*step, step)
f <- RFsimulate(model, x = x.seq, y.seq,z = NULL, grid=TRUE,spConform=FALSE) #1000
I think, the memory should not be an issue as these are relatively small sizes and I am running this code a computer with 256 GB RAM. I have a similar issue when I try to increase N beyond 700 even with alpha=1 and beta=1. The default value of 'memory.limit()' is 261819, I could increase up to 1e13 using 'memory.limit(1e13).' However, this did not resolve the issue. I am not sure what the problem exactly is. Thanks.