sim_psr: Single-Index signal regression using P-splines

View source: R/sim_psr.R

sim_psrR Documentation

Single-Index signal regression using P-splines

Description

sim_psr is a single-index signal regression model that estimates both the signal coefficients vector and the unknown link function using P-splines.

Usage

sim_psr(
  y,
  X,
  x_index = c(1:ncol(X)),
  nsegs = rep(10, 2),
  bdegs = rep(3, 3),
  lambdas = rep(1, 2),
  pords = rep(2, 2),
  max_iter = 100
)

Arguments

y

a response vector of length m, usually continuous.

X

The signal regressors with dimension m by p.

x_index

an index of length p for columns of signal matrix; default is simple sequence, c(1: ncol(X)).

nsegs

a vector of length 2 containing the number of evenly spaced segments between min and max, for each the coefficient vector and the (unknown) link function, resp. (default c(10, 10)).

bdegs

a vector of length 2 containing the degree of B-splines, for the coefficient vector and the (unknown) link function, resp. (default cubic or c(3, 3)).

lambdas

a vector of length 2 containing the positive tuning parameters, for each the coefficient vector and the (unknown) link function, resp. (default c(1, 1)).

pords

a vector of length 2 containing the difference penalty order, for each the coefficient vector and the (unknown) link function, resp. (defaultc(2, 2) ).

max_iter

a scalar for the maximum number of iterations (default 100).

Value

y

the response vector of length m.

alpha

the P-spline coefficient vector of length (nsegs[1]+bdeg[1]).

iter

the number of iterations used for the single-index fit.

yint

the estimated y-intercept for the single-index model.

B

the B-spline matrix built along the signal index, using nsegs[1], used for the coefficient vector.

Q

the effective regressors from the psVCSignal portion of the single-index fit with dimension m by length(alpha).

nsegs

a vector of length 2 containing the number of evenly spaced segments between min and max, for each the coefficient vector and the link function, resp.

bdegs

a vector of length 2 containing the degree of B-splines, for each the coefficient vector and the link function, resp.

lambdas

a vector of length 2 containing the positive tuning parameters, for each the coefficient vector and the link function, resp.

pords

a vector of length 2 containing the difference penalty order, for each the coefficient vector and the link function, resp.

eta

the estimated linear predictor for the single-index fit.

cv

the leave-one-out cross-validation statistic or the standard error of prediction for the single-index fit.

delta_alpha

change measure in signal-coefficent parameters at convervence.

x_index

the index of length p for columns of signal matrix.

f_fit

the psNormal object, fitting link function f(eta).

f_eta

the predicted values of the link function estimated with f_fit or estimated f(eta), at x = eta.

Author(s)

Paul Eilers, Brian Marx, and Bin Li

References

Eilers, P.H.C., B. Li, B.D. Marx (2009). Multivariate calibration with single-index signal regression, Chemometrics and Intellegent Laboratory Systems, 96(2), 196-202.

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

Examples

library(JOPS)
# Get the data
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])
oout <- 23
dX <- t(dX[, -oout])
y <- y[-oout]

pords <- c(2, 2)
nsegs <- c(27, 7)
bdegs = c(3, 3)
lambdas <- c(1e-6, .1)
max_iter <- 100

# Single-index model
fit <- sim_psr(y, dX, diindex, nsegs, bdegs, lambdas, pords,
             max_iter)

plot(fit, xlab = "Wavelength (nm)", ylab = " ")


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

Related to sim_psr in JOPS...