SpATS.nogeno: Two-dimensional P-spline smoothing

View source: R/SpATS.nogeno.R

SpATS.nogenoR Documentation

Two-dimensional P-spline smoothing

Description

Two-dimensional smoothing of scattered data points with tensor product P-splines.

Usage

SpATS.nogeno(
  response,
  spatial,
  fixed = NULL,
  random = NULL,
  data,
  family = gaussian(),
  offset = 0,
  weights = NULL,
  control = list(maxit = 100)
)

Arguments

response

a character string with the name of the variable that contains the response variable of interest.

spatial

a right hand formula object specifying the spatial P-Spline model. See SAP and PSANOVA for more details about how to specify the spatial trend.

fixed

an optional right hand formula object specifying the fixed effects.

random

an optional right hand formula object specifying the random effects. Currently, only sets of independent and identically distributed random effects can be incorporated.

data

a data frame containing the variables.

family

object of class family specifying the distribution and link function.

offset

an optional numerical vector containing an a priori known component to be included in the linear predictor during fitting.

weights

an optional numerical vector of weights to be used in the fitting process. By default, the weights are considered to be one.

control

a list of control values.

Details

This function is a modified version of the function SpATS in the package SpATS. The difference is that genotypes have been removed.

Value

A list with the following components:

call

the matched call.

data

the original supplied data argument with a new column with the weights used during the fitting process.

model

a list with the model components: response, spatial, fixed and/or random.

fitted

a numeric vector with the fitted values.

residuals

a numeric vector with deviance residuals.

psi

a two-length vector with the values of the dispersion parameters at convergence. For Gaussian responses both elements coincide, being the (REML) estimate of dispersion parameter. For non-Gaussian responses, the result depends on the argument update.psi of the controlSpATS function. If this argument was specified to FALSE (the default), the first component of the vector corresponds to the default value used for the dispersion parameter (usually 1). The second element, correspond to the (REML) estimate of the dispersion parameter at convergence. If the argument update.psi was specified to TRUE, both components coincide (as in the Gaussian case).

var.comp

a numeric vector with the (REML) variance component estimates. This vector contains the variance components associated with the spatial trend, as well as those related with the random model terms.

eff.dim

a numeric vector with the estimated effective dimension (or effective degrees of freedom) for each model component (spatial, fixed and/or random).

dim

a numeric vector with the (model) dimension of each model component (spatial, fixed and/or random). This value corresponds to the number of parameters to be estimated.

dim.nom

a numeric vector with the (nominal) dimension of each component (spatial, fixed and/or random). For the random terms of the model, this value corresponds to upper bound for the effective dimension (i.e., the maximum effective dimension a random term can achive). This nominal dimension is rank[X, Z_k] - rank[X], where Z_k is the design matrix of the kth random factor and X is the design matrix of the fixed part of the model. In most cases (but not always), the nominal dimension corresponds to the model dimension minus one, “lost” due to the implicit constraint that ensures the mean of the random effects to be zero.

nobs

number of observations used to fit the model.

niterations

number of iterations EM-algorithm.

deviance

the (REML) deviance at convergence (i.e., -2 times the restricted log-likelihood).

coeff

a numeric vector with the estimated fixed and random effect coefficients.

terms

a list with the model terms: response, spatial, fixed and/or random. The information provided here is useful for printing and prediction purposes.

vcov

inverse of the coefficient matrix of the mixed models equations. The inverse is needed for the computation of standard errors. For computational issues, the inverse is returned as a list: C22_inv corresponds to the coefficient matrix associated with the spatial, the fixed and the random components.

Author(s)

Maria-Xose Rodriguez-Alvarez and Paul Eilers

References

Rodriguez-Alvarez, M.X, Boer, M.P., van Eeuwijk, F.A., and Eilers, P.H.C. (2018). Correcting for spatial heterogeneity in plant breeding experiments with P-splines. Spatial Statistics, 23, 52 - 71. https://doi.org/10.1016/j.spasta.2017.10.003.

Examples

# Get the data
library(SemiPar)
data(ethanol)

# Fit the PS-ANOVA model
ps2d <- SpATS.nogeno(response = "NOx",
                     spatial = ~PSANOVA(E, C,  nseg = c(20, 20), nest.div = c(2, 2)),
                     data = ethanol,
                     control = list(maxit = 100, tolerance = 1e-05,
                                    monitoring = 0, update.psi = FALSE))

# Report effective dimensions, if desired
# print(summary(ps2d))

# Compute component surface and their sum on a fine grid
Tr = obtain.spatialtrend(ps2d, grid = c(100, 100))

# Plot surface and contours
image(Tr$row.p, Tr$col.p, Tr$fit, col = terrain.colors(100), xlab = 'C', ylab = 'E')
contour(Tr$row.p, Tr$col.p, Tr$fit, add = TRUE, col = 'blue')
points(ethanol$C, ethanol$E, pch = '+')

JOPS documentation built on Sept. 8, 2023, 5:42 p.m.

Related to SpATS.nogeno in JOPS...