nbkal {repeated} | R Documentation |
Negative Binomial Models with Kalman Update
Description
nbkal
fits a negative binomial regression with Kalman update over
time. The variance is proportional to the mean function, whereas, for
kalcount
with exponential intensity, it is a
quadratic function of the mean.
Usage
nbkal(
response,
times,
mu,
preg,
pdepend,
kalman = TRUE,
print.level = 0,
ndigit = 10,
gradtol = 1e-05,
steptol = 1e-05,
fscale = 1,
iterlim = 100,
typsize = abs(p),
stepmax = 10 * sqrt(p %*% p)
)
Arguments
response |
A list of two column matrices with counts and corresponding
times for each individual, one matrix or dataframe of counts, or an object
of class, response (created by |
times |
When response is a matrix, a vector of possibly unequally spaced times when they are the same for all individuals or a matrix of times. Not necessary if equally spaced. Ignored if response has class, response or repeated. |
mu |
The mean function. |
preg |
The initial parameter estimates for the mean function. |
pdepend |
The estimates for the dependence parameters, either one or three. |
kalman |
If TRUE, fits the kalman update model, otherwise, a standard negative binomial distribution. |
print.level |
Arguments for nlm. |
ndigit |
Arguments for nlm. |
gradtol |
Arguments for nlm. |
steptol |
Arguments for nlm. |
fscale |
Arguments for nlm. |
iterlim |
Arguments for nlm. |
typsize |
Arguments for nlm. |
stepmax |
Arguments for nlm. |
Details
Marginal and individual profiles can be plotted using
mprofile
and iprofile
and
residuals with plot.residuals
.
Value
A list of classes nbkal
and recursive
is returned.
Author(s)
P. Lambert and J.K. Lindsey
References
Lambert, P. (1996) Applied Statistics 45, 31-38.
Lambert, P. (1996) Biometrics 52, 50-55.
Examples
y <- matrix(rnbinom(20,5,0.5), ncol=5)
times <- matrix(rep(seq(10,50,by=10),4), ncol=5, byrow=TRUE)
y0 <- matrix(rep(rnbinom(5,5,0.5),4), ncol=5, byrow=TRUE)
mu <- function(p) p[1]*log(y0)+(times<30)*p[2]*
(times-30)+(times>30)*p[3]*(times-30)
nbkal(y, preg=c(1.3,0.008,-0.05), times=times, pdep=1.2, mu=mu)