psPoisson | R Documentation |
psPoisson
is used to smooth scattered
Poisson data using P-splines with a log link function.
psPoisson(
x,
y,
xl = min(x),
xr = max(x),
nseg = 10,
bdeg = 3,
pord = 2,
lambda = 1,
wts = NULL,
show = FALSE,
iter = 100,
xgrid = 100
)
x |
the vector for the continuous regressor of |
y |
the response vector, usually count 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, or 3 (defalult). |
pord |
the number of the order of the difference penalty, usually 1, 2 (default), or 3. |
lambda |
the (positive) number for the tuning parameter for the penalty (default 1). |
wts |
the vector of general weights, zeros are allowed (default 1). |
show |
Set to TRUE or FALSE to display iteration history (default FALSE). |
iter |
a scalar to set the maximum number of iterations, default |
xgrid |
a scalar or a vector that gives the |
pcoef |
a vector of length |
muhat |
a vector of length |
B |
the |
dev |
deviance of fit. |
effdim |
effective dimension of fit. |
aic |
AIC. |
wts |
the vector of given prior weights. |
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. |
family |
the family of the response (
|
link |
the link function used ( |
xgrid |
gridded x values, useful for plotting. |
ygrid |
gridded fitted linear predictor values, useful for plotting. |
mugrid |
gridded (inverse link) fitted mean values, useful for plotting. |
se_eta |
gridded standard errors for the linear predictor. |
dispersion |
Dispersion parameter estimated |
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.
library(JOPS)
library(boot)
# Extract the data
Count <- hist(boot::coal$date, breaks = c(1851:1963), plot = FALSE)$counts
Year <- c(1851:1962)
xl <- min(Year)
xr <- max(Year)
# Poisson smoothing
nseg <- 20
bdeg <- 3
fit1 <- psPoisson(Year, Count, xl, xr, nseg, bdeg, pord = 2, lambda = 1)
plot(fit1, xlab = "Year", ylab = "Count", se = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.