Skip to content

Commit

Permalink
Fixed prediction method also for mmclogit objects
Browse files Browse the repository at this point in the history
  • Loading branch information
melff committed Jan 10, 2021
1 parent bf55b35 commit cc40a71
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: mclogit
Type: Package
Title: Multinomial Logit Models, with or without Random Effects or Overdispersion
Version: 0.8.7
Date: 2020-12-23
Version: 0.8.7.1
Date: 2021-01-10
Author: Martin Elff
Maintainer: Martin Elff <[email protected]>
Description: Provides estimators for multinomial logit models in their
Expand Down
15 changes: 7 additions & 8 deletions pkg/R/mclogit.R
Original file line number Diff line number Diff line change
Expand Up @@ -727,20 +727,19 @@ predict.mmclogit <- function(object, newdata=NULL,type=c("link","response"),se.f
contrasts.arg=object$contrasts,
xlev=object$xlevels
)
groups <- random$groups
orig.groups <- object$groups
olevels <- lapply(orig.groups,levels)
groups <- mf[groups]
groups <- lapply(groups,as.integer)
groups <- Map(factor,x=groups,levels=olevels)
nlev <- length(groups)
if(nlev > 1){
for(i in 2:nlev){
mm <- attr(all.groups[[i]],"unique")
mmm <- cumprod(mm)
groups[[i]] <- mmm[i]*groups[[i-1]]+groups[[i]]
groups[[i]] <- interaction(groups[c(i-1,i)])
}
}
Z <- Map(mkZ2,
all.groups=all.groups,
groups=groups,
rX=list(Z))
Z <- lapply(groups,mkZ,
rX=Z)
Z <- blockMatrix(Z)

random.effects <- object$random.effects
Expand Down
3 changes: 3 additions & 0 deletions pkg/inst/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2021-01-10:
- Fixed prediction method also for mmclogit objects

2020-12-23:
- Refactored computations
- Fixed predictions from random-effects models where group indices are not
Expand Down

0 comments on commit cc40a71

Please sign in to comment.