Skip to content
New issue

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

Simulate new init fix #1008

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion glmmTMB/DESCRIPTION
@@ -1,6 +1,6 @@
Package: glmmTMB
Title: Generalized Linear Mixed Models using Template Model Builder
Version: 1.1.9
Version: 1.1.9-9000
Authors@R: c(person("Mollie","Brooks",
comment=c(ORCID="0000-0001-6963-8326"),
role = c("aut", "cre"),
Expand Down
6 changes: 4 additions & 2 deletions glmmTMB/R/utils.R
Expand Up @@ -654,8 +654,10 @@ simulate_new <- function(object,
form <- object
form[[3]] <- form[[2]]
form[[2]] <- quote(..y)
## insert a legal value: 1.0 is OK as long as family != "beta_family"
newdata[["..y"]] <- if (family$family == "beta_family") 0.5 else 1.0
## insert a legal value: 1.0 is OK as long as family != "beta"
## (note the family *function* is 'beta_family' but the internal
## $family value is 'beta')
newdata[["..y"]] <- if (family$family == "beta") 0.5 else 1.0
r1 <- glmmTMB(form,
data = newdata,
family = family,
Expand Down
12 changes: 10 additions & 2 deletions glmmTMB/inst/NEWS.Rd
Expand Up @@ -4,7 +4,15 @@
\title{glmmTMB News}
\encoding{UTF-8}

\section{CHANGES IN VERSION 1.1.9}{
\section{CHANGES IN VERSION 1.1.9-9000}{
\subsection{BUG FIXES}{
\itemize{
\item fixed bug in \code{simulate_new} for \code{family = "beta_family")
}
} % bug fixes
} % 1.1.9-9000

\section{CHANGES IN VERSION 1.1.9 (2024-03-20)}{
\subsection{USER-VISIBLE CHANGES}{
\itemize{
\item the underlying parameterization of the dispersion for
Expand Down Expand Up @@ -52,7 +60,7 @@
attributes (GH #977)
} % itemize
} % bug fixes
} % 1.1.8-9000
} % 1.1.9

\section{CHANGES IN VERSION 1.1.8 (2023-10-07)}{
\subsection{NEW FEATURES}{
Expand Down
13 changes: 13 additions & 0 deletions glmmTMB/tests/testthat/test-methods.R
Expand Up @@ -660,6 +660,19 @@ test_that("de novo simulation error checking", {
"unmatched parameter names: junk")
})

test_that("good simulate_new response values for beta", {
data("sleepstudy", package = "lme4")
ss <- simulate_new(
~ Days + (Days | Subject),
newdata = sleepstudy,
newparams = list(beta = c(-1, 0.1),
theta = c(-1, -1, 0),
betad = 10),
family = "beta_family",
seed = 101)
expect_equal(head(ss[[1]], 3),
c(0.246573218210702, 0.309824346705961, 0.367484246522732))
})

test_that("weighted residuals", {
set.seed(101)
Expand Down