-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I've got the following reprex which appears to be returning a slightly different likelihood for AD inputs. From some basic testing, the individual components appear consistent but their combination diverges:
set.seed(2024)
L <- chol(matrix(c(1, 0.5, 0.5, 1), nrow = 2))
z <- matrix(rnorm(1000), ncol = 2) %*% L
y <- qexp(pnorm(z, log.p = TRUE), rate = 2, log.p = TRUE)
library(RTMB)
ll_function <- function(pars) {
q <- qnorm(pexp(y, rate = pars[1]))
Sigma <- matrix(c(1, pars[2], pars[2], 1), nrow = 2)
sum(RTMB::dmvnorm(q, Sigma = Sigma, log = TRUE))
}
obj <- MakeADFun(
func = function(pars) ll_function(pars$v),
parameters = list(v = c(0.1,0.5)),
silent=TRUE
)
obj$fn(c(0.1,0.5))
#> [1] -2177.436
ll_function(c(0.1,0.5))
#> [1] -2127.248Created on 2025-10-16 with reprex v2.1.1
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.5.1 (2025-06-13 ucrt)
os Windows 11 x64 (build 26100)
system x86_64, mingw32
ui RStudio
language (EN)
collate English_Australia.utf8
ctype English_Australia.utf8
tz Australia/Perth
date 2025-10-16
rstudio 2025.09.1+401 Cucumberleaf Sunflower (desktop)
pandoc 3.6.3 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
lattice 0.22-7 2025-04-02 [2] CRAN (R 4.5.1)
MASS 7.3-65 2025-02-28 [2] CRAN (R 4.5.1)
Matrix 1.7-4 2025-08-28 [1] CRAN (R 4.5.1)
Rcpp 1.1.0 2025-07-02 [1] CRAN (R 4.5.1)
RcppEigen 0.3.4.0.2 2024-08-24 [1] CRAN (R 4.5.1)
RTMB 1.8 2025-10-16 [1] Github (kaskr/RTMB@aab2fb7)
TMB 1.9.18 2025-10-13 [1] CRAN (R 4.5.1)
[1] C:/Users/Andrew/AppData/Local/R/win-library/4.5
[2] C:/Program Files/R/R-4.5.1/library
Metadata
Metadata
Assignees
Labels
No labels