Extract the Number of Observations from a GLARMA Model Fit

Results of the boat race between Oxford and Cambridge from 1829–2011.

1 |

A data frame containing the following columns:

[, 1] | Year | Year in which the race occurred. Some years are missing when the race was not run. |

[, 2] | Intercept | A vector of ones, providing the intercept in the model. |

[, 3] | Camwin | A binary response, zero for an Oxford win, one for a Cambridge win. |

[, 4] | WinnerWeight | Weight of winning team's crew. |

[, 5] | LoserWeight | Weight of losing team's crew. |

[, 6] | Diff | Difference between winning team's weight and losing team's weight. |

Klingenberg, Bernhard (2008) Regression models for binary time series
with gaps. *Computational Statistics & Data Analysis*,
**52**, 4076–4090.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ```
### Example with Oxford-Cambridge Boat Race
data(OxBoatRace)
y1 <- OxBoatRace$Camwin
n1 <- rep(1, length(OxBoatRace$Year))
Y <- cbind(y1, n1 - y1)
X <- cbind(OxBoatRace$Intercept, OxBoatRace$Diff)
colnames(X) <- c("Intercept", "Weight Diff")
oxcamglm <- glm(Y ~ Diff + I(Diff^2),
data = OxBoatRace,
family = binomial(link = "logit"), x = TRUE)
summary(oxcamglm)
X <- oxcamglm$x
glarmamod <- glarma(Y, X, thetaLags = c(1, 2), type = "Bin", method = "NR",
residuals = "Pearson", maxit = 100, grad = 1e-6)
summary(glarmamod)
likTests(glarmamod)
## Plot Probability of Cambridge win versus Cambridge Weight advantage:
beta <- coef(glarmamod, "beta")
par(mfrow = c(1, 1))
plot(OxBoatRace$Diff, 1 / (1 + exp(-(beta[1] + beta[2] * OxBoatRace$Diff +
beta[3] * OxBoatRace$Diff^2))),
ylab = "Prob", xlab = "Weight Diff")
title("Probability of Cambridge win \n versus Cambridge weight advantage")
## Residuals and fit plots
par(mfrow=c(3, 2))
plot.glarma(glarmamod)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.