Predictions of the spatial trend from an SpATS object

Share:

Description

Takes a fitted SpATS object produced by SpATS() and produces predictions of the spatial trend on a regular two-dimensional array.

Usage

1
obtain.spatialtrend(object, grid = c(100, 100), ...)

Arguments

object

an object of class SpATS as produced by SpATS()

grid

a numeric vector with the number of grid points along the x- and y- coordinates respectively. Atomic values are recycled. The default is 100.

...

further arguments passed to or from other methods. Not yet implemented.

Details

For each spatial coordinate, grid[k] equally spaced values between the minimum and the maximum are computed (k = 1, 2). The spatial trend is then predicted on the regular two-dimensional array defined by each combination of the x- and y- coordinate values.

Value

A list with the following components:

col.p

x-coordinate values at which predictions have been computed.

row.p

y-coordinate values at which predictions have been computed

fit

a matrix of dimension length(row.p) x length(col.p) with the predicted spatial trend.

See Also

SpATS, plot.SpATS, predict.SpATS

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(SpATS)
data(wheatdata)
wheatdata$R <- as.factor(wheatdata$row)
wheatdata$C <- as.factor(wheatdata$col)

m0 <- SpATS(response = "yield", spatial = ~ SAP(col, row, nseg = c(10,20)), 
 genotype = "geno", fixed = ~ colcode + rowcode, random = ~ R + C, 
 data = wheatdata, control =  list(tolerance = 1e-03))

spat.trend.1 <- obtain.spatialtrend(m0)
spat.trend.2 <- obtain.spatialtrend(m0, grid = c(10, 10))

colors = topo.colors(100)
op <- par(mfrow = c(1,2))
fields::image.plot(spat.trend.1$col.p, spat.trend.1$row.p, t(spat.trend.1$fit), 
 main = "Prediction on a grid of 100 x 100", col = colors, xlab = "Columns", ylab = "Rows")
fields::image.plot(spat.trend.2$col.p, spat.trend.2$row.p, t(spat.trend.2$fit), 
 main = "Prediction on a grid of 10 x 10", col = colors, xlab = "Columns", ylab = "Rows")
par(op)