Closed GidonFrischkorn closed 1 month ago
An idea of the function:
tidy_M3 <- function(
.data,
responses,
group = NULL,
) {
# Add response column to group
new_group = c(group, "response")
# Aggregate responses
data_output <- .data %>%
select(all_of(responses), all_of(group)) %>%
pivot_longer(cols = all_of(responses), names_to = "response", values_to = "value") %>%
summarise(
Resp = sum(value, na.rm = TRUE),
.by = all_of(new_group)) %>%
mutate(
{{nDV_name}} := sum(Resp, na.rm = TRUE),
.by = all_of(group)) %>%
pivot_wider(names_from = response, values_from = Resp)
return(data_output)
}
This function should be applicable to all multinomial distribution data: https://github.com/chenyu-psy/smartr/blob/main/R/agg_multinomial.R
For now, I have decided not to implement this only for the m3
, but I have created a discussion in the bmm
repository: #236
This function should take the
bmmodel
and thebmmformula
and then aggregate the data to optimize model estimation. This will speed up model estimation for allbmmodel
that do not need to fit trial wise data