library(fmesher)
n_loc <- 2000
loc_2d_mesh <- matrix(runif(n_loc * 2), n_loc, 2)
mesh_2d <- fm_mesh_2d(loc = loc_2d_mesh, cutoff = 0.01, max.edge = c(0.1, 0.5))
op <- matern2d.operators(hx = 0.08, hy = 0.08, hxy = 0.5, nu = 0.5,
sigma = 1, mesh = mesh_2d)
u <- simulate(op)
n.obs <- 2000
obs.loc <- cbind(runif(n.obs),runif(n.obs))
A <- fm_basis(mesh_2d,obs.loc)
sigma.e <- 0.1
Y <- as.vector(A%*%u + sigma.e*rnorm(n.obs))
A <- op$make_A(obs.loc)
proj <- fm_evaluator(mesh_2d, dims = c(100, 100),
xlim = c(0,1), ylim = c(0,1))
Aprd <- op$make_A(proj$lattice$loc)
u.krig <- predict(op, A = A, Aprd = Aprd, Y = Y, sigma.e = sigma.e)
Run the code above in your browser using DataLab