Post on 22-May-2018
The pgam PackageMay 12, 2006
Version 0.4.5
Date 2006-05-05
Author Washington Junger <wjunger@ims.uerj.br> and Antonio Ponce de Leon<ponce@ims.uerj.br>
Maintainer Washington Junger <wjunger@ims.uerj.br>
Depends R (>= 2.0.0)
Title Poisson-Gamma Additive Models.
Description This work is an extension of the state space model for Poisson count data,Poisson-Gamma model, towards a semiparametric specification. Just like the generalizedadditive models (GAM), cubic splines are used for covariate smoothing. The semiparametricmodels are fitted by an iterative process that combines maximization of likelihood andbackfitting algorithm.
License GPL version 2 or later
R topics documented:AIC.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2aihrio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3backfitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5bkfsmooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6coef.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7deviance.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8elapsedtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9envelope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10envelope.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12fitted.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12fnz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13formparser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14framebuilder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16intensity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18logLik.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19lpnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1
2 AIC.pgam
periodogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22pgam.filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24pgam.fit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25pgam.hes2se . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26pgam.likelihood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27pgam.par2psi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28pgam.psi2par . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29plot.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29predict.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30print.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32print.summary.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33residuals.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34summary.pgam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35tbl2tex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Index 38
AIC.pgam AIC extraction
Description
Method for approximate Akaike Information Criterion extraction.
Usage
## S3 method for class 'pgam':AIC(object, k = 2, ...)
Arguments
object object of class pgam holding the fitted model
k default is 2 for AIC. If k = log (n) then an approximation for BIC is obtained.Important to note that these are merely approximations.
... further arguments passed to method
Details
An approximate measure of parsimony of the Poisson-Gama Additive Models can be achieved bythe expression
AIC = (D (y; µ) + 2gle) / (n − τ)
where gle is the number of degrees of freedom of the fitted model and τ is the index of the firstnon-zero observation.
Value
The approximate AIC value of the fitted model.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
aihrio 3
References
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 paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
Hastie, T. J., Tibshirani, R. J.(1990) Generalized Additive Models. Chapman and Hall, London
See Also
pgam, deviance.pgam, logLik.pgam
Examples
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")
AIC(m)
aihrio Sample dataset
Description
This is a dataset for Poisson-Gamma Additive Models functions testing.
Usage
data(aihrio)
Format
A data frame with 365 observations on the following 33 variables.
DATE a factor with levels
TIME a numeric vector
ITRESP65 a numeric vector
ITCIRC65 a numeric vector
ITDPOC65 a numeric vector
ITPNM65 a numeric vector
ITAVC65 a numeric vector
ITIAM65 a numeric vector
4 aihrio
ITDIC65 a numeric vector
ITTCA65 a numeric vector
ITRESP5 a numeric vector
ITPNEU5 a numeric vector
ITDPC5 a numeric vector
WEEK a numeric vector
MON a numeric vector
TUE a numeric vector
WED a numeric vector
THU a numeric vector
FRI a numeric vector
SAT a numeric vector
SUN a numeric vector
HOLIDAYS a numeric vector
MONTH a numeric vector
warm.season a numeric vector
tmpmed a numeric vector
tmpmin a numeric vector
tmpmax a numeric vector
wet a numeric vector
rain a numeric vector
rainy a numeric vector
PM a numeric vector
SO2 a numeric vector
CO a numeric vector
Details
This is a reduced dataset of those used to estimate possible effects of air pollution on hospitaladmissions outcomes in Universidade do Estado do Rio de Janeiro, Rio de Janeiro, Brasil.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
Source
Secretaria de Meio Ambiente da Cidade do Rio de Janeiro, MinistÃl’rio de AeronÃautica and Data-sus.
backfitting 5
backfitting Backfitting algorithm
Description
Fit the nonparametric part of the model via backfitting algorithm.
Usage
backfitting(y, x, df, smoother = "spline", w = rep(1, length(y)), eps = 0.001, maxit = 100, info = TRUE)
Arguments
y dependent variable for fitting. In semiparametric models, this is the partial resid-uals of parametric fit
x matrix of covariatesdf equivalent degrees of freedom. If NULL the smoothing parameter is selected by
cross-validationsmoother string with the name of the smoother to be usedw vector with the diagonal elements of the weight matrix. Default is a vector of 1
with the same length of y
eps convergence control criterionmaxit convergence control iterationsinfo if FALSE only fitted values are returned. It it is faster during iterations
Details
Backfitting algorithm estimates the approximating regression surface, working around the "curse ofdimentionality".
More details soon enough.
Value
Fitted smooth curves and partial residuals.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: aroughness penalty approach. Chapman and Hall, London
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’trico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
Hastie, T. J., Tibshirani, R. J.(1990) Generalized Additive Models. Chapman and Hall, London
6 bkfsmooth
See Also
pgam, predict.pgam, bkfsmooth
bkfsmooth Smoothing of nonparametric terms
Description
Interface for smoothing functions
Usage
bkfsmooth(y, x, df, smoother = "spline", w = rep(1, length(y)))
Arguments
y dependent variable for fitting. In semiparametric models, this is the partial resid-uals of parametric fit
x independent variable. Univariate fit only
df equivalent degrees of freedom. If NULL the smoothing parameter is selected bycross-validation
smoother string with the name of the smoother to be used
w vector with the diagonal elements of the weight matrix. Default is a vector of 1with the same length of y
Details
Although several smoothers can be used in semiparametric regression models, only natural cubicsplines is intended to be used in Poisson-Gamma Additive Models due to its interesting mathemat-ical properties.
Nowadays, this function interfaces the smooth.spline in stats library. It will become notdependent soon enough.
Value
fitted smoothed values
lev diagonal of the influence matrix
df degrees of freedom
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
coef.pgam 7
References
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: aroughness penalty approach. Chapman and Hall, London
Hastie, T. J., Tibshirani, R. J.(1990) Generalized Additive Models. Chapman and Hall, London
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’trico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
See Also
pgam, predict.pgam
coef.pgam Coefficients extraction
Description
Method for parametric coefficients extraction.
Usage
## S3 method for class 'pgam':coef(object, ...)
Arguments
object object of class pgam holding the fitted model
... further arguments passed to method
Details
This function only retrieves the estimated coefficients from the model object returned by pgam.
Value
Vector of coefficients estimates of the model fitted.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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 paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
8 deviance.pgam
See Also
pgam, pgam.fit, predict.pgam
Examples
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")
coef(m)
deviance.pgam Deviance extraction
Description
Method for total deviance value extraction.
Usage
## S3 method for class 'pgam':deviance(object, ...)
Arguments
object object of class pgam holding the fitted model... further arguments passed to method
Details
See predict.pgam for further information on deviance extration in Poisson-Gamma models.
Value
The sum of deviance components.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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 paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
elapsedtime 9
See Also
pgam, pgam.fit, pgam.likelihood
Examples
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")
deviance(m)
elapsedtime Utility function
Description
Gadget to compute the elapsed time of a process
Usage
elapsedtime(st, et)
Arguments
st start time
et end time
Details
Start and end times can be obtained with proc.time.
Value
String with the elapsed time in hh:mm:ss format.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉
See Also
pgam
10 envelope.pgam
envelope Generic function for simulated envelope generation.
Description
A normal plot with simulated envelope of the residual is produced.
Usage
envelope(object, ...)
Arguments
object object holding the fitted model
... further arguments to passed to methods
Value
An object of class envelope holding the information needed to plot the envelope.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉
References
Atkinson, A. C. (1985) Plots, transformations and regression : an introduction to graphical methodsof diagnostic regression analysis. Oxford Science Publications, Oxford.
envelope.pgam Normal plot with simulated envelope of the residuals.
Description
A normal plot with simulated envelope of the residual is produced.
Usage
## S3 method for class 'pgam':envelope(object, type = "deviance", size = 0.95, rep = 19, optim.method = NULL,epsilon = 0.001, maxit = 100, plot = TRUE, title="Simulated Envelope of Residuals", verbose = FALSE, ...)
envelope.pgam 11
Arguments
object object of class pgam holding the fitted model
type type of residuals to be extracted. Default is deviance. Options are describedin residuals.pgam
size value giving the size of the envelope. Default is .95 which is equivalent to a95% band
rep number of replications for envelope construction. Default is 19
optim.method optimization method to be passed to pgam and therefore to optim
epsilon convergence control to be passed to pgam
maxit convergence control to be passed to pgam
plot if TRUE a plot of the envelope is produced
title title for the plot
verbose if TRUE a sort of information is printed during the running time
... further arguments to plot function
Details
Method for the generic function envelope.
Sometimes the usual Q-Q plot shows an unsatisfactory pattern of the residuals of a model fitted andwe are led to think that the model is badly specificated. The normal plot with simulated envelopeindicates that under the distribution of the response variable the model is OK if only a few pointsfall off the envelope.
If object is of class pgam the envelope is estimated and optionally plotted, else if is of classenvelope then it is only plotted.
Value
An object of class envelope holding the information needed to plot the envelope.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
Atkinson, A. C. (1985) Plots, transformations and regression : an introduction to graphical methodsof diagnostic regression analysis. Oxford Science Publications, Oxford.
See Also
pgam, predict.pgam, residuals.pgam
12 fitted.pgam
f Utility function
Description
Generate the partition of design matrix regarded to the seasonal factor in its argument. Used in themodel formula.
Usage
f(factorvar)
Arguments
factorvar variable with the seasonal levels
Value
List containing data matrix of dummy variables, level names and seasonal periods.
Note
This function is intended to be called from within a model formula.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉
See Also
pgam, formparser
fitted.pgam Fitted values extraction
Description
Method for fitted values extraction.
Usage
## S3 method for class 'pgam':fitted(object, ...)
Arguments
object object of class pgam holding the fitted model
... further arguments passed to method
fnz 13
Details
Actually, the fitted values are worked out by the function predict.pgam. Thus, this method issupposed to turn fitted values extraction easier. See predict.pgam for details on one-step aheadprediction.
Value
Vector of predicted values of the model fitted.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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 paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
See Also
pgam, pgam.fit, predict.pgam
Examples
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")
f <- fitted(m)
fnz Utility function
Description
Return the index of first non-zero observation of a variable.
Usage
fnz(y)
14 formparser
Arguments
y variable vector
Value
The index of first non-zero value.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉
See Also
pgam
formparser Read the model formula and split it into the parametric and nonpara-metric partitions
Description
Read the model formula and split it into two new ones concerning the parametric and nonparametricpartitions of the predictor.
Usage
formparser(formula, env=parent.frame())
Arguments
formula object representing the model formula. R standard for GLM modelsparent.frame an environment to be used as the parent of the environment created
Details
This function extracts all the information in the model formula. Most important, split the modelinto two parts regarding the parametric nature of the model. A model can be specified as following:
Y f (sfr) + V 1 + V 2 + V 3 + g (V 4, df4) + g (V 5, df5)
where sfr is a seasonal factor with period r and dfi is the degree of freedom of the smoother of thei-th covariate. Actually, two new formulae will be created:
sf1 + . . . + sfr + V 1 + V 2 + V 3
andV 4 + V 5
These two formulae will be used to build the necessary datasets for model estimation. Dummyvariables reproducing the seasonal factors will be created also.Models without explanatory variables must be specified as in the following formula
Y NULL
framebuilder 15
Value
List containing the information needed for model fitting.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉
See Also
pgam, f, g
framebuilder Utility function
Description
Generate a data frame given a formula and a dataset.
Usage
framebuilder(formula, dataset)
Arguments
formula model formula
dataset model dataset
Details
Actually, this function is a wrapper for model.frame.
Value
A data frame restricted to the model.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
See Also
pgam, formparser
16 g
g Utility function
Description
Collect information to smooth the term in its argument. Used in the model formula.
Usage
g(var, df = NULL)
Arguments
var variable to be smoothed
df equivalent degrees of freedom to be passed to the smoother. If NULL, smoothingparameter is selected by cross-validation
Details
This function only sets things up for model fitting. The smooth terms are actually fitted by bkfsmooth.
Value
List containing the same elements of its argument.
Note
This function is intended to be called from within a model formula.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉
References
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: aroughness penalty approach. Chapman and Hall, London
Hastie, T. J., Tibshirani, R. J.(1990) Generalized Additive Models. Chapman and Hall, London
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
See Also
pgam, formparser
intensity 17
intensity Utility function
Description
Apply spectral decomposition to its argument.
Usage
intensity(w, x)
Arguments
w frequency values
x time series
Details
The function apllies the spectral decomposition to the time series according to the following ex-pression ((∑
(x ∗ cos (w ∗ t)))2
+(∑
(x ∗ cos (w ∗ t)))2
)/n
Value
Decomposed series.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
Box, G., Jenkins, G., Reinsel, G. (1994) Time Series Analysis : Forecasting and Control. 3rdedition, Prentice Hall, New Jersey.
Diggle, P. J. (1989) Time Series : A Biostatistical Introduction. Oxford University Press, Oxford.
See Also
pgam, periodogram
18 link
link Utility function
Description
Apply the link function or its inverse to the argument.
Usage
link(x, link = "log", inv = FALSE)
Arguments
x vector containing the predictor
link string with the name of the link function
inv if TRUE its inverse is applied
Details
This function is intended to port other link functions than log () to Poisson-Gamma Additive Mod-els. For now, the only allowed value is "log".
Value
Evaluated link function at x values.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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
McCullagh, P., Nelder, J. A. (1989). Generalized Linear Models. Chapman and Hall, 2nd edition,London
See Also
pgam, formparser
logLik.pgam 19
logLik.pgam Loglik extraction
Description
Method for loglik value extraction.
Usage
## S3 method for class 'pgam':logLik(object, ...)
Arguments
object object of class pgam holding the fitted model
... further arguments passed to method
Details
See pgam.likelihood for more information on log-likelihood evaluation in Poisson-Gammamodels.
Value
The maximum value achieved by the likelihood optimization process.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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 paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
See Also
pgam, pgam.fit, pgam.likelihood
20 lpnorm
Examples
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")
logLik(m)
lpnorm Utility function
Description
Compute the Lp-norm of two sequencies.
Usage
lpnorm(seq1, seq2 = 0, p = 0)
Arguments
seq1 first sequency
seq2 second sequency
p L-space of the norm. 0 is infinity norm or max norm, 1 is the absolute valuenorm, 2 is L2 norm and so on
Value
The computed norm value.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉
See Also
pgam
periodogram 21
periodogram Raw Periodogram
Description
A raw periodogram is returned and optionally plotted.
Usage
periodogram(y, rows = trunc(length(na.omit(y))/2-1), plot = TRUE, ...)
Arguments
y time series
rows number of rows to be returned. Default and largest is n/2 − 1, where n is thenumber of valid observations of the time series y
plot if TRUE a raw periodogram is plotted
... further arguments to plot function
Details
The raw periodogram is an estimator of the spectrum of a time series, it still is a good indicator ofunresolved seasonality patterns in residuals of the fitted model. See intensity for frequenciesextraction.
This function plots a fancy periodogram where the intensities of the angular frequencies are plottedresembling tiny lollipops.
Value
Periodogram ordered by intensity.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
Box, G., Jenkins, G., Reinsel, G. (1994) Time Series Analysis : Forecasting and Control. 3rdedition, Prentice Hall, New Jersey.
Diggle, P. J. (1989) Time Series : A Biostatistical Introduction. Oxford University Press, Oxford.
See Also
pgam, intensity
22 pgam
pgam Poisson-Gamma Additive Models
Description
Fit Poisson-Gamma Additive Models using the roughness penalty approach
Usage
pgam(formula, dataset, omega = 0.8, beta = 0.1, offset = 1, digits = getOption("digits"),na.action="na.exclude", maxit = 100, eps = 1e-06, lfn.scale=1, control = list(),optim.method = "L-BFGS-B", bkf.eps = 0.001, bkf.maxit = 100, se.estimation = "numerical",verbose = TRUE)
Arguments
formula a model formula. See formparser for details
dataset a data set in the environment search path. Missing data is temporarily not han-dled
omega initial value for the discount factor
beta vector of initial values for covariates coefficients. If a sigle value is supplied itis replicated to fill in the whole vector
offset default is 1. Other value can be supplied here
digits number of decimal places for printing information out
na.action action to be taken if missing values are found. Default is "na.exclude" andresiduals and predictions are padded to fit the length of the data. If "na.fail"then the process will stop if missing values are found. If "na.omit" the pro-cess will continue without padding though. If "na.pass" the process willstop due to errors
maxit convergence control iterations
eps convergence control criterion
lfn.scale scales the likelihood function and is passed to control in optim. Value mustbe positive to ensure maximization
control convergence control of optim. See its help for details
optim.method optimization method passed to optim. Different methods can lead to differentresults, so the user must attempt to the trade off between speed and robustness.For example, BFGS is faster but sensitive to starting values and L-BFGS-B ismore robust but slower. See its help for details.
bkf.eps convergence control criterion for the backfitting algorithm
bkf.maxit convergence control iterations for the backfitting algorithmse.estimation
if numerical numerical standard error of parameters are returned. If analyticalthen analytical extraction of the standard errors is performed. By setting it tonone standard error estimation is avoided
verbose if TRUE information during estimation process is printed out
pgam 23
Details
The formula is parsed by formparser in order to extract all the information necessary for modelfit. Split the model into two parts regarding the parametric nature of the model. A model can bespecified as following:
Y f (sfr) + V 1 + V 2 + V 3 + g (V 4, df4) + g (V 5, df5)
where sfr is a seasonal factor with period r and dfi is the degree of freedom of the smoother of thei-th covariate. Actually, two new formulae will be created:
sf1 + . . . + sfr + V 1 + V 2 + V 3
andV 4 + V 5
These two formulae will be used to build the necessary datasets for model estimation. Dummyvariables reproducing the seasonal factors will be created also.
Models without explanatory variables must be specified as in the following formula
Y NULL
There are a lot of details to be written. It will be very soon.
Specific information can be obtained on functions help.
This algorithm fits fully parametric Poisson-Gamma model also.
Value
List containing an object of class pgam.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
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 paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: aroughness penalty approach. Chapman and Hall, London
See Also
predict.pgam, formparser, residuals.pgam, backfitting
24 pgam.filter
Examples
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")
summary(m)
pgam.filter Estimation of the conditional distributions parameters of the level
Description
The priori and posteriori conditional distributions of the level is gamma and their parameters areestimated through this recursive filter. See Details for a thorough description.
Usage
pgam.filter(w, y, eta)
Arguments
w running estimate of discount factor ω of a Poisson-Gamma model
y n length vector of the time series observations
eta full linear or semiparametric predictor. Linear predictor is a trivial case of semi-parameric model
Details
Consider Yt−1 a vector of observed values of a Poisson process untill the instant t− 1. Conditionalon that, µt has gamma distribution with parameters given by
at|t−1 = ωat−1
bt|t−1 = ωbt−1 exp (−ηt)
Once yt is known, the posteriori distribution of µt|Yt is also gamma with parameters given by
at = ωat−1 + yt
bt = ωbt−1 + exp (ηt)
with t = τ, . . . , n, where τ is the index of the first non-zero observation of y.
Diffuse initialization of the filter is applied by setting a0 = 0 and b0 = 0. A proper distribution ofµt is obtained at t = τ , where τ is the fisrt non-zero observation of the time series.
Value
A list containing the time varying parmeters of the priori and posteriori conditional distribution isreturned.
pgam.fit 25
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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
Harvey, A. C. (1990) Forecasting, structural time series models and the Kalman Filter. Cambridge,New York
Campos, E. L., De Leon, A. C. M. P., Fernandes, C. A. C. (2003) Modelo Poisson-Gama paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
See Also
pgam, pgam.likelihood, pgam.fit, predict.pgam
pgam.fit One-step ahead prediction and variance
Description
Estimate one-step ahead expectation and variance of yt conditional on observed time series untilthe instant t − 1.
Usage
pgam.fit(w, y, eta, partial.resid)
Arguments
w estimate of discount factor ω of a Poisson-Gamma model
y observed time series which is the response variable of the model
eta semiparametric predictorpartial.resid
type of partial residuals.
Details
Partial residuals for semiparametric estimation is extracted. Those are regarded to the parametricpartition fit of the model. Available types are raw, pearson and deviance. The type raw isprefered. Properties of other form of residuals not fully tested. Must be careful on choosing it. Seedetails in predict.pgam and residuals.pgam.
26 pgam.hes2se
Value
yhat vector of one-step ahead prediction
resid vector partial residuals
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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
Harvey, A. C. (1990) Forecasting, structural time series models and the Kalman Filter. Cambridge,New York
Campos, E. L., De Leon, A. C. M. P., Fernandes, C. A. C. (2003) Modelo Poisson-Gama paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: aroughness penalty approach. Chapman and Hall, London
See Also
pgam, residuals.pgam, predict.pgam
pgam.hes2se Utility function
Description
Put hyperparameters hessian matrix in the form of omega and beta standard error.
Usage
pgam.hes2se(hes, fperiod, se.estimation="numerical")
Arguments
hes hessian matrix returned by optim
fperiod vector containing as many seasonal factors as there are in model formulase.estimation
indicate what method is used to extract the stardard errors
pgam.likelihood 27
Value
List containing the hyperparameters omega and beta standard errors.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
See Also
pgam, formparser
pgam.likelihood Likelihood function to be maximized
Description
This is the log-likelihood function that is passed to optim for likelihood maximization.
Usage
pgam.likelihood(par, y, x, offset, fperiod, env = parent.frame())
Arguments
par vector of parameters to be optimized
y observed time series which is the response variable of the model
x observed explanatory variables for parametric fit
offset model offset. Just like in GLM
fperiod vector of seasonal factors to be passed to pgam.par2psi
env the caller environment for log-likelihood value to be stored
Details
Log-likelihood function of hyperparameters ω and β is given by
log L (ω, β) =n∑
t=τ+1
log Γ(at|t−1 + yt
)− log yt! − log Γ
(at|t−1
)+ at|t−1 log bt|t−1 −
(at|t−1 + yt
)log
(1 + bt|t−1
)where at|t−1 and bt|t−1 are estimated as it is shown in pgam.filter.
Value
List containing log-likelihood value, optimum linear predictor and the gamma parameters vectors.
Note
This function is not intended to be called directly.
28 pgam.par2psi
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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
Harvey, A. C. (1990) Forecasting, structural time series models and the Kalman Filter. Cambridge,New York
Campos, E. L., De Leon, A. C. M. P., Fernandes, C. A. C. (2003) Modelo Poisson-Gama paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’trico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
See Also
pgam, pgam.filter, pgam.fit
pgam.par2psi Utility function
Description
Put unconstrained optimized parameters back into omega and beta form.
Usage
pgam.par2psi(par, fperiod)
Arguments
par vector of unconstrained parameters
fperiod vector containing as many seasonal factors as there are in model formula
Value
List containing the hyperparameters omega and beta.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
See Also
pgam, formparser
pgam.psi2par 29
pgam.psi2par Utility function
Description
Put hyperparameters into unconstrained form for optimization.
Usage
pgam.psi2par(w, beta, fperiod)
Arguments
w discount factor of the Poisson-Gamma model
beta explanatory variables coefficients
fperiod vector containing as many seasonal factors as there are in model formula
Value
Vector of unconstrained parameters.
Note
This function is not intended to be called directly.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
See Also
pgam, formparser
plot.pgam Plot of estimated curves
Description
Plot of the local level and, when semiparametric model is fitted, the estimated smooth terms.
Usage
## S3 method for class 'pgam':plot(x, rug = TRUE, se = TRUE, at.once = FALSE, scaled = FALSE, ...)
30 predict.pgam
Arguments
x object of class pgam holding the fitted model
rug if TRUE a density rug is drawn on the bottom of the graphic
se if TRUE error band is drawn around the fitted values
at.once if TRUE each plot goes to a separate window, else the user is prompted to con-tinue
scaled if TRUE the same scale will be used for plots of smoothed functions
... further arguments passed to method
Details
Error band of smooth terms is approximated.
Value
No value returned.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
See Also
pgam, pgam.fit, pgam.likelihood
Examples
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")
plot(m,at.once=TRUE)
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, ...)
predict.pgam 31
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 krows and p columns
... further arguments passed to method
Details
It estimates predicted values, their variances, deviance components, generalized Pearson statisticscomponents, local level, smoothed prediction and forecast.
Considering a Poisson process and a gamma priori, the predictive distribution of the model is neg-ative binomial with parameters at|t−1 and bt|t−1. So, the conditional mean and variance are givenby
E (yt|Yt−1) = at|t−1/bt|t−1
andV ar (yt|Yt−1) = at|t−1
(1 + bt|t−1
)/b2
t|t−1
Deviance components are estimated as follow
D (y; µ) = 2n∑
t=τ+1
at|t−1 log(
at|t−1
ytbt|t−1
)−
(at|t−1 + yt
)log
(yt + at|t−1
)(1 + bt|t−1
)yt
Generalized Pearson statistics has the form
X2 =n∑
t=τ+1
(ytbt|t−1 − at|t−1
)2
at|t−1
(1 + bt|t−1
)Approximate scale parameter is given by the expression
φ = fracX2edf
where edf is the number o degrees of reedom of the fitted model.
Value
List with those described in Details
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: aroughness 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
32 print.pgam
Campos, E. L., De Leon, A. C. M. P., Fernandes, C. A. C. (2003) Modelo Poisson-Gama paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’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
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")
p <- predict(m)$yhatplot(ITRESP5)lines(p)
print.pgam Model output
Description
Print model information
Usage
## S3 method for class 'pgam':print(x, digits, ...)
Arguments
x object of class summary.pgam holding the fitted model information
digits number of decimal places for output
... further arguments passed to method
Details
This function only prints out the information.
print.summary.pgam 33
Value
No value is returned.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
See Also
pgam, predict.pgam
print.summary.pgam Summary output
Description
Print output of model information
Usage
## S3 method for class 'pgam':print.summary(x, digits, ...)
Arguments
x object of class summary.pgam holding the fitted model information
digits number of decimal places for output
... further arguments passed to method
Details
This function actually only prints out the information.
Value
No value is returned.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
See Also
pgam, predict.pgam
34 residuals.pgam
residuals.pgam Residuals extraction
Description
Method for residuals extraction.
Usage
## S3 method for class 'pgam':residuals(object, type = "deviance", ...)
Arguments
object object of class pgam holding the fitted model
type type of residuals to be extracted. Default is deviance. Options are describedin Details
... further arguments passed to method
Details
The types of residuals available and a brief description are the following:
responseThese are raw residuals of the form rt = yt − E (yt|Yt−1).
pearsonPearson residuals are quite known and for this model they take the form rt = (yt − E (yt|Yt−1)) /V ar (yt|Yt−1).
devianceDeviance residuals are estimated by rt = sign (yt − E (yt|Yt−1)) ∗ sqrt (dt), where dt is thedeviance contribution of the t-th observation. See deviance.pgam for details on deviance com-ponent estimation.
std_devianceSame as deviance, but the deviance component is divided by (1 − ht), where ht is the t-th elementof the diagonal of the pseudo hat matrix of the approximating linear model. So they turn intort = sign (yt − E (yt|Yt−1)) ∗ sqrt (dt/ (1 − ht)).The element ht has the form ht = ω exp (ηt+1) /
∑t−1j=0 ωj exp (ηt−j), where η is the predictor of
the approximating linear model.
std_scl_devianceJust like the last one except for the dispersion parameter in its expression, so they have the form rt =sign (yt − E (yt|Yt−1)) ∗ sqrt (dt/φ ∗ (1 − ht)), where φ is the estimated dispersion parameter ofthe model. See summary.pgam for φ estimation.
Value
Vector of residuals of the model fitted.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
summary.pgam 35
References
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 paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
McCullagh, P., Nelder, J. A. (1989). Generalized Linear Models. Chapman and Hall, 2nd edition,London
Pierce, D. A., Schafer, D. W. (1986) Residuals in generalized linear models. Journal of the Ameri-can Statistical Association, 81(396),977-986
See Also
pgam, pgam.fit, predict.pgam
Examples
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")
r <- resid(m,"pearson")plot(r)
summary.pgam Summary output
Description
Output of model information
Usage
## S3 method for class 'pgam':summary(object, smo.test = FALSE, ...)
Arguments
object object of class pgam holding the fitted model
smo.test Approximate significance test of smoothing terms. It can take long, so defaultis FALSE
... further arguments passed to method
36 summary.pgam
Details
Hypothesis tests of coefficients are based o t distribution. Significance tests of smooth terms areapproximate for model selection purpose only. Be very careful about the later.
Value
List containing all the information about the model fitted.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉 and Antonio Ponce de Leon 〈ponce@ims.uerj.br〉
References
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 paraSÃl’ries Temporais de Dados de Contagem - Teoria e AplicaÃgÃtes. 10a ESTE - Escola de SÃl’riesTemporais e Econometria
Junger, W. L. (2004) Modelo Poisson-Gama Semi-ParamÃl’rico: Uma Abordagem de Penaliza-ÃgÃco por Rugosidade. MSc Thesis. Rio de Janeiro, PUC-Rio, Departamento de EngenhariaElÃl’trica
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: aroughness penalty approach. Chapman and Hall, London
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
Pierce, D. A., Schafer, D. W. (1986) Residuals in generalized linear models. Journal of the Ameri-can Statistical Association, 81(396),977-986
See Also
pgam, predict.pgam
Examples
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")
summary(m)
tbl2tex 37
tbl2tex LaTeX table exporter
Description
Export a data frame to a fancy LaTeX table environment.
Usage
tbl2tex(tbl, label = "tbl:label(must_be_changed!)", caption = "Table generated with tbl2tex.", centered = TRUE, alignment = "center", digits = getOption("digits"), hline = TRUE, vline = TRUE, file = "", topleftcell = " ")
Arguments
tbl object of type data frame or matrixlabel label for LaTeX cross referencecaption caption for LaTeX tabular environmentcentered logical. TRUE for centered cellsalignment alignment of the object on the pagedigits decimal digits after decimal pointhline logical. TRUE for horizontal bordersvline logical. TRUE for vertical bordersfile filename for outputting. If none is provided, LaTeX code is routed through the
consoletopleftcell text for the top-left cell of the table
Details
This is a utility function intended to ease convertion of R objects to LaTeX format. It only exportsdata frame or data matrix nonetheless.
Value
LaTeX code is routed through file or console for copying and pasting.
Note
For now, it handles only numerical data.
Author(s)
Washington Leite Junger 〈wjunger@ims.uerj.br〉
See Also
pgam
Examples
library(pgam)data(aihrio)m <- aihrio[1:10,4:10]tbl2tex(m,label="tbl:r_example",caption="R example of tbl2tex",digits=4)
Index
∗Topic datasetsaihrio, 2
∗Topic internalbackfitting, 4bkfsmooth, 5elapsedtime, 8envelope, 9fnz, 13formparser, 14framebuilder, 15intensity, 16link, 17lpnorm, 19pgam.filter, 23pgam.fit, 24pgam.hes2se, 25pgam.likelihood, 26pgam.par2psi, 27pgam.psi2par, 28
∗Topic regressionAIC.pgam, 1coef.pgam, 6deviance.pgam, 7envelope.pgam, 10f, 11fitted.pgam, 12g, 15logLik.pgam, 18periodogram, 20pgam, 21plot.pgam, 28predict.pgam, 29print.pgam, 31print.summary.pgam, 32residuals.pgam, 33summary.pgam, 34tbl2tex, 36
∗Topic smoothAIC.pgam, 1coef.pgam, 6deviance.pgam, 7envelope.pgam, 10f, 11
fitted.pgam, 12g, 15logLik.pgam, 18periodogram, 20pgam, 21plot.pgam, 28predict.pgam, 29print.pgam, 31print.summary.pgam, 32residuals.pgam, 33summary.pgam, 34tbl2tex, 36
∗Topic tsAIC.pgam, 1coef.pgam, 6deviance.pgam, 7envelope.pgam, 10f, 11fitted.pgam, 12g, 15logLik.pgam, 18periodogram, 20pgam, 21plot.pgam, 28predict.pgam, 29print.pgam, 31print.summary.pgam, 32residuals.pgam, 33summary.pgam, 34tbl2tex, 36
AIC.pgam, 1aihrio, 2
backfitting, 4, 22bkfsmooth, 5, 5, 16
coef.pgam, 6
deviance.pgam, 2, 7, 33
elapsedtime, 8envelope, 9, 10envelope.pgam, 10
38
INDEX 39
f, 11, 14fitted.pgam, 12fnz, 13formparser, 11, 14, 15, 16, 18, 21, 22,
26–28framebuilder, 15
g, 14, 15
intensity, 16, 20
link, 17logLik.pgam, 2, 18lpnorm, 19
model.frame, 15
optim, 10, 21
periodogram, 17, 20pgam, 2, 5–20, 21, 24–29, 31, 32, 34–36pgam.filter, 23, 26, 27pgam.fit, 7, 8, 12, 19, 24, 24, 27, 29, 34pgam.hes2se, 25pgam.likelihood, 8, 18, 19, 24, 26, 29pgam.par2psi, 27pgam.psi2par, 28plot, 10, 20plot.pgam, 28predict.pgam, 5–7, 11, 12, 22, 24, 25, 29,
32, 34, 35print.pgam, 31print.summary.pgam, 32proc.time, 8
residuals.pgam, 10, 11, 22, 24, 25, 31, 33
smooth.spline, 5summary.pgam, 33, 34
tbl2tex, 36