Package 'pgam'

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

Help Index


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)k=\log\left(n\right) 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 by the expression

AIC=(D(y;μ^)+2gle)/(nτ)AIC=\left(D\left(y;\hat\mu\right)+2gle\right)/\left(n-\tau\right)

where glegle is the number of degrees of freedom of the fitted model and τ\tau is the index of the first non-zero observation.

Value

The approximate AIC value of the fitted model.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

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

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

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)

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

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 hospital admissions outcomes in Universidade do Estado do Rio de Janeiro, Rio de Janeiro, Brasil.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

Source

Secretary for the Environment of the Rio de Janeiro City, Brazilian Ministry of Defense and Brazilian Ministry of Health


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 [email protected] and Antonio Ponce de Leon [email protected]

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

Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.

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 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 [email protected] and Antonio Ponce de Leon [email protected]

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

Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.

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)

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, ...)

Arguments

object

object of class pgam holding the fitted model

type

type of residuals to be extracted. Default is deviance. Options are described in residuals.pgam

size

value giving the size of the envelope. Default is .95 which is equivalent to a 95% band

rep

number of replications for envelope construction. Default is 19

, that is the smallest 95% band that can be build

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 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.

Value

An object of class envelope holding the information needed to plot the envelope.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

References

Atkinson, A. C. (1985) Plots, transformations and regression : an introduction to graphical methods of diagnostic regression analysis. Oxford Science Publications, Oxford.

See Also

pgam, predict.pgam, residuals.pgam


Utility function

Description

Generate the partition of design matrix regarded to the seasonal factor in its argument. Used in the model 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 [email protected]

See Also

pgam, formparser


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

Details

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.

Value

Vector of predicted values of the model fitted.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

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

Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.

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)

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, smoothing parameter 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 [email protected]

References

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.

See Also

pgam, formparser


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-Gamma models.

Value

The maximum value achieved by the likelihood optimization process.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

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

Junger, W. L. (2004) Semiparametric Poisson-Gamma models: a roughness penalty approach. MSc Dissertation. Rio de Janeiro, PUC-Rio, Department of Electrical Engineering.

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")

logLik(m)

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/21n/2-1, where nn is the number of valid observations of the time series yy

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 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.

Value

Periodogram ordered by intensity.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

References

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.

See Also

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 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 11. 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" and residuals 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 process will continue without padding though. If "na.pass" the process will stop 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 must be 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 different results, 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 is more 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 algorithm

se.estimation

if numerical numerical standard error of parameters are returned. If analytical then analytical extraction of the standard errors is performed. By setting it to none standard error estimation is avoided

verbose

if TRUE information during estimation process is printed out

Details

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:

Y f(sfr)+V1+V2+V3+g(V4,df4)+g(V5,df5)Y~f\left(sf_{r}\right)+V1+V2+V3+g\left(V4,df_{4}\right)+g\left(V5,df_{5}\right)

where sfrsf_{r} is a seasonal factor with period rr and dfidf_{i} is the degree of freedom of the smoother of the i-th covariate. Actually, two new formulae will be created:

 sf1++sfr+V1+V2+V3~sf_{1}+\dots+sf_{r}+V1+V2+V3

and

 V4+V5~V4+V5

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

Y NULLY~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 [email protected] and Antonio Ponce de Leon [email protected]

References

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

See Also

predict.pgam, formparser, residuals.pgam, backfitting

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)

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, ...)

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 continue

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 [email protected] and Antonio Ponce de Leon [email protected]

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)

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 kk rows and pp columns

...

further arguments passed to method

Details

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 att1a_{t|t-1} and btt1b_{t|t-1}. So, the conditional mean and variance are given by

E(ytYt1)=att1/btt1E\left(y_{t}|Y_{t-1}\right)=a_{t|t-1}/b_{t|t-1}

and

Var(ytYt1)=att1(1+btt1)/btt12Var\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(y;μ^)=2t=τ+1natt1log(att1ytbtt1)(att1+yt)log(yt+att1)(1+btt1)ytD\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

X2=t=τ+1n(ytbtt1att1)2att1(1+btt1)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)}

Approximate scale parameter is given by the expression

ϕ^=fracX2edf\hat\phi=frac{X^{2}}{edf}

where edfedf is the number o degrees of reedom of the fitted model.

Value

List with those described in Details

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

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

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

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)$yhat
plot(ITRESP5)
lines(p)

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.

Value

No value is returned.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

See Also

pgam, predict.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 [email protected] and Antonio Ponce de Leon [email protected]

See Also

pgam, predict.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 described in Details

...

further arguments passed to method

Details

The types of residuals available and a brief description are the following:

response
These are raw residuals of the form rt=ytE(ytYt1)r_{t}=y_{t}-E\left(y_{t}|Y_{t-1}\right).

pearson
Pearson residuals are quite known and for this model they take the form rt=(ytE(ytYt1))/Var(ytYt1)r_{t}=\left(y_{t}-E\left(y_{t}|Y_{t-1}\right)\right)/Var\left(y_{t}|Y_{t-1}\right).

deviance
Deviance residuals are estimated by rt=sign(ytE(ytYt1))sqrt(dt)r_{t}=sign\left(y_{t}-E\left(y_{t}|Y_{t-1}\right)\right)*sqrt\left(d_{t}\right), where dtd_{t} 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 (1ht)(1-h_{t}), where hth_{t} is the t-th element of the diagonal of the pseudo hat matrix of the approximating linear model. So they turn into rt=sign(ytE(ytYt1))sqrt(dt/(1ht))r_{t}=sign\left(y_{t}-E\left(y_{t}|Y_{t-1}\right)\right)*sqrt\left(d_{t}/\left(1-h_{t}\right)\right).
The element hth_{t} has the form ht=ωexp(ηt+1)/j=0t1ωjexp(ηtj)h_{t}=\omega\exp\left(\eta_{t+1}\right)/\sum_{j=0}^{t-1}\omega^{j}\exp\left(\eta_{t-j}\right), where η\eta 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 rt=sign(ytE(ytYt1))sqrt(dt/ϕ(1ht))r_{t}=sign\left(y_{t}-E\left(y_{t}|Y_{t-1}\right)\right)*sqrt\left(d_{t}/\phi*\left(1-h_{t}\right)\right), where ϕ\phi is the estimated dispersion parameter of the model. See summary.pgam for ϕ\phi estimation.

Value

Vector of residuals of the model fitted.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

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

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

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 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 default is FALSE

...

further arguments passed to method

Details

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.

Value

List containing all the information about the model fitted.

Author(s)

Washington Leite Junger [email protected] and Antonio Ponce de Leon [email protected]

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

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

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)

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 matrix

label

label for LaTeX cross reference

caption

caption for LaTeX tabular environment

centered

logical. TRUE for centered cells

alignment

alignment of the object on the page

digits

decimal digits after decimal point

hline

logical. TRUE for horizontal borders

vline

logical. TRUE for vertical borders

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

Details

This is a utility function intended to ease convertion of R objects to LaTeX format. It only exports data 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 [email protected]

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)