R version 4.5.0 beta (2025-03-27 r88065 ucrt) -- "How About a Twenty-Six" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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 an HTML browser interface to help. Type 'q()' to quit R. > ### model.frame > ### glm example > require(MASS) Loading required package: MASS > data(Insurance) > glmmod <- glm(Claims ~ District + Group + Age + offset(log(Holders)), + data = Insurance, family = poisson) > head(model.frame(glmmod)) Claims District Group Age offset(log(Holders)) 1 38 1 <1l <25 5.283204 2 35 1 <1l 25-29 5.575949 3 20 1 <1l 30-35 5.505332 4 156 1 <1l >35 7.426549 5 63 1 1-1.5l <25 5.648974 6 84 1 1-1.5l 25-29 6.284134 > ### glarma example > require(glarma) Loading required package: glarma > data(DriverDeaths) > y <- DriverDeaths[, "Deaths"] > X <- as.matrix(DriverDeaths[, 2:5]) > Population <- DriverDeaths[, "Population"] > > ### No ARMA component > glarmamodNoARMA <- glarma(y, X, offset = log(Population/100000), + type = "Poi", method = "FS", + residuals = "Pearson", maxit = 100, grad = 1e-6) > head(model.frame(glarmamodNoARMA)) y Intercept ReducedBAC FriSat lnOMVDRate (offset) 1 1 1 0 10 0.4382549 2.126394 2 4 1 0 8 0.1739533 2.128411 3 4 1 0 9 0.6418539 2.130338 4 4 1 0 9 0.6418539 2.132301 5 3 1 0 8 0.5766134 2.134175 6 3 1 0 10 0.6981347 2.136085 > glmmod <- glm(y ~ X - 1, offset = log(Population/100000), + family = poisson) > head(model.frame(glmmod)) y X.Intercept X.ReducedBAC X.FriSat X.lnOMVDRate (offset) 1 1 1.0000000 0.0000000 10.0000000 0.4382549 2.126394 2 4 1.0000000 0.0000000 8.0000000 0.1739533 2.128411 3 4 1.0000000 0.0000000 9.0000000 0.6418539 2.130338 4 4 1.0000000 0.0000000 9.0000000 0.6418539 2.132301 5 3 1.0000000 0.0000000 8.0000000 0.5766134 2.134175 6 3 1.0000000 0.0000000 10.0000000 0.6981347 2.136085 > summary(glarmamodNoARMA) Call: glarma(y = y, X = X, offset = log(Population/1e+05), type = "Poi", method = "FS", residuals = "Pearson", maxit = 100, grad = 1e-06) Pearson Residuals: Min 1Q Median 3Q Max -1.7324 -0.7636 0.1172 0.6009 3.6566 Linear Model Coefficients: Estimate Std.Error z-ratio Pr(>|z|) Intercept -2.14983 0.82072 -2.619 0.00881 ** ReducedBAC -0.39052 0.16018 -2.438 0.01477 * FriSat 0.08873 0.09244 0.960 0.33710 lnOMVDRate 0.55427 0.23248 2.384 0.01712 * Null deviance: 95.499 on 71 degrees of freedom Residual deviance: 67.318 on 68 degrees of freedom AIC: 260.3531 Number of Fisher Scoring iterations: 1 LRT and Wald Test: Alternative hypothesis: model is a GLARMA process Null hypothesis: model is a GLM with the same regression structure Statistic p-value LR Test 0 1 Wald Test 0 1 > summary(glmmod) Call: glm(formula = y ~ X - 1, family = poisson, offset = log(Population/1e+05)) Coefficients: Estimate Std. Error z value Pr(>|z|) XIntercept -2.14983 0.82072 -2.619 0.00881 ** XReducedBAC -0.39052 0.16018 -2.438 0.01477 * XFriSat 0.08873 0.09244 0.960 0.33710 XlnOMVDRate 0.55427 0.23248 2.384 0.01712 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 585.479 on 72 degrees of freedom Residual deviance: 79.097 on 68 degrees of freedom AIC: 260.35 Number of Fisher Scoring iterations: 5 > print(glarmamodNoARMA) Call: glarma(y = y, X = X, offset = log(Population/1e+05), type = "Poi", method = "FS", residuals = "Pearson", maxit = 100, grad = 1e-06) Linear Model Coefficients: Intercept ReducedBAC FriSat lnOMVDRate -2.14983471 -0.39051857 0.08872983 0.55427460 Degrees of Freedom: 71 Total (i.e. Null); 68 Residual Null Deviance: 95.49879 Residual Deviance: 67.31763 AIC: 260.3531 > print(glmmod) Call: glm(formula = y ~ X - 1, family = poisson, offset = log(Population/1e+05)) Coefficients: XIntercept XReducedBAC XFriSat XlnOMVDRate -2.14983 -0.39052 0.08873 0.55427 Degrees of Freedom: 72 Total (i.e. Null); 68 Residual Null Deviance: 585.5 Residual Deviance: 79.1 AIC: 260.4 > > ### No offset > glarmamod <- glarma(y, X, phiLags = c(12), + type = "Poi", method = "FS", + residuals = "Pearson", maxit = 100, grad = 1e-6) > head(model.frame(glarmamod)) y Intercept ReducedBAC FriSat lnOMVDRate 1 1 1 0 10 0.4382549 2 4 1 0 8 0.1739533 3 4 1 0 9 0.6418539 4 4 1 0 9 0.6418539 5 3 1 0 8 0.5766134 6 3 1 0 10 0.6981347 > > ### Offset included > glarmamodOffset <- glarma(y, X, offset = log(Population/100000), + phiLags = c(12), + type = "Poi", method = "FS", + residuals = "Pearson", maxit = 100, grad = 1e-6) > head(model.frame(glarmamodOffset)) y Intercept ReducedBAC FriSat lnOMVDRate (offset) 1 1 1 0 10 0.4382549 2.126394 2 4 1 0 8 0.1739533 2.128411 3 4 1 0 9 0.6418539 2.130338 4 4 1 0 9 0.6418539 2.132301 5 3 1 0 8 0.5766134 2.134175 6 3 1 0 10 0.6981347 2.136085 > > ### summary > summary(glmmod) Call: glm(formula = y ~ X - 1, family = poisson, offset = log(Population/1e+05)) Coefficients: Estimate Std. Error z value Pr(>|z|) XIntercept -2.14983 0.82072 -2.619 0.00881 ** XReducedBAC -0.39052 0.16018 -2.438 0.01477 * XFriSat 0.08873 0.09244 0.960 0.33710 XlnOMVDRate 0.55427 0.23248 2.384 0.01712 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 585.479 on 72 degrees of freedom Residual deviance: 79.097 on 68 degrees of freedom AIC: 260.35 Number of Fisher Scoring iterations: 5 > summary(glarmamodOffset) Call: glarma(y = y, X = X, offset = log(Population/1e+05), type = "Poi", method = "FS", residuals = "Pearson", phiLags = c(12), maxit = 100, grad = 1e-06) Pearson Residuals: Min 1Q Median 3Q Max -1.7016 -0.7951 0.1192 0.5898 3.7190 GLARMA Coefficients: Estimate Std.Error z-ratio Pr(>|z|) phi_12 -0.03379 0.08994 -0.376 0.707 Linear Model Coefficients: Estimate Std.Error z-ratio Pr(>|z|) Intercept -2.13517 0.80601 -2.649 0.00807 ** ReducedBAC -0.38594 0.15610 -2.472 0.01342 * FriSat 0.08662 0.09086 0.953 0.34043 lnOMVDRate 0.55724 0.22975 2.425 0.01529 * Null deviance: 95.499 on 71 degrees of freedom Residual deviance: 67.556 on 67 degrees of freedom AIC: 262.1928 Number of Fisher Scoring iterations: 12 LRT and Wald Test: Alternative hypothesis: model is a GLARMA process Null hypothesis: model is a GLM with the same regression structure Statistic p-value LR Test 0.160 0.689 Wald Test 0.141 0.707 > summary(glarmamod) Call: glarma(y = y, X = X, type = "Poi", method = "FS", residuals = "Pearson", phiLags = c(12), maxit = 100, grad = 1e-06) Pearson Residuals: Min 1Q Median 3Q Max -1.6890 -0.7972 0.1085 0.6110 3.6885 GLARMA Coefficients: Estimate Std.Error z-ratio Pr(>|z|) phi_12 -0.03347 0.09039 -0.37 0.711 Linear Model Coefficients: Estimate Std.Error z-ratio Pr(>|z|) Intercept 0.02327 0.80685 0.029 0.9770 ReducedBAC -0.33442 0.15625 -2.140 0.0323 * FriSat 0.08667 0.09093 0.953 0.3405 lnOMVDRate 0.55127 0.22998 2.397 0.0165 * Null deviance: 93.273 on 71 degrees of freedom Residual deviance: 67.359 on 67 degrees of freedom AIC: 262.0302 Number of Fisher Scoring iterations: 12 LRT and Wald Test: Alternative hypothesis: model is a GLARMA process Null hypothesis: model is a GLM with the same regression structure Statistic p-value LR Test 0.157 0.692 Wald Test 0.137 0.711 > > ### print > print(glmmod) Call: glm(formula = y ~ X - 1, family = poisson, offset = log(Population/1e+05)) Coefficients: XIntercept XReducedBAC XFriSat XlnOMVDRate -2.14983 -0.39052 0.08873 0.55427 Degrees of Freedom: 72 Total (i.e. Null); 68 Residual Null Deviance: 585.5 Residual Deviance: 79.1 AIC: 260.4 > print(glarmamodOffset) Call: glarma(y = y, X = X, offset = log(Population/1e+05), type = "Poi", method = "FS", residuals = "Pearson", phiLags = c(12), maxit = 100, grad = 1e-06) GLARMA Coefficients: phi_12 -0.03379462 Linear Model Coefficients: Intercept ReducedBAC FriSat lnOMVDRate -2.1351716 -0.3859354 0.0866179 0.5572363 Degrees of Freedom: 71 Total (i.e. Null); 67 Residual Null Deviance: 95.49879 Residual Deviance: 67.55618 AIC: 262.1928 > print(glarmamod) Call: glarma(y = y, X = X, type = "Poi", method = "FS", residuals = "Pearson", phiLags = c(12), maxit = 100, grad = 1e-06) GLARMA Coefficients: phi_12 -0.03346743 Linear Model Coefficients: Intercept ReducedBAC FriSat lnOMVDRate 0.02327398 -0.33441992 0.08666815 0.55127101 Degrees of Freedom: 71 Total (i.e. Null); 67 Residual Null Deviance: 93.27293 Residual Deviance: 67.35896 AIC: 262.0302 > > ### coef > coef(glmmod) XIntercept XReducedBAC XFriSat XlnOMVDRate -2.14983471 -0.39051857 0.08872983 0.55427460 > coef(glarmamodOffset) $ARMA phi_12 -0.03379462 $beta Intercept ReducedBAC FriSat lnOMVDRate -2.1351716 -0.3859354 0.0866179 0.5572363 > coef(glarmamod) $ARMA phi_12 -0.03346743 $beta Intercept ReducedBAC FriSat lnOMVDRate 0.02327398 -0.33441992 0.08666815 0.55127101 > > > > > > > proc.time() user system elapsed 0.51 0.12 0.57