predict.pspfit: Predict function for 'psNormal', 'psBinomial', 'psPoisson'

View source: R/predict_support.R

predict.pspfitR Documentation

Predict function for psNormal, psBinomial, psPoisson

Description

Prediction function which returns both linear predictor and inverse link predictions at arbitrary data locations (using psNormal, psBinomial, psPoisson with class pspfit).

Usage

## S3 method for class 'pspfit'
predict(object, ..., x, type = "mu")

Arguments

object

an object using psNormal, psBinomial, or psPoisson .

...

other parameters.

x

a scalar or vector of arbitrary x locations for desired prediction.

type

the mean value type = "mu" (default) or linear predictor type = "eta".

Value

pred

the estimated mean (inverse link function) (default) or the linear predictor prediction with type = "eta", at arbitary x locations.

Author(s)

Paul Eilers and Brian Marx

References

Eilers, P.H.C., Marx, B.D., and Durban, M. (2015). Twenty years of P-splines, SORT, 39(2): 149-186.

Eilers, P.H.C. and Marx, B.D. (2021). Practical Smoothing, The Joys of P-splines. Cambridge University Press.

Examples

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)
names(fit1)
plot(fit1, xlab = "Year", ylab = "Count", se = 2)
predict(fit1, x = fit1$x[1:5])
predict(fit1, x = fit1$x[1:5], type = "eta")

JOPS documentation built on Sept. 8, 2023, 5:42 p.m.

Related to predict.pspfit in JOPS...