Title: | Hierarchical Structural Equation Model |
---|---|
Description: | We present this package for fitting structural equation models using the hierarchical likelihood method. This package allows extended structural equation model, including dynamic structural equation model. We illustrate the use of our packages with well-known data sets. Therefore, this package are able to handle two serious problems inadmissible solution and factor indeterminacy <doi:10.3390/sym13040657>. |
Authors: | Rezzy Eko Caraka [aut, cre], Maengseok Noh [aut], Youngjo Lee [aut] |
Maintainer: | Rezzy Eko Caraka <[email protected]> |
License: | GPL-3 |
Version: | 1.0 |
Built: | 2024-10-21 03:16:04 UTC |
Source: | https://github.com/cran/hsem |
This package allows different models for multivariate reponse variables with a hierarchical structural equation models (HSEMs).
Package: | hsem |
Type: | Package |
Version: | 1.0 |
Date: | 2021-08-25 |
License: | Unlimited |
LazyLoad: | yes |
This is version 1.0 of the hsem package.
Rezzy Eko Caraka, Maengseok Noh, Youngjo Lee
Maintainer: Rezzy Eko Caraka <[email protected]>
The hsemfit is used to fit a hierarchical structural equation models (HSEMs) allowing different models for multivariate reponse variables. A variety of distributions and link functions for both response and the random effects are allowed. To call the fitting function hsemfit, models for the mean and dispersion must be specified by hsemmodleing object preferably created by calling the hsemmodeling function.
hsemfit(RespDist = "gaussian", BinomialDen = NULL, DataMain, MeanModel,DispersionModel = NULL, PhiFix = NULL, LamFix = NULL, structure = "correlated", mord = 0, dord = 1, convergence = 1e-05, Init_Corr = NULL, EstimateCorrelations = TRUE)
hsemfit(RespDist = "gaussian", BinomialDen = NULL, DataMain, MeanModel,DispersionModel = NULL, PhiFix = NULL, LamFix = NULL, structure = "correlated", mord = 0, dord = 1, convergence = 1e-05, Init_Corr = NULL, EstimateCorrelations = TRUE)
RespDist |
The distribution of the response is set by the option |
BinomialDen |
When |
DataMain |
The option |
MeanModel |
For the mean model, this option requries |
DispersionModel |
For the overdispersion model, this option requries |
PhiFix |
The option for overdispersion parameters (phi) to be estimated or maintaned constant.
Specifying defaults such as |
LamFix |
The option for random-effect variance (lambda) to be estimated or maintaned constant.
Specifying defaults such as |
structure |
The option |
mord |
The option |
dord |
The option |
convergence |
Setting this option determines the criterion for convergence, which is computed as the absolute difference between the values of all the estimated parameters in the previous and current iterations. The default criterion is 1e-06. |
Init_Corr |
Setting initial values of correlation (or shared parameters) between random effects |
EstimateCorrelations |
Correlation are estimated or fixed when |
res |
the output class resulted from jointfit_correlated. |
data(ml2) MM1<-hsemmodeling(Model="mean",Link="identity", LinPred=urge~urge1+dep1+(1|id)+(urge1|id)+(dep1|id), RandDist=c("gaussian","gaussian","gaussian")) DM1<-hsemmodeling(Model="dispersion",Link = "log", LinPred=phi~(1|id),RandDist=c("gaussian")) MM2<-hsemmodeling(Model="mean",Link="identity", LinPred=dep~urge1+dep1+(1|id)+(urge1|id)+(dep1|id), RandDist=c("gaussian","gaussian","gaussian")) DM2<-hsemmodeling(Model="dispersion",Link = "log", LinPred=phi~(1|id),RandDist=c("gaussian")) res<-hsemfit(RespDist=c("gaussian","gaussian"),DataMain=list(ml2,ml2), structure="independent",MeanModel=list(MM1,MM2), DispersionModel=list(DM1,DM2))
data(ml2) MM1<-hsemmodeling(Model="mean",Link="identity", LinPred=urge~urge1+dep1+(1|id)+(urge1|id)+(dep1|id), RandDist=c("gaussian","gaussian","gaussian")) DM1<-hsemmodeling(Model="dispersion",Link = "log", LinPred=phi~(1|id),RandDist=c("gaussian")) MM2<-hsemmodeling(Model="mean",Link="identity", LinPred=dep~urge1+dep1+(1|id)+(urge1|id)+(dep1|id), RandDist=c("gaussian","gaussian","gaussian")) DM2<-hsemmodeling(Model="dispersion",Link = "log", LinPred=phi~(1|id),RandDist=c("gaussian")) res<-hsemfit(RespDist=c("gaussian","gaussian"),DataMain=list(ml2,ml2), structure="independent",MeanModel=list(MM1,MM2), DispersionModel=list(DM1,DM2))
The hsemmodeling specifies a GLM, HGLM, DHGLM model for the mean parameters (mu), and a GLM, HGLM model for the overdispersion parameters (phi). GLM for mu, and GLM for phi are specified by adding only fixed terms to the linear predictors for the mu and phi, respectively.
hsemmodeling(Model="mean",Link=NULL,LinPred="constant",RandDist=NULL, Offset=NULL,LMatrix=NULL,LinkRandVariance=NULL,LinPredRandVariance=NULL, RandDistRandVariance="gaussian", LinkRandVariance2=NULL,LinPredRandVariance2=NULL)
hsemmodeling(Model="mean",Link=NULL,LinPred="constant",RandDist=NULL, Offset=NULL,LMatrix=NULL,LinkRandVariance=NULL,LinPredRandVariance=NULL, RandDistRandVariance="gaussian", LinkRandVariance2=NULL,LinPredRandVariance2=NULL)
Model |
This option specifies a GLM, HGLM or DHGLM model for mu when Model="mean" (default), and a GLM or HGLM for phi when Model="dispersion". |
Link |
The link function for the linear predictor is specified by the option Link. For Model="mean", Link can be "identity", "logit", "probit", "cloglog", "log", or "inverse". For Model="dispersion", the choice is either "log" or "inverse". The default, specified as NULL link, is "identity" for Model="mean" and "log" for Model="dispersion". |
LinPred |
The option LinPred specifies the fixed and random terms for the linear predictor for mu when specified as Model="mean" or for phi when Model="dispersion". For Model="mean", LinPred=y~x1+x2+(1|id1)+(1|id2) specifies y as the main response, x1 and x2 as fixed covariates and id1 and id2 as random terms. For Model="dispersion", the main response should be phi, e.g. phi~x1+x2+(1|id1)+(1|id2). This option can specify the model without random effects, e.g., LinPred=phi~x1+x2. The default is "constant", which is set to intercept only the model for the corresponding linear predictors. |
RandDist |
The option RandDist specifies the
distributions of the random terms represented in the option LinPred.
It is set as a vector of distribution names from "gaussain" (default),
"beta", "gamma", or "inverse-gamma" when Model="mean".
For Model="dispersion", the choice is "gaussian" (default), "gamma", or "inverse-gamma".
When more than one random terms are specified, e.g., |
Offset |
The option Offset can be used to specify a known component to be included in the linear predictor specified by LinPred during fitting. This should be the default (NULL) or a numeric vector of length equal to that of the appropriate data. |
LMatrix |
The option LMatrix sets a matrix that is used as a post-multiplier for the model matrix of the corresponding random effects. This option allows correlation structures to be defined for random effects. For example, when specified as Model="mean" and Lmatrix=L1+L2, the linear predictor for mu takes X beta + Z1 L1 r1 + Z2 L2 r2, where Z1 and Z2 are the model matrices for the random effects v1=L1 r1 and v2=L2 r2, specified in the option LinPred. |
LinkRandVariance |
The option LinkRandVariance specifies the link function for the linear predictor of the random-effect variances. The choice is either "log" (default) or "inverse". When more than two random terms are specified in the option LinPred, the user can set different link functions, e.g., LinkRandVariance=c("log","inverse") for each random term. |
LinPredRandVariance |
The option LinPredRandVariance specifies the fixed and random terms for the linear predictor of the random-effect variances for Model="mean". When y~x1+x2+(1|id1)+(1|id2) is specified in the option LinPred, LinPredRandVariance=c(lambda~xx1+(1|id11),lambda~xx2+(1|id12)) specifies xx1 and xx2 as fixed covariates and id11 and id12 as random terms in the lienar predictors for the variances of the random terms id1 and id2, respectively. For Model="dispersion", the random term is not allowed in the linear predictor of the random-effect variance. The default (NULL) is set to intercept only model for the corresponding linear predictors. |
RandDistRandVariance |
The option RandDistRandVariance specifies the distributions for the random terms in the LinPredRandVariance. The choice is "gaussian" (default), "gamma", or "inverse-gamma". |
LinkRandVariance2 |
This option specifies the link function for the linear predictor of the variance of random effects, which are specified in the option LinPredRandVariance. The choice is either "log" (default) or "inverse". |
LinPredRandVariance2 |
This option specifies the fixed terms for the linear predictor of the variance of random effects, which is specified in the option LinPredRandVariance. For example, when LinPredRandVariance=c(lambda~xx1+(1|id11),lambda~xx1+(1|id12)) is specified, LinPredRandVariance2=c(~xxx1,~xxx2) specifies xxx1 and xxx2 as fixed covariates for the linear predictor of random-effect variances for id11 and id12, respectively. The default (NULL) is set to constant variance for the random effects in LinPredRandVariance. |
By using an example for urge to smoke in the McNeish and Hamaker (2020), this data set is a simulated subset. It consists of 10 repetitions on regular time scales for 20 different individuals. For response variable, urge to Smoke is on a standardized scale average 0 and the standard deviation 1.
data("ml2")
data("ml2")
A data frame with 200 observations on the following 6 variables.
urge
standardized urge to smoke
urge1
previous urge to smoke
dep
standardized depression
dep1
previous depression
id
individual indicator
time
time indicator