Closed devillemereuil closed 4 years ago
Thanks for opening this issue! brm_multiple
will now accept lists of named lists as input to data2
.
I am attempting to implement use brm_multiple to sample from the distribution of the estimated variance-covariance matrix, perform the models and join the posterior distribution as op identified. However, I am struggling to translate my original brm model into a brm_multiple to do this.
Previously my code (as following vignette('brms_phylogenetics')): A <-ape::vcv.phylo(my_tree) mod1 <- brm( phen ~ cofactor + (1 | random) + (1 | gr(species_name, cov = A)) , data = data, family = bernoulli(), data2 = list(A = A), ... ) where data contains phen, cofactor, random and species_name, and A is a variance-covariance matrix from a phylo tree.
To run multiple imputations of trees now I have: mod_multiple<- brm_multiple( phen ~ cofactor + (1 | random) + (1 | gr(species_name, cov = my_tree_list)) , data = dataset_list, family = bernoulli(), data2 = my_tree_list, ... )
Where my_tree_list is a list of named lists of variance-covariance matrices created from different trees i.e. a list of list(A=A)from mod1 and dataset_lists is a list of the same dataset, length same as data2. However, this gives an Error: my_tree_list cannot be found in data2
I have also attempted data2 = list(A = list_of_vcvs) where list_of_vcvs is a list of the variance-covariance matrices rather than pre-converted into lists as above. This gives: error "data2" must be a kist of named lists.
However, this provides an error that my_tree_list cannot be found in data2 does anyone have any pointers as to what alterations I need to make to data2 or the gr(cov = A) part.
Thanks, Tom
Please avoid crossposting on github and discourse and ask questions on discourse. Github is reserved for bug reports and feature requests.
Context
The function
brm_multiple()
is useful to analyse multiple imputation of data. But sometimes, the covariance structure of random effects (as passed through thecov_ranef
argument) has itself been estimation with uncertainty. This is notoriously the case for phylogenetic comparative analyses, but can also be the case in quantitative genetics analysis and possibly also outside of my field. To account for such uncertainty in a Bayesian way, one can sample from the distribution of the estimated variance-covariance matrix, perform the models and join the posterior distribution. Thus,brm_multiple()
would be very efficient for this.Current limitations
In the current state, it doesn't seem possible to pass such a list of sampled matrices to
brm_multiple()
which would, at least, need to know how to handle lists of lists.Plan
@paul-buerkner offered the following plan: With the latest brms GitHub version, this actually came even closer in reach as
cov_ranef
is now implemented directly in theformula
interface in thecov
argument ofgr
. Enabling it inbrm_multiple()
then simply comes down to supporting lists of lists ofdata2
.