hturner / BradleyTerry2

BradleyTerry2 package for Bradley-Terry models in R
18 stars 0 forks source link

anova fails on terms with inestimable parameters #15

Open hturner opened 2 years ago

hturner commented 2 years ago

Potential fixes

# correction to anova.BTm to allow for NA coefficients
ok <- !is.na(coef(object))
ind <- varseq[ok] == nvars
trystat <- try(t(coef(object)[ok][ind]) %*% 
                 chol2inv(chol(object$varFix[ind, ind])) %*% 
                 coef(object)[ok][ind], silent = TRUE)

# similar in anova.BTmlist
ok <- !is.na(coef(object[[bigger]]))
ind <- object[[bigger]]$assign[ok] %in% which(term.ind)
stat[i] <- t(coef(object[[bigger]])[ok][ind]) %*% 
             chol2inv(chol(vcov(object[[bigger]], 
                                dispersion = dispersion)[ind, ind])) %*% 
             coef(object[[bigger]])[ok][ind]

Should names of vcov match names of coef?