Learn R Programming

JOPS (version 0.2.0)

predict.psvcsignal: Predict function for psVCSignal

Description

Prediction function which returns both linear predictor and inverse link predictions for an arbitrary matrix of signals with their vector of companion indexing covariates (using psVCSignal with class psvcsignal).

Usage

# S3 method for psvcsignal
predict(object, ..., X_pred, t_pred, type = "mu")

Value

pred

the estimated mean (inverse link function) (default) or the linear predictor prediction with type = "eta", at signals in matrix X_pred and covariates in vector t_pred.

Arguments

object

an object using psVCSignal.

...

other parameters.

X_pred

a matrix of q arbitrary signal vectors of dimension q by p1 for desired prediction.

t_pred

a q vector for the varying index variable associated with X_pred.

type

the mean value type = "mu" (default) or linear predictor type = "eta".

Author

Paul Eilers and Brian Marx

References

Eilers, P. H. C. and Marx, B. D. (2003). Multivariate calibration with temperature interaction using two-dimensional penalized signal regression. Chemometrics and Intellegent Laboratory Systems, 66, 159–174.

Eilers, P.H.C. and Marx, B.D. (2021). Practical Smoothing, The Joys of P-splines. Cambridge University Press.

Examples

Run this code
library(fds)
data(nirc)
iindex <- nirc$x
X <- nirc$y
sel <- 50:650 # 1200 <= x & x<= 2400
X <- X[sel, ]
iindex <- iindex[sel]
dX <- diff(X)
diindex <- iindex[-1]
y <- as.vector(labc[1, 1:40]) # percent fat
t_var <- as.vector(labc[4, 1:40]) # percent flour
oout <- 23
dX <- t(dX[, -oout])
y <- y[-oout]
t_var = t_var[-oout]
Pars = rbind(c(min(diindex), max(diindex), 25, 3, 1e-7, 2),
c(min(t_var), max(t_var), 20, 3, 0.0001, 2))
fit1 <- psVCSignal(y, dX, diindex, t_var, Pars = Pars,
family = "gaussian", link = "identity", int = TRUE)
predict(fit1, X_pred = dX[1:5,], t_pred = t_var[1:5])

Run the code above in your browser using DataLab