ps2DGLM | R Documentation |
ps2DGLM
is used to smooth scattered
normal or non-normal responses, with aniosotripic
penalization of tensor product P-splines.
ps2DGLM(
Data,
Pars = rbind(c(min(Data[, 1]), max(Data[, 1]), 10, 3, 1, 2), c(min(Data[, 2]),
max(Data[, 2]), 10, 3, 1, 2)),
ridge_adj = 0,
XYpred = Data[, 1:2],
z_predicted = NULL,
se_pred = 2,
family = "gaussian",
link = "default",
m_binomial = rep(1, nrow(Data)),
wts = rep(1, nrow(Data)),
r_gamma = rep(1, nrow(Data))
)
Data |
a matrix of 3 columns |
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, e.g. |
XYpred |
a matrix with two columns |
z_predicted |
a vector of responses associated with |
se_pred |
a scalar, default |
family |
|
link |
the link function, one of |
m_binomial |
vector of binomial trials, default is vector of ones with |
wts |
non-negative weights, which can be zero (default ones). |
r_gamma |
gamma scale parameter, default is vector ones with |
Support functions needed: pspline_fitter
, bbase
, and pspline_2dchecker
.
pcoef |
a vector of length |
mu |
a vector of |
dev |
the 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 |
the design and tuning parameters (see arguments above). |
dispersion_parm |
estimate of dispersion, |
summary_predicted |
inverse link prediction vectors, and |
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 |
Data |
a matrix of 3 columns |
Q |
the tensor product B-spline basis. |
qr |
the Q-R of the model. |
Paul Eilers and Brian Marx
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.
ps2DNormal
library(fields)
library(JOPS)
# Extract data
library(rpart)
Kyphosis <- kyphosis$Kyphosis
Age <- kyphosis$Age
Start <- kyphosis$Start
y <- 1 * (Kyphosis == "present") # make y 0/1
fit <- ps2DGLM(
Data = cbind(Start, Age, y),
Pars = rbind(c(1, 18, 10, 3, .1, 2), c(1, 206, 10, 3, .1, 2)),
family = "binomial", link = "logit")
plot(fit, xlab = "Start", ylab = "Age")
#title(main = "Probability of Kyphosis")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.