sim2Dimage | R Documentation |
Simulate a 2D image with a given mean and autocorrelation structure.
sim2Dimage(n, coords = NULL, x.sites, y.sites, mu, vgm, name.X = "X")
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 |
y.sites |
[integer, >0] number of y-coordinates. Ignored when |
mu |
[numeric vector] Expected value at each site. |
vgm |
[variogramModel] Variogram used to generate the background noise. Output of the |
name.X |
[character] name of the column for the design matrix. |
A list with two elements
coords: the coordinates of the sites
X: the design matrix containing the signal of each site for each replicate.
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.