predict.cozigam {COZIGAM} | R Documentation |
Takes a fitted cozigam
object produced by cozigam()
and
produces predictions given a new set of values for the model covariates or
the original values used for the model fit. Predictions can be accompanied
by standard errors, based on the distribution of the model coefficients
obtained by Louis' method.
## S3 method for class 'cozigam': predict(object, newdata, type="link", se.fit=FALSE, ...)
object |
A fitted cozigam object as produced by cozigam() . |
newdata |
A data frame containing the values of the model covariates at which
predictions are required. If this is not provided then predictions corresponding to
the original data are returned.
If newdata is provided then it must contain all the variables needed for prediction. |
type |
When this has the value "link" (default) the linear predictor (possibly
with associated standard errors) is returned.
When type="terms" each component of the linear predictor is returned seperately (possibly
with standard errors): this excludes any intercept.
When type="response" predictions on the scale of the response are returned (possibly
with approximate standard errors). |
se.fit |
Logical. If TRUE (not default), standard error estimates are returned
for each prediction. |
... |
Other arguments. |
The standard errors produced by predict.cozigam()
are based on the covariance matrix of
the parameters obtained by Louis' method in the fitted gam
object.
If se.fit
is TRUE
then a 3 item list is returned with items (both arrays) fit
,
se.fit
containing predictions and associated standard error estimates and p
containing predictions of associated zero-inflation rates,
otherwise a 2 item list without the array of standard error estimated is returned.
The dimensions of the returned arrays depends on whether type
is "terms"
or not:
if it is then the array is 2 dimensional with each term in the linear predictor separate,
otherwise the array is 1 dimensional and contains the linear predictor/predicted values (or
corresponding s.e.s). The linear predictor returned termwise will not include the intercept.
Hai Liu and Kung-Sik Chan
Liu, H and Chan, K.S. (2008) Constrained Generalized Additive Model with Zero-Inflated Data. Technical Report 388, Department of Statisics and Actuarial Science, The Unversity of Iowa. http://www.stat.uiowa.edu/techrep/tr388.pdf
Louis, T. A. (1982) Finding the Observed Information Matrix When Using EM Algorithm. J. R. Statist. Soc. B, 44, 226-233
set.seed(11) n <- 400 x1 <- runif(n, 0, 1) x2 <- runif(n, 0, 1) x3 <- runif(n, 0, 1) f <- test(x1,x2)*4-mean(test(x1,x2)*4) + f0(x3)/2-mean(f0(x3)/2) sig <- 0.5 mu0 <- f + 3 y <- mu0 + rnorm(n, 0, sig) alpha0 <- -2.2 delta0 <- 1.2 p0 <- .Call("logit_linkinv", alpha0 + delta0 * mu0, PACKAGE = "stats") z <- rbinom(rep(1,n), 1, p0) y[z==0] <- 0 res <- cozigam(y~s(x1,x2)+s(x3), constraint = "proportional", family = gaussian) newdata <- data.frame(x1=c(0.5,0.8), x2=c(0.2,0.1), x3=c(0.3,0.7)) predict(res, newdata=newdata, se.fit=TRUE, type="response")