File: emmeans.R

package info (click to toggle)
r-cran-mclogit 0.9.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 328 kB
  • sloc: makefile: 2
file content (25 lines) | stat: -rw-r--r-- 891 bytes parent folder | download
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
## Added by Russel V. Lenth
### emmeans support for mblogit and mmblogit models

recover_data.mblogit <- function(object, ...) {
    rd <- get("recover_data.multinom", asNamespace("emmeans"))
    rd(object, ...)
}

emm_basis.mblogit <- function(object, trms, xlev, grid, 
                              mode = c("prob", "latent"), vcov., ...) {
    object$coefficients <- object$coefmat
    object$lev <- levels(object$model[[1]])
    object$edf <- Inf
    # we have to rearrange the vcov elements in row-major order
    if(missing(vcov.))
        vcov. <- vcov(object)
    perm <- matrix(seq_along(as.numeric(object$coefmat)), 
                  ncol = ncol(object$coefmat))
    perm <- as.numeric(t(perm))
    vcov. <- vcov.[perm, perm]
    emb <- get("emm_basis.multinom", asNamespace("emmeans"))
    emb(object, trms = trms, xlev = xlev, grid = grid, mode = mode, vcov. = vcov., ...)
}