ggPMX icon indicating copy to clipboard operation
ggPMX copied to clipboard

Review Irina: Add correlations in parameter table

Open baltcir1 opened this issue 3 years ago • 1 comments

We miss correlations in the parameter table (v 1.2.6). This needs to be added.

baltcir1 avatar Feb 15 '22 13:02 baltcir1

And residual variability of PD in case controller is for PK and vice-versa. Below is the code to be used:

# Retrieve Parameter Table from the controller
pop_pars = ctr %>% get_data('estimates')

shrinkage <- ctr %>% pmx_comp_shrink() %>%
  mutate(SHRINK=paste0(round(SHRINK*100),'%')) %>%
  mutate(PARAM=paste0('omega_',EFFECT)) %>%
  select(PARAM,SHRINK)

pop_pars2 <- pop_pars %>%
  mutate(VALUE=as.character(signif(VALUE,3)),RSE=paste0(round(RSE),'%')) %>%
  #mutate(VALUE=paste0(VALUE,' (',RSE,')')) %>%
  select(PARAM,VALUE,RSE) %>%
  arrange(PARAM) %>% left_join(shrinkage) %>%
  mutate(SHRINK=ifelse(is.na(SHRINK),'',SHRINK))

pop_pars3 <- data.frame(PARAM='Structural parameters',VALUE='',RSE='',SHRINK='') %>%
bind_rows(pop_pars2 %>% filter(grepl('pop',PARAM))) %>%
bind_rows(data.frame(
  PARAM='Between-subject variability, standard deviations',VALUE='',RSE='',SHRINK='')
) %>%
  bind_rows(pop_pars2 %>% filter(grepl('omega',PARAM))) %>%
  bind_rows(data.frame(PARAM='Covariate effects',VALUE='',RSE='',SHRINK='')) %>%
  bind_rows(pop_pars2 %>% filter(grepl('beta_',PARAM))) %>%
  bind_rows(data.frame(PARAM='Correlations',VALUE='',RSE='',SHRINK='')) %>%
  bind_rows(pop_pars2 %>% filter(grepl('corr_',PARAM))) %>%
  bind_rows(data.frame(PARAM='Residual variability', VALUE='', RSE='',SHRINK='')) %>%
    # here we need flexibility because it will depend on the model
  bind_rows(pop_pars2 %>% filter(PARAM %in% c('a','b'))  
)

pop_pars3 %>%
kable(
  col.names = c("Parameter", "Value", "RSE", "Shrinkage"),
  caption=paste0('Parameter estimates (',nrow(pop_pars3)+1,' lines)')
)

ggPMXdevelopment avatar Apr 07 '22 09:04 ggPMXdevelopment