sim2Dimage: Simulate a 2D Image

View source: R/sim2Dimage.R

sim2DimageR Documentation

Simulate a 2D Image

Description

Simulate a 2D image with a given mean and autocorrelation structure.

Usage

sim2Dimage(n, coords = NULL, x.sites, y.sites, mu, vgm, name.X = "X")

Arguments

n

[integer, >0] number of images to be simulated

coords

[2 column data.frame] coordinates of the element in the image.

x.sites

[integer, >0] number of x-coordinates. Ignored when coords is specified.

y.sites

[integer, >0] number of y-coordinates. Ignored when coords is specified.

mu

[numeric vector] Expected value at each site.

vgm

[variogramModel] Variogram used to generate the background noise. Output of the vgm function.

name.X

[character] name of the column for the design matrix.

Value

A list with two elements

  • coords: the coordinates of the sites

  • X: the design matrix containing the signal of each site for each replicate.

Examples


if(require(sp) & require(gstat)){
out0 <- sim2Dimage(3, x.sites = 50, y.sites = 50,
                  mu = 0,
                 vgm = vgm(psill = 1, range = 2, model='Exp'))
dim(out0$X)
spdf0 <- cbind(out0$coords,out0$X[1,])
gridded(spdf0) <- ~x+y
plot(spdf0)

coords <- expand.grid(x = 1:50,
                      y = 1:50)
coords$mu <- 0
coords$mu[coords$x<=5 | coords$y<=5] <- 2

out1 <- sim2Dimage(3, coords = coords[,c("x","y")],
                  mu = coords$mu,
                 vgm = vgm(psill = 1, range = 2, model='Exp'))
spdf1 <- cbind(out1$coords,out1$X[1,])
gridded(spdf1) <- ~x+y
plot(spdf1)

}

bozenne/butils documentation built on Oct. 14, 2023, 6:19 a.m.