LCVAR {ClusterVAR} | R Documentation |
Fitting Latent Class VAR Models
Description
Function to fit a Latent Class VAR model with a given number of latent classes.
Usage
LCVAR(Data, yVars, Beep, Day = NULL, ID,
xContinuous = NULL, xFactor = NULL,
Clusters, Lags, Center = FALSE,
smallestClN = 3, Cores = 1,
RndSeed = NULL, Rand = 50, Rational = TRUE,
Initialization = NULL, SigmaIncrease = 10,
it = 50, Conv = 1e-05, pbar = TRUE, verbose = TRUE,
Covariates = "equal-within-clusters", ...)
Arguments
Data |
The data provided in a data.frame. |
yVars |
An integer vector specifying the position of the column(s) in dataframe |
Beep |
An integer specifying the position of the column in dataframe |
Day |
Optional argument. An integer specifying the position of the column in dataframe |
ID |
An integer specifying the position of the column in dataframe |
xContinuous |
Optional argument. An integer vector specifying the position of the column(s) in dataframe Data that contain the continuous exogenous variable(s), if present. Exogenous variables are also known as covariates or as moderators for the within-person mean. |
xFactor |
Optional argument. An integer vector specifying the position of the column(s) in dataframe Data that contain the categorical exogenous variable(s), if present. Exogenous variables are also known as covariates or as moderators for the within-person mean. |
Clusters |
An integer or integer vector specifying the numbers of latent classes (i.e., clusters) for which LCVAR models are to be calculated. |
Lags |
An integer or integer vector specifying the number of VAR(p) lags to consider. Needs to be a sequence of subsequent integers. The maximum number supported is |
Center |
Logical, indicating whether the data (i.e., the endogenous variables) should be centered per person before calculations. If |
smallestClN |
An integer specifying the lowest number of individuals allowed in a cluster. When during estimation the crisp cluster membership of a cluster indicates less than |
Cores |
A positive integer specifying the number of cores used to parallelize the computations. Specifying a high number of available cores can speed up computation. Defaults to |
RndSeed |
Optional argument. An integer specifying the value supplied to |
Rand |
The number of pseudo-random EM-starts used in fitting each possible model. For pseudo-random starts K individuals are randomly selected as cluster centres. Then individuals are partitioned into the cluster to which their individual VAR and individual covariate coefficients are closest. High numbers (e.g., 50 and above) ensure that a global optimum will be found, but will take longer to compute. Defaults to |
Rational |
Logical, indicating whether a rational EM-start should be used in addition to the other EM-starts. Defaults to |
Initialization |
Optional argument. An integer specifying the position of a column in dataframe |
SigmaIncrease |
A numerical value specifying the value by which every element of Sigma will be increased when posterior probabilities of cluster memberships are reset. Defaults to |
it |
An integer specifying the maximum number of EM-iterations allowed for every EM-start. After completing |
Conv |
A numerical value specifying the convergence criterion of the log likelihood to determine convergence of an EM-start. For details see Ernst et al. (2020) Inter-individual differences in multivariate time series: Latent class vector-autoregressive modelling. Defaults to |
pbar |
If |
verbose |
If |
Covariates |
Constraints on the parameters of the exogenous variable(s). So far only |
... |
Additional arguments passed to the function. |
Details
This function estimates the latent class vector-autoregressive model to obtain latent classes (i.e., clusters) of individuals who are similar in VAR coefficients and (if specified) in within-person means and infleunces of exogenous variable(s).
y_{i, t} = w_{i, t} + \mu_{k} + \beta_{k} x_{i, t}
w_{i, t} = (\sum_{a = 1}^{p} \Phi_{k, a} w_{i, t-a}) + u_{i, t}\qquad u_{i, t} \sim N(0, \Sigma_{k})
Here \mu_{k}
represents an m x 1 vector that contains the cluster-wise conditional within-person mean for each y-variable in cluster k. \beta_{k}
represents an m x q matrix that expresses the cluster-wise moderating influence of q exogenous variables (x_{i, t}
) on the within-person means in cluster k.
\Phi_{k, a}
represents an m×m matrix containing the cluster-wise VAR coefficients at lag a for cluster k. See the references below for details.
Value
An object of class 'ClusterVAR' providing several LCVAR models. The details of the output components are as follows:
Call |
A list of arguments from the original function call. |
All_Models |
All LCVAR models across all number of clusters, lag combinations, and number of EM-starts. |
Runtime |
The runtime the function took to complete. |
Author(s)
Anja Ernst
References
Ernst, A. F., Albers, C. J., Jeronimus, B. F., & Timmerman, M. E. (2020). Inter-individual differences in multivariate time-series: Latent class vector-autoregressive modeling. European Journal of Psychological Assessment, 36(3), 482–491. doi: 10.1027/1015-5759/a000578
Examples
head(SyntheticData)
LCVAR_outExample1 <- LCVAR(Data = SyntheticData,
yVars = 1:4, ID = 5, Beep = 9, Day = 10,
xContinuous = 7, xFactor = 8,
Clusters = 1:2, Lags = 1,
Center = TRUE,
Cores = 2, # Adapt to local machine
RndSeed = 123, Rand = 1, it = 25)
summary(LCVAR_outExample1)
summary(object = LCVAR_outExample1, show = "GNL", Number_of_Lags = 1)
coef(LCVAR_outExample1, Model = c(1, 1))
head(ExampleData)
LCVAR_outExample2 <- LCVAR(Data = ExampleData,
yVars = 1:4, ID = 5, Beep = 6,
xContinuous = 7, xFactor = 8,
Clusters = 1:2, Lags = 1:2,
Center = FALSE,
Cores = 2, RndSeed = 123,
Rand = 1,
it = 25, Conv = 1e-05)
summary(LCVAR_outExample2)
summary(object = LCVAR_outExample2, show = "GNL", Number_of_Lags = 1)
summary(object = LCVAR_outExample2, show = "GNC", Number_of_Clusters = 2)
coef(LCVAR_outExample2, Model = c(1, 1))
plot(LCVAR_outExample2, show = "specific", Model = c(1, 1))