Skip to main content
added 4 characters in body
Source Link
Dale
  • 171
  • 5
## load packages
library(semTools)
library(lavaan.mi)

## load imputed data
data3t.mi.1 <- readRDS("data3t.RDS")

## make the output of mice for the lavaan.mi function to work 
data3t.mi.1 <- NULL
for(i in 1:50) data3t.mi.1[[i]] <- mice::complete(data3t.mi, action=i, inc=FALSE)

## specify my model
model <- '
MRC_Ego_total ~ a1a * ECR_anxiety_average + a2a * ECR_avoidance_average
MRC_Altru_total ~ a1b * ECR_anxiety_average + a2b * ECR_avoidance_average
MRC_provide_total ~ a1c * ECR_anxiety_average + a2c * ECR_avoidance_average
MRC_recog_total ~ a1d * ECR_anxiety_average + a2d * ECR_avoidance_average
MRC_worthy_total ~ a1e * ECR_anxiety_average + a2e * ECR_avoidance_average

TABS_self_total_T ~ d1 * MRC_Ego_total + d3 * MRC_provide_total + d4 * MRC_recog_total
TABS_other_total_T ~ d2 * MRC_Altru_total + d5 * MRC_worthy_total

TABS_self_total_T ~ e1 * ECR_anxiety_average + e3 * ECR_avoidance_average
TABS_other_total_T ~ e2 * ECR_anxiety_average + e4 * ECR_avoidance_average

# outcomes
CBI_total ~ b1 * TABS_self_total_T + b3 * TABS_other_total_T + c1 * ECR_anxiety_average + c3 * ECR_avoidance_average
STSS_total ~ b2 * TABS_self_total_T + b4 * TABS_other_total_T + c2 * ECR_anxiety_average + c4 * ECR_avoidance_average

# variances of exogenous variables
ECR_anxiety_average ~~ v1 * ECR_anxiety_average
ECR_avoidance_average ~~ v2 * ECR_avoidance_average

# covariance of exogenous variables
ECR_anxiety_average ~~ cov1 * ECR_avoidance_average

# variances for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ v3 * MRC_Ego_total
MRC_Altru_total ~~ v4 * MRC_Altru_total
MRC_provide_total ~~ v5 * MRC_provide_total
MRC_recog_total ~~ v6 * MRC_recog_total
MRC_worthy_total ~~ v7 * MRC_worthy_total
TABS_self_total_T ~~ v8 * TABS_self_total_T
TABS_other_total_T ~~ v9 * TABS_other_total_T
CBI_total ~~ v10 * CBI_total
STSS_total ~~ v11 * STSS_total

# covariance for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ cov2 * MRC_Altru_total + cov3 * MRC_provide_total + cov4 * MRC_recog_total + cov5 * MRC_worthy_total
MRC_Altru_total ~~ cov6 * MRC_provide_total + cov7 * MRC_recog_total + cov8 * MRC_worthy_total
MRC_provide_total ~~ cov9 *MRC_recog_total + cov10 * MRC_worthy_total
MRC_recog_total ~~ cov11 * MRC_worthy_total
TABS_self_total_T ~~ cov12 * TABS_other_total_T
CBI_total ~~ cov13 * STSS_total

# indirect effects
indirect1 := a1a*d1*b1
indirect2 := a1a*d1*b2
indirect3 := a1b*d2*b3

# defined parameters
ECR_an_an := v1
ECR_av_av := v2
'

## the analysis ====
output <- lavaan.mi(model, data=data3t.mi.1, estimator = "MLM", se = "robust.huber.white")

## Monte Carlo CI
monteCarloCI(output, standardized = TRUE)

Giving:## the error message is:
Error in monteCarloCI(output2T, standardized = TRUE) : 
  argument "expr" is missing, with no default

## When including "ECR_an_an := v1" and "ECR_av_av := v2" gives an error message. 

## theThe error message is:
Error in chol.default(varcov) : 
  the leading minor of order 1 is not positive


## load packages
library(semTools)
library(lavaan.mi)

## load imputed data
data3t.mi.1 <- readRDS("data3t.RDS")

## make the output of mice for the lavaan.mi function to work 
data3t.mi.1 <- NULL
for(i in 1:50) data3t.mi.1[[i]] <- mice::complete(data3t.mi, action=i, inc=FALSE)

## specify my model
model <- '
MRC_Ego_total ~ a1a * ECR_anxiety_average + a2a * ECR_avoidance_average
MRC_Altru_total ~ a1b * ECR_anxiety_average + a2b * ECR_avoidance_average
MRC_provide_total ~ a1c * ECR_anxiety_average + a2c * ECR_avoidance_average
MRC_recog_total ~ a1d * ECR_anxiety_average + a2d * ECR_avoidance_average
MRC_worthy_total ~ a1e * ECR_anxiety_average + a2e * ECR_avoidance_average

TABS_self_total_T ~ d1 * MRC_Ego_total + d3 * MRC_provide_total + d4 * MRC_recog_total
TABS_other_total_T ~ d2 * MRC_Altru_total + d5 * MRC_worthy_total

TABS_self_total_T ~ e1 * ECR_anxiety_average + e3 * ECR_avoidance_average
TABS_other_total_T ~ e2 * ECR_anxiety_average + e4 * ECR_avoidance_average

# outcomes
CBI_total ~ b1 * TABS_self_total_T + b3 * TABS_other_total_T + c1 * ECR_anxiety_average + c3 * ECR_avoidance_average
STSS_total ~ b2 * TABS_self_total_T + b4 * TABS_other_total_T + c2 * ECR_anxiety_average + c4 * ECR_avoidance_average

# variances of exogenous variables
ECR_anxiety_average ~~ v1 * ECR_anxiety_average
ECR_avoidance_average ~~ v2 * ECR_avoidance_average

# covariance of exogenous variables
ECR_anxiety_average ~~ cov1 * ECR_avoidance_average

# variances for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ v3 * MRC_Ego_total
MRC_Altru_total ~~ v4 * MRC_Altru_total
MRC_provide_total ~~ v5 * MRC_provide_total
MRC_recog_total ~~ v6 * MRC_recog_total
MRC_worthy_total ~~ v7 * MRC_worthy_total
TABS_self_total_T ~~ v8 * TABS_self_total_T
TABS_other_total_T ~~ v9 * TABS_other_total_T
CBI_total ~~ v10 * CBI_total
STSS_total ~~ v11 * STSS_total

# covariance for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ cov2 * MRC_Altru_total + cov3 * MRC_provide_total + cov4 * MRC_recog_total + cov5 * MRC_worthy_total
MRC_Altru_total ~~ cov6 * MRC_provide_total + cov7 * MRC_recog_total + cov8 * MRC_worthy_total
MRC_provide_total ~~ cov9 *MRC_recog_total + cov10 * MRC_worthy_total
MRC_recog_total ~~ cov11 * MRC_worthy_total
TABS_self_total_T ~~ cov12 * TABS_other_total_T
CBI_total ~~ cov13 * STSS_total

# indirect effects
indirect1 := a1a*d1*b1
indirect2 := a1a*d1*b2
indirect3 := a1b*d2*b3

# defined parameters
ECR_an_an := v1
ECR_av_av := v2
'

## the analysis ====
output <- lavaan.mi(model, data=data3t.mi.1, estimator = "MLM", se = "robust.huber.white")

## Monte Carlo CI
monteCarloCI(output, standardized = TRUE)

Giving: 
Error in monteCarloCI(output2T, standardized = TRUE) : 
  argument "expr" is missing, with no default

## When including "ECR_an_an := v1" and "ECR_av_av := v2" gives an error message. 

## the error message is:
Error in chol.default(varcov) : 
  the leading minor of order 1 is not positive


## load packages
library(semTools)
library(lavaan.mi)

## load imputed data
data3t.mi.1 <- readRDS("data3t.RDS")

## make the output of mice for the lavaan.mi function to work 
data3t.mi.1 <- NULL
for(i in 1:50) data3t.mi.1[[i]] <- mice::complete(data3t.mi, action=i, inc=FALSE)

## specify my model
model <- '
MRC_Ego_total ~ a1a * ECR_anxiety_average + a2a * ECR_avoidance_average
MRC_Altru_total ~ a1b * ECR_anxiety_average + a2b * ECR_avoidance_average
MRC_provide_total ~ a1c * ECR_anxiety_average + a2c * ECR_avoidance_average
MRC_recog_total ~ a1d * ECR_anxiety_average + a2d * ECR_avoidance_average
MRC_worthy_total ~ a1e * ECR_anxiety_average + a2e * ECR_avoidance_average

TABS_self_total_T ~ d1 * MRC_Ego_total + d3 * MRC_provide_total + d4 * MRC_recog_total
TABS_other_total_T ~ d2 * MRC_Altru_total + d5 * MRC_worthy_total

TABS_self_total_T ~ e1 * ECR_anxiety_average + e3 * ECR_avoidance_average
TABS_other_total_T ~ e2 * ECR_anxiety_average + e4 * ECR_avoidance_average

# outcomes
CBI_total ~ b1 * TABS_self_total_T + b3 * TABS_other_total_T + c1 * ECR_anxiety_average + c3 * ECR_avoidance_average
STSS_total ~ b2 * TABS_self_total_T + b4 * TABS_other_total_T + c2 * ECR_anxiety_average + c4 * ECR_avoidance_average

# variances of exogenous variables
ECR_anxiety_average ~~ v1 * ECR_anxiety_average
ECR_avoidance_average ~~ v2 * ECR_avoidance_average

# covariance of exogenous variables
ECR_anxiety_average ~~ cov1 * ECR_avoidance_average

# variances for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ v3 * MRC_Ego_total
MRC_Altru_total ~~ v4 * MRC_Altru_total
MRC_provide_total ~~ v5 * MRC_provide_total
MRC_recog_total ~~ v6 * MRC_recog_total
MRC_worthy_total ~~ v7 * MRC_worthy_total
TABS_self_total_T ~~ v8 * TABS_self_total_T
TABS_other_total_T ~~ v9 * TABS_other_total_T
CBI_total ~~ v10 * CBI_total
STSS_total ~~ v11 * STSS_total

# covariance for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ cov2 * MRC_Altru_total + cov3 * MRC_provide_total + cov4 * MRC_recog_total + cov5 * MRC_worthy_total
MRC_Altru_total ~~ cov6 * MRC_provide_total + cov7 * MRC_recog_total + cov8 * MRC_worthy_total
MRC_provide_total ~~ cov9 *MRC_recog_total + cov10 * MRC_worthy_total
MRC_recog_total ~~ cov11 * MRC_worthy_total
TABS_self_total_T ~~ cov12 * TABS_other_total_T
CBI_total ~~ cov13 * STSS_total

# indirect effects
indirect1 := a1a*d1*b1
indirect2 := a1a*d1*b2
indirect3 := a1b*d2*b3

# defined parameters
ECR_an_an := v1
ECR_av_av := v2
'

## the analysis ====
output <- lavaan.mi(model, data=data3t.mi.1, estimator = "MLM", se = "robust.huber.white")

## Monte Carlo CI
monteCarloCI(output, standardized = TRUE)

## the error message is:
Error in monteCarloCI(output2T, standardized = TRUE) : 
  argument "expr" is missing, with no default

## including "ECR_an_an := v1" and "ECR_av_av := v2" gives an error message. The error message is:
Error in chol.default(varcov) : 
  the leading minor of order 1 is not positive


added 175 characters in body
Source Link
Dale
  • 171
  • 5
## load packages
library(semTools)
library(lavaan.mi)

## load imputed data
data3t.mi.1 <- readRDS("data3t.RDS")

## make the output of mice for the lavaan.mi function to work 
data3t.mi.1 <- NULL
for(i in 1:50) data3t.mi.1[[i]] <- mice::complete(data3t.mi, action=i, inc=FALSE)

## specify my model
model <- '
MRC_Ego_total ~ a1a * ECR_anxiety_average + a2a * ECR_avoidance_average
MRC_Altru_total ~ a1b * ECR_anxiety_average + a2b * ECR_avoidance_average
MRC_provide_total ~ a1c * ECR_anxiety_average + a2c * ECR_avoidance_average
MRC_recog_total ~ a1d * ECR_anxiety_average + a2d * ECR_avoidance_average
MRC_worthy_total ~ a1e * ECR_anxiety_average + a2e * ECR_avoidance_average

TABS_self_total_T ~ d1 * MRC_Ego_total + d3 * MRC_provide_total + d4 * MRC_recog_total
TABS_other_total_T ~ d2 * MRC_Altru_total + d5 * MRC_worthy_total

TABS_self_total_T ~ e1 * ECR_anxiety_average + e3 * ECR_avoidance_average
TABS_other_total_T ~ e2 * ECR_anxiety_average + e4 * ECR_avoidance_average

# outcomes
CBI_total ~ b1 * TABS_self_total_T + b3 * TABS_other_total_T + c1 * ECR_anxiety_average + c3 * ECR_avoidance_average
STSS_total ~ b2 * TABS_self_total_T + b4 * TABS_other_total_T + c2 * ECR_anxiety_average + c4 * ECR_avoidance_average

# variances of exogenous variables
ECR_anxiety_average ~~ v1 * ECR_anxiety_average
ECR_avoidance_average ~~ v2 * ECR_avoidance_average

# covariance of exogenous variables
ECR_anxiety_average ~~ cov1 * ECR_avoidance_average

# variances for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ v3 * MRC_Ego_total
MRC_Altru_total ~~ v4 * MRC_Altru_total
MRC_provide_total ~~ v5 * MRC_provide_total
MRC_recog_total ~~ v6 * MRC_recog_total
MRC_worthy_total ~~ v7 * MRC_worthy_total
TABS_self_total_T ~~ v8 * TABS_self_total_T
TABS_other_total_T ~~ v9 * TABS_other_total_T
CBI_total ~~ v10 * CBI_total
STSS_total ~~ v11 * STSS_total

# covariance for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ cov2 * MRC_Altru_total + cov3 * MRC_provide_total + cov4 * MRC_recog_total + cov5 * MRC_worthy_total
MRC_Altru_total ~~ cov6 * MRC_provide_total + cov7 * MRC_recog_total + cov8 * MRC_worthy_total
MRC_provide_total ~~ cov9 *MRC_recog_total + cov10 * MRC_worthy_total
MRC_recog_total ~~ cov11 * MRC_worthy_total
TABS_self_total_T ~~ cov12 * TABS_other_total_T
CBI_total ~~ cov13 * STSS_total

# indirect effects
indirect1 := a1a*d1*b1
indirect2 := a1a*d1*b2
indirect3 := a1b*d2*b3 

# defined parameters
ECR_an_an := v1
ECR_av_av := v2
'

## the analysis ====
output <- lavaan.mi(model, data=data3t.mi.1, estimator = "MLM", se = "robust.huber.white")

## Monte Carlo CI
monteCarloCI(output, standardized = TRUE)

Giving: 
Error in monteCarloCI(output2T, standardized = TRUE) : 
  argument "expr" is missing, with no default

## When including "ECR_an_an := v1" and "ECR_av_av := v2" gives an error message. 

## the error message is:
Error in chol.default(varcov) : 
  the leading minor of order 281 is not positive 


## load packages
library(semTools)
library(lavaan.mi)

## load imputed data
data3t.mi.1 <- readRDS("data3t.RDS")

## make the output of mice for the lavaan.mi function to work 
data3t.mi.1 <- NULL
for(i in 1:50) data3t.mi.1[[i]] <- mice::complete(data3t.mi, action=i, inc=FALSE)

## specify my model
model <- '
MRC_Ego_total ~ a1a * ECR_anxiety_average + a2a * ECR_avoidance_average
MRC_Altru_total ~ a1b * ECR_anxiety_average + a2b * ECR_avoidance_average
MRC_provide_total ~ a1c * ECR_anxiety_average + a2c * ECR_avoidance_average
MRC_recog_total ~ a1d * ECR_anxiety_average + a2d * ECR_avoidance_average
MRC_worthy_total ~ a1e * ECR_anxiety_average + a2e * ECR_avoidance_average

TABS_self_total_T ~ d1 * MRC_Ego_total + d3 * MRC_provide_total + d4 * MRC_recog_total
TABS_other_total_T ~ d2 * MRC_Altru_total + d5 * MRC_worthy_total

TABS_self_total_T ~ e1 * ECR_anxiety_average + e3 * ECR_avoidance_average
TABS_other_total_T ~ e2 * ECR_anxiety_average + e4 * ECR_avoidance_average

# outcomes
CBI_total ~ b1 * TABS_self_total_T + b3 * TABS_other_total_T + c1 * ECR_anxiety_average + c3 * ECR_avoidance_average
STSS_total ~ b2 * TABS_self_total_T + b4 * TABS_other_total_T + c2 * ECR_anxiety_average + c4 * ECR_avoidance_average

# variances of exogenous variables
ECR_anxiety_average ~~ v1 * ECR_anxiety_average
ECR_avoidance_average ~~ v2 * ECR_avoidance_average

# covariance of exogenous variables
ECR_anxiety_average ~~ cov1 * ECR_avoidance_average

# variances for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ v3 * MRC_Ego_total
MRC_Altru_total ~~ v4 * MRC_Altru_total
MRC_provide_total ~~ v5 * MRC_provide_total
MRC_recog_total ~~ v6 * MRC_recog_total
MRC_worthy_total ~~ v7 * MRC_worthy_total
TABS_self_total_T ~~ v8 * TABS_self_total_T
TABS_other_total_T ~~ v9 * TABS_other_total_T
CBI_total ~~ v10 * CBI_total
STSS_total ~~ v11 * STSS_total

# covariance for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ cov2 * MRC_Altru_total + cov3 * MRC_provide_total + cov4 * MRC_recog_total + cov5 * MRC_worthy_total
MRC_Altru_total ~~ cov6 * MRC_provide_total + cov7 * MRC_recog_total + cov8 * MRC_worthy_total
MRC_provide_total ~~ cov9 *MRC_recog_total + cov10 * MRC_worthy_total
MRC_recog_total ~~ cov11 * MRC_worthy_total
TABS_self_total_T ~~ cov12 * TABS_other_total_T
CBI_total ~~ cov13 * STSS_total

# indirect effects
indirect1 := a1a*d1*b1
indirect2 := a1a*d1*b2
indirect3 := a1b*d2*b3
'

## the analysis ====
output <- lavaan.mi(model, data=data3t.mi.1, estimator = "MLM", se = "robust.huber.white")

## Monte Carlo CI
monteCarloCI(output, standardized = TRUE)

Giving: 
Error in monteCarloCI(output2T, standardized = TRUE) : 
  argument "expr" is missing, with no default

Error in chol.default(varcov) : 
  the leading minor of order 28 is not positive
## load packages
library(semTools)
library(lavaan.mi)

## load imputed data
data3t.mi.1 <- readRDS("data3t.RDS")

## make the output of mice for the lavaan.mi function to work 
data3t.mi.1 <- NULL
for(i in 1:50) data3t.mi.1[[i]] <- mice::complete(data3t.mi, action=i, inc=FALSE)

## specify my model
model <- '
MRC_Ego_total ~ a1a * ECR_anxiety_average + a2a * ECR_avoidance_average
MRC_Altru_total ~ a1b * ECR_anxiety_average + a2b * ECR_avoidance_average
MRC_provide_total ~ a1c * ECR_anxiety_average + a2c * ECR_avoidance_average
MRC_recog_total ~ a1d * ECR_anxiety_average + a2d * ECR_avoidance_average
MRC_worthy_total ~ a1e * ECR_anxiety_average + a2e * ECR_avoidance_average

TABS_self_total_T ~ d1 * MRC_Ego_total + d3 * MRC_provide_total + d4 * MRC_recog_total
TABS_other_total_T ~ d2 * MRC_Altru_total + d5 * MRC_worthy_total

TABS_self_total_T ~ e1 * ECR_anxiety_average + e3 * ECR_avoidance_average
TABS_other_total_T ~ e2 * ECR_anxiety_average + e4 * ECR_avoidance_average

# outcomes
CBI_total ~ b1 * TABS_self_total_T + b3 * TABS_other_total_T + c1 * ECR_anxiety_average + c3 * ECR_avoidance_average
STSS_total ~ b2 * TABS_self_total_T + b4 * TABS_other_total_T + c2 * ECR_anxiety_average + c4 * ECR_avoidance_average

# variances of exogenous variables
ECR_anxiety_average ~~ v1 * ECR_anxiety_average
ECR_avoidance_average ~~ v2 * ECR_avoidance_average

# covariance of exogenous variables
ECR_anxiety_average ~~ cov1 * ECR_avoidance_average

# variances for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ v3 * MRC_Ego_total
MRC_Altru_total ~~ v4 * MRC_Altru_total
MRC_provide_total ~~ v5 * MRC_provide_total
MRC_recog_total ~~ v6 * MRC_recog_total
MRC_worthy_total ~~ v7 * MRC_worthy_total
TABS_self_total_T ~~ v8 * TABS_self_total_T
TABS_other_total_T ~~ v9 * TABS_other_total_T
CBI_total ~~ v10 * CBI_total
STSS_total ~~ v11 * STSS_total

# covariance for endogenous variables (mediators & outcome variables)
MRC_Ego_total ~~ cov2 * MRC_Altru_total + cov3 * MRC_provide_total + cov4 * MRC_recog_total + cov5 * MRC_worthy_total
MRC_Altru_total ~~ cov6 * MRC_provide_total + cov7 * MRC_recog_total + cov8 * MRC_worthy_total
MRC_provide_total ~~ cov9 *MRC_recog_total + cov10 * MRC_worthy_total
MRC_recog_total ~~ cov11 * MRC_worthy_total
TABS_self_total_T ~~ cov12 * TABS_other_total_T
CBI_total ~~ cov13 * STSS_total

# indirect effects
indirect1 := a1a*d1*b1
indirect2 := a1a*d1*b2
indirect3 := a1b*d2*b3 

# defined parameters
ECR_an_an := v1
ECR_av_av := v2
'

## the analysis ====
output <- lavaan.mi(model, data=data3t.mi.1, estimator = "MLM", se = "robust.huber.white")

## Monte Carlo CI
monteCarloCI(output, standardized = TRUE)

Giving: 
Error in monteCarloCI(output2T, standardized = TRUE) : 
  argument "expr" is missing, with no default

## When including "ECR_an_an := v1" and "ECR_av_av := v2" gives an error message. 

## the error message is:
Error in chol.default(varcov) : 
  the leading minor of order 1 is not positive 


deleted 40 characters in body
Source Link
Dale
  • 171
  • 5

Link to data: https://2ly.link/1yd33

Link to RDS imputed datasets: https://2ly.link/1yd2r

Link to data: https://2ly.link/1yd33

Link to RDS imputed datasets: https://2ly.link/1yd2r

Link to RDS imputed datasets: https://2ly.link/1yd2r

added 111 characters in body
Source Link
Dale
  • 171
  • 5
Loading
added 4 characters in body
Source Link
Dale
  • 171
  • 5
Loading
added 1242 characters in body
Source Link
Dale
  • 171
  • 5
Loading
added 2187 characters in body
Source Link
Dale
  • 171
  • 5
Loading
Source Link
Dale
  • 171
  • 5
Loading