Skip to contents

Besides print and summary methods there are also some standard extraction methods defined for objects of class "twinSIR": vcov, logLik and especially AIC and extractAIC, which extract Akaike's Information Criterion. Note that special care is needed, when fitting models with parameter constraints such as the epidemic effects \(\alpha\) in twinSIR models. Parameter constraints reduce the average increase in the maximized loglikelihood - thus the penalty for constrained parameters should be smaller than the factor 2 used in the ordinary definition of AIC. To this end, these two methods offer the calculation of the so-called one-sided AIC (OSAIC).


# S3 method for twinSIR
print(x, digits = max(3, getOption("digits") - 3), ...)
# S3 method for twinSIR
        correlation = FALSE, symbolic.cor = FALSE, ...)

# S3 method for twinSIR
AIC(object, ..., k = 2, one.sided = NULL, nsim = 1e3)
# S3 method for twinSIR
extractAIC(fit, scale = 0, k = 2, one.sided = NULL,
           nsim = 1e3, ...)

# S3 method for twinSIR
vcov(object, ...)
# S3 method for twinSIR
logLik(object, ...)

# S3 method for summary.twinSIR
      digits = max(3, getOption("digits") - 3), symbolic.cor = x$symbolic.cor,
      signif.stars = getOption("show.signif.stars"), ...)


x, object, fit

an object of class "twinSIR".
For the print method of the summary method, an object of class "summary.twinSIR".


integer, used for number formatting with signif(). Minimum number of significant digits to be printed in values.


logical. if TRUE, the correlation matrix of the estimated parameters is returned and printed.


logical. If TRUE, print the correlations in a symbolic form (see symnum) rather than as numbers.


For the summary method: arguments passed to extractAIC.twinSIR.
For the AIC method, optionally more fitted model objects.
For the print, extractAIC, vcov and logLik methods: unused (argument of the generic).


numeric specifying the "weight" of the penalty to be used; in an unconstrained fit k = 2 is the classical AIC.


logical or NULL (the default). Determines if the one-sided AIC should be calculated instead of using the classical penalty k*edf. The default value NULL chooses classical AIC in the case of an unconstrained fit and one-sided AIC in the case of constraints. The type of the fit can be seen in object$method (or fit$method respectively), where "L-BFGS" means constrained optimization.


when there are more than two epidemic covariates in the fit, the weights in the OSAIC formula have to be determined by simulation. Default is to use 1000 samples. Note that package quadprog is additionally required in this case.


unused (argument of the generic).


logical. If TRUE, “significance stars” are printed for each coefficient.


The print and summary methods allow the compact or comprehensive representation of the fitting results, respectively. The former only prints the original function call, the estimated coefficients and the maximum log-likelihood value. The latter prints the whole coefficient matrix with standard errors, z- and p-values (see printCoefmat), and additionally the number of infections per log-baseline interval, the (one-sided) AIC and the number of log-likelihood evaluations. They both append a big “WARNING”, if the optimization algorithm did not converge.

The estimated coefficients may be extracted by using the default coef-method from package stats.

The two AIC functions differ only in that AIC can take more than one fitted model object and that extractAIC always returns the number of parameters in the model (AIC only does with more than one fitted model object).

Concerning the choice of one-sided AIC: parameter constraints -- such as the non-negative constraints for the epidemic effects alpha in twinSIR models -- reduce the average increase in the maximized loglikelihood. Thus, the penalty for constrained parameters should be smaller than the factor 2 used in the ordinary definition of AIC. One-sided AIC (OSAIC) suggested by Hughes and King (2003) is such a proposal when \(p\) out of \(k = p + q\) parameters have non-negative constraints: $$OSAIC = -2 l(\theta, \tau) + 2 \sum_{g=0}^p w(p,g) (k-p+g)$$ where \(w(p,g)\) are \(p\)-specific weights. For more details see Section 5.2 in Höhle (2009).


The print methods return their first argument, invisibly, as they always should. The vcov and logLik

methods return the estimated variance-covariance matrix of the parameters (here, the inverse of the estimate of the expected Fisher information matrix), and the maximum log-likelihood value of the model, respectively. The summary method returns a list containing some summary statistics of the fitted model, which is nicely printed by the corresponding print method. For the AIC and extractAIC methods, see the documentation of the corresponding generic functions.


Hughes A, King M (2003) Model selection using AIC in the presence of one-sided information. Journal of Statistical Planning and Inference 115, pp. 397--411.

Höhle, M. (2009), Additive-Multiplicative Regression Models for Spatio-Temporal Epidemics, Biometrical Journal, 51(6):961-978.


Michael Höhle and Sebastian Meyer



# a simplistic twinSIR model
fit <- twinSIR(~ household + cox(AGE), data = hagelloch)


summary(fit, correlation = TRUE, symbolic.cor = TRUE)

AIC(fit, one.sided = FALSE)
extractAIC(fit, one.sided = FALSE)

# comparing models via AIC
fit2 <- update(fit, nIntervals = 2)
AIC(fit, fit2)   # the 2nd column should be named "OSAIC" here