Good evening,

I´m new to ctsem and hope you can give me some advices on my code or in general :)

So shortly to the background:

I am writing my masters thesis in organizational psychology and I collected some data by means of the diary method (15 days with 2 entries per day, 73 individuals, about different 10 variables).

As an example I would like to show you my codes for my 1.Hypothesis, which assumes that Feedback (Fges) triggers Reflection (Rges), and Reflection also influences Feedback over time.

The simple code is this one:

#open packages

library(“ctsem”)

library(“Rcpp”)

library(“OpenMx”)

library(“ctsemOMX”)

library(“MASS”)

#load and read data in wide format

wide_Fges_Rges_H1 ← read.csv2(“C:/Users/Wika/Master/Masterarbeit/finale Daten für die Auswertung/H1 - Feedback_Reflexion/wide_Fges_Rges_H1.csv”, TRUE)

wide_Fges_Rges_H1

#specify model

Model_Fges_Rges ← ctModel(n.manifest=2, n.latent=2, Tpoints=30, LAMBDA = diag(2),

manifestNames=c(“Fges”, “Rges”),

latentNames=c(“Fges”, “Rges”), TRAITVAR=“auto”)

#fit the model to the data

Model_Fges_Rges_fit<- ctFit(wide_Fges_Rges_H1, Model_Fges_Rges)

#summaries

summary(Model_Fges_Rges_fit, verbose = TRUE)

summary(Model_Fges_Rges_fit, verbose = TRUE)[“discreteDRIFTstd”]

#confidence intervals

Model_Fges_Rges_CI<- ctCI(Model_Fges_Rges_fit, confidenceintervals = “DRIFT”)

summary(Model_Fges_Rges_CI, verbose = TRUE)

#summary with model fit statistics

summary(Model_Fges_Rges_fit$mxobj, refModels=mxRefModels(Model_Fges_Rges_fit$mxobj, run = TRUE), verbose = TRUE)

However, I also have another, which I received from another student:

#load packages

library(“ctsem”)

library(“Rcpp”)

library(“OpenMx”)

library(“ctsemOMX”)

library(“MASS”)

#read data

wide_Fges_Rges_H1 ← read.csv2(“C:/Users/Wika/Master/Masterarbeit/finale Daten für die Auswertung/H1 - Feedback_Reflexion/wide_Fges_Rges_H1.csv”, TRUE)

wide_Fges_Rges_H1

#specify model

Model_Fges_Rges ← ctModel(LAMBDA=matrix(c(1, 0, 0, 1), 2, 2), type = “omx”, n.manifest = 2, n.latent = 2,

Tpoints = 30,

manifestNames = c(“Fges”, “Rges”),

latentNames = c(“Fges”, “Rges”),

id = “ID”,

time = “Time”,

T0MEANS = matrix(c(“mFges0”, “mRges0”), 2, 1),

MANIFESTMEANS = matrix(c(0, 0), 2, 1),

MANIFESTVAR=matrix(c(0, 0, 0, 0), 2, 2),

DRIFT=matrix(c(“Auto_Fges”, “FgestoRges”, “RgestoFges”, “Auto_Rges”), 2, 2),

CINT = matrix(c(“cint1”, “cint2”), 2, 1),

DIFFUSION = “auto”,

n.TDpred = “auto”,

TDpredNames = “auto”,

n.TIpred = “auto”,

TIpredNames = “auto”,

tipredDefault = TRUE,

TRAITVAR = NULL,

T0TRAITEFFECT = NULL,

MANIFESTTRAITVAR = NULL,

TDPREDMEANS = “auto”,

TDPREDEFFECT = “auto”,

T0TDPREDCOV = “auto”,

TDPREDVAR = “auto”,

TRAITTDPREDCOV = “auto”,

TDTIPREDCOV = “auto”,

TIPREDMEANS = “auto”,

TIPREDEFFECT = “auto”,

T0TIPREDEFFECT = “auto”,

TIPREDVAR = “auto”,

PARS = NULL,

startValues = NULL

)

#fit model to data

Model_Fges_Rges_LL ← 100000

for (i in 1:20) {

set.seed(i)

Model_Fges_Rges_fit ← ctFit(dataform = “wide”, dat=wide_Fges_Rges_H1, ctmodelobj=Model_Fges_Rges, retryattempts=100)

if (Model_Fges_Rges_fit$mxobj$output$Minus2LogLikelihood < Model_Fges_Rges_LL) {

Model_Fges_Rges_LL ← Model_Fges_Rges_fit$mxobj$output$Minus2LogLikelihood

Model_Fges_Rges_optFit ← Model_Fges_Rges_fit

optFitRun ← i

}

}

Model_Fges_Rges_fit ← Model_Fges_Rges_optFit

#summaries

summary(Model_Fges_Rges_fit)

summary(Model_Fges_Rges_fit, verbose = TRUE)

summary(Model_Fges_Rges_fit, verbose = TRUE)[“discreteDRIFTstd”]

summary(Model_Fges_Rges_fit$mxobj, refModels=mxRefModels(Model_Fges_Rges_fit$mxobj, run = TRUE), verbose = TRUE)

#confidence intervals

Model_Fges_Rges_cifit ← ctCI(Model_Fges_Rges_fit, confidenceintervals = “DRIFT”)

summary(Model_Fges_Rges_cifit, verbose = TRUE)

My issues are the following:

- Which of those suits better to fit the model I need?
- Confidence Intervals are not computed, however instead of an error I receive “NA” or “!!!”
- How can I compute T-values and the p-values for a T-test? Unfortunately, I did not find any sample codes for this.
- My CFI is quite bad, is there a possibility to improve this?
- Is it normal, that the last summary code “summary(Model_Fges_Rges_fit$mxobj, refModels=mxRefModels(Model_Fges_Rges_fit$mxobj, run = TRUE), verbose = TRUE)” takes about 8-10 hours to be computed? Is that due to much data or is there another issue?

Thanks in advance, I would appreciate any help :)