GraphicsPredictionBPBM: Plots the time series

View source: R/GraphicsPredictionBPBM.R

GraphicsPredictionBPBMR Documentation

Plots the time series

Description

This function takes into account the data used to estimate and the data used to predict. We use this function when we want to observe the results obtained with the BPBM model.

Usage

GraphicsPredictionBPBM(
  especie.All,
  names.especie,
  ExpectedValue.All,
  VarianceValue.All,
  Pred,
  Plot.Tipe,
  Varmas,
  Varmenos,
  Detail
)

Arguments

especie.All

Matrix that contains at row i the bacterial taxa of bacteria i at all time points.

names.especie

Vector with the names of the bacteria in the same order that are placed in the especie matrix.

ExpectedValue.All

Matrix that contains at row i the expected value of the bacterial taxa i at all time points. The bacteria must be placed in the same order than in especie. This matrix must comply: dim(ExpectedValue.All)[2]=dim(especie.All)[2]-1

VarianceValue.All

Matrix that contains at row i the variance of the bacterial taxa i at all time points. The bacteria must be placed in the same order than in especie.This matrix must comply: dim(VarianceValue.All)[2]=dim(especie.All)[2]-1

Pred

Number. Indicates the time point in which we start predicting.

Plot.Tipe

Character. If Plot.Tipe==Data the function displays a graphic of the dataset, if Plot.Tipe==DataExpected the function displays a graphic of the data and the expected values, if Plot.Tipe==All the function displays a graphic with the data, the expected values and the variance (the varmas and varmenos parameters are introduce and are taken into account to plot the variance of the predicted part).If Plot.Tipe==Var the function returns the boxplot of the variance at each time point and the variance of each bacteria. If Plot.Tipe==OnlyVar the function returns the boxplots of the variance at each time points.

Varmas

Matrix. Output of "PredictionBPBM" adding "$ExpVarmas". Matrix that contains at row i the expected value plus two times the sqrt(variance) of the bacteria i at all time points t=Tt,...,K, the rest of the time points has 0 values. The bacteria are placed at the same order than in especies.

Varmenos

Matrix. Output of "PredictionBPBM" adding "$ExpVarmenos". Matrix that contains at row i the expected value minus two times the sqrt(variance) of the bacteria i at all time points t=Tt,...,K, the rest of the time points has 0 values. The bacteria are placed at the same order than in especies.

Detail

Character. If Detail==no the graphic obtained when Plot.Tipe==DataExpected and Plot.Tipe==All will have the same y axis for all the taxa. If Detail==yes these functions will have different y axis.

Value

Returns the indicated plots with a vertical line when the time point is equal to Tt=Pred-1, in Pred=Tt+1 the predicction has started.

References

Creus-Martí, I., Moya, A., Santonja, F. J. (2022). Bayesian hierarchical compositional models for analysing longitudinal abundance data from microbiome studies. Complexity, 2022.

Examples



names.especie=c("Bact1", "Bact2", "Bact3")
especie.All=cbind(c(0.5,0.3,0.2),
                 c(0.6,0.3,0.1),
                 c(0.4,0.1,0.5),
                 c(0.4,0.1,0.5),
                 c(0.4,0.1,0.5),
                 c(0.4,0.1,0.5))
ExpectedValue.All=especie.All[,-1]+0.1
VarianceValue.All=matrix(c(runif(15,0.001,0.004)), 3,5)
Pred=4
Varmas=cbind(matrix(0,3,2),matrix(c(runif(9,0.001,0.004)) ,3 ,3 ))
Varmenos=cbind(matrix(0,3,2),matrix(c(runif(9,0.001,0.004)) ,3 ,3 ))

GraphicsPredictionBPBM(especie.All,
                      names.especie,
                      ExpectedValue.All,
                      VarianceValue.All ,
                      Pred ,
                      "Data",
                      Varmas,
                      Varmenos,
                      "no")

GraphicsPredictionBPBM(especie.All,
                      names.especie,
                      ExpectedValue.All,
                      VarianceValue.All ,
                      Pred ,
                      "DataExpected",
                      Varmas,
                      Varmenos,
                      "no")

GraphicsPredictionBPBM(especie.All,
                      names.especie,
                      ExpectedValue.All,
                      VarianceValue.All,
                      Pred ,
                      "All",
                      Varmas,
                      Varmenos,
                      "no")

GraphicsPredictionBPBM(especie.All,
                      names.especie,
                      ExpectedValue.All,
                      VarianceValue.All ,
                      Pred ,
                      "Var",
                      Varmas,
                      Varmenos,
                      "no")

GraphicsPredictionBPBM(especie.All,
                      names.especie,
                      ExpectedValue.All,
                      VarianceValue.All ,
                      Pred ,
                      "OnlyVar",
                      Varmas,
                      Varmenos,
                      "no")


CoDaLoMic documentation built on April 12, 2025, 2:18 a.m.