Description Usage Format Source Examples
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)
|
Call:
glm(formula = Y ~ Diff + I(Diff^2), family = binomial(link = "logit"),
data = OxBoatRace, x = TRUE)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4850 -1.2109 0.8953 1.0055 1.9305
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.382472 0.202334 1.89 0.05872 .
Diff 0.114623 0.037331 3.07 0.00214 **
I(Diff^2) -0.010097 0.004855 -2.08 0.03756 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 216.16 on 155 degrees of freedom
Residual deviance: 198.62 on 153 degrees of freedom
AIC: 204.62
Number of Fisher Scoring iterations: 5
Call: glarma(y = Y, X = X, type = "Bin", method = "NR", residuals = "Pearson",
thetaLags = c(1, 2), maxit = 100, grad = 1e-06)
Pearson Residuals:
Min 1Q Median 3Q Max
-1.8865 -0.7968 0.4395 0.8436 2.9658
GLARMA Coefficients:
Estimate Std.Error z-ratio Pr(>|z|)
theta_1 0.3396 0.1709 1.987 0.046975 *
theta_2 0.5552 0.1459 3.804 0.000142 ***
Linear Model Coefficients:
Estimate Std.Error z-ratio Pr(>|z|)
(Intercept) 0.349954 0.267249 1.309 0.19038
Diff 0.114755 0.038238 3.001 0.00269 **
I(Diff^2) -0.011333 0.004916 -2.305 0.02114 *
Null deviance: 216.16 on 155 degrees of freedom
Residual deviance: 148.53 on 151 degrees of freedom
AIC: 193.0553
Number of Newton Raphson iterations: 5
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 15.56 0.000417 ***
Wald Test 17.51 0.000158 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Statistic p-value
LR Test 15.564 0.0004173 ***
Wald Test 17.510 0.0001577 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.