I have a positive definite matrix B and i need to generate a random field X using the matrix B as a covariance matrix of the field. I have this code to generate 10,000 realizations of the field
library(RandomFields)
RFoptions(seed=NA)
library(Matrix)
A<-matrix(c(1,2,7,2,5,6,7,6,9),3,3)
B<-nearPD(A,keepDiag =T,maxit = 200)
B<-matrix(B$mat,3,3)
lengB<-3
from<-0
to<-1
tB <- seq(from, to, length=lengB)
model<-RMfixcov(B)
X<-RFsimulate(model,x=seq(from, to, length=100),y=seq(from, to, length=100))
The error I've got faced by is:
Error in rfInit(model = list("Simulate", setseed = eval(parse(text = "quote(set.seed(seed=seed))")), : 'RFsimulate' : number of data (9) not a multiple of the number of locations (10000 x 0)^2
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire