predict.pcdfit: Predictions from a panel count model

View source: R/predict.R

predict.pcdfitR Documentation

Predictions from a panel count model

Description

Predictions from a panel count model

Usage

## S3 method for class 'pcdfit'
predict(object, newdata, type = c("lp", "mean"), ...)

Arguments

object

A fitted pcdreg() model.

newdata

Data to predict for. Defaults to the data the model was fitted to. For type = "mean" it must also contain the variables in the pcd() response, since the prediction follows each subject's covariate trajectory; the counts themselves are ignored.

type

"lp" returns the linear predictor \beta' X(t) for each row. "mean" returns the predicted mean number of events at every fitted examination time within each subject's follow-up: \int_0^t \exp(\beta' X(s)) \, d\hat\Lambda(s) for pcdreg(), and \hat\mu(t) \exp(\beta' X(t)) for pcdreg().

...

Ignored.

Details

The rate model's predicted mean is non-decreasing in t by construction, because it integrates a positive quantity. The means model's is not: it is a fitted \hat\mu(t) rescaled by a covariate value that may itself move up and down, so a predicted mean count that falls is possible and is the practical drawback of that model with time-varying covariates.

Value

For type = "lp", a numeric vector with one element per row of newdata. For type = "mean", a tibble with columns id, time and mean.

Examples

set.seed(1)
d <- sim_pcd(60, beta = c(1, -1), lambda = function(t) 8 / (1 + t))
fit <- pcdreg(pcd(id, tstart, tstop, count) ~ x1 + x2, data = d)
head(predict(fit))
head(predict(fit, type = "mean"))

pcdreg documentation built on Nov. 10, 2026, 5:09 p.m.