Package 'hsem'

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

Help Index


Hierarchical Structural Equation Models

Description

This package allows different models for multivariate reponse variables with a hierarchical structural equation models (HSEMs).

Details

Package: hsem
Type: Package
Version: 1.0
Date: 2021-08-25
License: Unlimited
LazyLoad: yes

This is version 1.0 of the hsem package.

Author(s)

Rezzy Eko Caraka, Maengseok Noh, Youngjo Lee

Maintainer: Rezzy Eko Caraka <[email protected]>


Fitting Hierarchical Structural Equation Models using h-likelihood Approach

Description

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.

Usage

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)

Arguments

RespDist

The distribution of the response is set by the option RespDist. The user can set it to: "gaussian" (default), "binomial", "poisson", or "gamma".

BinomialDen

When RespDist="binomial", one should use the option BinomialDen to specify the denominator for the binomial distribution. This should be "NULL" (default) or a numeric vector of length equal to the length of DataMain. When specified as BinomialDen=NULL and RespDist="binomial", the denominator is 1.

DataMain

The option DataMain determines the data frame to be used (non-optional).

MeanModel

For the mean model, this option requries DGHLMMODELING object which should specified by the option Model="mean".

DispersionModel

For the overdispersion model, this option requries DGHLMMODELING object which should be specified by the option Model="dispersion".

PhiFix

The option for overdispersion parameters (phi) to be estimated or maintaned constant. Specifying defaults such as PhiFix =NULL implies that phi is to be estimated. If not, phi is fixed at a value specified by PhiFix.

LamFix

The option for random-effect variance (lambda) to be estimated or maintaned constant. Specifying defaults such as LamFix =NULL implies that lambda is to be estimated. If not, lambda is fixed at a value specified by LamFix.

structure

The option structure determines structure of random effects. When structure="correlated" (or "shared"), correlated (or shared) random-effects model is specified.

mord

The option mord specifies the order of Laplace approximation to the marginal likelihood for fitting the mean parameters. The choice is either 0 or 1 (default).

dord

The option dord specifies the order of adjusted profile likelihood for fitting the dispersion parameters. The choice is either 1 (default) or 2.

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 EstimateCorrelations=TRUE (default) or EstimateCorrelations=FALSE.

Value

res

the output class resulted from jointfit_correlated.

Examples

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))

Defining the Fixed and Random Models for the Mean and Dispersion parameters in HSEMs

Description

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.

Usage

hsemmodeling(Model="mean",Link=NULL,LinPred="constant",RandDist=NULL,
Offset=NULL,LMatrix=NULL,LinkRandVariance=NULL,LinPredRandVariance=NULL,
RandDistRandVariance="gaussian",
LinkRandVariance2=NULL,LinPredRandVariance2=NULL)

Arguments

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., y~x1+x2+(1|id1)+(1|id2) in the option LinPred, the different distributions for each random term can be specified, e.g., c("gaussian", "gamma"), which assumes normal distribution for the random term "id1" and gamma distribution for the random term "id2", respectively.

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.


simulated urge to smoke data

Description

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.

Usage

data("ml2")

Format

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