Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculating a Consensus Emergence Model with a longitudinal data set

    Hey,

    I want to do research on the question how a climate of psychological safety emerges. Therefore I collected data of 2 groups over 9 measurment times. Now I want to assess the presence of consensus within my data. Therefore I found the text of Lang et. al. 2019, who suggest and develop the consensus emergence model (CEM) and even supply a "r" code for calulating it. Since I wasn't able to run the r code with r studio and the authors state, that the model can be easily executed in stata I want to ask for help to use the CEM.
    Maybe one of you can help me to transform the r code into a stata code, taking into account that I have 2 groups, 7 variables for psychological safety and 9 measurement times? Thanks a lot in advance.

    This is the "r" code written in the study:
    R code for the army data
    library(nlme)
    #################### PREPARE DATA #######################
    ## get and prepare data
    library(multilevel)
    data(univbct)
    #prepare variables
    univbct2<-univbct
    univbct2$UNIT<-paste(univbct2$BTN,univbct2$COMPANY,sep="")
    RMEANS<-aggregate(READY1 ~ UNIT,univbct2[univbct2$TIME==0,],mean)
    names(RMEANS)<-c("UNIT","CREAD")
    univbct2<-merge(univbct2,RMEANS,by="UNIT")
    #delete persons with single observations
    univbct2<-univbct2[rowSums(sapply(subset(univbct2,select=c(JOBSAT1,JO BSAT2,JOBSAT3)),is.na))<2,]
    # at least three
    members<-table(univbct2$UNIT)/3
    univbct2<-univbct2[univbct2$UNIT %in% names(members[members>2]), ]
    ################### ANALYSIS ##############################
    ## control settings for lme
    csettings=lmeControl(opt="nlminb") # default setting
    #alternative
    #csettings=lmeControl(maxIter=3000,msMaxIter=3000, opt="optim",optimMethod="Nelder-Mead")
    # 3-Level null model. The higher-level unit identifier is UNIT, the person identifier is SUBNUM
    # The identifier used first in the list command refers to the highest level (here level-3).
    # pdSymm specifies the nature of the random effects covariance matrix and refers to a symmetric
    # matrix
    # univbct2 is the dataset
    M2a<-lme(JSAT ~ TIME, random = list(UNIT=pdSymm(~TIME),SUBNUM=pdSymm(~1)),
    data = univbct2,na.action=na.omit,control=csettings)
    # 3-level CEM model. Change in the residual variance over time is added to the null model
    M2b<-update(M2a,weights=varExp( form = ~ TIME))
    anova(M2a,M2b)
    #view additional model details with summary()
    summary(M2b)
    # 3-level with standardized group-level predictor
    # scale(..) centers and standardizes the predictor
    # scale(..,scale=FALSE) centers but does not standardize the predictor
    # each predictor in the residual variance part of the model needs a separate varExp command
    # otherwise R just estimates one coefficient for all predictors
    m3a<-lme(JSAT ~ TIME*scale(CREAD), random = list(UNIT=pdSymm(~TIME),SUBNUM=pdSymm(~1)),
    data = univbct2,na.action=na.omit,control=csettings,weigh ts=varExp( form = ~ TIME))
    m3b<-update(m3a,weights=varComb(varExp( form = ~ TIME),varExp( form = ~ scale(CREAD))))
    m3c<-update(m3b,weights=varComb(varExp( form = ~ TIME),varExp( form = ~ scale(CREAD)),
    varExp( form = ~ scale(CREAD)*TIME)))
    anova(m3a,m3b,m3c)
    # 2-level with unstandardized group-level predictor
    # scale(..,scale=FALSE) centers but does not standardize the predictor
    m3a2<-lme(JSAT ~ TIME*scale(CREAD,scale=FALSE), random = list(UNIT=pdSymm(~TIME)),
    data = univbct2,na.action=na.omit,control=csettings,weigh ts=varExp( form = ~ TIME))
    m3b2<-update(m3a2,weights=varComb(varExp( form = ~ TIME),varExp( form = ~
    scale(CREAD,scale=FALSE))))
    m3c2<-update(m3b2,weights=varComb(varExp( form = ~ TIME),varExp( form = ~
    scale(CREAD,scale=FALSE)),
    varExp( form = ~ scale(CREAD,scale=FALSE)*TIME)))
    anova(m3a2,m3b2,m3c2)

    Literature:
    Lang, J. W., Bliese, P. D., & de Voogt, A. (2018). Modeling consensus emergence in groups using longitudinal multilevel methods. Personnel Psychology, 71(2), 255-281.
Working...
X