
Last chance! 50% off unlimited learning
Sale ends in
Smooth signal (multivariate calibration) regression using P-splines.
psSignal(
y,
x_signal,
x_index = c(1:ncol(x_signal)),
nseg = 10,
bdeg = 3,
pord = 3,
lambda = 1,
wts = 1 + 0 * y,
family = "gaussian",
link = "default",
m_binomial = 1 + 0 * y,
r_gamma = wts,
y_predicted = NULL,
x_predicted = x_signal,
ridge_adj = 0,
int = TRUE
)
a vector with length(n)
of estimated P-spline coefficients.
a vector with length(m)
of estimated means.
a vector of length(m)
of estimated linear predictors.
the B-spline basis (for the coefficients), with dimension p
by n
.
the deviance of fit.
the approximate effective dimension of fit.
AIC.
approximate df residual.
a vector of length p
, containing estimated smooth signal coefficients.
a vector of length p
, containing standard errors of smooth signal coefficients.
leave-one-out standard error prediction, when family = "gaussian"
.
standard error prediction for y_predict
, when family = "gaussian"
, NULL otherwise.
the number of evenly spaced B-spline segments.
the degree of B-splines.
the order of the difference penalty.
the positive tuning parameter.
the family of the response.
the link function.
the estimated y-intercept (when int = TRUE
.)
a logical variable related to use of y-intercept in model.
estimate of dispersion, Dev/df_resid
.
inverse link prediction vectors, and twice se bands.
estimated linear predictor of length(y)
.
leave-one-out prediction of mean, when family = "gaussian"
, NULL otherwise.
percent correct classification based on 0.5 cut-off, when family = binomial
, NULL otherwise.
a vector to of length ncol(x_signal) == p
, associated with the ordering of the signal.
a (glm) response vector, usually continuous, binomial or count data.
a matrix of continuous regressor with nrow(x_signal) == length(y)
, often
a discrete digitization of a signal or histogram or time series.
a vector to of length ncol(x_signal) == p
, associated with the
ordering index of the signal. Default is 1:ncol(x_signal)
.
the number of evenly spaced segments between xl
and xr
(default 10).
the degree of the basis, usually 1, 2, or 3 (defalult).
the order of the difference penalty, usually 1, 2, or 3 (defalult).
the (positive) tuning parameter for the penalty (default 1).
the weight vector of length(y)
; default is 1.
the response distribution, e.g.
"gaussian", "binomial", "poisson", "Gamma"
distribution; quotes are needed. Default is "gaussian"
.
the link function, one of "identity"
, "log"
, "sqrt"
,
"logit"
, "probit"
, "cloglog"
, "loglog"
, "reciprocal"
;
quotes are needed (default "identity"
).
a vector of binomial trials having length(y); default is 1 vector for family = "binomial"
, NULL otherwise.
a vector of gamma shape parameters. Default is 1 vector for family = "Gamma"
, NULL otherwise.
a vector of responses associated
with x_predicted
which are used to calculate standard error of external prediction. Default is NULL.
a matrix of external signals to yield external prediction.
A ridge penalty tuning parameter, which can be set to small value, e.g. 1e-8
to stabilize estimation, (default 0).
set to TRUE or FALSE to include intercept term in linear predictor (default TRUE).
Brian Marx
Support functions needed: pspline_fitter
, bbase
and pspline_checker
.
Marx, B.D. and Eilers, P.H.C. (1999). Generalized linear regression for sampled signals and curves: A P-spline approach. Technometrics, 41(1): 1-13.
Eilers, P.H.C. and Marx, B.D. (2021). Practical Smoothing, The Joys of P-splines. Cambridge University Press.
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]) # percent fat
oout <- 23
dX <- t(dX[, -oout])
y <- y[-oout]
fit1 <- psSignal(y, dX, diindex, nseg = 25, bdeg = 3, lambda = 0.0001,
pord = 2, family = "gaussian", link = "identity", x_predicted = dX, int = TRUE)
plot(fit1, xlab = "Coefficient Index", ylab = "ps Smooth Coeff")
title(main = "25 B-spline segments with tuning = 0.0001")
names(fit1)
Run the code above in your browser using DataLab