predict.cozigam {COZIGAM} | R Documentation |
Predict from a COZIGAM fitted by the cozigam
function,
given a new set of covariate values, if supplied, or
the original set of covariate values used for the model fit.
The standard errors of the point predictors are also computed.
## S3 method for class 'cozigam': predict(object, newdata, type="link", se.fit=FALSE, ...)
object |
A fitted cozigam object as produced by the cozigam function. |
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), the standard errors are returned. |
... |
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 three-item list is returned with items (both arrays) fit
,
se.fit
containing the point predictors and associated standard error estimates and p
containing the corresponding zero-inflation rates,
otherwise a two-item list without the array of standard error estimates 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 included separately,
otherwise the array is 1-dimensional and contains the linear predictor/predicted values (or
corresponding standard errors). The linear predictor returned termwise excludes 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, 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 <- 600 x1 <- runif(n, 0, 1) x2 <- runif(n, 0, 1) x3 <- runif(n, 0, 1) f <- testfn(x1, x2)*4-mean(testfn(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), conv.crit.out = 1e-4, family = gaussian) newdata <- data.frame(x1=c(0.5,0.8), x2=c(0.2,0.1), x3=c(0.3,0.7)) pred <- predict(res, newdata=newdata, se.fit=TRUE, type="response")