Skip to content

Commit

Permalink
update approach to handling formulas
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Nov 25, 2024
1 parent 8155ab9 commit aabcfeb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
23 changes: 18 additions & 5 deletions R/latent_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,26 @@ epidist_gen_log_lik_latent <- function(family) {
#' @export
epidist_formula_model.epidist_latent_model <- function(
data, formula, ...) {
# data is only used to dispatch on
# Update main formula
formula <- stats::update(
formula, delay | vreal(relative_obs_time, pwindow, swindow) +
vint(woverlap, noverlap) ~ .,
pwindow ~ 0 + as.factor(.row_id),
swindow ~ 0 + as.factor(.row_id)
formula, delay | vreal(relative_obs_time, pwindow, swindow) ~ .
)

# Only update pwindow/swindow formulas if intercept only
fixed_dpars <- names(formula$pfix)
formula_dpars <- names(formula$pforms)

# Check if pwindow needs updating
if (!("pwindow" %in% fixed_dpars) ||
identical(formula_dpars$pwindow, as.formula("pwindow ~ 1"))) {
formula$pforms$pwindow <- as.formula("pwindow ~ 0 + as.factor(.row_id)")
}

# Check if swindow needs updating
if (!("swindow" %in% fixed_dpars) ||
identical(formula_dpars$swindow, as.formula("swindow ~ 1"))) {
formula$pforms$swindow <- as.formula("swindow ~ 0 + as.factor(.row_id)")
}
return(formula)
}

Expand Down
7 changes: 0 additions & 7 deletions inst/stan/latent_model/tparameters.stan

This file was deleted.

0 comments on commit aabcfeb

Please sign in to comment.