I assume the new data for both should be the same, the second one is the right one, hwever dataset_id___altered = NA is wrong as dataset is a grouping variable, not a covariate
mutate(brms_fit_adjusted_tissue = map(brms_fit, ~ .x |> remove_unwanted_effect(
newdata = .x$data |> mutate(assay_groups=NA, sex = NA, age_bin = NA, disease_groups = NA, ethnicity_groups = NA), # age_bin*sex + disease_groups + ethnicity_groups + assay_groups
robust = TRUE,
re_formula = ~ (1 | tissue_groups)
))) |>
mutate(brms_fit_adjusted_tissue_new = map(brms_fit, ~ .x |> remove_unwanted_effect_new(
newdata = .x$data |> mutate(assay_groups___altered=NA, ethnicity_groups = NA, sex = NA, age_bin = NA, disease_groups___altered = NA, dataset_id___altered = NA), # age_bin*sex + disease_groups + ethnicity_groups + assay_groups
robust = FALSE, correct_by_offset = FALSE,
re_formula = ~ (1 | tissue_groups)
))) |>
I assume the new data for both should be the same, the second one is the right one, hwever
dataset_id___altered = NAis wrong as dataset is a grouping variable, not a covariate