MaStatLab / LTN

Other
2 stars 1 forks source link

fit and predict #1

Open mmp3 opened 3 years ago

mmp3 commented 3 years ago

Hi!

Thank you for creating this R package. How do you use the functions to fit a model and then predict on new data?

Thank you!

ZhuoqunWang0120 commented 3 years ago

Hi,

Thanks for the questions.

  1. To fit LTN to exchangeable samples and obtain posterior samples of $\mu$ and $\Omega$, use gibbs_ltn. You will need to input your data and specify the number of Gibbs iterations. gibbs_ltn allows two forms of input data:

    • A phyloseq object that at least contains an OTU table and the corresponding phylogenetic tree. In this case, set the data parameter to the phyloseq object.
    • Two matrices Y and YL, where Y[i,j]=total counts of all descendant OTUs of node j in sample i, and YL[i,j]=total counts of all descendant OTUs of the left child of node j in sample i.

    You only need to specify either data or Y and YL.

    Details of other parameters can be found in the documentation of this function.

    The output is a list of posterior samples of $\mu$ and $\Omega$, the population mean and precision matrix.

  2. To fit the mixed-effects model for two-group comparison, for example on a longitudinal dataset, use ltnme. The parameters are similar to those of gibbs_ltn and details can be found in the documentation of this function. The output consists of four parts:

    • gibbs_samples
    • PJAP: the posterior joint probability of existence of cross-group difference
    • PMAP: the posterior probability of existence of cross-group difference at each node
    • alpha_mean: posterior mean of $\alpha$, defined as alpha[j]=difference of the log-odds at node j between the two groups.

You can find some examples on these two functions here.

Regarding prediction, we did not specifically implement functions for this task. Could you be more specific on what you want to predict? If you want posterior predictive samples of the OTU counts in the case 1 above, it can be generated from the output of gibbs_ltn. Otherwise it might be more complicated both in the sense of coding and modelling.