LN_hierarchical {BayesLN} | R Documentation |

Function that estimates a log-normal linear mixed model with GIG priors on the variance components, in order to assure the existence of the posterior moments of key functionals in the original data scale like conditioned means or the posterior predictive distribution.

```
LN_hierarchical(
formula_lme,
data_lme,
y_transf = TRUE,
functional = c("Subject", "Marginal", "PostPredictive"),
data_pred = NULL,
order_moment = 2,
nsamp = 10000,
par_tau = NULL,
par_sigma = NULL,
var_pri_beta = 10000,
inits = list(NULL),
verbose = TRUE,
burnin = 0.1 * nsamp,
n_thin = 1
)
```

`formula_lme` |
A two-sided linear formula object describing
both the fixed-effects and random-effects part of the model is required. For details see |

`data_lme` |
Optional data frame containing the variables named in |

`y_transf` |
Logical. If |

`functional` |
Functionals of interest: |

`data_pred` |
Data frame with the covariate patterns of interest for prediction. All the covariates present in the |

`order_moment` |
Order of the posterior moments that are required to be finite. |

`nsamp` |
Number of Monte Carlo iterations. |

`par_tau` |
List of vectors defining the triplets of hyperparaemters for each random effect variance (as many vectors as the number of specified random effects variances). |

`par_sigma` |
Vector containing the tiplet of hyperparameters for the prior of the data variance. |

`var_pri_beta` |
Prior variance for the model coefficients. |

`inits` |
List of object for initializing the chains. Objects with compatible dimensions must be named with |

`verbose` |
Logical. If |

`burnin` |
Number of iterations to consider as burn-in. |

`n_thin` |
Number of thinning observations. |

The function allows to estimate a log-normal linear mixed model through a Gibbs sampler. The model equation is specified as in `lmer`

model and the target functionals to estimate need to be declared.
A weakly informative prior setting is automatically assumed, always keeping the finiteness of the posterior moments of the target functionals.

The output list provided is composed of three parts. The object `$par_prior`

contains the parameters fixed for the variance components priors. The object `$samples`

contains the posterior samples for all the paramters.
They are returned as a `mcmc`

object and they can be analysed trough the functions contained in the
`coda`

package in order to check for the convergence of the algorithm. Finally, in `$summaries`

an overview of the posteriors of the model parameters and of the target functionals is provided.

```
library(BayesLN)
# Load the dataset included in the package
data("laminators")
data_pred_new <- data.frame(Worker = unique(laminators$Worker))
Mod_est<-LN_hierarchical(formula_lme = log_Y~(1|Worker),
data_lme = laminators,
data_pred = data_pred_new,
functional = c("Subject","Marginal"),
order_moment = 2, nsamp = 50000, burnin = 10000)
```

[Package *BayesLN* version 0.2.10 Index]