Learn R Programming

pgam (version 0.3.3)

predict.pgam: Prediction

Description

Prediction and forecasting of the fitted model.

Usage

## S3 method for class 'pgam':
predict(object, forecast = FALSE, k = 1, x = NULL, ...)

Arguments

object
object of class pgam holding the fitted model
forecast
if TRUE the function tries to forecast
k
steps for forecasting
x
covariate values for forecasting if the model has covariates. Must have the $k$ rows and $p$ columns
...
further arguments passed to method

Value

  • List with those described in Details

Details

It estimates predicted values, their variances, deviance components, generalized Pearson statistics components, local level, smoothed prediction, forecast and dispersion parameter.

Considering a Poisson process and a gamma priori, the predictive distribution of the model is negative binomial with parameters $a_{t|t-1}$ and $b_{t|t-1}$. So, the conditional mean and variance are given by $$E\left(y_{t}|Y_{t-1}\right)=a_{t|t-1}/b_{t|t-1}$$ and $$Var\left(y_{t}|Y_{t-1}\right)=a_{t|t-1}\left(1+b_{t|t-1}\right)/b_{t|t-1}^{2}$$

Deviance components are estimated as follow $$D\left(y;\hat\mu\right)=2\sum_{t=\tau+1}^{n}{a_{t|t-1}\log \left(\frac{a_{t|t-1}}{y_{t}b_{t|t-1}}\right)-\left(a_{t|t-1}+y_{t}\right)\log \frac{\left(y_{t}+a_{t|t-1}\right)}{\left(1+b_{t|t-1}\right)y_{t}}}$$

Generalized Pearson statistics has the form $$X^{2}=\sum_{t=\tau+1}^{n}\frac{\left(y_{t}b_{t|t-1}-a_{t|t-1}\right)^{2}} {a_{t|t-1}\left(1+b_{t|t-1}\right)}$$

Dispersion parameter estimation is computed by $$\phi=\frac{X^{2}}{gl_{r}}$$ where $gl_{r}$ is the residuals degrees of freedom.

References

Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: a roughness penalty approach. Chapman and Hall, London

Harvey, A. C., Fernandes, C. (1989) Time series models for count data or qualitative observations. Journal of Business and Economic Statistics, 7(4):407--417

Campos, E. L., De Leon, A. C. M. P., Fernandes, C. A. C. (2003) Modelo Poisson-Gama para S�ries Temporais de Dados de Contagem - Teoria e Aplica��es. 10a ESTE - Escola de S�ries Temporais e Econometria

Junger, W. L. (2004) Modelo Poisson-Gama Semi-Param�trico: Uma Abordagem de Penaliza��o por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de Engenharia El�trica

Harvey, A. C. (1990) Forecasting, structural time series models and the Kalman Filter. Cambridge, New York

Hastie, T. J., Tibshirani, R. J.(1990) Generalized Additive Models. Chapman and Hall, London

McCullagh, P., Nelder, J. A. (1989). Generalized Linear Models. Chapman and Hall, 2nd edition, London

See Also

pgam, residuals.pgam

Examples

Run this code
library(pgam)
data(aihrio)
attach(aihrio)
form <- ITRESP5~f(WEEK)+HOLIDAYS+rain+PM+g(tmpmax,7)+g(wet,3)
m <- pgam(form,aihrio,omega=.8,beta=.01,maxit=1e2,eps=1e-4,optim.method="BFGS",partial.resid="response")

p <- predict(m)$yhat
plot(ITRESP5)
lines(p)

Run the code above in your browser using DataLab