From 2ab7cc3e1aa182b41bed37111ebf7d8541452cc8 Mon Sep 17 00:00:00 2001 From: Ben Bolker Date: Fri, 26 Apr 2024 10:34:00 -0400 Subject: [PATCH] fix Gamma simulation (#782, still needs test) --- R/predict.R | 2 +- inst/NEWS.Rd | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/R/predict.R b/R/predict.R index 8ec62139..4bd2840b 100644 --- a/R/predict.R +++ b/R/predict.R @@ -935,7 +935,7 @@ Gamma_simfun <- function(object, nsim, ftd=fitted(object), if (any(wts != 1)) message("using weights to scale shape parameter") ## used to use gamma.shape(), but sigma() is more general ## (wouldn't work *outside* of the merMod context though) - shape <- sigma(object)*wts + shape <- 1/sigma(object)^2*wts rgamma(nsim*length(ftd), shape = shape, rate = shape/ftd) } diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 6e8e0b56..9a663754 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -9,9 +9,10 @@ \itemize{ \item \code{predict(., re.form=...)} works in a wider range of cases (GH #691) + \item Gamma simulation now uses correct shape parameter (GH #782) } } % bug fixes -} % 1.1-35.3 +} % 1.1-35.9000 \section{CHANGES IN VERSION 1.1-35.3 (2024-04-16)}{ \subsection{BUG FIXES}{