vcov method for class "btfit"

# S3 method for btfit
vcov(object, subset = NULL, ref = NULL, ...)

Arguments

object

An object of class "btfit", typically the result ob of ob <- btfit(..). See btfit.

subset

A condition for selecting one or more subsets of the components. This can either be a character vector of names of the components (i.e. a subset of names(object$pi)), a single predicate function (that takes a vector of object$pi as its argument), or a logical vector of the same length as the number of components, (i.e. length(object$pi)).

ref

A reference item. Either a string with the item name, or the number 1, or NULL. If NULL, then the coefficients are constrained such that their mean is zero. If an item name is given, the coefficient estimates are shifted so that the coefficient for the ref item is zero. If there is more than one component, the components that do not include the ref item will be treated as if ref = NULL. If ref = 1, then the first item of each component is made the reference item.

...

other arguments

Value

A square numeric matrix, which is a non-full-rank variance-covariance matrix for the estimates in coef(object, subset = subset, ref = ref); or a list of such matrices if object has more than one component. The rows and columns of the matrix (or matrices) are arranged in the same order as the object$pi vector(s). -#' @author David Firth, Ella Kaye

Details

N.B. this can be slow when there are a large number of items in any component.

See also

btfit, coef.btfit, summary.btfit

Examples

citations_btdata <- btdata(BradleyTerryScalable::citations) #' fit1 <- btfit(citations_btdata, 1) #' vcov(fit1) toy_df_4col <- codes_to_counts(BradleyTerryScalable::toy_data, c("W1", "W2", "D")) toy_btdata <- btdata(toy_df_4col) fit2a <- btfit(toy_btdata, 1) vcov(fit2a)
#> $`2` #> 3 x 3 sparse Matrix of class "dgCMatrix" #> player2 #> player1 Han Gal Fin #> Han 0.8299348 -0.1583918 -0.6715430 #> Gal -0.1583918 0.5891966 -0.4308048 #> Fin -0.6715430 -0.4308048 1.1023478 #> #> $`3` #> 4 x 4 sparse Matrix of class "dgCMatrix" #> player2 #> player1 Cyd Amy Ben Dan #> Cyd 0.98128004 -0.07839002 -0.5792022 -0.3236878 #> Amy -0.07839002 0.48866229 -0.2694660 -0.1408063 #> Ben -0.57920218 -0.26946596 0.8917219 -0.0430538 #> Dan -0.32368784 -0.14080631 -0.0430538 0.5075479 #>
vcov(fit2a, subset = function(x) length(x) > 3)
#> $`3` #> 4 x 4 sparse Matrix of class "dgCMatrix" #> player2 #> player1 Cyd Amy Ben Dan #> Cyd 0.98128004 -0.07839002 -0.5792022 -0.3236878 #> Amy -0.07839002 0.48866229 -0.2694660 -0.1408063 #> Ben -0.57920218 -0.26946596 0.8917219 -0.0430538 #> Dan -0.32368784 -0.14080631 -0.0430538 0.5075479 #>
vcov(fit2a, subset = function(x) "Cyd" %in% names(x))
#> $`3` #> 4 x 4 sparse Matrix of class "dgCMatrix" #> player2 #> player1 Cyd Amy Ben Dan #> Cyd 0.98128004 -0.07839002 -0.5792022 -0.3236878 #> Amy -0.07839002 0.48866229 -0.2694660 -0.1408063 #> Ben -0.57920218 -0.26946596 0.8917219 -0.0430538 #> Dan -0.32368784 -0.14080631 -0.0430538 0.5075479 #>
fit2b <- btfit(toy_btdata, 1.1) vcov(fit2b, ref = "Cyd")
#> 8 x 8 sparse Matrix of class "dgCMatrix" #> player2 #> player1 Eve Cyd Han Amy Gal Ben Dan Fin #> Eve 8.688958 . 8.688958 1.309503 8.688958 2.458541 2.002889 8.688958 #> Cyd . . . . . . . . #> Han 8.688958 . 17.644428 1.309503 16.025396 2.458541 2.002889 15.972397 #> Amy 1.309503 . 1.309503 1.628197 1.309503 1.365954 1.247476 1.309503 #> Gal 8.688958 . 16.025396 1.309503 16.134179 2.458541 2.002889 15.613713 #> Ben 2.458541 . 2.458541 1.365954 2.458541 2.995004 1.869082 2.458541 #> Dan 2.002889 . 2.002889 1.247476 2.002889 1.869082 2.149915 2.002889 #> Fin 8.688958 . 15.972397 1.309503 15.613713 2.458541 2.002889 17.329810