Learn R Programming

mult.latent.reg (version 0.1.9)

mult.reg_2level: Selecting the best results for multivariate two level model

Description

This wrapper function runs multiple times the function mult.em_2level for fitting Zhang et al.'s (2023) multivariate response models with two-level random effect, and select the best results with the smallest AIC value.

Value

The best estimated result (with the smallest AIC value) in the model \(x_{ij} = \alpha + \beta z_k + \Gamma v_{ij} + \varepsilon_{ij} \) obtained through the EM algorithm (Zhang et al., 2023), where the upper-level unit is indexed by \(i\), and the lower-level unit is indexed by \(j\).

p

The estimates for the parameter \(\pi_k\), which is a vector of length \(K\).

alpha

The estimates for the parameter \(\alpha\), which is a vector of length \(m\).

z

The estimates for the parameter \(z_k\), which is a vector of length \(K\).

beta

The estimates for the parameter \(\beta\), which is a vector of length \(m\).

gamma

The estimates for the parameter \(\Gamma\), which is a matrix.

sigma

The estimates for the parameter \(\Sigma_k\). When var_fun = 1, \(\Sigma_k\) is a diagonal matrix and \(\Sigma_k = \Sigma\), and we obtain a vector of the diagonal elements; When var_fun = 2, \(\Sigma_k\) is a diagonal matrix, and we obtain K vectors of the diagonal elements.

W

The posterior probability matrix.

loglikelihood

The approximated log-likelihood of the fitted model.

disparity

The disparity (-2logL) of the fitted model.

number_parameters

The number of parameters estimated in the EM algorithm.

AIC

The AIC value (-2logL + 2number_parameters).

aic_data

All AIC values in each run.

Starting_values

Lists of starting values for parameters used in each num_runs. It allows reproduction of the best result (obtained from mult.reg_2level) in a single run using mult.em_2level by setting start equal to the list of starting values that were used to obtain the best result in mult.reg_2level.

Arguments

data

A data set object; we denote the dimension of a data set to be \(m\).

v

Covariate(s).

K

Number of mixture components, the default is K = 2.

steps

Number of iterations within each num_runs, the default is steps = 20.

num_runs

Number of function iteration runs, the default is num_runs = 20.

start

Containing parameters involved in the proposed model (p, alpha, z, beta, sigma, gamma) in a list, the starting values can be obtained through the use of start_em. More details can be found in start_em.

option

Four options for selecting the starting values for the parameters in the model. The default is option = 1. More details can be found in start_em.

var_fun

There are two types of variance specifications; var_fun = 1, the same diagonal variance specification to all K components of the mixture; var_fun = 2, different diagonal variance matrices for different components; The default is var_fun = 2.

References

Zhang, Y., Einbeck, J. and Drikvandi, R. (2023). A multilevel multivariate response model for data with latent structures. In: Proceedings of the 37th International Workshop on Statistical Modelling, pages 343-348. Link on RG: https://www.researchgate.net/publication/375641972_A_multilevel_multivariate_response_model_for_data_with_latent_structures

See Also

mult.em_2level.

Examples

Run this code
# \donttest{
##run the mult.em_2level() multiple times and select the best results with the smallest AIC value
set.seed(7)
results <- mult.reg_2level(trading_data, K=4, steps = 10, num_runs = 5,
                           var_fun = 2, option = 1)
## Reproduce the best result: the best result is the 2nd run in the above example.
rep_best_result <- mult.em_2level(trading_data, K=4, steps = 10,
var_fun = 2, option = 1,
start = results$Starting_values[[2]])
# }

Run the code above in your browser using DataLab