We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
predict.mmblogit()
random
I'm not 100% sure, but I think line
mclogit/pkg/R/mblogit.R
Line 872 in dadb418
data(VA, package = "MASS") ngrp <- 8L VA$grp <- gl(n = ngrp, k = floor(nrow(VA) / ngrp), length = nrow(VA), labels = paste0("gr", seq_len(ngrp))) set.seed(2643) VA$grp <- sample(VA$grp) nsbj <- 13L VA$sbj <- gl(n = nsbj, k = floor(nrow(VA) / nsbj), length = nrow(VA), labels = paste0("subj", seq_len(nsbj))) VA$sbj <- sample(VA$sbj) fit_multi <- mclogit::mblogit(cell ~ treat + age + Karn, random = list(~ 1 | sbj, ~ 1 | grp), data = VA) VA_new <- head(VA, 1) VA_new$sbj <- "subj1" VA_new$grp <- "gr1" lpreds_multi <- predict(fit_multi, newdata = VA_new) # Manual check: VA_new$treat2 <- as.numeric(VA_new$treat == "2") fixnms_b <- c("treat2", "age", "Karn") nlats <- nlevels(VA$cell) - 1L mfixef <- fit_multi$coefmat mranef <- setNames(fit_multi$random.effects, names(fit_multi$groups)) # Actual result: lpreds_multi_man <- matrix(mfixef[, "(Intercept)"], nrow = nrow(VA_new), ncol = nlats, byrow = TRUE) + as.matrix(VA_new[, fixnms_b, drop = FALSE]) %*% t(mfixef[, fixnms_b]) + t(mranef$sbj[1:3, ]) all.equal(unname(lpreds_multi), unname(lpreds_multi_man), tolerance = 1e-15) ## --> Gives TRUE. # Expected result: lpreds_multi_man_expect <- lpreds_multi_man + t(mranef$grp[1:3, ]) all.equal(unname(lpreds_multi), unname(lpreds_multi_man_expect), tolerance = 1e-15) ## --> Gives "Mean relative difference: 0.2396385". # After commenting line `ZD <- blockMatrix(ZD)` in mclogit:::predict.mmblogit() and # running lpreds_multi <- predict(fit_multi, newdata = VA_new) # I get all.equal(unname(lpreds_multi), unname(lpreds_multi_man), tolerance = 1e-15) ## --> Gives "Mean relative difference: 0.2759492". # and all.equal(unname(lpreds_multi), unname(lpreds_multi_man_expect), tolerance = 1e-15) ## --> Gives TRUE. # as expected.
EDIT: I was using mclogit version 0.9.4.1 (at commit dadb418) for this.
The text was updated successfully, but these errors were encountered:
Thanks for the report and the vigorous testing. I'll see to it ASAP.
Sorry, something went wrong.
This appears to be fixed in release 0.9.4.2
Incorporate the fix for mclogit issue 24 (melff/mclogit#24).
4351a8d
Yes, I can confirm this. Thank you!
No branches or pull requests
I'm not 100% sure, but I think line
mclogit/pkg/R/mblogit.R
Line 872 in dadb418
EDIT: I was using mclogit version 0.9.4.1 (at commit dadb418) for this.
The text was updated successfully, but these errors were encountered: