psNormal {JOPS} | R Documentation |
Smoothing scattered (normal) data using P-splines.
Description
psNormal
is used to smooth scattered (normal) data using P-splines (with identity link function).
Usage
psNormal(
x,
y,
xl = min(x),
xr = max(x),
nseg = 10,
bdeg = 3,
pord = 2,
lambda = 1,
wts = NULL,
xgrid = 100
)
Arguments
x |
the vector for the continuous regressor of |
y |
the response vector, usually continuous data. |
xl |
the number for the min along |
xr |
the number for the max along |
nseg |
the number of evenly spaced segments between |
bdeg |
the number of the degree of the basis, usually 1, 2 (default), or 3. |
pord |
the number of the order of the difference penalty, usually 1, 2, or 3 (defalult). |
lambda |
the (positive) number for the tuning parameter for the penalty (default 1). |
wts |
the vector of general weights, default is 1; zero allowed. |
xgrid |
a scalar or a vector that gives the |
Value
pcoeff |
a vector of length |
muhat |
a vector of length |
B |
a matrix of dimension |
wts |
a vector of length |
effdim |
estimated effective dimension. |
ed_resid |
approximate df residual. |
sigma |
square root of MSE. |
cv |
standard error of leave-one-out prediction or root average PRESS. |
nseg |
the number of B-spline segments. |
bdeg |
the degree of the B-spline basis. |
pord |
the order of the difference penalty. |
lambda |
the positive tuning parameter. |
xgrid |
gridded x values, useful for plotting. |
ygrid |
gridded fitted mean values, useful for plotting. |
se_eta |
gridded standard errors for the fitted mean values, useful for plotting. |
P |
"half" of the penalty, such that |
Author(s)
Paul Eilers and Brian Marx
References
Eilers, P.H.C. and Marx, B.D. (2021). Practical Smoothing, The Joys of P-splines. Cambridge University Press.
Eilers, P.H.C., Marx, B.D., and Durban, M. (2015). Twenty years of P-splines, SORT, 39(2): 149-186.
Examples
library(JOPS)
library(MASS)
data(mcycle)
x <- mcycle$times
y <- mcycle$accel
fit1 <- psNormal(x, y, nseg = 20, bdeg = 3, pord = 2, lambda = .8)
plot(fit1, se = 2, xlab = "Time (ms)", ylab = "Acceleration")