Open sbfnk opened 1 year ago
As pointed out by @pratikunterwegs in https://github.com/epiverse-trace/cfr/issues/107#issuecomment-1818517559 the first task also be performed using base R:
sim_data <- rnorm(50, 4, 2)
log_l <- function(par) -sum(dnorm(sim_data, par[1], par[2], log = TRUE))
x <- optim(c(3, 1), log_l, hessian = TRUE)
x$par
#> [1] 3.998069 1.957719
prop_sigma <- sqrt(diag(solve(x$hessian)))
ci <- matrix(x$par, nrow = 2, ncol = 2, byrow = TRUE) +
1.96 * c(1, -1) %*% t(prop_sigma)
ci
#> [,1] [,2]
#> [1,] 4.540720 2.341556
#> [2,] 3.455417 1.573881
Created on 2023-11-20 with reprex v2.0.2
Thanks. Although does that assume likelihood surface is normally distributed (or can be approximated by one), i.e. the 1.96 * c(1, -1)
line. Seems like would be useful to have ability to generate profile (i.e. by finding points 1.92 from MLE by refitting across the range of values of parameter of interest) rather than relying on marginals or normal approximations?
Actually this distinction might be a useful point to make in a vignette somewhere (e.g. epichains, where R and k may be correlated, and hence marginal would give overconfident estimates)
Some of the functionality as outlined in the README of the
init_setup
branch already exists in some form elsewhere - it might be worth adding a note for the specific use case the package aiming to address.Created on 2023-11-20 with reprex v2.0.2