Skip to contents

This function calculates the posterior distribution of the latent variables and computes the expected values for different model configurations. It approximates expectations using methods like Gaussian-Legendre (GL), Monte Carlo (MC), or Trapezoidal (TI) methods.

Usage

E_z(
  serial,
  model,
  method = "gl",
  period = c(0, 1),
  par1,
  gamma_par = c(2, 0.1),
  data,
  n_samples = NULL,
  n_intervals = NULL,
  n_points = NULL
)

Arguments

serial

Integer, specifies the expected value to calculate (e.g., 1 to 6).

model

Character, specifies the model type ("M0", "M1", "M2", etc.).

method

Character, specifies the numerical method for approximation ("gl", "mc", or "ti").

period

Numeric vector of length 2, defines the integration limits (e.g., `c(0, 1)`).

par1

List, model parameters for each variable. Includes `delta_Lambda` and `delta_Lambda0`.

gamma_par

Numeric vector, parameters for the gamma distribution, used for specific models (e.g., `c(2, 0.1)`).

data

Matrix, observed data where rows represent samples and columns represent variables.

n_samples

Integer, the number of random samples for Monte Carlo integration. Default is NULL.

n_intervals

Integer, the number of intervals for Trapezoidal integration. Default is NULL.

n_points

Integer, the number of points for Gaussian-Legendre integration. Default is NULL.

Value

Numeric matrix, expected values for the latent variables based on the provided `serial` and `model`. The result varies depending on the type of expectation (e.g., posterior mean, variance, etc.).