Learn R Programming

JOPS (version 0.2.0)

predict.pspfit: 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 pspfit
predict(object, ..., x, type = "mu")

Value

pred

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

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".

Author

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

Run this code
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")

Run the code above in your browser using DataLab