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 generalized additive models (GAM), cubic splines are used for covariate smoothing. The semiparametric models are fitted by an iterative process that combines maximization of likelihood and backfitting algorithm. |
Authors: | Washington Junger <[email protected]> |
Maintainer: | Washington Junger <[email protected]> |
License: | GPL-3 | file LICENSE |
Version: | 0.4.17 |
Built: | 2025-01-22 05:11:24 UTC |
Source: | https://github.com/wjunger/pgam |
Method for approximate Akaike Information Criterion extraction.
## S3 method for class 'pgam' AIC(object, k = 2, ...)
## S3 method for class 'pgam' AIC(object, k = 2, ...)
object |
object of class |
k |
default is 2 for AIC. If |
... |
further arguments passed to method |
An approximate measure of parsimony of the Poisson-Gama Additive Models can be achieved by the expression
where is the number of degrees of freedom of the fitted model and
is the index of the first non-zero observation.
The approximate AIC value of the fitted model.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
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
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
Hastie, T. J., Tibshirani, R. J.(1990) Generalized Additive Models. Chapman and Hall, London
pgam
, deviance.pgam
, logLik.pgam
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)
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)
This is a dataset for Poisson-Gamma Additive Models functions testing.
data(aihrio)
data(aihrio)
A data frame with 365 observations on the following 33 variables.
a factor with levels
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
a numeric vector
This is a reduced dataset of those used to estimate possible effects of air pollution on hospital admissions outcomes in Universidade do Estado do Rio de Janeiro, Rio de Janeiro, Brasil.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
Secretary for the Environment of the Rio de Janeiro City, Brazilian Ministry of Defense and Brazilian Ministry of Health
Method for parametric coefficients extraction.
## S3 method for class 'pgam' coef(object, ...)
## S3 method for class 'pgam' coef(object, ...)
object |
object of class |
... |
further arguments passed to method |
This function only retrieves the estimated coefficients from the model object returned by pgam
.
Vector of coefficients estimates of the model fitted.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
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
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
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)
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)
Method for total deviance value extraction.
## S3 method for class 'pgam' deviance(object, ...)
## S3 method for class 'pgam' deviance(object, ...)
object |
object of class |
... |
further arguments passed to method |
See predict.pgam
for further information on deviance extration in Poisson-Gamma models.
The sum of deviance components.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
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
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
pgam
, pgam.fit
, pgam.likelihood
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)
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)
A normal plot with simulated envelope of the residual is produced.
## 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, ...)
## 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, ...)
object |
object of class |
type |
type of residuals to be extracted. Default is |
size |
value giving the size of the envelope. Default is |
rep |
number of replications for envelope construction. Default is |
, that is the smallest 95% band that can be build
optim.method |
optimization method to be passed to |
epsilon |
convergence control to be passed to |
maxit |
convergence control to be passed to |
plot |
if |
title |
title for the plot |
verbose |
if |
... |
further arguments to |
Method for the generic function envelope
.
Sometimes the usual Q-Q plot shows an unsatisfactory pattern of the residuals of a model fitted and we are led to think that the model is badly specificated. The normal plot with simulated envelope indicates that under the distribution of the response variable the model is OK if only a few points fall off the envelope.
If object
is of class pgam
the envelope is estimated and optionally plotted, else if is of class envelope
then it is only plotted.
An object of class envelope
holding the information needed to plot the envelope.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
Atkinson, A. C. (1985) Plots, transformations and regression : an introduction to graphical methods of diagnostic regression analysis. Oxford Science Publications, Oxford.
pgam
, predict.pgam
, residuals.pgam
Generate the partition of design matrix regarded to the seasonal factor in its argument. Used in the model formula.
f(factorvar)
f(factorvar)
factorvar |
variable with the seasonal levels |
List containing data matrix of dummy variables, level names and seasonal periods.
This function is intended to be called from within a model formula.
Washington Leite Junger [email protected]
Method for fitted values extraction.
## S3 method for class 'pgam' fitted(object, ...)
## S3 method for class 'pgam' fitted(object, ...)
object |
object of class |
... |
further arguments passed to method |
Actually, the fitted values are worked out by the function predict.pgam
. Thus, this method is supposed to turn fitted values extraction easier. See predict.pgam
for details on one-step ahead prediction.
Vector of predicted values of the model fitted.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
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
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
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)
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)
Collect information to smooth the term in its argument. Used in the model formula.
g(var, df = NULL)
g(var, df = NULL)
var |
variable to be smoothed |
df |
equivalent degrees of freedom to be passed to the smoother. If |
This function only sets things up for model fitting. The smooth terms are actually fitted by bkfsmooth
.
List containing the same elements of its argument.
This function is intended to be called from within a model formula.
Washington Leite Junger [email protected]
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: a roughness penalty approach. Chapman and Hall, London
Hastie, T. J., Tibshirani, R. J.(1990) Generalized Additive Models. Chapman and Hall, London
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
Method for loglik value extraction.
## S3 method for class 'pgam' logLik(object, ...)
## S3 method for class 'pgam' logLik(object, ...)
object |
object of class |
... |
further arguments passed to method |
See pgam.likelihood
for more information on log-likelihood evaluation in Poisson-Gamma models.
The maximum value achieved by the likelihood optimization process.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
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
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
pgam
, pgam.fit
, pgam.likelihood
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)
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)
A raw periodogram is returned and optionally plotted.
periodogram(y, rows = trunc(length(na.omit(y))/2-1), plot = TRUE, ...)
periodogram(y, rows = trunc(length(na.omit(y))/2-1), plot = TRUE, ...)
y |
time series |
rows |
number of rows to be returned. Default and largest is |
plot |
if |
... |
further arguments to |
The raw periodogram is an estimator of the spectrum of a time series, it still is a good indicator of unresolved seasonality patterns in residuals of the fitted model. Check the function intensity
for frequencies extraction.
This function plots a fancy periodogram where the intensities of the angular frequencies are plotted resembling tiny lollipops.
Periodogram ordered by intensity.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
Box, G., Jenkins, G., Reinsel, G. (1994) Time Series Analysis : Forecasting and Control. 3rd edition, Prentice Hall, New Jersey.
Diggle, P. J. (1989) Time Series : A Biostatistical Introduction. Oxford University Press, Oxford.
Fit Poisson-Gamma Additive Models using the roughness penalty approach
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)
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)
formula |
a model formula. See |
dataset |
a data set in the environment search path. Missing data is temporarily not handled |
omega |
initial value for the discount factor |
beta |
vector of initial values for covariates coefficients. If a sigle value is supplied it is replicated to fill in the whole vector |
offset |
default is |
digits |
number of decimal places for printing information out |
na.action |
action to be taken if missing values are found. Default is |
maxit |
convergence control iterations |
eps |
convergence control criterion |
lfn.scale |
scales the likelihood function and is passed to |
control |
convergence control of |
optim.method |
optimization method passed to |
bkf.eps |
convergence control criterion for the backfitting algorithm |
bkf.maxit |
convergence control iterations for the backfitting algorithm |
se.estimation |
if |
verbose |
if |
The formula is parsed by formparser
in order to extract all the information necessary for model fit. Split the model into two parts regarding the parametric nature of the model.
A model can be specified as following:
where is a seasonal factor with period
and
is the degree of freedom of the smoother of the i-th covariate. Actually, two new formulae will be created:
and
These two formulae will be used to build the necessary datasets for model estimation. Dummy variables reproducing the seasonal factors will be created also.
Models without explanatory variables must be specified as in the following formula
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.
List containing an object of class pgam
.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
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
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: a roughness penalty approach. Chapman and Hall, London
predict.pgam
, formparser
, residuals.pgam
, backfitting
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)
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)
Plot of the local level and, when semiparametric model is fitted, the estimated smooth terms.
## S3 method for class 'pgam' plot(x, rug = TRUE, se = TRUE, at.once = FALSE, scaled = FALSE, ...)
## S3 method for class 'pgam' plot(x, rug = TRUE, se = TRUE, at.once = FALSE, scaled = FALSE, ...)
x |
object of class |
rug |
if |
se |
if |
at.once |
if |
scaled |
if |
... |
further arguments passed to method |
Error band of smooth terms is approximated.
No value returned.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
pgam
, pgam.fit
, pgam.likelihood
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)
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)
Prediction and forecasting of the fitted model.
## S3 method for class 'pgam' predict(object, forecast = FALSE, k = 1, x = NULL, ...)
## S3 method for class 'pgam' predict(object, forecast = FALSE, k = 1, x = NULL, ...)
object |
object of class |
forecast |
if |
k |
steps for forecasting |
x |
covariate values for forecasting if the model has covariates. Must have the |
... |
further arguments passed to method |
It estimates predicted values, their variances, deviance components, generalized Pearson statistics components, local level, smoothed prediction and forecast.
Considering a Poisson process and a gamma priori, the predictive distribution of the model is negative binomial with parameters and
. So, the conditional mean and variance are given by
and
Deviance components are estimated as follow
Generalized Pearson statistics has the form
Approximate scale parameter is given by the expression
where is the number o degrees of reedom of the fitted model.
List with those described in Details
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
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
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
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
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)$yhat plot(ITRESP5) lines(p)
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)$yhat plot(ITRESP5) lines(p)
Print model information
## S3 method for class 'pgam' print(x, digits, ...)
## S3 method for class 'pgam' print(x, digits, ...)
x |
object of class |
digits |
number of decimal places for output |
... |
further arguments passed to method |
This function only prints out the information.
No value is returned.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
Print output of model information
## S3 method for class 'pgam' print.summary(x, digits, ...)
## S3 method for class 'pgam' print.summary(x, digits, ...)
x |
object of class |
digits |
number of decimal places for output |
... |
further arguments passed to method |
This function actually only prints out the information.
No value is returned.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
Method for residuals extraction.
## S3 method for class 'pgam' residuals(object, type = "deviance", ...)
## S3 method for class 'pgam' residuals(object, type = "deviance", ...)
object |
object of class |
type |
type of residuals to be extracted. Default is |
... |
further arguments passed to method |
The types of residuals available and a brief description are the following:
response
These are raw residuals of the form .
pearson
Pearson residuals are quite known and for this model they take the form .
deviance
Deviance residuals are estimated by , where
is the deviance contribution of the t-th observation. See
deviance.pgam
for details on deviance component estimation.
std_deviance
Same as deviance, but the deviance component is divided by , where
is the t-th element of the diagonal of the pseudo hat matrix of the approximating linear model. So they turn into
.
The element has the form
, where
is the predictor of the approximating linear model.
std_scl_deviance
Just like the last one except for the dispersion parameter in its expression, so they have the form , where
is the estimated dispersion parameter of the model. See
summary.pgam
for estimation.
Vector of residuals of the model fitted.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
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
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
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 American Statistical Association, 81(396),977-986
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)
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)
Output of model information
## S3 method for class 'pgam' summary(object, smo.test = FALSE, ...)
## S3 method for class 'pgam' summary(object, smo.test = FALSE, ...)
object |
object of class |
smo.test |
Approximate significance test of smoothing terms. It can take long, so default is |
... |
further arguments passed to method |
Hypothesis tests of coefficients are based o t distribution. Significance tests of smooth terms are approximate for model selection purpose only. Be very careful about the later.
List containing all the information about the model fitted.
Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]
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
Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.
Green, P. J., Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: a roughness 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 American Statistical Association, 81(396),977-986
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)
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)
Export a data frame to a fancy LaTeX table environment.
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 = " ")
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 = " ")
tbl |
object of type data frame or matrix |
label |
label for LaTeX cross reference |
caption |
caption for LaTeX tabular environment |
centered |
logical. |
alignment |
alignment of the object on the page |
digits |
decimal digits after decimal point |
hline |
logical. |
vline |
logical. |
file |
filename for outputting. If none is provided, LaTeX code is routed through the console |
topleftcell |
text for the top-left cell of the table |
This is a utility function intended to ease convertion of R objects to LaTeX format. It only exports data frame or data matrix nonetheless.
LaTeX code is routed through file or console for copying and pasting.
For now, it handles only numerical data.
Washington Leite Junger [email protected]
library(pgam) data(aihrio) m <- aihrio[1:10,4:10] tbl2tex(m,label="tbl:r_example",caption="R example of tbl2tex",digits=4)
library(pgam) data(aihrio) m <- aihrio[1:10,4:10] tbl2tex(m,label="tbl:r_example",caption="R example of tbl2tex",digits=4)