R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("pgam-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('pgam') This is pgam library version 0.4.3 > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "AIC.pgam" > > ### * AIC.pgam > > flush(stderr()); flush(stdout()) > > ### Name: AIC.pgam > ### Title: AIC extraction > ### Aliases: AIC.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > AIC(m) [1] 1.313397 > > > > > cleanEx(); ..nameEx <- "coef.pgam" > > ### * coef.pgam > > flush(stderr()); flush(stdout()) > > ### Name: coef.pgam > ### Title: Coefficients extraction > ### Aliases: coef.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > coef(m) (Discount) WEEK.1 WEEK.2 WEEK.3 WEEK.4 0.8608709184 -0.4747100583 0.2453708909 0.1651389660 0.1873044777 WEEK.5 WEEK.6 WEEK.7 HOLIDAYS rain 0.1104593126 0.1465003289 -0.3800639177 -0.3101366665 -0.0035355425 PM 0.0009979136 > > > > > cleanEx(); ..nameEx <- "deviance.pgam" > > ### * deviance.pgam > > flush(stderr()); flush(stdout()) > > ### Name: deviance.pgam > ### Title: Deviance extraction > ### Aliases: deviance.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > deviance(m) [1] 426.3603 > > > > > cleanEx(); ..nameEx <- "fitted.pgam" > > ### * fitted.pgam > > flush(stderr()); flush(stdout()) > > ### Name: fitted.pgam > ### Title: Fitted values extraction > ### Aliases: fitted.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > f <- fitted(m) > > > > > cleanEx(); ..nameEx <- "logLik.pgam" > > ### * logLik.pgam > > flush(stderr()); flush(stdout()) > > ### Name: logLik.pgam > ### Title: Loglik extraction > ### Aliases: logLik.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > logLik(m) [1] 1075.727 > > > > > cleanEx(); ..nameEx <- "pgam" > > ### * pgam > > flush(stderr()); flush(stdout()) > > ### Name: pgam > ### Title: Poisson-Gamma Additive Models > ### Aliases: pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > summary(m) Function call: pgam(formula = form, dataset = aihrio, omega = 0.8, beta = 0.01, maxit = 100, eps = 1e-04, optim.method = "BFGS") Model formula: ITRESP5 ~ f(WEEK) + HOLIDAYS + rain + PM + g(tmpmax, 7) + g(wet, 3) Parametric coefficients: Estimate std. err. t ratio Pr(>|t|) (Discount) 0.8608709 0.04614704 18.65495 < 2.22e-16 WEEK.1 -0.4747101 0.03915625 -12.12348 < 2.22e-16 WEEK.2 0.2453709 0.02868606 8.553664 4.4409e-16 WEEK.3 0.165139 0.02965303 5.569042 5.1698e-08 WEEK.4 0.1873045 0.02936112 6.379337 5.7401e-10 WEEK.5 0.1104593 0.03039694 3.633895 0.00032176 WEEK.6 0.1465003 0.03040014 4.819068 2.1674e-06 WEEK.7 -0.3800639 0.102413 -3.711091 0.00024059 HOLIDAYS -0.3101367 0.07786684 -3.98291 8.3108e-05 rain -0.003535543 0.002024043 -1.746772 0.08157 PM 0.0009979136 0.0007971613 1.251834 0.21148 Approximate significance of smooth terms: edf chi.sq p-value tmpmax 6 NA NA wet 2 NA NA Log-likelihood value is 1075.727 after BFGS has converged. Estimation process of semiparametric model stopped after 3 iterations at 3.82e-05. Residual deviance is 426.3603 on 344 estimated degrees of freedom. Approximate dispersion parameter equals 1.231335 based on generalized Pearson statistics 423.5793. Diffuse initialization wasted the 1 first observation(s). Besides, 0 observation(s) was(were) lost due to missing data. > > > > > cleanEx(); ..nameEx <- "plot.pgam" > > ### * plot.pgam > > flush(stderr()); flush(stdout()) > > ### Name: plot.pgam > ### Title: Plot of estimated curves > ### Aliases: plot.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > plot(m,at.once=TRUE) > > > > > cleanEx(); ..nameEx <- "predict.pgam" > > ### * predict.pgam > > flush(stderr()); flush(stdout()) > > ### Name: predict.pgam > ### Title: Prediction > ### Aliases: predict.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > p <- predict(m)$yhat > plot(ITRESP5) > lines(p) > > > > > cleanEx(); ..nameEx <- "residuals.pgam" > > ### * residuals.pgam > > flush(stderr()); flush(stdout()) > > ### Name: residuals.pgam > ### Title: Residuals extraction > ### Aliases: residuals.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > r <- resid(m,"pearson") > plot(r) > > > > > cleanEx(); ..nameEx <- "summary.pgam" > > ### * summary.pgam > > flush(stderr()); flush(stdout()) > > ### Name: summary.pgam > ### Title: Summary output > ### Aliases: summary.pgam > ### Keywords: ts smooth regression > > ### ** 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") iter: 1 | norm: Inf iter: 2 | norm: 0.0020767 iter: 3 | norm: 3.82e-05 Semiparametric model estimation algorithm has converged. Final run: Getting estimated parameters, functions and numerical hessian matrix... Counts (fn | gr): 37 2 Estimation process took 00:00:02 (hh:mm:ss) > > summary(m) Function call: pgam(formula = form, dataset = aihrio, omega = 0.8, beta = 0.01, maxit = 100, eps = 1e-04, optim.method = "BFGS") Model formula: ITRESP5 ~ f(WEEK) + HOLIDAYS + rain + PM + g(tmpmax, 7) + g(wet, 3) Parametric coefficients: Estimate std. err. t ratio Pr(>|t|) (Discount) 0.8608709 0.04614704 18.65495 < 2.22e-16 WEEK.1 -0.4747101 0.03915625 -12.12348 < 2.22e-16 WEEK.2 0.2453709 0.02868606 8.553664 4.4409e-16 WEEK.3 0.165139 0.02965303 5.569042 5.1698e-08 WEEK.4 0.1873045 0.02936112 6.379337 5.7401e-10 WEEK.5 0.1104593 0.03039694 3.633895 0.00032176 WEEK.6 0.1465003 0.03040014 4.819068 2.1674e-06 WEEK.7 -0.3800639 0.102413 -3.711091 0.00024059 HOLIDAYS -0.3101367 0.07786684 -3.98291 8.3108e-05 rain -0.003535543 0.002024043 -1.746772 0.08157 PM 0.0009979136 0.0007971613 1.251834 0.21148 Approximate significance of smooth terms: edf chi.sq p-value tmpmax 6 NA NA wet 2 NA NA Log-likelihood value is 1075.727 after BFGS has converged. Estimation process of semiparametric model stopped after 3 iterations at 3.82e-05. Residual deviance is 426.3603 on 344 estimated degrees of freedom. Approximate dispersion parameter equals 1.231335 based on generalized Pearson statistics 423.5793. Diffuse initialization wasted the 1 first observation(s). Besides, 0 observation(s) was(were) lost due to missing data. > > > > > cleanEx(); ..nameEx <- "tbl2tex" > > ### * tbl2tex > > flush(stderr()); flush(stdout()) > > ### Name: tbl2tex > ### Title: LaTeX table exporter > ### Aliases: tbl2tex > ### Keywords: ts smooth regression > > ### ** Examples > > library(pgam) > data(aihrio) > m <- aihrio[1:10,4:10] > tbl2tex(m,label="tbl:r_example",caption="R example of tbl2tex",digits=4) % File generated in R environment by tbl2tex() % Creation date: Wed Jul 13 18:04:01 2005 % Suggestions to Washington Junger \begin{table} \centering \caption{R example of tbl2tex} \label{tbl:r_example} \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline & ITCIRC65 & ITDPOC65 & ITPNM65 & ITAVC65 & ITIAM65 & ITDIC65 & ITTCA65 \\ \hline 1 & 21 & 3 & 2 & 2 & 4 & 5 & 0 \\ \hline 2 & 36 & 6 & 8 & 9 & 1 & 6 & 3 \\ \hline 3 & 38 & 2 & 10 & 2 & 3 & 6 & 1 \\ \hline 4 & 43 & 4 & 5 & 4 & 3 & 4 & 5 \\ \hline 5 & 45 & 4 & 2 & 1 & 4 & 5 & 2 \\ \hline 6 & 16 & 3 & 1 & 0 & 0 & 0 & 1 \\ \hline 7 & 23 & 2 & 4 & 3 & 2 & 3 & 3 \\ \hline 8 & 35 & 5 & 3 & 2 & 5 & 7 & 6 \\ \hline 9 & 40 & 6 & 4 & 5 & 2 & 5 & 5 \\ \hline 10 & 33 & 4 & 4 & 6 & 1 & 4 & 4 \\ \hline \end{tabular} \end{table} % End of tbl2tex() generated file. > > > > ### *