ps2DSignal | R Documentation |
ps2DSignal
is a function used to regress a (glm) response onto a two-dimensional
signal or image, with aniosotripic penalization of tensor product P-splines.
ps2DSignal(
y,
M,
p1,
p2,
M_type = "stacked",
M1_index = c(1:p1),
M2_index = c(1:p2),
Pars = rbind(c(1, p1, 10, 3, 1, 2), c(1, p2, 10, 3, 1, 2)),
ridge_adj = 1e-06,
M_pred = M,
y_predicted = NULL,
family = "gaussian",
link = "default",
m_binomial = 1 + 0 * y,
wts = 1 + 0 * y,
r_gamma = 1 + 0 * y,
int = TRUE,
se_pred = 2
)
y |
a response vector of length |
M |
The signal/image regressors, which are either "stacked" or "unfolded",
with dimensions ( |
p1 |
the row dimension of the image. |
p2 |
the column dimension of the image. |
M_type |
"stacked" (signal as matrix) or "unfolded" (signal as vector). |
M1_index |
an index of length |
M2_index |
an index of length |
Pars |
a matrix of 2 rows, where the first and second row
sets the P-spline paramters for |
ridge_adj |
A ridge penalty tuning parameter (usually set to small value, default |
M_pred |
(e.g. stacked ( |
y_predicted |
a vector of responses from a cv data set (assoc. with |
family |
the response distribution, e.g.
|
link |
the link function, one of |
m_binomial |
a vector of binomial trials having |
wts |
the weight vector of |
r_gamma |
a vector of gamma shape parameters. Default is 1 vector for for |
int |
set to TRUE or FALSE to include intercept term in linear predictor (default |
se_pred |
a scalar, e.g. |
Support functions needed: pspline_fitter
, bbase
, and pspline_2dchecker
.
pcoef |
a vector of length |
summary_predicted |
inverse link prediction vectors, and standard error surfaces. |
dev |
deviance of fit. |
eff_df |
the approximate effective dimension of fit. |
aic |
AIC. |
df_resid |
approximate df residual. |
cv |
leave-one-out standard error prediction, when |
cv_predicted |
standard error prediction for |
avediff_pred |
mean absolute difference prediction, when |
Pars |
design and tuning parameters (see above arguments). |
Dispersion_parm |
estimate of dispersion, |
summary_predicted |
inverse link prediction vectors at |
eta_predicted |
estimated linear predictor of |
press_mu |
leave-one-out prediction of mean, when |
bin_percent_correct |
percent correct classification based on 0.5 cut-off,
when |
B |
Tensor basis ( |
Q |
Effective regressors ( |
Ahat |
smooth P-spline coefficient vector of length |
M |
the signal/image regressors. |
y |
the response vector. |
M1index |
index of length |
M2index |
index of length |
M_type |
"stacked" or "unfolded". |
w |
GLM weight vector of length |
h |
"hat" diagonals. |
ridge_adj |
additional ridge tuning parameter to stabilize estimation. |
Paul Eilers and Brian Marx
Marx, B.D. and Eilers, P.H.C. (2005). Multidimensional penalized signal regression, Technometrics, 47: 13-22.
Eilers, P.H.C. and Marx, B.D. (2021). Practical Smoothing, The Joys of P-splines. Cambridge University Press.
library(fields)
library(JOPS)
# Get the data
x0 <- Sugar$X
x0 <- x0 - apply(x0, 1, mean) # center Signal
y <- as.vector(Sugar$y[, 3]) # Response is Ash
# Inputs for two-dimensional signal regression
nseg <- c(7, 37)
pord <- c(3, 3)
min_ <- c(230, 275)
max_ <- c(340, 560)
M1_index <- rev(c(340, 325, 305, 290, 255, 240, 230))
M2_index <- seq(from = 275, to = 560, by = .5)
p1 <- length(M1_index)
p2 <- length(M2_index)
# Fit optimal model based on LOOCV
opt_lam <- c(8858.6679, 428.1332) # Found via svcm
Pars_opt <- rbind(
c(min_[1], max_[1], nseg[1], 3, opt_lam[1], pord[1]),
c(min_[2], max_[2], nseg[2], 3, opt_lam[2], pord[2])
)
fit <- ps2DSignal(y, x0, p1, p2, "unfolded", M1_index, M2_index,
Pars_opt,int = TRUE, ridge_adj = 0.0001,
M_pred = x0 )
# Plotting coefficient image
plot(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.