Last updated: 2021-08-10

Checks: 7 0

Knit directory: femNATCD_MethSeq/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210128) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 723a1aa. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.Rhistory
    Ignored:    code/.Rhistory
    Ignored:    data/Epicounts.csv
    Ignored:    data/Epimeta.csv
    Ignored:    data/Epitpm.csv
    Ignored:    data/KangUnivers.txt
    Ignored:    data/Kang_DataPreprocessing.RData
    Ignored:    data/Kang_dataset_genesMod_version2.txt
    Ignored:    data/PatMeta.csv
    Ignored:    data/ProcessedData.RData
    Ignored:    data/RTrawdata/
    Ignored:    data/SNPCommonFilt.csv
    Ignored:    data/femNAT_PC20.txt
    Ignored:    output/BrainMod_Enrichemnt.pdf
    Ignored:    output/Brain_Module_Heatmap.pdf
    Ignored:    output/DMR_Results.csv
    Ignored:    output/GOres.xlsx
    Ignored:    output/LME_GOplot.pdf
    Ignored:    output/LME_Results.csv
    Ignored:    output/LME_Results_Sig.csv
    Ignored:    output/LME_tophit.svg
    Ignored:    output/ProcessedData.RData
    Ignored:    output/RNAvsMETplots.pdf
    Ignored:    output/Regions_GOplot.pdf
    Ignored:    output/ResultsgroupComp.txt
    Ignored:    output/SEM_summary_groupEpi_M15.txt
    Ignored:    output/SEM_summary_groupEpi_M2.txt
    Ignored:    output/SEM_summary_groupEpi_M_all.txt
    Ignored:    output/SEM_summary_groupEpi_TopHit.txt
    Ignored:    output/SEM_summary_groupEpi_all.txt
    Ignored:    output/SEMplot_Epi_M15.html
    Ignored:    output/SEMplot_Epi_M15.png
    Ignored:    output/SEMplot_Epi_M15_files/
    Ignored:    output/SEMplot_Epi_M2.html
    Ignored:    output/SEMplot_Epi_M2.png
    Ignored:    output/SEMplot_Epi_M2_files/
    Ignored:    output/SEMplot_Epi_M_all.html
    Ignored:    output/SEMplot_Epi_M_all.png
    Ignored:    output/SEMplot_Epi_M_all_files/
    Ignored:    output/SEMplot_Epi_TopHit.html
    Ignored:    output/SEMplot_Epi_TopHit.png
    Ignored:    output/SEMplot_Epi_TopHit_files/
    Ignored:    output/SEMplot_Epi_all.html
    Ignored:    output/SEMplot_Epi_all.png
    Ignored:    output/SEMplot_Epi_all_files/
    Ignored:    output/barplots.pdf
    Ignored:    output/circos_DMR_tags.svg
    Ignored:    output/circos_LME_tags.svg
    Ignored:    output/clinFact.RData
    Ignored:    output/dds_filt_analyzed.RData
    Ignored:    output/designh0.RData
    Ignored:    output/designh1.RData
    Ignored:    output/envFact.RData
    Ignored:    output/functional_Enrichemnt.pdf
    Ignored:    output/gostres.pdf
    Ignored:    output/modelFact.RData
    Ignored:    output/resdmr.RData
    Ignored:    output/resultsdmr_table.RData
    Ignored:    output/table1_filtered.Rmd
    Ignored:    output/table1_filtered.docx
    Ignored:    output/table1_unfiltered.Rmd
    Ignored:    output/table1_unfiltered.docx
    Ignored:    setup_built.R

Unstaged changes:
    Modified:   output/README.md

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/03_01_Posthoc_analyses_Gene_Enrichment.Rmd) and HTML (docs/03_01_Posthoc_analyses_Gene_Enrichment.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 723a1aa achiocch 2021-08-09 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 70cd649 achiocch 2021-08-06 Build site.
Rmd 611ca24 achiocch 2021-08-06 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 2a53a87 achiocch 2021-08-06 Build site.
Rmd e4425b8 achiocch 2021-08-06 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html e3a9ae3 achiocch 2021-08-04 Build site.
Rmd 3979990 achiocch 2021-08-04 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html f6bbdc0 achiocch 2021-08-04 Build site.
Rmd 1a30b73 achiocch 2021-08-04 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 1a30b73 achiocch 2021-08-04 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 710904a achiocch 2021-08-03 Build site.
Rmd 16112c3 achiocch 2021-08-03 wflow_publish(c(“analysis/", "code/”, “docs/”))
html 16112c3 achiocch 2021-08-03 wflow_publish(c(“analysis/", "code/”, “docs/”))
html cde8384 achiocch 2021-08-03 Build site.
Rmd d3629d5 achiocch 2021-08-03 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html d3629d5 achiocch 2021-08-03 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html d761be4 achiocch 2021-07-31 Build site.
Rmd b452d2f achiocch 2021-07-30 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html b452d2f achiocch 2021-07-30 wflow_publish(c(“analysis/", "code/”, "docs/*"))
Rmd 1a9f36f achiocch 2021-07-30 reviewed analysis
html 2734c4e achiocch 2021-05-08 Build site.
html a847823 achiocch 2021-05-08 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 9cc52f7 achiocch 2021-05-08 Build site.
html 158d0b4 achiocch 2021-05-08 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 0f262d1 achiocch 2021-05-07 Build site.
html 5167b90 achiocch 2021-05-07 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 05aac7f achiocch 2021-04-23 Build site.
Rmd 5f070a5 achiocch 2021-04-23 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html f5c5265 achiocch 2021-04-19 Build site.
Rmd dc9e069 achiocch 2021-04-19 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html dc9e069 achiocch 2021-04-19 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 17f1eec achiocch 2021-04-10 Build site.
Rmd 4dee231 achiocch 2021-04-10 wflow_publish(c(“analysis/", "code/”, "docs/*"))
html 91de221 achiocch 2021-04-05 Build site.
Rmd b6c6b33 achiocch 2021-04-05 updated GO function, and model def
html 4ea1bba achiocch 2021-02-25 Build site.
Rmd 6c21638 achiocch 2021-02-25 wflow_publish(c(“analysis/", "code/”, "docs/*"), update = F)
html 6c21638 achiocch 2021-02-25 wflow_publish(c(“analysis/", "code/”, "docs/*"), update = F)

Sensitivity Analyses

Sensitivity EWAS

including SES

collector=data.frame(originalP=results_Deseq$pvalue,
                     originall2FC=results_Deseq$log2FoldChange)

rownames(collector)=paste0("Epi", 1:nrow(collector))

parm="EduPar"

workingcopy = dds_filt
workingcopy=workingcopy[,as.vector(!is.na(colData(dds_filt)[parm]))]
modelpar=as.character(design(dds_filt))[2]
tmpmod=gsub("0", paste0("~ 0 +",parm), modelpar)
tmpmod=gsub("int_dis \\+", "", tmpmod)

modelpar=as.formula(tmpmod)
design(workingcopy) = modelpar

workingcopy = DESeq(workingcopy, parallel = T)
using pre-existing size factors
estimating dispersions
gene-wise dispersion estimates: 6 workers
mean-dispersion relationship
final dispersion estimates, fitting model and testing: 6 workers
parmres=results(workingcopy)

collector[,paste0(parm,"P")] = parmres$pvalue
collector[,paste0(parm,"l2FC")] = parmres$log2FoldChange

idx=collector$originalP<=thresholdp
idx=collector[,paste0(parm,"P")]<=thresholdp

table(collector$originalP<=thresholdp, collector[paste0(parm,"P")]<=thresholdp) %>% fisher.test()

    Fisher's Exact Test for Count Data

data:  .
p-value < 2.2e-16
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 47.31585 57.91749
sample estimates:
odds ratio 
  52.34226 
cor.test(collector$originall2FC[idx],collector[,paste0(parm,"l2FC")][idx],
         method = "spearman")

    Spearman's rank correlation rho

data:  collector$originall2FC[idx] and collector[, paste0(parm, "l2FC")][idx]
S = 199820136, p-value < 2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.9275243 
qqplot(y=-log10(collector[,paste0(parm,"P")]), 
       x = -log(runif(nrow(collector))), xlim=c(0,12),ylim=c(0,12),
       col="gray", ylab="", xlab="")
par(new=T)
qqplot(y=-log10(collector$originalP), 
       x = -log(runif(nrow(collector))),xlim=c(0,12),ylim=c(0,12),
       xlab="expected",ylab="observed")
abline(0,1,col="red")
legend("topleft", pch=1, col=c("black", "gray"), legend=c("original", parm))

plot(collector$originall2FC[idx],collector[,paste0(parm,"l2FC")][idx], pch=16, 
     main="log 2 foldchange", ylab=parm, xlab="original")

excluding int_dis

### excluding int_dist

modelpar=as.character(design(dds_filt))[2]
modelpar=as.formula(paste("~",gsub("int_dis +", "", modelpar)))

design(workingcopy) = modelpar

workingcopy = DESeq(workingcopy, parallel=T)
using pre-existing size factors
estimating dispersions
gene-wise dispersion estimates: 6 workers
mean-dispersion relationship
final dispersion estimates, fitting model and testing: 6 workers
parmres=results(workingcopy)

parm="wo.int.dis"
collector[,paste0(parm,"P")] = parmres$pvalue
collector[,paste0(parm,"l2FC")] = parmres$log2FoldChange

idx=collector$originalP<=thresholdp
idx=collector[,paste0(parm,"P")]<=thresholdp

table(collector$originalP<=thresholdp, collector[paste0(parm,"P")]<=thresholdp) %>% fisher.test()

    Fisher's Exact Test for Count Data

data:  .
p-value < 2.2e-16
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 78.91108 96.18862
sample estimates:
odds ratio 
  87.22894 
cor.test(collector$originall2FC[idx],collector[,paste0(parm,"l2FC")][idx],
         method = "spearman")

    Spearman's rank correlation rho

data:  collector$originall2FC[idx] and collector[, paste0(parm, "l2FC")][idx]
S = 122592852, p-value < 2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.9464573 
qqplot(y=-log10(collector[,paste0(parm,"P")]), 
       x = -log(runif(nrow(collector))), xlim=c(0,12),ylim=c(0,12),
       col="gray", ylab="", xlab="")
par(new=T)
qqplot(y=-log10(collector$originalP), 
       x = -log(runif(nrow(collector))),xlim=c(0,12),ylim=c(0,12),
       xlab="expected",ylab="observed")
abline(0,1,col="red")
legend("topleft", pch=1, col=c("black", "gray"), legend=c("original", parm))

plot(collector$originall2FC[idx],collector[,paste0(parm,"l2FC")][idx], pch=16, 
     main="log 2 foldchange", ylab=parm, xlab="original")

## Sensitivity main hit

For the most significant tag of interest (5’ of the SLITRK5 gene), we tested if the group effect is stable if correcting for Ethnicity (PC1-PC4) or CD associated environmental risk factors.

tophit=which.min(results_Deseq$padj)
methdata=log2_cpm[tophit,]
Probdat=as.data.frame(colData(dds_filt))
Probdat$topHit=methdata[rownames(Probdat)]


model0=as.character(design(dds_filt))[2]
model0=as.formula(gsub("0 +", "topHit ~ 0 + ", model0))

lmres=lm(model0, data=Probdat)
lmrescoeff = as.data.frame(coefficients(summary(lmres)))

totestpar=c("site","PC_1", "PC_2", "PC_3", "PC_4", envFact)

ressens=data.frame(matrix(nrow = length(totestpar)+1, ncol=c(3)))
colnames(ressens) = c("beta", "se", "p.value")
rownames(ressens) = c("original", totestpar)

ressens["original",] = lmrescoeff["groupCD", c("Estimate", "Std. Error", "Pr(>|t|)")]

for( parm in totestpar){
  modelpar=as.character(design(dds_filt))[2]
  modelpar=as.formula(gsub("0", paste0("topHit ~ 0 +",parm), modelpar))
  lmres=lm(modelpar, data=Probdat)
  lmrescoeff = as.data.frame(coefficients(summary(lmres)))
  ressens[parm,] = lmrescoeff["groupCD", c("Estimate", "Std. Error", "Pr(>|t|)")] 
}

modelpar=as.character(design(dds_filt))[2]
modelpar=as.formula(gsub("int_dis +", "", gsub("0", "topHit ~ 0", modelpar)))

lmres=lm(modelpar, data=Probdat)
lmrescoeff = as.data.frame(coefficients(summary(lmres)))
ressens["w/o_int_dis",] = lmrescoeff["groupCD", c("Estimate", "Std. Error", "Pr(>|t|)")] 


a = barplot(height = ressens$beta, 
            ylim=rev(range(c(0,ressens$beta-ressens$se)))*1.3, 
            names.arg = rownames(ressens), col=Set3, border = NA, las=3, 
            ylab="beta[se]", main="Effect sensitvity analysis")

arrows(a,ressens$beta, a, ressens$beta+ressens$se, angle = 90, length = 0.1)
arrows(a,ressens$beta, a, ressens$beta-ressens$se, angle = 90, length = 0.1)

text(a, min(ressens$beta-ressens$se)*1.15, 
     formatC(ressens$p.value), cex=0.6, srt=90)

All models are corrected for:
site, Age, Pubstat, int_dis, medication, contraceptives, cigday_1,
site is included as random effect.

original: model defined as 0 + +Age + int_dis + medication + contraceptives + cigday_1 + V8 + group

all other models represent the original model + the variable of interest

Real-time PCR validation

Data loading and parsing

RefGenes = c("GUSB")
Targets_of_Int = c("SLITRK5", "MIR4500HG")
nreplicates = 3
flagscore=Inf #replication quality error

SamplesMeta=read_xlsx(paste0(Home,"/data/RTrawdata/ZelllinienRNA_femNAT.xlsx"))
as.data.frame(SamplesMeta) -> SamplesMeta
                      
SamplesMeta$Pou=paste("POU", SamplesMeta$Pou)
rownames(SamplesMeta)=SamplesMeta$Pou

SamplesMeta$Group = dds_filt$group[match(SamplesMeta$femNATID, dds_filt$ID_femNAT)]


Files=list.files(paste0(Home,"/data/RTrawdata/"), full.names = T)

Files=Files[grepl("_data",Files)]

Sets=unique(substr(basename(Files), 1,8))

Targets_all=vector()
Samples_all=vector()


geoMean=function(x){
  x=x[!is.na(x)]
  if(length(x)==0)
    return(NA)
  else
    return((prod(x))^(1/length(x)))}

for (Set in Sets){

    Setfiles=Files[grep(Set, Files)]

    for( i in 1:length(Setfiles)){
      tmp=read.table(Setfiles[i], skip=8, header=T, sep="\t", comment.char = "", fill=T)[1:96,]
      tmp=tmp[,c("Sample.Name", "Target.Name","CÑ.")]
      colnames(tmp)=c("Sample.Name", "Target.Name", "CT")
      tmp$Target.Name=gsub("SLITRK5_L", "SLITRK5_", tmp$Target.Name)
      tmp$Target.Name=gsub("VD_", "", tmp$Target.Name)
      tmp$Target.Name=gsub("_", "", tmp$Target.Name)
      tmp$Target.Name=substr(tmp$Target.Name,1, regexpr("#", tmp$Target.Name)-1)
      tmp$CT=as.numeric(tmp$CT)
      
      # set bad replicates to NA 
      tmpmu = tapply(tmp$CT, paste0(tmp$Sample.Name,"_",tmp$Target.Name), mean, na.rm=T)
      tmpsd = tapply(tmp$CT, paste0(tmp$Sample.Name,"_",tmp$Target.Name), sd, na.rm=T)
      for (corr in which(tmpsd>flagscore)){
        index=unlist(strsplit(names(tmpmu)[corr], "_"))
        tmp[which(tmp$Sample.Name==index[1] & tmp$Target.Name==index[2]),"CT"] = NA
      }
      assign(paste0("tmp_",Set,"_",i),tmp)
    }
    
    tmp=do.call("rbind", mget(apropos(paste0("tmp_",Set))))
    tmp=tmp[which(!(tmp$Sample.Name==""|is.na(tmp$Sample.Name))), ]
    tmp=tmp[!tmp$Sample.Name=="NTC",]
    
    Samples=unique(tmp$Sample.Name)
    Targets=unique(tmp$Target.Name)
    Samples_all=unique(c(Samples_all, Samples))
    Targets_all=unique(c(Targets_all, Targets))
    
    Reform=data.frame(matrix(NA, nrow=length(Samples), ncol=length(Targets)*nreplicates))
    
    colnames(Reform)=paste0(rep(Targets, each=3), letters[1:nreplicates])
    rownames(Reform)=Samples
    
    for (i in Samples) {
      #print(i)
      for (j in Targets){
        Reform[i,grep(j, colnames(Reform))]=tmp[tmp$Sample.Name==i & tmp$Target.Name==j,"CT"]
      }
    }
    
    HK=colnames(Reform)[grep(paste0(RefGenes, collapse="|"),colnames(Reform))]
    
    GMHK=apply(Reform[,HK], 1, geoMean)
    tmp2=Reform-GMHK
    
    assign(paste0(Set,"_dCT"), tmp2)
    rm(list=c(apropos("tmp"), "Reform", "GMHK"))
    
}
Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'get_java_tmp_dir' nicht gefunden
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'set_java_tmp_dir' nicht gefunden
Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'get_java_tmp_dir' nicht gefunden
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'set_java_tmp_dir' nicht gefunden
Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'get_java_tmp_dir' nicht gefunden
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'set_java_tmp_dir' nicht gefunden
Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'get_java_tmp_dir' nicht gefunden
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'set_java_tmp_dir' nicht gefunden
Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'get_java_tmp_dir' nicht gefunden
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'set_java_tmp_dir' nicht gefunden
Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'get_java_tmp_dir' nicht gefunden
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'set_java_tmp_dir' nicht gefunden
Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'get_java_tmp_dir' nicht gefunden
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'set_java_tmp_dir' nicht gefunden
Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt

Warning: NAs durch Umwandlung erzeugt
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'get_java_tmp_dir' nicht gefunden
Warning in rm(list = c(apropos("tmp"), "Reform", "GMHK")): Objekt
'set_java_tmp_dir' nicht gefunden
Samples_all=unique(Samples_all)
Targets_all = unique(Targets_all)

mergedCTtable=data.frame(matrix(NA,ncol=length(Targets_all)*nreplicates, nrow=length(Samples_all)))
colnames(mergedCTtable)=paste0(rep(unique(Targets_all), each=nreplicates), letters[1:nreplicates])
rownames(mergedCTtable)=Samples_all

CTobj=apropos("_dCT")

for( obj in CTobj){
  DF=get(obj)
  for(k in colnames(DF)){
    for(l in rownames(DF)){
      mergedCTtable[l,k]=DF[l,k]
    }
  }
}

CTmeans=colMeans(mergedCTtable, na.rm = T)

meanvec=tapply(CTmeans,gsub(paste0(letters[1:nreplicates],collapse="|"),"",names(CTmeans)), mean, na.rm=T)
meanvec = rep(meanvec, each=nreplicates)
names(meanvec) = paste0(names(meanvec), letters[1:nreplicates])
meanvec=meanvec[colnames(mergedCTtable)]
ddCT=apply(mergedCTtable,1, function(x){x-meanvec}) 

FC=2^-ddCT


SamplesMeta$inset=F
SamplesMeta$inset[SamplesMeta$Pou %in% colnames(FC)]=T

SamplesMeta=SamplesMeta[SamplesMeta$inset,]

CTRLCASEsorter=c(which(SamplesMeta$Group=="CTRL"),which(SamplesMeta$Group=="CD"))
SamplesMeta = SamplesMeta[CTRLCASEsorter, ]

searcher=paste0(Targets_of_Int, collapse = "|")

FC = FC[grepl(searcher, rownames(FC)),SamplesMeta$Pou]

MuFC=apply(FC, 2, function(x){tapply(log2(x), gsub("a|b|c","",rownames(FC)), mean, na.rm=T)})
SDFC=apply(FC, 2, function(x){tapply(log2(x), gsub("a|b|c","",rownames(FC)), sd, na.rm=T)})

plot erelative expression by samples

pdf(paste0(Home, "/output/barplots.pdf"))

for(i in Targets_of_Int){
  if(any(!is.na(MuFC[i,]))){
  a=barplot(unlist(MuFC[i,]), col=as.numeric(SamplesMeta[colnames(MuFC),"Group"])+1, main=i, las=3, 
            ylim=c(-max(abs(MuFC[i,])*1.2, na.rm=T), (max(abs(MuFC[i,])*1.2, na.rm=T))))
  arrows(a, MuFC[i,], a, MuFC[i,]+SDFC[i,], angle = 90, length = 0.1)
  arrows(a, MuFC[i,], a, MuFC[i,]-SDFC[i,], angle = 90, length = 0.1)
  legend("topleft", c("case", "control"), col=c(1,2), pch=15, bty="n")
  } else {
    plot(0,0, type="n", main=paste(i, "not detected"))
  }
}

dev.off()
png 
  2 
for(i in Targets_of_Int){
  if(any(!is.na(MuFC[i,]))){
  a=barplot(unlist(MuFC[i,]), col=as.numeric(SamplesMeta[colnames(MuFC),"Group"])+1, main=i, las=3, 
            ylim=c(-max(abs(MuFC[i,])*1.2, na.rm=T), (max(abs(MuFC[i,])*1.2, na.rm=T))))
  arrows(a, MuFC[i,], a, MuFC[i,]+SDFC[i,], angle = 90, length = 0.1)
  arrows(a, MuFC[i,], a, MuFC[i,]-SDFC[i,], angle = 90, length = 0.1)
  legend("topleft", c("case", "control"), col=c(1,2), pch=15, bty="n")
  } else {
    plot(0,0, type="n", main=paste(i, "not detected"))
  }
}

compare across groups

sink(paste0(Home, "/output/ResultsgroupComp.txt"))

Group=SamplesMeta$Group
for(i in Targets_of_Int){
  print(i)
  print(summary(try(lm(unlist(MuFC[i,])~Group))))
  print(t.test(unlist(MuFC[i,])~Group))
}
[1] "SLITRK5"

Call:
lm(formula = unlist(MuFC[i, ]) ~ Group)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.3710 -0.4489  0.1142  0.4382  0.9983 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  -0.1703     0.1718  -0.991    0.334
GroupCD       0.5109     0.2975   1.717    0.102

Residual standard error: 0.6427 on 19 degrees of freedom
Multiple R-squared:  0.1343,    Adjusted R-squared:  0.08878 
F-statistic: 2.949 on 1 and 19 DF,  p-value: 0.1022


    Welch Two Sample t-test

data:  unlist(MuFC[i, ]) by Group
t = -2.0316, df = 18.197, p-value = 0.05706
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -1.03871726  0.01701686
sample estimates:
mean in group CTRL   mean in group CD 
        -0.1702834          0.3405668 

[1] "MIR4500HG"

Call:
lm(formula = unlist(MuFC[i, ]) ~ Group)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.7172 -1.2116 -0.2660  0.5749  5.4474 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  -0.6053     0.5683  -1.065    0.301
GroupCD       0.6614     0.9607   0.688    0.500

Residual standard error: 2.049 on 18 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.02566,   Adjusted R-squared:  -0.02847 
F-statistic: 0.474 on 1 and 18 DF,  p-value: 0.4999


    Welch Two Sample t-test

data:  unlist(MuFC[i, ]) by Group
t = -0.65047, df = 10.602, p-value = 0.5292
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.909646  1.586853
sample estimates:
mean in group CTRL   mean in group CD 
       -0.60525003         0.05614653 
sink()


SamplesMeta$femNATID2=paste0("ID_",gsub("-","_",SamplesMeta$femNATID))

SamplesMeta=SamplesMeta[SamplesMeta$Pou %in% colnames(MuFC),]
MuFC=MuFC[,SamplesMeta$Pou]

TPM4RNA=selEpitpm[,SamplesMeta$femNATID2]
colnames(TPM4RNA)=SamplesMeta$Pou

tags=list()


Targets=Targets_of_Int


sigtags=which(restab$padj<=0.05)

tagsOI=grep(paste0(Targets, collapse = "|"),selEpiMeta$gene)

sigtagsOI = tagsOI[tagsOI %in% sigtags]

fintagsOI=data.frame(tags=sigtagsOI, gene=selEpiMeta[sigtagsOI,"gene"])

#Targ=Targets[1]
#tag=tags[1]

compare against methylation level

pdf(paste0(Home,"/output/RNAvsMETplots.pdf"), width = 15, height = 8)

MuFC=as.data.frame(MuFC)
MuFCsel=MuFC[Targets,]
par(mar=c(5,5,5,3), mfrow=c(1,2))
for (Targ in Targets){
  tags=fintagsOI$tags[grep(Targ, fintagsOI$gene)]
  for (tag in tags){
    data=data.frame(tpm=unlist(TPM4RNA[tag,SamplesMeta$Pou]) , 
                    RT=unlist(MuFCsel[grep(Targ, rownames(MuFCsel)),SamplesMeta$Pou]))
    plot(data$tpm,data$RT, 
         xlab="methylation tpm", 
         ylab = "mRNA log2FC vs mean", 
         ylim=c(-3,3),
         col=4-as.numeric(SamplesMeta$Group), 
         pch=as.numeric(SamplesMeta$Group)+14,
         main=paste(tag, "Meth vs mRNA Expr", Targ))
    legend("topleft", c("control", "case"), pch=c(15,16), col=c(3,2), bty="n")
    a=lm(RT~tpm, data)
    b=summary(a)
    abline(a, col="blue")

    SperCor=cor(data$RT,data$tpm,use = "c", method = "spearman")
    mtext(3, text = paste("beta = ", round(coefficients(a)[2],2), 
                          "; se =", round(b$coefficients[2,2],2), 
                          "; pvalue = ", round(b$coefficients[2,4],3), 
                          "; sperman cor = ", round(SperCor,3)))
  }
}

dev.off()
png 
  2 
MuFC=as.data.frame(MuFC)
MuFCsel=MuFC[Targets,]
par(mar=c(5,5,5,3), mfrow=c(1,2))
for (Targ in Targets){
  tags=fintagsOI$tags[grep(Targ, fintagsOI$gene)]
  for (tag in tags){
    data=data.frame(tpm=unlist(TPM4RNA[tag,SamplesMeta$Pou]) , 
                    RT=unlist(MuFCsel[grep(Targ, rownames(MuFCsel)),SamplesMeta$Pou]))
    plot(data$tpm,data$RT, 
         xlab="methylation tpm", 
         ylab = "mRNA log2FC vs mean", 
         ylim=c(-3,3),
         col=4-as.numeric(SamplesMeta$Group), 
         pch=as.numeric(SamplesMeta$Group)+14,
         main=paste(tag, "Meth vs mRNA Expr", Targ))
    legend("topleft", c("control", "case"), pch=c(15,16), col=c(3,2), bty="n")
    a=lm(RT~tpm, data)
    b=summary(a)
    abline(a, col="blue")
    SperCor=cor(data$RT,data$tpm,use = "c", method = "spearman")
    mtext(3, text = paste("beta = ", round(coefficients(a)[2],2), 
                          "; se =", round(b$coefficients[2,2],2), 
                          "; pvalue = ", round(b$coefficients[2,4],3), 
                          "; Spearman cor = ", round(SperCor,3)))
  }
}

Systems Analysis

Genomic feature enrichment

Significant loci with a p-value <= 0.01 and a absolute log2 fold-change lager 0.5 were tested for enrichment in annotated genomic feature using fisher exact test.

Ranges=rowData(dds_filt)

TotTagsofInterest=sum(Ranges$WaldPvalue_groupCD<=thresholdp & abs(Ranges$groupCD)>thresholdLFC)

Resall=data.frame()
index = Ranges$WaldPvalue_groupCD<=thresholdp& abs(Ranges$groupCD)>thresholdLFC
for (feat in unique(Ranges$feature)){
  tmp=table(Ranges$feature == feat, signif=index)
  resfish=fisher.test(tmp)
  res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
  Resall = rbind(Resall, res)
}
tmp=table(Ranges$tf_binding!="", signif=index)
resfish=fisher.test(tmp)
res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
Resall = rbind(Resall, res)
tmp=table(Ranges$cpg=="cpg", signif=index)
resfish=fisher.test(tmp)
res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
Resall = rbind(Resall, res)
colnames(Resall)=c("OR", "CI95L", "CI95U", "P")
rownames(Resall)=c(unique(Ranges$feature), "TF-binding", "CpG-island")
Resall$Beta = log(Resall$OR)
Resall$SE = (log(Resall$OR)-log(Resall$CI95L))/1.96
Resall$Padj=p.adjust(Resall$P, method = "bonferroni")

Resdown=data.frame()
index = Ranges$WaldPvalue_groupCD<=thresholdp & Ranges$groupCD<thresholdLFC
for (feat in unique(Ranges$feature)){
  tmp=table(Ranges$feature == feat, signif=index)
  resfish=fisher.test(tmp)
  res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
  Resdown = rbind(Resdown, res)
}
tmp=table(Ranges$tf_binding!="", signif=index)
resfish=fisher.test(tmp)
res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
Resdown = rbind(Resdown, res)
tmp=table(Ranges$cpg=="cpg", signif=index)
resfish=fisher.test(tmp)
res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
Resdown = rbind(Resdown, res)
colnames(Resdown)=c("OR", "CI95L", "CI95U", "P")
rownames(Resdown)=c(unique(Ranges$feature), "TF-binding", "CpG-island")
Resdown$Beta = log(Resdown$OR)
Resdown$SE = (log(Resdown$OR)-log(Resdown$CI95L))/1.96
Resdown$Padj=p.adjust(Resdown$P, method = "bonferroni")

Resup=data.frame()
index = Ranges$WaldPvalue_groupCD<=thresholdp & Ranges$groupCD>thresholdLFC
for (feat in unique(Ranges$feature)){
  tmp=table(Ranges$feature == feat, signif=index)
  resfish=fisher.test(tmp)
  res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
  Resup = rbind(Resup, res)
}
tmp=table(Ranges$tf_binding!="", signif=index)
resfish=fisher.test(tmp)
res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
Resup = rbind(Resup, res)
tmp=table(Ranges$cpg=="cpg", signif=index)
resfish=fisher.test(tmp)
res = c(resfish$estimate, unlist(resfish$conf.int), resfish$p.value)
Resup = rbind(Resup, res)
colnames(Resup)=c("OR", "CI95L", "CI95U", "P")
rownames(Resup)=c(unique(Ranges$feature), "TF-binding", "CpG-island")
Resup$Beta = log(Resup$OR)
Resup$SE = (log(Resup$OR)-log(Resup$CI95L))/1.96
Resup$Padj=p.adjust(Resup$P, method = "bonferroni")

multiORplot(Resall, Pval = "P", Padj = "Padj", beta="Beta",SE = "SE", pheno="All diff. methylated loci")

multiORplot(Resup, Pval = "P", Padj = "Padj", beta="Beta",SE = "SE", pheno="hypomethylated loci")

multiORplot(Resdown, Pval = "P", Padj = "Padj", beta="Beta",SE = "SE", pheno="Hypermethylated loci")

pdf(paste0(Home, "/output/functional_Enrichemnt.pdf"))
multiORplot(Resall, Pval = "P", Padj = "Padj", beta="Beta",SE = "SE", pheno="All diff. methylated loci")
multiORplot(Resup, Pval = "P", Padj = "Padj", beta="Beta",SE = "SE", pheno="hypomethylated loci")
multiORplot(Resdown, Pval = "P", Padj = "Padj", beta="Beta",SE = "SE", pheno="Hypermethylated loci")
dev.off()
png 
  2 

GO-term Enrichment

Significant loci and differentially methylated regions with a p-value <= 0.01 and an absolute log2 fold-change lager 0.5 were tested for enrichment among GO-terms Molecular Function, Cellular Compartment and Biological Processes, KEGG pathways, Transcription factor Binding sites, Human Protein Atlas Tissue Expression, Human Phenotypes.

getGOresults = function(geneset, genereference){
  resgo = gost(geneset, organism = "hsapiens",
               correction_method = "g_SCS",
               domain_scope = "custom",
               sources = c("GO:BP", "GO:MF", "GO:CC"),
               custom_bg = genereference)
  if(length(resgo) != 0){
    return(resgo)
  } else {
    print("no significant results")
    return(NULL)
  }  
}

gene_univers = getuniquegenes(as.data.frame(rowRanges(dds_filt))$gene)


idx = (results_Deseq$pvalue <= thresholdp & 
         (abs(results_Deseq$log2FoldChange) > thresholdLFC))

genes_reg = getuniquegenes(as.data.frame(rowRanges(dds_filt))$gene[idx])


dmr_genes = unique(resultsdmr_table$name[resultsdmr_table$p.value<=thresholdp & 
                   abs(resultsdmr_table$value)>=thresholdLFC])


Genes_of_interset = list("01_dmregions" = dmr_genes,  
                         "02_dmtag" = genes_reg
                         )

gostres = getGOresults(Genes_of_interset, gene_univers)

gostplot(gostres, capped = TRUE, interactive = T)
p = gostplot(gostres, capped = TRUE, interactive = F)

toptab = gostres$result

pp = publish_gostplot(p, filename = paste0(Home,"/output/gostres.pdf"))
The image is saved to C:/Users/chiocchetti/Projects/femNATCD_MethSeq/output/gostres.pdf
write.xlsx2(toptab, file = paste0(Home,"/output/GOres.xlsx"), sheetName = "GO_enrichment")

Brain Developmental Processes Enrichment tests

Gene sets identified to be deferentially methylated with a p-value <= 0.01 and an absolute log2 fold-change larger 0.5 were tested for enrichment among gene-modules coregulated during Brain expression.

Kang Modules

# define Reference Universe 

KangUnivers<- read.table(paste0(Home,"/data/KangUnivers.txt"), sep="\t", header=T)
colnames(KangUnivers)<-c("EntrezId","Symbol")

Kang_genes<-read.table(paste0(Home,"/data/Kang_dataset_genesMod_version2.txt"),sep="\t",header=TRUE)

#3)Generate Gene universe to be used for single gene lists
tmp=merge(KangUnivers,Kang_genes,by.y="EntrezGene",by.x="EntrezId",all=TRUE) #18826
KangUni_Final<-tmp[duplicated(tmp$EntrezId)==FALSE,] #18675


# Local analysis gene universe
Annotation_list<-data.frame(Symbol = gene_univers)

# match modules 
Annotation_list$Module = Kang_genes$Module[match(Annotation_list$Symbol,Kang_genes$symbol)]

# check if overlapping in gene universes
Annotation_list$univers = Annotation_list$Symbol %in% KangUni_Final$Symbol

# drop duplicates 
Annotation_list = Annotation_list[duplicated(Annotation_list$Symbol)==FALSE,]

# selct only genes that have been detected on both datasets
Annotation_list = Annotation_list[Annotation_list$univers==T,] 

# final reference 
UniversalGeneset=Annotation_list$Symbol

# define Gene lists to test 
# sort and order Modules to be tested

Modules=unique(Annotation_list$Module)
Modules = Modules[! Modules %in% c(NA, "")]
Modules = Modules[order(as.numeric(gsub("M","",Modules)))]

GL_all=list()

for(i in Modules){
  GL_all[[i]]=Annotation_list$Symbol[Annotation_list$Module%in%i]
}
GL_all[["M_all"]]=Kang_genes$symbol[Kang_genes$Module %in% Modules]


GOI1 = Genes_of_interset

Resultsall=list()
for(j in names(GOI1)){
  Res = data.frame()
  for(i in names(GL_all)){
    Modulegene=GL_all[[i]]
    Factorgene=GOI1[[j]]
    Testframe<-fisher.test(table(factor(UniversalGeneset %in% Factorgene,levels=c("TRUE","FALSE")),
                                 factor(UniversalGeneset %in% Modulegene,levels=c("TRUE","FALSE"))))
    beta=log(Testframe$estimate)
    Res[i, "beta"] =beta
    Res[i, "SE"]=abs(beta-log(Testframe$conf.int[1]))/1.96
    Res[i, "Pval"]=Testframe$p.value
    Res[i, "OR"]=(Testframe$estimate)
    Res[i, "ORL"]=(Testframe$conf.int[1])
    Res[i, "ORU"]=(Testframe$conf.int[2])
  }
  Res$Padj = p.adjust(Res$Pval, method = "bonferroni")
  Resultsall[[j]] = Res
  
}
par(mfrow = c(2,1))
for (i in names(Resultsall)){ 
  multiORplot(datatoplot = Resultsall[[i]], pheno=i)
}

par(mfrow = c(1,1))
pdf(paste0(Home, "/output/BrainMod_Enrichemnt.pdf"))
for (i in names(Resultsall)){
  multiORplot(datatoplot = Resultsall[[i]], pheno=i)
}
dev.off()
png 
  2 
Modsig = c()

for(r in names(Resultsall)){
  a=rownames(Resultsall[[r]])[Resultsall[[r]]$Padj<=0.05]
  Modsig = c(Modsig,a)
}

Brain espresseion heatmaps

# show brains and expression
Modsig2=unique(Modsig[Modsig!="M_all"])

load(paste0(Home,"/data/Kang_DataPreprocessing.RData")) #Load the Kang expression data of all genes 
datExprPlot=matriz #Expression data of Kang loaded as Rdata object DataPreprocessing.RData


Genes = GL_all[names(GL_all)!="M_all"]

Genes_expression<-list()

pcatest<-list()
for (i in names(Genes)){
  Genes_expression[[i]]<-matriz[,which(colnames(matriz) %in% Genes[[i]])]
  pcatest[[i]]=prcomp(t(as.matrix(Genes_expression[[i]])),retx=TRUE)
}

# PCA test
PCA<-data.frame(pcatest[[1]]$rotation)
PCA$donor_name<-rownames(PCA)
PC1<-data.frame(PCA[,c(1,ncol(PCA))])

#Combining the age with expression data
list <- strsplit(sampleInfo$age, " ")
library("plyr")
------------------------------------------------------------------------------
You have loaded plyr after dplyr - this is likely to cause problems.
If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
library(plyr); library(dplyr)
------------------------------------------------------------------------------

Attache Paket: 'plyr'
The following object is masked from 'package:matrixStats':

    count
The following object is masked from 'package:IRanges':

    desc
The following object is masked from 'package:S4Vectors':

    rename
The following objects are masked from 'package:dplyr':

    arrange, count, desc, failwith, id, mutate, rename, summarise,
    summarize
The following object is masked from 'package:purrr':

    compact
df <- ldply(list)
colnames(df) <- c("Age", "time")

sampleInfo<-cbind(sampleInfo[,1:9],df)
sampleInfo$Age<-as.numeric(sampleInfo$Age)

sampleInfo$period<-ifelse(sampleInfo$time=="pcw",sampleInfo$Age*7,ifelse(sampleInfo$time=="yrs",sampleInfo$Age*365+270,ifelse(sampleInfo$time=="mos",sampleInfo$Age*30+270,NA)))

#We need it just for the donor names

PCA_matrix<-merge.with.order(PC1,sampleInfo,by.y="SampleID",by.x="donor_name",keep_order=1)

#Select which have phenotype info present 
matriz2<-matriz[which(rownames(matriz) %in% PCA_matrix$donor_name),]
FactorGenes_expression<-list()
#Factors here mean modules
for (i in names(Genes)){
  FactorGenes_expression[[i]]<-matriz2[,which(colnames(matriz2) %in% Genes[[i]])]
}


FactorseGE<-list()
for (i in names(Genes)){
  FactorseGE[[i]]<-FactorGenes_expression[[i]]
}

allModgenes=NULL
colors=vector()
for ( i in names(Genes)){
  allModgenes=cbind(allModgenes,FactorseGE[[i]])
  colors=c(colors, rep(i, ncol(FactorseGE[[i]])))
}


lengths=unlist(lapply(FactorGenes_expression, ncol), use.names = F)

MEorig=moduleEigengenes(allModgenes, colors)

PCA_matrixfreeze=PCA_matrix

index=!PCA_matrix$structure_acronym %in% c("URL", "DTH", "CGE","LGE", "MGE",  "Ocx", "PCx", "M1C-S1C","DIE", "TCx", "CB")
PCA_matrix=PCA_matrix[index,]
ME = MEorig$eigengenes[index,]
matsel = matriz2[index,]

colnames(ME) = gsub("ME", "", colnames(ME))

timepoints=seq(56,15000, length.out=1000)
matrix(c("CB", "THA", "CBC", "MD"), ncol=2 ) -> cnm


brainheatmap=function(Module){
  MEmod=ME[,Module]
  toplot=data.frame(matrix(NA, nrow=length(table(PCA_matrix$structure_acronym)), ncol=998))
  rownames(toplot)=unique(PCA_matrix$structure_acronym)
  target <- c("OFC", "DFC", "VFC", "MFC","M1C","S1C","IPC","A1C","STC","ITC","V1C","HIP","AMY","STR","MD","CBC")
  toplot<-toplot[c(6,2,8,5,11,12,10,9,7,4,14,3,1,13,16,15),]
  
  
  for ( i in unique(PCA_matrix$structure_acronym)){
    index=PCA_matrix$structure_acronym==i
    LOESS=loess(MEmod[index]~PCA_matrix$period[index])
    toplot[i,]=predict(LOESS,newdata = round(exp(seq(log(56),log(15000), length.out=998)),2))
    colnames(toplot)[c(1,77,282,392,640,803,996)]<-
      c("1pcw","21pcw","Birth","1.3years","5.4years","13.6years","40.7years")
  }
  
  
  
  cols=viridis(100)
  labvec <- c(rep(NA, 1000))
  
  labvec[c(1,77,282,392,640,803,996)] <- c("1pcw","21pcw","Birth","1.3years","5.4years","13.6years","40.7years")
  
  
  toplot<-toplot[,1:998]
  date<-c(1:998)
  dateY<-paste0(round(date/365,2),"_Years")
  
  names(toplot)<-dateY
  
  par(xpd=FALSE) 
  heatmap.2(as.matrix(toplot), col = cols, 
            main=Module,
            trace = "none", 
            na.color = "grey",
            Colv = F, Rowv = F,
            labCol = labvec,
            #breaks = seq(-0.1,0.1, length.out=101),
            symkey = T,
            scale = "row",
            key.title = "",
            dendrogram = "none",
            key.xlab = "eigengene",
            density.info = "none",
            #main=paste("Module",1),
            srtCol=90,
            tracecol = "none", 
            cexRow = 1,
            add.expr=eval.parent(abline(v=282),
                                 axis(1,at=c(1,77,282,392,640,803,996),
                                      labels =FALSE)),cexCol = 1)
  
 
}

brainheatmap_gene=function(Genename){
  MEmod=matsel[,Genename]
  toplot=data.frame(matrix(NA, nrow=length(table(PCA_matrix$structure_acronym)), ncol=998))
  rownames(toplot)=unique(PCA_matrix$structure_acronym)
  target <- c("OFC", "DFC", "VFC", "MFC","M1C","S1C","IPC","A1C","STC","ITC","V1C","HIP","AMY","STR","MD","CBC")
  toplot<-toplot[c(6,2,8,5,11,12,10,9,7,4,14,3,1,13,16,15),]


  for ( i in unique(PCA_matrix$structure_acronym)){
    index=PCA_matrix$structure_acronym==i
    LOESS=loess(MEmod[index]~PCA_matrix$period[index])
    toplot[i,]=predict(LOESS,newdata = round(exp(seq(log(56),log(15000), length.out=998)),2))
    colnames(toplot)[c(1,77,282,392,640,803,996)]<-
      c("1pcw","21pcw","Birth","1.3years","5.4years","13.6years","40.7years")
  }



  cols=viridis(100)
  labvec <- c(rep(NA, 1000))

  labvec[c(1,77,282,392,640,803,996)] <- c("1pcw","21pcw","Birth","1.3years","5.4years","13.6years","40.7years")


  toplot<-toplot[,1:998]
  date<-c(1:998)
  dateY<-paste0(round(date/365,2),"_Years")

  names(toplot)<-dateY

  par(xpd=FALSE)
  heatmap.2(as.matrix(toplot), col = cols,
            main=Genename,
            trace = "none",
            na.color = "grey",
            Colv = F, Rowv = F,
            labCol = labvec,
            #breaks = seq(-0.1,0.1, length.out=101),
            symkey = F,
            scale = "none",
            key.title = "",
            dendrogram = "none",
            key.xlab = "eigengene",
            density.info = "none",
            #main=paste("Module",1),
            #srtCol=90,
            tracecol = "none",
            cexRow = 1,
            add.expr=eval.parent(abline(v=282),
                                 axis(1,at=c(1,77,282,392,640,803,996),
                                      labels =FALSE))
            ,cexCol = 1)
}


brainheatmap_gene("SLITRK5")

for(Module in Modsig2){
  brainheatmap(Module)
}

pdf(paste0(Home, "/output/Brain_Module_Heatmap.pdf"))

brainheatmap_gene("SLITRK5")
for(Module in Modsig2){
  brainheatmap(Module)
}
dev.off()
png 
  2 

Risk Factor Mediation Analysis

Risk factor loading and correlation plots

dropfact=c("site", "0", "group")

modelFact=strsplit(as.character(design(dds_filt))[2], " \\+ ")[[1]]


Patdata=as.data.frame(colData(dds_filt))

load(paste0(Home, "/output/envFact.RData"))

envFact=envFact[!envFact %in% dropfact] 
modelFact=modelFact[!modelFact %in% dropfact] 

EpiMarker = c()

# TopHit
Patdata$Epi_TopHit=log2_cpm[base::which.min(results_Deseq$pvalue),]

# 1PC of all diff met
tmp=glmpca(log2_cpm[base::which(results_Deseq$pvalue<=thresholdp),], 1)

Patdata$Epi_all= tmp$factors$dim1
  
EpiMarker = c(EpiMarker, "Epi_TopHit", "Epi_all")

#Brain Modules

Epitestset=GL_all[Modsig]

for(n in names(Epitestset)){
  index=gettaglistforgenelist(genelist = Epitestset[[n]], dds_filt)
  index = base::intersect(index, base::which(results_Deseq$pvalue<=thresholdp))
  # get eigenvalue
  epiname=paste0("Epi_",n)
  tmp=glmpca(log2_cpm[index,], 1)
  Patdata[,epiname]= tmp$factors$dim1
  EpiMarker = c(EpiMarker, epiname)
}

cormat = cor(apply(Patdata[,c("group", envFact, modelFact, EpiMarker)] %>% mutate_all(as.numeric), 2, minmax_scaling),
             use = "pairwise.complete.obs")

par(mfrow=c(1,2))
corrplot(cormat, main="correlations")
corrplot(cormat, order = "hclust", main="correlations ordered")

SEM analysis

fullmodEnv=paste(unique(envFact,modelFact), sep = "+", collapse = "+")

Dataset = Patdata[,c("group", envFact, modelFact,EpiMarker)]

model = "
Epi~1+a*Matsmk+b*Matagg+c*FamScore+d*EduPar+e*n_trauma+Age+int_dis+medication+contraceptives+cigday_1+V8
group~1+f*Matsmk+g*Matagg+h*FamScore+i*EduPar+j*n_trauma+Age+int_dis+medication+contraceptives+cigday_1+V8+z*Epi

#direct
directMatsmk := f
directMatagg := g
directFamScore := h
directEduPar := i
directn_trauma := j

#indirect
EpiMatsmk := a*z
EpiMatagg := b*z
EpiFamScore := c*z
EpiEduPar := d*z
Epin_trauma := e*z

total := f + g + h + i + j + (a*z)+(b*z)+(c*z)+(d*z)+(e*z)

Epi~~Epi
group~~group
"

Netlist = list()

for (marker in EpiMarker) {
  Dataset$Epi = Dataset[,marker]
  Datasetscaled = Dataset %>% mutate_if(is.numeric, minmax_scaling)
  Datasetscaled = Datasetscaled %>% mutate_if(is.factor, ~ as.numeric(.)-1)
  
  fit<-lavaan(model,data=Datasetscaled, )
  
  sink(paste0(Home,"/output/SEM_summary_group",marker,".txt"))
  summary(fit)
  print(fitMeasures(fit))
  print(parameterEstimates(fit))
  sink()
  cat("############################\n")
  cat("############################\n")
  cat(marker, "\n")
  cat("############################\n")
  cat("############################\n")
  summary(fit)
  cat("\n")
  print(fitMeasures(fit))
  cat("\n")
  print(parameterEstimates(fit))
  cat("\n")
  
  #SOURCE FOR PLOT https://stackoverflow.com/questions/51270032/how-can-i-display-only-significant-path-lines-on-a-path-diagram-r-lavaan-sem
  restab=lavaan::standardizedSolution(fit) %>% dplyr::filter(!is.na(pvalue)) %>% 
    arrange(desc(pvalue)) %>% mutate_if("is.numeric","round",3) %>% 
    dplyr::select(-ci.lower,-ci.upper,-z)
  
  pvalue_cutoff <- 0.05
  
  obj <- semPlot:::semPlotModel(fit)
  original_Pars <- obj@Pars
  
  print(original_Pars)
  
  check_Pars <- obj@Pars %>% dplyr:::filter(!(edge %in% c("int","<->") | lhs == rhs)) # this is the list of parameter to sift thru
  keep_Pars <- obj@Pars %>% dplyr:::filter(edge %in% c("int","<->") | lhs == rhs) # this is the list of parameter to keep asis
  
  test_against <- lavaan::standardizedSolution(fit) %>% dplyr::filter(pvalue < pvalue_cutoff, rhs != lhs)
  
  # for some reason, the rhs and lhs are reversed in the standardizedSolution() output, for some of the values
  # I'll have to reverse it myself, and test against both orders
  
  test_against_rev <- test_against %>% dplyr::rename(rhs2 = lhs, lhs = rhs) %>% dplyr::rename(rhs = rhs2)
  
  checked_Pars <-
    check_Pars %>% semi_join(test_against, by = c("lhs", "rhs")) %>% bind_rows(
      check_Pars %>% semi_join(test_against_rev, by = c("lhs", "rhs"))
    )
  
  obj@Pars <- keep_Pars %>% bind_rows(checked_Pars) %>% 
    mutate_if("is.numeric","round",3) %>% 
    mutate_at(c("lhs","rhs"),~gsub("Epi", marker,.))
  
  obj@Vars = obj@Vars %>% mutate_at(c("name"),~gsub("Epi", marker,.))
  
  DF = obj@Pars
  DF = DF[DF$lhs!=DF$rhs,]
  DF = DF[abs(DF$est)>0.1,]
  
  DF = DF[DF$edge == "~>",] # only include directly modelled effects in figure 
  
  nodes <- data.frame(id=obj@Vars$name, label = obj@Vars$name)
  nodes$color<-Dark8[8]
  nodes$color[nodes$label == "group"] = Dark8[3]
  nodes$color[nodes$label == marker] = Dark8[4]
  nodes$color[nodes$label %in% envFact] = Dark8[5]
  
  edges <- data.frame(from = DF$lhs, 
                      to = DF$rhs, 
                      width=abs(DF$est), 
                      arrows ="to")
  
  edges$dashes = F
  edges$label =  DF$est
  edges$color=c("firebrick", "forestgreen")[1:2][factor(sign(DF$est), levels=c(-1,0,1),labels=c(1,2,2))]
  edges$width=2
  cexlab = 18
  plotnet<- visNetwork(nodes, edges,  
                       main=list(text=marker,
                                 style="font-family:arial;font-size:20px;text-align:center"),
                       submain=list(text="significant paths", 
                                    style="font-family:arial;text-align:center")) %>% 
    visEdges(arrows =list(to = list(enabled = TRUE, scaleFactor = 0.7)),
                       font=list(size=cexlab, style="font-family:arial;text-align:center")) %>%
    visNodes(font=list(size=cexlab, style="font-family:arial;text-align:center")) %>%
    
    visPhysics(enabled = T, solver = "forceAtlas2Based")
  
  
  Netlist[[marker]] = plotnet
  htmlfile = paste0(Home,"/output/SEMplot_",marker,".html")
  visSave(plotnet, htmlfile)
  webshot(paste0(Home,"/output/SEMplot_",marker,".html"), zoom = 1, 
          file = paste0(Home,"/output/SEMplot_",marker,".png"))
  
}
############################
############################
Epi_TopHit 
############################
############################
lavaan 0.6-7 ended normally after 45 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                         27
                                                      
                                                  Used       Total
  Number of observations                            80          99
                                                                  
Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  Epi ~                                               
    Matsmk     (a)   -0.033    0.045   -0.731    0.465
    Matagg     (b)   -0.014    0.068   -0.213    0.831
    FamScore   (c)    0.056    0.064    0.887    0.375
    EduPar     (d)   -0.038    0.082   -0.468    0.640
    n_trauma   (e)    0.085    0.088    0.964    0.335
    Age              -0.090    0.087   -1.036    0.300
    int_dis          -0.074    0.047   -1.580    0.114
    medication       -0.044    0.051   -0.876    0.381
    contrcptvs       -0.017    0.046   -0.361    0.718
    cigday_1         -0.111    0.090   -1.228    0.219
    V8               -0.089    0.262   -0.339    0.735
  group ~                                             
    Matsmk     (f)   -0.002    0.080   -0.031    0.976
    Matagg     (g)    0.198    0.122    1.623    0.105
    FamScore   (h)    0.020    0.114    0.178    0.858
    EduPar     (i)   -0.473    0.147   -3.213    0.001
    n_trauma   (j)    0.289    0.159    1.824    0.068
    Age              -0.346    0.157   -2.205    0.027
    int_dis           0.170    0.086    1.977    0.048
    medication        0.276    0.091    3.026    0.002
    contrcptvs       -0.023    0.083   -0.271    0.787
    cigday_1          0.662    0.163    4.052    0.000
    V8                0.319    0.470    0.679    0.497
    Epi        (z)   -1.004    0.200   -5.015    0.000

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.843    0.159    5.320    0.000
   .group             1.166    0.330    3.528    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.023    0.004    6.325    0.000
   .group             0.075    0.012    6.325    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    directMatsmk     -0.002    0.080   -0.031    0.976
    directMatagg      0.198    0.122    1.623    0.105
    directFamScore    0.020    0.114    0.178    0.858
    directEduPar     -0.473    0.147   -3.213    0.001
    directn_trauma    0.289    0.159    1.824    0.068
    EpiMatsmk         0.033    0.045    0.723    0.470
    EpiMatagg         0.015    0.068    0.213    0.831
    EpiFamScore      -0.057    0.065   -0.874    0.382
    EpiEduPar         0.039    0.083    0.466    0.641
    Epin_trauma      -0.085    0.090   -0.947    0.344
    total            -0.025    0.318   -0.077    0.938

               npar                fmin               chisq                  df 
             27.000               0.000               0.000               0.000 
             pvalue      baseline.chisq         baseline.df     baseline.pvalue 
                 NA             106.412              23.000               0.000 
                cfi                 tli                nnfi                 rfi 
              1.000               1.000               1.000               1.000 
                nfi                pnfi                 ifi                 rni 
              1.000               0.000               1.000               1.000 
               logl   unrestricted.logl                 aic                 bic 
             26.929              26.929               0.143              64.457 
             ntotal                bic2               rmsea      rmsea.ci.lower 
             80.000             -20.683               0.000               0.000 
     rmsea.ci.upper        rmsea.pvalue                 rmr          rmr_nomean 
              0.000                  NA               0.000               0.000 
               srmr        srmr_bentler srmr_bentler_nomean                crmr 
              0.000               0.000               0.000               0.000 
        crmr_nomean          srmr_mplus   srmr_mplus_nomean               cn_05 
              0.000               0.000               0.000                  NA 
              cn_01                 gfi                agfi                pgfi 
                 NA               1.000               1.000               0.000 
                mfi                ecvi 
              1.000               0.675 

               lhs op                                     rhs          label
1              Epi ~1                                                       
2              Epi  ~                                  Matsmk              a
3              Epi  ~                                  Matagg              b
4              Epi  ~                                FamScore              c
5              Epi  ~                                  EduPar              d
6              Epi  ~                                n_trauma              e
7              Epi  ~                                     Age               
8              Epi  ~                                 int_dis               
9              Epi  ~                              medication               
10             Epi  ~                          contraceptives               
11             Epi  ~                                cigday_1               
12             Epi  ~                                      V8               
13           group ~1                                                       
14           group  ~                                  Matsmk              f
15           group  ~                                  Matagg              g
16           group  ~                                FamScore              h
17           group  ~                                  EduPar              i
18           group  ~                                n_trauma              j
19           group  ~                                     Age               
20           group  ~                                 int_dis               
21           group  ~                              medication               
22           group  ~                          contraceptives               
23           group  ~                                cigday_1               
24           group  ~                                      V8               
25           group  ~                                     Epi              z
26             Epi ~~                                     Epi               
27           group ~~                                   group               
28          Matsmk ~~                                  Matsmk               
29          Matsmk ~~                                  Matagg               
30          Matsmk ~~                                FamScore               
31          Matsmk ~~                                  EduPar               
32          Matsmk ~~                                n_trauma               
33          Matsmk ~~                                     Age               
34          Matsmk ~~                                 int_dis               
35          Matsmk ~~                              medication               
36          Matsmk ~~                          contraceptives               
37          Matsmk ~~                                cigday_1               
38          Matsmk ~~                                      V8               
39          Matagg ~~                                  Matagg               
40          Matagg ~~                                FamScore               
41          Matagg ~~                                  EduPar               
42          Matagg ~~                                n_trauma               
43          Matagg ~~                                     Age               
44          Matagg ~~                                 int_dis               
45          Matagg ~~                              medication               
46          Matagg ~~                          contraceptives               
47          Matagg ~~                                cigday_1               
48          Matagg ~~                                      V8               
49        FamScore ~~                                FamScore               
50        FamScore ~~                                  EduPar               
51        FamScore ~~                                n_trauma               
52        FamScore ~~                                     Age               
53        FamScore ~~                                 int_dis               
54        FamScore ~~                              medication               
55        FamScore ~~                          contraceptives               
56        FamScore ~~                                cigday_1               
57        FamScore ~~                                      V8               
58          EduPar ~~                                  EduPar               
59          EduPar ~~                                n_trauma               
60          EduPar ~~                                     Age               
61          EduPar ~~                                 int_dis               
62          EduPar ~~                              medication               
63          EduPar ~~                          contraceptives               
64          EduPar ~~                                cigday_1               
65          EduPar ~~                                      V8               
66        n_trauma ~~                                n_trauma               
67        n_trauma ~~                                     Age               
68        n_trauma ~~                                 int_dis               
69        n_trauma ~~                              medication               
70        n_trauma ~~                          contraceptives               
71        n_trauma ~~                                cigday_1               
72        n_trauma ~~                                      V8               
73             Age ~~                                     Age               
74             Age ~~                                 int_dis               
75             Age ~~                              medication               
76             Age ~~                          contraceptives               
77             Age ~~                                cigday_1               
78             Age ~~                                      V8               
79         int_dis ~~                                 int_dis               
80         int_dis ~~                              medication               
81         int_dis ~~                          contraceptives               
82         int_dis ~~                                cigday_1               
83         int_dis ~~                                      V8               
84      medication ~~                              medication               
85      medication ~~                          contraceptives               
86      medication ~~                                cigday_1               
87      medication ~~                                      V8               
88  contraceptives ~~                          contraceptives               
89  contraceptives ~~                                cigday_1               
90  contraceptives ~~                                      V8               
91        cigday_1 ~~                                cigday_1               
92        cigday_1 ~~                                      V8               
93              V8 ~~                                      V8               
94          Matsmk ~1                                                       
95          Matagg ~1                                                       
96        FamScore ~1                                                       
97          EduPar ~1                                                       
98        n_trauma ~1                                                       
99             Age ~1                                                       
100        int_dis ~1                                                       
101     medication ~1                                                       
102 contraceptives ~1                                                       
103       cigday_1 ~1                                                       
104             V8 ~1                                                       
105   directMatsmk :=                                       f   directMatsmk
106   directMatagg :=                                       g   directMatagg
107 directFamScore :=                                       h directFamScore
108   directEduPar :=                                       i   directEduPar
109 directn_trauma :=                                       j directn_trauma
110      EpiMatsmk :=                                     a*z      EpiMatsmk
111      EpiMatagg :=                                     b*z      EpiMatagg
112    EpiFamScore :=                                     c*z    EpiFamScore
113      EpiEduPar :=                                     d*z      EpiEduPar
114    Epin_trauma :=                                     e*z    Epin_trauma
115          total := f+g+h+i+j+(a*z)+(b*z)+(c*z)+(d*z)+(e*z)          total
       est    se      z pvalue ci.lower ci.upper
1    0.843 0.159  5.320  0.000    0.533    1.154
2   -0.033 0.045 -0.731  0.465   -0.120    0.055
3   -0.014 0.068 -0.213  0.831   -0.148    0.119
4    0.056 0.064  0.887  0.375   -0.068    0.181
5   -0.038 0.082 -0.468  0.640   -0.199    0.123
6    0.085 0.088  0.964  0.335   -0.088    0.257
7   -0.090 0.087 -1.036  0.300   -0.261    0.080
8   -0.074 0.047 -1.580  0.114   -0.167    0.018
9   -0.044 0.051 -0.876  0.381   -0.144    0.055
10  -0.017 0.046 -0.361  0.718   -0.108    0.074
11  -0.111 0.090 -1.228  0.219   -0.288    0.066
12  -0.089 0.262 -0.339  0.735   -0.603    0.425
13   1.166 0.330  3.528  0.000    0.518    1.814
14  -0.002 0.080 -0.031  0.976   -0.159    0.155
15   0.198 0.122  1.623  0.105   -0.041    0.436
16   0.020 0.114  0.178  0.858   -0.204    0.245
17  -0.473 0.147 -3.213  0.001   -0.762   -0.185
18   0.289 0.159  1.824  0.068   -0.021    0.600
19  -0.346 0.157 -2.205  0.027   -0.653   -0.039
20   0.170 0.086  1.977  0.048    0.001    0.338
21   0.276 0.091  3.026  0.002    0.097    0.455
22  -0.023 0.083 -0.271  0.787   -0.186    0.141
23   0.662 0.163  4.052  0.000    0.342    0.982
24   0.319 0.470  0.679  0.497   -0.602    1.240
25  -1.004 0.200 -5.015  0.000   -1.397   -0.612
26   0.023 0.004  6.325  0.000    0.016    0.031
27   0.075 0.012  6.325  0.000    0.052    0.098
28   0.194 0.000     NA     NA    0.194    0.194
29   0.049 0.000     NA     NA    0.049    0.049
30  -0.009 0.000     NA     NA   -0.009   -0.009
31  -0.005 0.000     NA     NA   -0.005   -0.005
32   0.007 0.000     NA     NA    0.007    0.007
33  -0.003 0.000     NA     NA   -0.003   -0.003
34   0.021 0.000     NA     NA    0.021    0.021
35   0.004 0.000     NA     NA    0.004    0.004
36   0.021 0.000     NA     NA    0.021    0.021
37   0.017 0.000     NA     NA    0.017    0.017
38   0.003 0.000     NA     NA    0.003    0.003
39   0.090 0.000     NA     NA    0.090    0.090
40   0.034 0.000     NA     NA    0.034    0.034
41  -0.016 0.000     NA     NA   -0.016   -0.016
42   0.007 0.000     NA     NA    0.007    0.007
43   0.000 0.000     NA     NA    0.000    0.000
44   0.032 0.000     NA     NA    0.032    0.032
45   0.007 0.000     NA     NA    0.007    0.007
46   0.007 0.000     NA     NA    0.007    0.007
47   0.010 0.000     NA     NA    0.010    0.010
48   0.001 0.000     NA     NA    0.001    0.001
49   0.131 0.000     NA     NA    0.131    0.131
50  -0.029 0.000     NA     NA   -0.029   -0.029
51   0.026 0.000     NA     NA    0.026    0.026
52   0.004 0.000     NA     NA    0.004    0.004
53   0.064 0.000     NA     NA    0.064    0.064
54   0.004 0.000     NA     NA    0.004    0.004
55   0.058 0.000     NA     NA    0.058    0.058
56   0.043 0.000     NA     NA    0.043    0.043
57   0.001 0.000     NA     NA    0.001    0.001
58   0.053 0.000     NA     NA    0.053    0.053
59  -0.008 0.000     NA     NA   -0.008   -0.008
60   0.003 0.000     NA     NA    0.003    0.003
61  -0.019 0.000     NA     NA   -0.019   -0.019
62   0.010 0.000     NA     NA    0.010    0.010
63  -0.013 0.000     NA     NA   -0.013   -0.013
64  -0.015 0.000     NA     NA   -0.015   -0.015
65   0.000 0.000     NA     NA    0.000    0.000
66   0.051 0.000     NA     NA    0.051    0.051
67   0.002 0.000     NA     NA    0.002    0.002
68   0.041 0.000     NA     NA    0.041    0.041
69   0.017 0.000     NA     NA    0.017    0.017
70   0.018 0.000     NA     NA    0.018    0.018
71   0.021 0.000     NA     NA    0.021    0.021
72   0.000 0.000     NA     NA    0.000    0.000
73   0.047 0.000     NA     NA    0.047    0.047
74   0.008 0.000     NA     NA    0.008    0.008
75  -0.002 0.000     NA     NA   -0.002   -0.002
76   0.035 0.000     NA     NA    0.035    0.035
77   0.008 0.000     NA     NA    0.008    0.008
78  -0.001 0.000     NA     NA   -0.001   -0.001
79   0.210 0.000     NA     NA    0.210    0.210
80   0.060 0.000     NA     NA    0.060    0.060
81   0.060 0.000     NA     NA    0.060    0.060
82   0.044 0.000     NA     NA    0.044    0.044
83   0.006 0.000     NA     NA    0.006    0.006
84   0.144 0.000     NA     NA    0.144    0.144
85   0.035 0.000     NA     NA    0.035    0.035
86   0.003 0.000     NA     NA    0.003    0.003
87   0.002 0.000     NA     NA    0.002    0.002
88   0.210 0.000     NA     NA    0.210    0.210
89   0.048 0.000     NA     NA    0.048    0.048
90   0.003 0.000     NA     NA    0.003    0.003
91   0.061 0.000     NA     NA    0.061    0.061
92   0.001 0.000     NA     NA    0.001    0.001
93   0.005 0.000     NA     NA    0.005    0.005
94   0.262 0.000     NA     NA    0.262    0.262
95   0.100 0.000     NA     NA    0.100    0.100
96   0.225 0.000     NA     NA    0.225    0.225
97   0.606 0.000     NA     NA    0.606    0.606
98   0.196 0.000     NA     NA    0.196    0.196
99   0.562 0.000     NA     NA    0.562    0.562
100  0.300 0.000     NA     NA    0.300    0.300
101  0.175 0.000     NA     NA    0.175    0.175
102  0.300 0.000     NA     NA    0.300    0.300
103  0.124 0.000     NA     NA    0.124    0.124
104  0.529 0.000     NA     NA    0.529    0.529
105 -0.002 0.080 -0.031  0.976   -0.159    0.155
106  0.198 0.122  1.623  0.105   -0.041    0.436
107  0.020 0.114  0.178  0.858   -0.204    0.245
108 -0.473 0.147 -3.213  0.001   -0.762   -0.185
109  0.289 0.159  1.824  0.068   -0.021    0.600
110  0.033 0.045  0.723  0.470   -0.056    0.121
111  0.015 0.068  0.213  0.831   -0.119    0.148
112 -0.057 0.065 -0.874  0.382   -0.184    0.070
113  0.039 0.083  0.466  0.641   -0.124    0.201
114 -0.085 0.090 -0.947  0.344   -0.262    0.091
115 -0.025 0.318 -0.077  0.938   -0.648    0.599

    label            lhs edge            rhs           est           std group
1                         int            Epi  8.434318e-01  5.1061068034      
2       a         Matsmk   ~>            Epi -3.256589e-02 -0.0867458090      
3       b         Matagg   ~>            Epi -1.446988e-02 -0.0262800474      
4       c       FamScore   ~>            Epi  5.638498e-02  0.1233719659      
5       d         EduPar   ~>            Epi -3.844427e-02 -0.0536417890      
6       e       n_trauma   ~>            Epi  8.486733e-02  0.1156887173      
7                    Age   ~>            Epi -9.011773e-02 -0.1181445558      
8                int_dis   ~>            Epi -7.447596e-02 -0.2066168314      
9             medication   ~>            Epi -4.445645e-02 -0.1022635101      
10        contraceptives   ~>            Epi -1.677936e-02 -0.0465505654      
11              cigday_1   ~>            Epi -1.109172e-01 -0.1655047672      
12                    V8   ~>            Epi -8.888125e-02 -0.0364107243      
13                        int          group  1.165925e+00  2.3683987682      
14      f         Matsmk   ~>          group -2.446741e-03 -0.0021868436      
15      g         Matagg   ~>          group  1.975479e-01  0.1203864798      
16      h       FamScore   ~>          group  2.040864e-02  0.0149834349      
17      i         EduPar   ~>          group -4.733994e-01 -0.2216376279      
18      j       n_trauma   ~>          group  2.893049e-01  0.1323275936      
19                   Age   ~>          group -3.459797e-01 -0.1521942610      
20               int_dis   ~>          group  1.695679e-01  0.1578474033      
21            medication   ~>          group  2.764057e-01  0.2133423356      
22        contraceptives   ~>          group -2.254823e-02 -0.0209897017      
23              cigday_1   ~>          group  6.616969e-01  0.3312950397      
24                    V8   ~>          group  3.191387e-01  0.0438674912      
25      z            Epi   ~>          group -1.004455e+00 -0.3370346801      
26                   Epi  <->            Epi  2.334009e-02  0.8554260788      
27                 group  <->          group  7.491604e-02  0.3091313057      
28                Matsmk  <->         Matsmk  1.935938e-01  1.0000000000      
29                Matsmk  <->         Matagg  4.875000e-02  0.3693241433      
30                Matsmk  <->       FamScore -9.062500e-03 -0.0569887592      
31                Matsmk  <->         EduPar -5.494792e-03 -0.0541843459      
32                Matsmk  <->       n_trauma  7.366071e-03  0.0743497863      
33                Matsmk  <->            Age -3.177083e-03 -0.0333441329      
34                Matsmk  <->        int_dis  2.125000e-02  0.1053910232      
35                Matsmk  <->     medication  4.062500e-03  0.0242997446      
36                Matsmk  <-> contraceptives  2.125000e-02  0.1053910232      
37                Matsmk  <->       cigday_1  1.672656e-02  0.1542372547      
38                Matsmk  <->             V8  2.891537e-03  0.0971189320      
39                Matagg  <->         Matagg  9.000000e-02  1.0000000000      
40                Matagg  <->       FamScore  3.375000e-02  0.3112715087      
41                Matagg  <->         EduPar -1.635417e-02 -0.2365241196      
42                Matagg  <->       n_trauma  7.142857e-03  0.1057402114      
43                Matagg  <->            Age  3.079710e-04  0.0047405101      
44                Matagg  <->        int_dis  3.250000e-02  0.2364027144      
45                Matagg  <->     medication  7.500000e-03  0.0657951695      
46                Matagg  <-> contraceptives  7.500000e-03  0.0545544726      
47                Matagg  <->       cigday_1  1.006250e-02  0.1360858260      
48                Matagg  <->             V8  8.168666e-04  0.0402393217      
49              FamScore  <->       FamScore  1.306250e-01  1.0000000000      
50              FamScore  <->         EduPar -2.911458e-02 -0.3495149022      
51              FamScore  <->       n_trauma  2.633929e-02  0.3236534989      
52              FamScore  <->            Age  3.591486e-03  0.0458878230      
53              FamScore  <->        int_dis  6.375000e-02  0.3849084009      
54              FamScore  <->     medication  4.375000e-03  0.0318580293      
55              FamScore  <-> contraceptives  5.750000e-02  0.3471722832      
56              FamScore  <->       cigday_1  4.326563e-02  0.4856887960      
57              FamScore  <->             V8  7.717159e-04  0.0315547719      
58                EduPar  <->         EduPar  5.312066e-02  1.0000000000      
59                EduPar  <->       n_trauma -7.924107e-03 -0.1526891136      
60                EduPar  <->            Age  2.727582e-03  0.0546490350      
61                EduPar  <->        int_dis -1.885417e-02 -0.1785114035      
62                EduPar  <->     medication  1.005208e-02  0.1147832062      
63                EduPar  <-> contraceptives -1.312500e-02 -0.1242676068      
64                EduPar  <->       cigday_1 -1.475130e-02 -0.2596730517      
65                EduPar  <->             V8 -8.750126e-06 -0.0005610523      
66              n_trauma  <->       n_trauma  5.070153e-02  1.0000000000      
67              n_trauma  <->            Age  1.562500e-03  0.0320439451      
68              n_trauma  <->        int_dis  4.107143e-02  0.3980335009      
69              n_trauma  <->     medication  1.741071e-02  0.2034979577      
70              n_trauma  <-> contraceptives  1.785714e-02  0.1730580439      
71              n_trauma  <->       cigday_1  2.101562e-02  0.3786692420      
72              n_trauma  <->             V8 -4.635661e-04 -0.0304243917      
73                   Age  <->            Age  4.689505e-02  1.0000000000      
74                   Age  <->        int_dis  7.989130e-03  0.0805056484      
75                   Age  <->     medication -1.634964e-03 -0.0198700345      
76                   Age  <-> contraceptives  3.480072e-02  0.3506833348      
77                   Age  <->       cigday_1  8.435575e-03  0.1580445206      
78                   Age  <->             V8 -1.316962e-03 -0.0898732659      
79               int_dis  <->        int_dis  2.100000e-01  1.0000000000      
80               int_dis  <->     medication  6.000000e-02  0.3445843938      
81               int_dis  <-> contraceptives  6.000000e-02  0.2857142857      
82               int_dis  <->       cigday_1  4.393750e-02  0.3890038953      
83               int_dis  <->             V8  5.574778e-03  0.1797788722      
84            medication  <->     medication  1.443750e-01  1.0000000000      
85            medication  <-> contraceptives  3.500000e-02  0.2010075631      
86            medication  <->       cigday_1  3.234375e-03  0.0345360471      
87            medication  <->             V8  2.058179e-03  0.0800493604      
88        contraceptives  <-> contraceptives  2.100000e-01  1.0000000000      
89        contraceptives  <->       cigday_1  4.831250e-02  0.4277382803      
90        contraceptives  <->             V8  2.655222e-03  0.0856272484      
91              cigday_1  <->       cigday_1  6.074961e-02  1.0000000000      
92              cigday_1  <->             V8  1.490410e-03  0.0893623867      
93                    V8  <->             V8  4.578872e-03  1.0000000000      
94                        int         Matsmk  2.625000e-01  0.5966005392      
95                        int         Matagg  1.000000e-01  0.3333333333      
96                        int       FamScore  2.250000e-01  0.6225430175      
97                        int         EduPar  6.062500e-01  2.6303892538      
98                        int       n_trauma  1.964286e-01  0.8723567443      
99                        int            Age  5.621377e-01  2.5958475642      
100                       int        int_dis  3.000000e-01  0.6546536707      
101                       int     medication  1.750000e-01  0.4605661865      
102                       int contraceptives  3.000000e-01  0.6546536707      
103                       int       cigday_1  1.243750e-01  0.5046163860      
104                       int             V8  5.286908e-01  7.8130836675      
    fixed par
1   FALSE   1
2   FALSE   2
3   FALSE   3
4   FALSE   4
5   FALSE   5
6   FALSE   6
7   FALSE   7
8   FALSE   8
9   FALSE   9
10  FALSE  10
11  FALSE  11
12  FALSE  12
13  FALSE  13
14  FALSE  14
15  FALSE  15
16  FALSE  16
17  FALSE  17
18  FALSE  18
19  FALSE  19
20  FALSE  20
21  FALSE  21
22  FALSE  22
23  FALSE  23
24  FALSE  24
25  FALSE  25
26  FALSE  26
27  FALSE  27
28   TRUE   0
29   TRUE   0
30   TRUE   0
31   TRUE   0
32   TRUE   0
33   TRUE   0
34   TRUE   0
35   TRUE   0
36   TRUE   0
37   TRUE   0
38   TRUE   0
39   TRUE   0
40   TRUE   0
41   TRUE   0
42   TRUE   0
43   TRUE   0
44   TRUE   0
45   TRUE   0
46   TRUE   0
47   TRUE   0
48   TRUE   0
49   TRUE   0
50   TRUE   0
51   TRUE   0
52   TRUE   0
53   TRUE   0
54   TRUE   0
55   TRUE   0
56   TRUE   0
57   TRUE   0
58   TRUE   0
59   TRUE   0
60   TRUE   0
61   TRUE   0
62   TRUE   0
63   TRUE   0
64   TRUE   0
65   TRUE   0
66   TRUE   0
67   TRUE   0
68   TRUE   0
69   TRUE   0
70   TRUE   0
71   TRUE   0
72   TRUE   0
73   TRUE   0
74   TRUE   0
75   TRUE   0
76   TRUE   0
77   TRUE   0
78   TRUE   0
79   TRUE   0
80   TRUE   0
81   TRUE   0
82   TRUE   0
83   TRUE   0
84   TRUE   0
85   TRUE   0
86   TRUE   0
87   TRUE   0
88   TRUE   0
89   TRUE   0
90   TRUE   0
91   TRUE   0
92   TRUE   0
93   TRUE   0
94   TRUE   0
95   TRUE   0
96   TRUE   0
97   TRUE   0
98   TRUE   0
99   TRUE   0
100  TRUE   0
101  TRUE   0
102  TRUE   0
103  TRUE   0
104  TRUE   0
############################
############################
Epi_all 
############################
############################
lavaan 0.6-7 ended normally after 51 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                         27
                                                      
                                                  Used       Total
  Number of observations                            80          99
                                                                  
Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  Epi ~                                               
    Matsmk     (a)    0.014    0.023    0.614    0.539
    Matagg     (b)    0.023    0.036    0.635    0.525
    FamScore   (c)   -0.037    0.033   -1.093    0.274
    EduPar     (d)   -0.090    0.043   -2.096    0.036
    n_trauma   (e)    0.025    0.046    0.542    0.588
    Age               0.034    0.046    0.747    0.455
    int_dis           0.023    0.025    0.923    0.356
    medication        0.007    0.027    0.276    0.783
    contrcptvs       -0.016    0.024   -0.646    0.518
    cigday_1          0.022    0.047    0.463    0.643
    V8                0.060    0.138    0.437    0.662
  group ~                                             
    Matsmk     (f)   -0.019    0.044   -0.430    0.667
    Matagg     (g)    0.134    0.067    1.998    0.046
    FamScore   (h)    0.089    0.063    1.404    0.160
    EduPar     (i)   -0.125    0.083   -1.499    0.134
    n_trauma   (j)    0.118    0.087    1.356    0.175
    Age              -0.372    0.086   -4.318    0.000
    int_dis           0.166    0.047    3.546    0.000
    medication        0.296    0.050    5.896    0.000
    contrcptvs        0.048    0.046    1.050    0.294
    cigday_1          0.698    0.089    7.809    0.000
    V8                0.202    0.259    0.779    0.436
    Epi        (z)    3.424    0.210   16.296    0.000

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.134    0.083    1.608    0.108
   .group            -0.140    0.159   -0.881    0.378

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.006    0.001    6.325    0.000
   .group             0.023    0.004    6.325    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    directMatsmk     -0.019    0.044   -0.430    0.667
    directMatagg      0.134    0.067    1.998    0.046
    directFamScore    0.089    0.063    1.404    0.160
    directEduPar     -0.125    0.083   -1.499    0.134
    directn_trauma    0.118    0.087    1.356    0.175
    EpiMatsmk         0.049    0.080    0.614    0.540
    EpiMatagg         0.078    0.122    0.635    0.526
    EpiFamScore      -0.125    0.115   -1.091    0.275
    EpiEduPar        -0.310    0.149   -2.079    0.038
    Epin_trauma       0.086    0.159    0.542    0.588
    total            -0.025    0.318   -0.077    0.938

               npar                fmin               chisq                  df 
             27.000               0.000               0.000               0.000 
             pvalue      baseline.chisq         baseline.df     baseline.pvalue 
                 NA             199.783              23.000               0.000 
                cfi                 tli                nnfi                 rfi 
              1.000               1.000               1.000               1.000 
                nfi                pnfi                 ifi                 rni 
              1.000               0.000               1.000               1.000 
               logl   unrestricted.logl                 aic                 bic 
            125.945             125.945            -197.890            -133.575 
             ntotal                bic2               rmsea      rmsea.ci.lower 
             80.000            -218.716               0.000               0.000 
     rmsea.ci.upper        rmsea.pvalue                 rmr          rmr_nomean 
              0.000                  NA               0.000               0.000 
               srmr        srmr_bentler srmr_bentler_nomean                crmr 
              0.000               0.000               0.000               0.000 
        crmr_nomean          srmr_mplus   srmr_mplus_nomean               cn_05 
              0.000               0.000               0.000                  NA 
              cn_01                 gfi                agfi                pgfi 
                 NA               1.000               1.000               0.000 
                mfi                ecvi 
              1.000               0.675 

               lhs op                                     rhs          label
1              Epi ~1                                                       
2              Epi  ~                                  Matsmk              a
3              Epi  ~                                  Matagg              b
4              Epi  ~                                FamScore              c
5              Epi  ~                                  EduPar              d
6              Epi  ~                                n_trauma              e
7              Epi  ~                                     Age               
8              Epi  ~                                 int_dis               
9              Epi  ~                              medication               
10             Epi  ~                          contraceptives               
11             Epi  ~                                cigday_1               
12             Epi  ~                                      V8               
13           group ~1                                                       
14           group  ~                                  Matsmk              f
15           group  ~                                  Matagg              g
16           group  ~                                FamScore              h
17           group  ~                                  EduPar              i
18           group  ~                                n_trauma              j
19           group  ~                                     Age               
20           group  ~                                 int_dis               
21           group  ~                              medication               
22           group  ~                          contraceptives               
23           group  ~                                cigday_1               
24           group  ~                                      V8               
25           group  ~                                     Epi              z
26             Epi ~~                                     Epi               
27           group ~~                                   group               
28          Matsmk ~~                                  Matsmk               
29          Matsmk ~~                                  Matagg               
30          Matsmk ~~                                FamScore               
31          Matsmk ~~                                  EduPar               
32          Matsmk ~~                                n_trauma               
33          Matsmk ~~                                     Age               
34          Matsmk ~~                                 int_dis               
35          Matsmk ~~                              medication               
36          Matsmk ~~                          contraceptives               
37          Matsmk ~~                                cigday_1               
38          Matsmk ~~                                      V8               
39          Matagg ~~                                  Matagg               
40          Matagg ~~                                FamScore               
41          Matagg ~~                                  EduPar               
42          Matagg ~~                                n_trauma               
43          Matagg ~~                                     Age               
44          Matagg ~~                                 int_dis               
45          Matagg ~~                              medication               
46          Matagg ~~                          contraceptives               
47          Matagg ~~                                cigday_1               
48          Matagg ~~                                      V8               
49        FamScore ~~                                FamScore               
50        FamScore ~~                                  EduPar               
51        FamScore ~~                                n_trauma               
52        FamScore ~~                                     Age               
53        FamScore ~~                                 int_dis               
54        FamScore ~~                              medication               
55        FamScore ~~                          contraceptives               
56        FamScore ~~                                cigday_1               
57        FamScore ~~                                      V8               
58          EduPar ~~                                  EduPar               
59          EduPar ~~                                n_trauma               
60          EduPar ~~                                     Age               
61          EduPar ~~                                 int_dis               
62          EduPar ~~                              medication               
63          EduPar ~~                          contraceptives               
64          EduPar ~~                                cigday_1               
65          EduPar ~~                                      V8               
66        n_trauma ~~                                n_trauma               
67        n_trauma ~~                                     Age               
68        n_trauma ~~                                 int_dis               
69        n_trauma ~~                              medication               
70        n_trauma ~~                          contraceptives               
71        n_trauma ~~                                cigday_1               
72        n_trauma ~~                                      V8               
73             Age ~~                                     Age               
74             Age ~~                                 int_dis               
75             Age ~~                              medication               
76             Age ~~                          contraceptives               
77             Age ~~                                cigday_1               
78             Age ~~                                      V8               
79         int_dis ~~                                 int_dis               
80         int_dis ~~                              medication               
81         int_dis ~~                          contraceptives               
82         int_dis ~~                                cigday_1               
83         int_dis ~~                                      V8               
84      medication ~~                              medication               
85      medication ~~                          contraceptives               
86      medication ~~                                cigday_1               
87      medication ~~                                      V8               
88  contraceptives ~~                          contraceptives               
89  contraceptives ~~                                cigday_1               
90  contraceptives ~~                                      V8               
91        cigday_1 ~~                                cigday_1               
92        cigday_1 ~~                                      V8               
93              V8 ~~                                      V8               
94          Matsmk ~1                                                       
95          Matagg ~1                                                       
96        FamScore ~1                                                       
97          EduPar ~1                                                       
98        n_trauma ~1                                                       
99             Age ~1                                                       
100        int_dis ~1                                                       
101     medication ~1                                                       
102 contraceptives ~1                                                       
103       cigday_1 ~1                                                       
104             V8 ~1                                                       
105   directMatsmk :=                                       f   directMatsmk
106   directMatagg :=                                       g   directMatagg
107 directFamScore :=                                       h directFamScore
108   directEduPar :=                                       i   directEduPar
109 directn_trauma :=                                       j directn_trauma
110      EpiMatsmk :=                                     a*z      EpiMatsmk
111      EpiMatagg :=                                     b*z      EpiMatagg
112    EpiFamScore :=                                     c*z    EpiFamScore
113      EpiEduPar :=                                     d*z      EpiEduPar
114    Epin_trauma :=                                     e*z    Epin_trauma
115          total := f+g+h+i+j+(a*z)+(b*z)+(c*z)+(d*z)+(e*z)          total
       est    se      z pvalue ci.lower ci.upper
1    0.134 0.083  1.608  0.108   -0.029    0.297
2    0.014 0.023  0.614  0.539   -0.032    0.060
3    0.023 0.036  0.635  0.525   -0.047    0.093
4   -0.037 0.033 -1.093  0.274   -0.102    0.029
5   -0.090 0.043 -2.096  0.036   -0.175   -0.006
6    0.025 0.046  0.542  0.588   -0.066    0.116
7    0.034 0.046  0.747  0.455   -0.055    0.124
8    0.023 0.025  0.923  0.356   -0.026    0.071
9    0.007 0.027  0.276  0.783   -0.045    0.060
10  -0.016 0.024 -0.646  0.518   -0.064    0.032
11   0.022 0.047  0.463  0.643   -0.071    0.115
12   0.060 0.138  0.437  0.662   -0.210    0.330
13  -0.140 0.159 -0.881  0.378   -0.452    0.172
14  -0.019 0.044 -0.430  0.667   -0.106    0.068
15   0.134 0.067  1.998  0.046    0.003    0.266
16   0.089 0.063  1.404  0.160   -0.035    0.213
17  -0.125 0.083 -1.499  0.134   -0.288    0.038
18   0.118 0.087  1.356  0.175   -0.053    0.289
19  -0.372 0.086 -4.318  0.000   -0.542   -0.203
20   0.166 0.047  3.546  0.000    0.074    0.258
21   0.296 0.050  5.896  0.000    0.197    0.394
22   0.048 0.046  1.050  0.294   -0.042    0.139
23   0.698 0.089  7.809  0.000    0.523    0.873
24   0.202 0.259  0.779  0.436   -0.306    0.710
25   3.424 0.210 16.296  0.000    3.012    3.836
26   0.006 0.001  6.325  0.000    0.004    0.008
27   0.023 0.004  6.325  0.000    0.016    0.030
28   0.194 0.000     NA     NA    0.194    0.194
29   0.049 0.000     NA     NA    0.049    0.049
30  -0.009 0.000     NA     NA   -0.009   -0.009
31  -0.005 0.000     NA     NA   -0.005   -0.005
32   0.007 0.000     NA     NA    0.007    0.007
33  -0.003 0.000     NA     NA   -0.003   -0.003
34   0.021 0.000     NA     NA    0.021    0.021
35   0.004 0.000     NA     NA    0.004    0.004
36   0.021 0.000     NA     NA    0.021    0.021
37   0.017 0.000     NA     NA    0.017    0.017
38   0.003 0.000     NA     NA    0.003    0.003
39   0.090 0.000     NA     NA    0.090    0.090
40   0.034 0.000     NA     NA    0.034    0.034
41  -0.016 0.000     NA     NA   -0.016   -0.016
42   0.007 0.000     NA     NA    0.007    0.007
43   0.000 0.000     NA     NA    0.000    0.000
44   0.032 0.000     NA     NA    0.032    0.032
45   0.007 0.000     NA     NA    0.007    0.007
46   0.007 0.000     NA     NA    0.007    0.007
47   0.010 0.000     NA     NA    0.010    0.010
48   0.001 0.000     NA     NA    0.001    0.001
49   0.131 0.000     NA     NA    0.131    0.131
50  -0.029 0.000     NA     NA   -0.029   -0.029
51   0.026 0.000     NA     NA    0.026    0.026
52   0.004 0.000     NA     NA    0.004    0.004
53   0.064 0.000     NA     NA    0.064    0.064
54   0.004 0.000     NA     NA    0.004    0.004
55   0.058 0.000     NA     NA    0.058    0.058
56   0.043 0.000     NA     NA    0.043    0.043
57   0.001 0.000     NA     NA    0.001    0.001
58   0.053 0.000     NA     NA    0.053    0.053
59  -0.008 0.000     NA     NA   -0.008   -0.008
60   0.003 0.000     NA     NA    0.003    0.003
61  -0.019 0.000     NA     NA   -0.019   -0.019
62   0.010 0.000     NA     NA    0.010    0.010
63  -0.013 0.000     NA     NA   -0.013   -0.013
64  -0.015 0.000     NA     NA   -0.015   -0.015
65   0.000 0.000     NA     NA    0.000    0.000
66   0.051 0.000     NA     NA    0.051    0.051
67   0.002 0.000     NA     NA    0.002    0.002
68   0.041 0.000     NA     NA    0.041    0.041
69   0.017 0.000     NA     NA    0.017    0.017
70   0.018 0.000     NA     NA    0.018    0.018
71   0.021 0.000     NA     NA    0.021    0.021
72   0.000 0.000     NA     NA    0.000    0.000
73   0.047 0.000     NA     NA    0.047    0.047
74   0.008 0.000     NA     NA    0.008    0.008
75  -0.002 0.000     NA     NA   -0.002   -0.002
76   0.035 0.000     NA     NA    0.035    0.035
77   0.008 0.000     NA     NA    0.008    0.008
78  -0.001 0.000     NA     NA   -0.001   -0.001
79   0.210 0.000     NA     NA    0.210    0.210
80   0.060 0.000     NA     NA    0.060    0.060
81   0.060 0.000     NA     NA    0.060    0.060
82   0.044 0.000     NA     NA    0.044    0.044
83   0.006 0.000     NA     NA    0.006    0.006
84   0.144 0.000     NA     NA    0.144    0.144
85   0.035 0.000     NA     NA    0.035    0.035
86   0.003 0.000     NA     NA    0.003    0.003
87   0.002 0.000     NA     NA    0.002    0.002
88   0.210 0.000     NA     NA    0.210    0.210
89   0.048 0.000     NA     NA    0.048    0.048
90   0.003 0.000     NA     NA    0.003    0.003
91   0.061 0.000     NA     NA    0.061    0.061
92   0.001 0.000     NA     NA    0.001    0.001
93   0.005 0.000     NA     NA    0.005    0.005
94   0.262 0.000     NA     NA    0.262    0.262
95   0.100 0.000     NA     NA    0.100    0.100
96   0.225 0.000     NA     NA    0.225    0.225
97   0.606 0.000     NA     NA    0.606    0.606
98   0.196 0.000     NA     NA    0.196    0.196
99   0.562 0.000     NA     NA    0.562    0.562
100  0.300 0.000     NA     NA    0.300    0.300
101  0.175 0.000     NA     NA    0.175    0.175
102  0.300 0.000     NA     NA    0.300    0.300
103  0.124 0.000     NA     NA    0.124    0.124
104  0.529 0.000     NA     NA    0.529    0.529
105 -0.019 0.044 -0.430  0.667   -0.106    0.068
106  0.134 0.067  1.998  0.046    0.003    0.266
107  0.089 0.063  1.404  0.160   -0.035    0.213
108 -0.125 0.083 -1.499  0.134   -0.288    0.038
109  0.118 0.087  1.356  0.175   -0.053    0.289
110  0.049 0.080  0.614  0.540   -0.108    0.207
111  0.078 0.122  0.635  0.526   -0.162    0.317
112 -0.125 0.115 -1.091  0.275   -0.350    0.100
113 -0.310 0.149 -2.079  0.038   -0.602   -0.018
114  0.086 0.159  0.542  0.588   -0.225    0.397
115 -0.025 0.318 -0.077  0.938   -0.648    0.599

    label            lhs edge            rhs           est           std group
1                         int            Epi  1.340350e-01  1.5607946831      
2       a         Matsmk   ~>            Epi  1.438673e-02  0.0737115016      
3       b         Matagg   ~>            Epi  2.267876e-02  0.0792260638      
4       c       FamScore   ~>            Epi -3.652791e-02 -0.1537324451      
5       d         EduPar   ~>            Epi -9.048835e-02 -0.2428577535      
6       e       n_trauma   ~>            Epi  2.508125e-02  0.0657638654      
7                    Age   ~>            Epi  3.417169e-02  0.0861702767      
8                int_dis   ~>            Epi  2.287155e-02  0.1220486240      
9             medication   ~>            Epi  7.364844e-03  0.0325864541      
10        contraceptives   ~>            Epi -1.577718e-02 -0.0841911924      
11              cigday_1   ~>            Epi  2.200542e-02  0.0631580848      
12                    V8   ~>            Epi  6.028766e-02  0.0475045571      
13                        int          group -1.402433e-01 -0.2848827026      
14      f         Matsmk   ~>          group -1.900061e-02 -0.0169823275      
15      g         Matagg   ~>          group  1.344228e-01  0.0819177900      
16      h       FamScore   ~>          group  8.885591e-02  0.0652354318      
17      i         EduPar   ~>          group -1.249223e-01 -0.0584865328      
18      j       n_trauma   ~>          group  1.181732e-01  0.0540522085      
19                   Age   ~>          group -3.724755e-01 -0.1638495711      
20               int_dis   ~>          group  1.660560e-01  0.1545782565      
21            medication   ~>          group  2.958406e-01  0.2283430460      
22        contraceptives   ~>          group  4.833207e-02  0.0449913640      
23              cigday_1   ~>          group  6.977545e-01  0.3493481727      
24                    V8   ~>          group  2.019714e-01  0.0277621578      
25      z            Epi   ~>          group  3.424325e+00  0.5973536050      
26                   Epi  <->            Epi  6.453078e-03  0.8750282428      
27                 group  <->          group  2.279575e-02  0.0940636938      
28                Matsmk  <->         Matsmk  1.935938e-01  1.0000000000      
29                Matsmk  <->         Matagg  4.875000e-02  0.3693241433      
30                Matsmk  <->       FamScore -9.062500e-03 -0.0569887592      
31                Matsmk  <->         EduPar -5.494792e-03 -0.0541843459      
32                Matsmk  <->       n_trauma  7.366071e-03  0.0743497863      
33                Matsmk  <->            Age -3.177083e-03 -0.0333441329      
34                Matsmk  <->        int_dis  2.125000e-02  0.1053910232      
35                Matsmk  <->     medication  4.062500e-03  0.0242997446      
36                Matsmk  <-> contraceptives  2.125000e-02  0.1053910232      
37                Matsmk  <->       cigday_1  1.672656e-02  0.1542372547      
38                Matsmk  <->             V8  2.891537e-03  0.0971189320      
39                Matagg  <->         Matagg  9.000000e-02  1.0000000000      
40                Matagg  <->       FamScore  3.375000e-02  0.3112715087      
41                Matagg  <->         EduPar -1.635417e-02 -0.2365241196      
42                Matagg  <->       n_trauma  7.142857e-03  0.1057402114      
43                Matagg  <->            Age  3.079710e-04  0.0047405101      
44                Matagg  <->        int_dis  3.250000e-02  0.2364027144      
45                Matagg  <->     medication  7.500000e-03  0.0657951695      
46                Matagg  <-> contraceptives  7.500000e-03  0.0545544726      
47                Matagg  <->       cigday_1  1.006250e-02  0.1360858260      
48                Matagg  <->             V8  8.168666e-04  0.0402393217      
49              FamScore  <->       FamScore  1.306250e-01  1.0000000000      
50              FamScore  <->         EduPar -2.911458e-02 -0.3495149022      
51              FamScore  <->       n_trauma  2.633929e-02  0.3236534989      
52              FamScore  <->            Age  3.591486e-03  0.0458878230      
53              FamScore  <->        int_dis  6.375000e-02  0.3849084009      
54              FamScore  <->     medication  4.375000e-03  0.0318580293      
55              FamScore  <-> contraceptives  5.750000e-02  0.3471722832      
56              FamScore  <->       cigday_1  4.326563e-02  0.4856887960      
57              FamScore  <->             V8  7.717159e-04  0.0315547719      
58                EduPar  <->         EduPar  5.312066e-02  1.0000000000      
59                EduPar  <->       n_trauma -7.924107e-03 -0.1526891136      
60                EduPar  <->            Age  2.727582e-03  0.0546490350      
61                EduPar  <->        int_dis -1.885417e-02 -0.1785114035      
62                EduPar  <->     medication  1.005208e-02  0.1147832062      
63                EduPar  <-> contraceptives -1.312500e-02 -0.1242676068      
64                EduPar  <->       cigday_1 -1.475130e-02 -0.2596730517      
65                EduPar  <->             V8 -8.750126e-06 -0.0005610523      
66              n_trauma  <->       n_trauma  5.070153e-02  1.0000000000      
67              n_trauma  <->            Age  1.562500e-03  0.0320439451      
68              n_trauma  <->        int_dis  4.107143e-02  0.3980335009      
69              n_trauma  <->     medication  1.741071e-02  0.2034979577      
70              n_trauma  <-> contraceptives  1.785714e-02  0.1730580439      
71              n_trauma  <->       cigday_1  2.101562e-02  0.3786692420      
72              n_trauma  <->             V8 -4.635661e-04 -0.0304243917      
73                   Age  <->            Age  4.689505e-02  1.0000000000      
74                   Age  <->        int_dis  7.989130e-03  0.0805056484      
75                   Age  <->     medication -1.634964e-03 -0.0198700345      
76                   Age  <-> contraceptives  3.480072e-02  0.3506833348      
77                   Age  <->       cigday_1  8.435575e-03  0.1580445206      
78                   Age  <->             V8 -1.316962e-03 -0.0898732659      
79               int_dis  <->        int_dis  2.100000e-01  1.0000000000      
80               int_dis  <->     medication  6.000000e-02  0.3445843938      
81               int_dis  <-> contraceptives  6.000000e-02  0.2857142857      
82               int_dis  <->       cigday_1  4.393750e-02  0.3890038953      
83               int_dis  <->             V8  5.574778e-03  0.1797788722      
84            medication  <->     medication  1.443750e-01  1.0000000000      
85            medication  <-> contraceptives  3.500000e-02  0.2010075631      
86            medication  <->       cigday_1  3.234375e-03  0.0345360471      
87            medication  <->             V8  2.058179e-03  0.0800493604      
88        contraceptives  <-> contraceptives  2.100000e-01  1.0000000000      
89        contraceptives  <->       cigday_1  4.831250e-02  0.4277382803      
90        contraceptives  <->             V8  2.655222e-03  0.0856272484      
91              cigday_1  <->       cigday_1  6.074961e-02  1.0000000000      
92              cigday_1  <->             V8  1.490410e-03  0.0893623867      
93                    V8  <->             V8  4.578872e-03  1.0000000000      
94                        int         Matsmk  2.625000e-01  0.5966005392      
95                        int         Matagg  1.000000e-01  0.3333333333      
96                        int       FamScore  2.250000e-01  0.6225430175      
97                        int         EduPar  6.062500e-01  2.6303892538      
98                        int       n_trauma  1.964286e-01  0.8723567443      
99                        int            Age  5.621377e-01  2.5958475642      
100                       int        int_dis  3.000000e-01  0.6546536707      
101                       int     medication  1.750000e-01  0.4605661865      
102                       int contraceptives  3.000000e-01  0.6546536707      
103                       int       cigday_1  1.243750e-01  0.5046163860      
104                       int             V8  5.286908e-01  7.8130836675      
    fixed par
1   FALSE   1
2   FALSE   2
3   FALSE   3
4   FALSE   4
5   FALSE   5
6   FALSE   6
7   FALSE   7
8   FALSE   8
9   FALSE   9
10  FALSE  10
11  FALSE  11
12  FALSE  12
13  FALSE  13
14  FALSE  14
15  FALSE  15
16  FALSE  16
17  FALSE  17
18  FALSE  18
19  FALSE  19
20  FALSE  20
21  FALSE  21
22  FALSE  22
23  FALSE  23
24  FALSE  24
25  FALSE  25
26  FALSE  26
27  FALSE  27
28   TRUE   0
29   TRUE   0
30   TRUE   0
31   TRUE   0
32   TRUE   0
33   TRUE   0
34   TRUE   0
35   TRUE   0
36   TRUE   0
37   TRUE   0
38   TRUE   0
39   TRUE   0
40   TRUE   0
41   TRUE   0
42   TRUE   0
43   TRUE   0
44   TRUE   0
45   TRUE   0
46   TRUE   0
47   TRUE   0
48   TRUE   0
49   TRUE   0
50   TRUE   0
51   TRUE   0
52   TRUE   0
53   TRUE   0
54   TRUE   0
55   TRUE   0
56   TRUE   0
57   TRUE   0
58   TRUE   0
59   TRUE   0
60   TRUE   0
61   TRUE   0
62   TRUE   0
63   TRUE   0
64   TRUE   0
65   TRUE   0
66   TRUE   0
67   TRUE   0
68   TRUE   0
69   TRUE   0
70   TRUE   0
71   TRUE   0
72   TRUE   0
73   TRUE   0
74   TRUE   0
75   TRUE   0
76   TRUE   0
77   TRUE   0
78   TRUE   0
79   TRUE   0
80   TRUE   0
81   TRUE   0
82   TRUE   0
83   TRUE   0
84   TRUE   0
85   TRUE   0
86   TRUE   0
87   TRUE   0
88   TRUE   0
89   TRUE   0
90   TRUE   0
91   TRUE   0
92   TRUE   0
93   TRUE   0
94   TRUE   0
95   TRUE   0
96   TRUE   0
97   TRUE   0
98   TRUE   0
99   TRUE   0
100  TRUE   0
101  TRUE   0
102  TRUE   0
103  TRUE   0
104  TRUE   0
############################
############################
Epi_M2 
############################
############################
lavaan 0.6-7 ended normally after 44 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                         27
                                                      
                                                  Used       Total
  Number of observations                            80          99
                                                                  
Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  Epi ~                                               
    Matsmk     (a)    0.009    0.033    0.272    0.786
    Matagg     (b)   -0.017    0.051   -0.328    0.743
    FamScore   (c)   -0.054    0.047   -1.133    0.257
    EduPar     (d)   -0.010    0.061   -0.164    0.870
    n_trauma   (e)    0.018    0.066    0.277    0.782
    Age              -0.042    0.065   -0.646    0.518
    int_dis          -0.010    0.035   -0.274    0.784
    medication        0.018    0.038    0.473    0.636
    contrcptvs        0.074    0.035    2.145    0.032
    cigday_1         -0.058    0.067   -0.866    0.386
    V8               -0.522    0.195   -2.674    0.007
  group ~                                             
    Matsmk     (f)    0.041    0.083    0.496    0.620
    Matagg     (g)    0.192    0.126    1.527    0.127
    FamScore   (h)   -0.100    0.119   -0.841    0.400
    EduPar     (i)   -0.447    0.152   -2.933    0.003
    n_trauma   (j)    0.226    0.163    1.382    0.167
    Age              -0.305    0.162   -1.887    0.059
    int_dis           0.233    0.087    2.664    0.008
    medication        0.342    0.094    3.632    0.000
    contrcptvs        0.082    0.089    0.929    0.353
    cigday_1          0.704    0.168    4.185    0.000
    V8               -0.211    0.507   -0.416    0.678
    Epi        (z)   -1.187    0.278   -4.262    0.000

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.886    0.118    7.504    0.000
   .group             1.370    0.384    3.570    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.013    0.002    6.325    0.000
   .group             0.080    0.013    6.325    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    directMatsmk      0.041    0.083    0.496    0.620
    directMatagg      0.192    0.126    1.527    0.127
    directFamScore   -0.100    0.119   -0.841    0.400
    directEduPar     -0.447    0.152   -2.933    0.003
    directn_trauma    0.226    0.163    1.382    0.167
    EpiMatsmk        -0.011    0.039   -0.271    0.786
    EpiMatagg         0.020    0.060    0.327    0.744
    EpiFamScore       0.064    0.058    1.095    0.273
    EpiEduPar         0.012    0.073    0.164    0.870
    Epin_trauma      -0.022    0.078   -0.277    0.782
    total            -0.025    0.318   -0.077    0.938

               npar                fmin               chisq                  df 
             27.000               0.000               0.000               0.000 
             pvalue      baseline.chisq         baseline.df     baseline.pvalue 
                 NA             101.992              23.000               0.000 
                cfi                 tli                nnfi                 rfi 
              1.000               1.000               1.000               1.000 
                nfi                pnfi                 ifi                 rni 
              1.000               0.000               1.000               1.000 
               logl   unrestricted.logl                 aic                 bic 
             47.771              47.771             -41.542              22.773 
             ntotal                bic2               rmsea      rmsea.ci.lower 
             80.000             -62.368               0.000               0.000 
     rmsea.ci.upper        rmsea.pvalue                 rmr          rmr_nomean 
              0.000                  NA               0.000               0.000 
               srmr        srmr_bentler srmr_bentler_nomean                crmr 
              0.000               0.000               0.000               0.000 
        crmr_nomean          srmr_mplus   srmr_mplus_nomean               cn_05 
              0.000               0.000               0.000                  NA 
              cn_01                 gfi                agfi                pgfi 
                 NA               1.000               1.000               0.000 
                mfi                ecvi 
              1.000               0.675 

               lhs op                                     rhs          label
1              Epi ~1                                                       
2              Epi  ~                                  Matsmk              a
3              Epi  ~                                  Matagg              b
4              Epi  ~                                FamScore              c
5              Epi  ~                                  EduPar              d
6              Epi  ~                                n_trauma              e
7              Epi  ~                                     Age               
8              Epi  ~                                 int_dis               
9              Epi  ~                              medication               
10             Epi  ~                          contraceptives               
11             Epi  ~                                cigday_1               
12             Epi  ~                                      V8               
13           group ~1                                                       
14           group  ~                                  Matsmk              f
15           group  ~                                  Matagg              g
16           group  ~                                FamScore              h
17           group  ~                                  EduPar              i
18           group  ~                                n_trauma              j
19           group  ~                                     Age               
20           group  ~                                 int_dis               
21           group  ~                              medication               
22           group  ~                          contraceptives               
23           group  ~                                cigday_1               
24           group  ~                                      V8               
25           group  ~                                     Epi              z
26             Epi ~~                                     Epi               
27           group ~~                                   group               
28          Matsmk ~~                                  Matsmk               
29          Matsmk ~~                                  Matagg               
30          Matsmk ~~                                FamScore               
31          Matsmk ~~                                  EduPar               
32          Matsmk ~~                                n_trauma               
33          Matsmk ~~                                     Age               
34          Matsmk ~~                                 int_dis               
35          Matsmk ~~                              medication               
36          Matsmk ~~                          contraceptives               
37          Matsmk ~~                                cigday_1               
38          Matsmk ~~                                      V8               
39          Matagg ~~                                  Matagg               
40          Matagg ~~                                FamScore               
41          Matagg ~~                                  EduPar               
42          Matagg ~~                                n_trauma               
43          Matagg ~~                                     Age               
44          Matagg ~~                                 int_dis               
45          Matagg ~~                              medication               
46          Matagg ~~                          contraceptives               
47          Matagg ~~                                cigday_1               
48          Matagg ~~                                      V8               
49        FamScore ~~                                FamScore               
50        FamScore ~~                                  EduPar               
51        FamScore ~~                                n_trauma               
52        FamScore ~~                                     Age               
53        FamScore ~~                                 int_dis               
54        FamScore ~~                              medication               
55        FamScore ~~                          contraceptives               
56        FamScore ~~                                cigday_1               
57        FamScore ~~                                      V8               
58          EduPar ~~                                  EduPar               
59          EduPar ~~                                n_trauma               
60          EduPar ~~                                     Age               
61          EduPar ~~                                 int_dis               
62          EduPar ~~                              medication               
63          EduPar ~~                          contraceptives               
64          EduPar ~~                                cigday_1               
65          EduPar ~~                                      V8               
66        n_trauma ~~                                n_trauma               
67        n_trauma ~~                                     Age               
68        n_trauma ~~                                 int_dis               
69        n_trauma ~~                              medication               
70        n_trauma ~~                          contraceptives               
71        n_trauma ~~                                cigday_1               
72        n_trauma ~~                                      V8               
73             Age ~~                                     Age               
74             Age ~~                                 int_dis               
75             Age ~~                              medication               
76             Age ~~                          contraceptives               
77             Age ~~                                cigday_1               
78             Age ~~                                      V8               
79         int_dis ~~                                 int_dis               
80         int_dis ~~                              medication               
81         int_dis ~~                          contraceptives               
82         int_dis ~~                                cigday_1               
83         int_dis ~~                                      V8               
84      medication ~~                              medication               
85      medication ~~                          contraceptives               
86      medication ~~                                cigday_1               
87      medication ~~                                      V8               
88  contraceptives ~~                          contraceptives               
89  contraceptives ~~                                cigday_1               
90  contraceptives ~~                                      V8               
91        cigday_1 ~~                                cigday_1               
92        cigday_1 ~~                                      V8               
93              V8 ~~                                      V8               
94          Matsmk ~1                                                       
95          Matagg ~1                                                       
96        FamScore ~1                                                       
97          EduPar ~1                                                       
98        n_trauma ~1                                                       
99             Age ~1                                                       
100        int_dis ~1                                                       
101     medication ~1                                                       
102 contraceptives ~1                                                       
103       cigday_1 ~1                                                       
104             V8 ~1                                                       
105   directMatsmk :=                                       f   directMatsmk
106   directMatagg :=                                       g   directMatagg
107 directFamScore :=                                       h directFamScore
108   directEduPar :=                                       i   directEduPar
109 directn_trauma :=                                       j directn_trauma
110      EpiMatsmk :=                                     a*z      EpiMatsmk
111      EpiMatagg :=                                     b*z      EpiMatagg
112    EpiFamScore :=                                     c*z    EpiFamScore
113      EpiEduPar :=                                     d*z      EpiEduPar
114    Epin_trauma :=                                     e*z    Epin_trauma
115          total := f+g+h+i+j+(a*z)+(b*z)+(c*z)+(d*z)+(e*z)          total
       est    se      z pvalue ci.lower ci.upper
1    0.886 0.118  7.504  0.000    0.655    1.117
2    0.009 0.033  0.272  0.786   -0.056    0.074
3   -0.017 0.051 -0.328  0.743   -0.116    0.083
4   -0.054 0.047 -1.133  0.257   -0.146    0.039
5   -0.010 0.061 -0.164  0.870   -0.130    0.110
6    0.018 0.066  0.277  0.782   -0.110    0.147
7   -0.042 0.065 -0.646  0.518   -0.169    0.085
8   -0.010 0.035 -0.274  0.784   -0.078    0.059
9    0.018 0.038  0.473  0.636   -0.056    0.092
10   0.074 0.035  2.145  0.032    0.006    0.142
11  -0.058 0.067 -0.866  0.386   -0.190    0.074
12  -0.522 0.195 -2.674  0.007   -0.905   -0.139
13   1.370 0.384  3.570  0.000    0.618    2.122
14   0.041 0.083  0.496  0.620   -0.121    0.203
15   0.192 0.126  1.527  0.127   -0.055    0.439
16  -0.100 0.119 -0.841  0.400   -0.333    0.133
17  -0.447 0.152 -2.933  0.003   -0.745   -0.148
18   0.226 0.163  1.382  0.167   -0.094    0.546
19  -0.305 0.162 -1.887  0.059   -0.622    0.012
20   0.233 0.087  2.664  0.008    0.062    0.404
21   0.342 0.094  3.632  0.000    0.158    0.527
22   0.082 0.089  0.929  0.353   -0.091    0.256
23   0.704 0.168  4.185  0.000    0.374    1.034
24  -0.211 0.507 -0.416  0.678   -1.205    0.783
25  -1.187 0.278 -4.262  0.000   -1.732   -0.641
26   0.013 0.002  6.325  0.000    0.009    0.017
27   0.080 0.013  6.325  0.000    0.055    0.105
28   0.194 0.000     NA     NA    0.194    0.194
29   0.049 0.000     NA     NA    0.049    0.049
30  -0.009 0.000     NA     NA   -0.009   -0.009
31  -0.005 0.000     NA     NA   -0.005   -0.005
32   0.007 0.000     NA     NA    0.007    0.007
33  -0.003 0.000     NA     NA   -0.003   -0.003
34   0.021 0.000     NA     NA    0.021    0.021
35   0.004 0.000     NA     NA    0.004    0.004
36   0.021 0.000     NA     NA    0.021    0.021
37   0.017 0.000     NA     NA    0.017    0.017
38   0.003 0.000     NA     NA    0.003    0.003
39   0.090 0.000     NA     NA    0.090    0.090
40   0.034 0.000     NA     NA    0.034    0.034
41  -0.016 0.000     NA     NA   -0.016   -0.016
42   0.007 0.000     NA     NA    0.007    0.007
43   0.000 0.000     NA     NA    0.000    0.000
44   0.032 0.000     NA     NA    0.032    0.032
45   0.007 0.000     NA     NA    0.007    0.007
46   0.007 0.000     NA     NA    0.007    0.007
47   0.010 0.000     NA     NA    0.010    0.010
48   0.001 0.000     NA     NA    0.001    0.001
49   0.131 0.000     NA     NA    0.131    0.131
50  -0.029 0.000     NA     NA   -0.029   -0.029
51   0.026 0.000     NA     NA    0.026    0.026
52   0.004 0.000     NA     NA    0.004    0.004
53   0.064 0.000     NA     NA    0.064    0.064
54   0.004 0.000     NA     NA    0.004    0.004
55   0.058 0.000     NA     NA    0.058    0.058
56   0.043 0.000     NA     NA    0.043    0.043
57   0.001 0.000     NA     NA    0.001    0.001
58   0.053 0.000     NA     NA    0.053    0.053
59  -0.008 0.000     NA     NA   -0.008   -0.008
60   0.003 0.000     NA     NA    0.003    0.003
61  -0.019 0.000     NA     NA   -0.019   -0.019
62   0.010 0.000     NA     NA    0.010    0.010
63  -0.013 0.000     NA     NA   -0.013   -0.013
64  -0.015 0.000     NA     NA   -0.015   -0.015
65   0.000 0.000     NA     NA    0.000    0.000
66   0.051 0.000     NA     NA    0.051    0.051
67   0.002 0.000     NA     NA    0.002    0.002
68   0.041 0.000     NA     NA    0.041    0.041
69   0.017 0.000     NA     NA    0.017    0.017
70   0.018 0.000     NA     NA    0.018    0.018
71   0.021 0.000     NA     NA    0.021    0.021
72   0.000 0.000     NA     NA    0.000    0.000
73   0.047 0.000     NA     NA    0.047    0.047
74   0.008 0.000     NA     NA    0.008    0.008
75  -0.002 0.000     NA     NA   -0.002   -0.002
76   0.035 0.000     NA     NA    0.035    0.035
77   0.008 0.000     NA     NA    0.008    0.008
78  -0.001 0.000     NA     NA   -0.001   -0.001
79   0.210 0.000     NA     NA    0.210    0.210
80   0.060 0.000     NA     NA    0.060    0.060
81   0.060 0.000     NA     NA    0.060    0.060
82   0.044 0.000     NA     NA    0.044    0.044
83   0.006 0.000     NA     NA    0.006    0.006
84   0.144 0.000     NA     NA    0.144    0.144
85   0.035 0.000     NA     NA    0.035    0.035
86   0.003 0.000     NA     NA    0.003    0.003
87   0.002 0.000     NA     NA    0.002    0.002
88   0.210 0.000     NA     NA    0.210    0.210
89   0.048 0.000     NA     NA    0.048    0.048
90   0.003 0.000     NA     NA    0.003    0.003
91   0.061 0.000     NA     NA    0.061    0.061
92   0.001 0.000     NA     NA    0.001    0.001
93   0.005 0.000     NA     NA    0.005    0.005
94   0.262 0.000     NA     NA    0.262    0.262
95   0.100 0.000     NA     NA    0.100    0.100
96   0.225 0.000     NA     NA    0.225    0.225
97   0.606 0.000     NA     NA    0.606    0.606
98   0.196 0.000     NA     NA    0.196    0.196
99   0.562 0.000     NA     NA    0.562    0.562
100  0.300 0.000     NA     NA    0.300    0.300
101  0.175 0.000     NA     NA    0.175    0.175
102  0.300 0.000     NA     NA    0.300    0.300
103  0.124 0.000     NA     NA    0.124    0.124
104  0.529 0.000     NA     NA    0.529    0.529
105  0.041 0.083  0.496  0.620   -0.121    0.203
106  0.192 0.126  1.527  0.127   -0.055    0.439
107 -0.100 0.119 -0.841  0.400   -0.333    0.133
108 -0.447 0.152 -2.933  0.003   -0.745   -0.148
109  0.226 0.163  1.382  0.167   -0.094    0.546
110 -0.011 0.039 -0.271  0.786   -0.088    0.067
111  0.020 0.060  0.327  0.744   -0.098    0.138
112  0.064 0.058  1.095  0.273   -0.050    0.177
113  0.012 0.073  0.164  0.870   -0.130    0.154
114 -0.022 0.078 -0.277  0.782   -0.174    0.131
115 -0.025 0.318 -0.077  0.938   -0.648    0.599

    label            lhs edge            rhs           est           std group
1                         int            Epi  8.859017e-01  7.1543326542      
2       a         Matsmk   ~>            Epi  9.021716e-03  0.0320566678      
3       b         Matagg   ~>            Epi -1.656132e-02 -0.0401235978      
4       c       FamScore   ~>            Epi -5.363064e-02 -0.1565343657      
5       d         EduPar   ~>            Epi -1.003047e-02 -0.0186696766      
6       e       n_trauma   ~>            Epi  1.817114e-02  0.0330427552      
7                    Age   ~>            Epi -4.183865e-02 -0.0731685995      
8                int_dis   ~>            Epi -9.609875e-03 -0.0355640294      
9             medication   ~>            Epi  1.786833e-02  0.0548294026      
10        contraceptives   ~>            Epi  7.415667e-02  0.2744374851      
11              cigday_1   ~>            Epi -5.823698e-02 -0.1159188714      
12                    V8   ~>            Epi -5.220008e-01 -0.2852554979      
13                        int          group  1.369907e+00  2.7827560211      
14      f         Matsmk   ~>          group  4.096898e-02  0.0366171779      
15      g         Matagg   ~>          group  1.924313e-01  0.1172684285      
16      h       FamScore   ~>          group -9.986321e-02 -0.0733166719      
17      i         EduPar   ~>          group -4.466855e-01 -0.2091306504      
18      j       n_trauma   ~>          group  2.256206e-01  0.1031984814      
19                   Age   ~>          group -3.051044e-01 -0.1342134586      
20               int_dis   ~>          group  2.329730e-01  0.2168699501      
21            medication   ~>          group  3.422619e-01  0.2641731418      
22        contraceptives   ~>          group  8.229681e-02  0.0766084634      
23              cigday_1   ~>          group  7.040069e-01  0.3524785748      
24                    V8   ~>          group -2.109666e-01 -0.0289985961      
25      z            Epi   ~>          group -1.186555e+00 -0.2984614300      
26                   Epi  <->            Epi  1.294098e-02  0.8439844069      
27                 group  <->          group  8.024479e-02  0.3311197091      
28                Matsmk  <->         Matsmk  1.935938e-01  1.0000000000      
29                Matsmk  <->         Matagg  4.875000e-02  0.3693241433      
30                Matsmk  <->       FamScore -9.062500e-03 -0.0569887592      
31                Matsmk  <->         EduPar -5.494792e-03 -0.0541843459      
32                Matsmk  <->       n_trauma  7.366071e-03  0.0743497863      
33                Matsmk  <->            Age -3.177083e-03 -0.0333441329      
34                Matsmk  <->        int_dis  2.125000e-02  0.1053910232      
35                Matsmk  <->     medication  4.062500e-03  0.0242997446      
36                Matsmk  <-> contraceptives  2.125000e-02  0.1053910232      
37                Matsmk  <->       cigday_1  1.672656e-02  0.1542372547      
38                Matsmk  <->             V8  2.891537e-03  0.0971189320      
39                Matagg  <->         Matagg  9.000000e-02  1.0000000000      
40                Matagg  <->       FamScore  3.375000e-02  0.3112715087      
41                Matagg  <->         EduPar -1.635417e-02 -0.2365241196      
42                Matagg  <->       n_trauma  7.142857e-03  0.1057402114      
43                Matagg  <->            Age  3.079710e-04  0.0047405101      
44                Matagg  <->        int_dis  3.250000e-02  0.2364027144      
45                Matagg  <->     medication  7.500000e-03  0.0657951695      
46                Matagg  <-> contraceptives  7.500000e-03  0.0545544726      
47                Matagg  <->       cigday_1  1.006250e-02  0.1360858260      
48                Matagg  <->             V8  8.168666e-04  0.0402393217      
49              FamScore  <->       FamScore  1.306250e-01  1.0000000000      
50              FamScore  <->         EduPar -2.911458e-02 -0.3495149022      
51              FamScore  <->       n_trauma  2.633929e-02  0.3236534989      
52              FamScore  <->            Age  3.591486e-03  0.0458878230      
53              FamScore  <->        int_dis  6.375000e-02  0.3849084009      
54              FamScore  <->     medication  4.375000e-03  0.0318580293      
55              FamScore  <-> contraceptives  5.750000e-02  0.3471722832      
56              FamScore  <->       cigday_1  4.326563e-02  0.4856887960      
57              FamScore  <->             V8  7.717159e-04  0.0315547719      
58                EduPar  <->         EduPar  5.312066e-02  1.0000000000      
59                EduPar  <->       n_trauma -7.924107e-03 -0.1526891136      
60                EduPar  <->            Age  2.727582e-03  0.0546490350      
61                EduPar  <->        int_dis -1.885417e-02 -0.1785114035      
62                EduPar  <->     medication  1.005208e-02  0.1147832062      
63                EduPar  <-> contraceptives -1.312500e-02 -0.1242676068      
64                EduPar  <->       cigday_1 -1.475130e-02 -0.2596730517      
65                EduPar  <->             V8 -8.750126e-06 -0.0005610523      
66              n_trauma  <->       n_trauma  5.070153e-02  1.0000000000      
67              n_trauma  <->            Age  1.562500e-03  0.0320439451      
68              n_trauma  <->        int_dis  4.107143e-02  0.3980335009      
69              n_trauma  <->     medication  1.741071e-02  0.2034979577      
70              n_trauma  <-> contraceptives  1.785714e-02  0.1730580439      
71              n_trauma  <->       cigday_1  2.101562e-02  0.3786692420      
72              n_trauma  <->             V8 -4.635661e-04 -0.0304243917      
73                   Age  <->            Age  4.689505e-02  1.0000000000      
74                   Age  <->        int_dis  7.989130e-03  0.0805056484      
75                   Age  <->     medication -1.634964e-03 -0.0198700345      
76                   Age  <-> contraceptives  3.480072e-02  0.3506833348      
77                   Age  <->       cigday_1  8.435575e-03  0.1580445206      
78                   Age  <->             V8 -1.316962e-03 -0.0898732659      
79               int_dis  <->        int_dis  2.100000e-01  1.0000000000      
80               int_dis  <->     medication  6.000000e-02  0.3445843938      
81               int_dis  <-> contraceptives  6.000000e-02  0.2857142857      
82               int_dis  <->       cigday_1  4.393750e-02  0.3890038953      
83               int_dis  <->             V8  5.574778e-03  0.1797788722      
84            medication  <->     medication  1.443750e-01  1.0000000000      
85            medication  <-> contraceptives  3.500000e-02  0.2010075631      
86            medication  <->       cigday_1  3.234375e-03  0.0345360471      
87            medication  <->             V8  2.058179e-03  0.0800493604      
88        contraceptives  <-> contraceptives  2.100000e-01  1.0000000000      
89        contraceptives  <->       cigday_1  4.831250e-02  0.4277382803      
90        contraceptives  <->             V8  2.655222e-03  0.0856272484      
91              cigday_1  <->       cigday_1  6.074961e-02  1.0000000000      
92              cigday_1  <->             V8  1.490410e-03  0.0893623867      
93                    V8  <->             V8  4.578872e-03  1.0000000000      
94                        int         Matsmk  2.625000e-01  0.5966005392      
95                        int         Matagg  1.000000e-01  0.3333333333      
96                        int       FamScore  2.250000e-01  0.6225430175      
97                        int         EduPar  6.062500e-01  2.6303892538      
98                        int       n_trauma  1.964286e-01  0.8723567443      
99                        int            Age  5.621377e-01  2.5958475642      
100                       int        int_dis  3.000000e-01  0.6546536707      
101                       int     medication  1.750000e-01  0.4605661865      
102                       int contraceptives  3.000000e-01  0.6546536707      
103                       int       cigday_1  1.243750e-01  0.5046163860      
104                       int             V8  5.286908e-01  7.8130836675      
    fixed par
1   FALSE   1
2   FALSE   2
3   FALSE   3
4   FALSE   4
5   FALSE   5
6   FALSE   6
7   FALSE   7
8   FALSE   8
9   FALSE   9
10  FALSE  10
11  FALSE  11
12  FALSE  12
13  FALSE  13
14  FALSE  14
15  FALSE  15
16  FALSE  16
17  FALSE  17
18  FALSE  18
19  FALSE  19
20  FALSE  20
21  FALSE  21
22  FALSE  22
23  FALSE  23
24  FALSE  24
25  FALSE  25
26  FALSE  26
27  FALSE  27
28   TRUE   0
29   TRUE   0
30   TRUE   0
31   TRUE   0
32   TRUE   0
33   TRUE   0
34   TRUE   0
35   TRUE   0
36   TRUE   0
37   TRUE   0
38   TRUE   0
39   TRUE   0
40   TRUE   0
41   TRUE   0
42   TRUE   0
43   TRUE   0
44   TRUE   0
45   TRUE   0
46   TRUE   0
47   TRUE   0
48   TRUE   0
49   TRUE   0
50   TRUE   0
51   TRUE   0
52   TRUE   0
53   TRUE   0
54   TRUE   0
55   TRUE   0
56   TRUE   0
57   TRUE   0
58   TRUE   0
59   TRUE   0
60   TRUE   0
61   TRUE   0
62   TRUE   0
63   TRUE   0
64   TRUE   0
65   TRUE   0
66   TRUE   0
67   TRUE   0
68   TRUE   0
69   TRUE   0
70   TRUE   0
71   TRUE   0
72   TRUE   0
73   TRUE   0
74   TRUE   0
75   TRUE   0
76   TRUE   0
77   TRUE   0
78   TRUE   0
79   TRUE   0
80   TRUE   0
81   TRUE   0
82   TRUE   0
83   TRUE   0
84   TRUE   0
85   TRUE   0
86   TRUE   0
87   TRUE   0
88   TRUE   0
89   TRUE   0
90   TRUE   0
91   TRUE   0
92   TRUE   0
93   TRUE   0
94   TRUE   0
95   TRUE   0
96   TRUE   0
97   TRUE   0
98   TRUE   0
99   TRUE   0
100  TRUE   0
101  TRUE   0
102  TRUE   0
103  TRUE   0
104  TRUE   0
############################
############################
Epi_M15 
############################
############################
lavaan 0.6-7 ended normally after 43 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                         27
                                                      
                                                  Used       Total
  Number of observations                            80          99
                                                                  
Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  Epi ~                                               
    Matsmk     (a)   -0.055    0.046   -1.192    0.233
    Matagg     (b)    0.074    0.071    1.046    0.296
    FamScore   (c)    0.113    0.066    1.706    0.088
    EduPar     (d)    0.229    0.085    2.683    0.007
    n_trauma   (e)   -0.062    0.092   -0.680    0.497
    Age              -0.088    0.090   -0.973    0.331
    int_dis          -0.065    0.049   -1.325    0.185
    medication       -0.024    0.053   -0.456    0.649
    contrcptvs        0.032    0.048    0.660    0.509
    cigday_1         -0.052    0.094   -0.552    0.581
    V8                0.007    0.273    0.026    0.979
  group ~                                             
    Matsmk     (f)   -0.055    0.058   -0.943    0.346
    Matagg     (g)    0.326    0.088    3.695    0.000
    FamScore   (h)    0.137    0.083    1.644    0.100
    EduPar     (i)   -0.083    0.111   -0.747    0.455
    n_trauma   (j)    0.108    0.114    0.953    0.341
    Age              -0.391    0.113   -3.464    0.001
    int_dis           0.145    0.061    2.353    0.019
    medication        0.284    0.066    4.337    0.000
    contrcptvs        0.043    0.060    0.722    0.470
    cigday_1          0.693    0.117    5.945    0.000
    V8                0.419    0.338    1.241    0.215
    Epi        (z)   -1.538    0.139  -11.093    0.000

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.597    0.165    3.619    0.000
   .group             1.236    0.220    5.606    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.025    0.004    6.325    0.000
   .group             0.039    0.006    6.325    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    directMatsmk     -0.055    0.058   -0.943    0.346
    directMatagg      0.326    0.088    3.695    0.000
    directFamScore    0.137    0.083    1.644    0.100
    directEduPar     -0.083    0.111   -0.747    0.455
    directn_trauma    0.108    0.114    0.953    0.341
    EpiMatsmk         0.085    0.072    1.185    0.236
    EpiMatagg        -0.114    0.109   -1.041    0.298
    EpiFamScore      -0.173    0.103   -1.686    0.092
    EpiEduPar        -0.352    0.135   -2.608    0.009
    Epin_trauma       0.096    0.141    0.678    0.498
    total            -0.025    0.318   -0.077    0.938

               npar                fmin               chisq                  df 
             27.000               0.000               0.000               0.000 
             pvalue      baseline.chisq         baseline.df     baseline.pvalue 
                 NA             161.655              23.000               0.000 
                cfi                 tli                nnfi                 rfi 
              1.000               1.000               1.000               1.000 
                nfi                pnfi                 ifi                 rni 
              1.000               0.000               1.000               1.000 
               logl   unrestricted.logl                 aic                 bic 
             50.121              50.121             -46.242              18.073 
             ntotal                bic2               rmsea      rmsea.ci.lower 
             80.000             -67.068               0.000               0.000 
     rmsea.ci.upper        rmsea.pvalue                 rmr          rmr_nomean 
              0.000                  NA               0.000               0.000 
               srmr        srmr_bentler srmr_bentler_nomean                crmr 
              0.000               0.000               0.000               0.000 
        crmr_nomean          srmr_mplus   srmr_mplus_nomean               cn_05 
              0.000               0.000               0.000               1.000 
              cn_01                 gfi                agfi                pgfi 
              1.000               1.000               1.000               0.000 
                mfi                ecvi 
              1.000               0.675 

               lhs op                                     rhs          label
1              Epi ~1                                                       
2              Epi  ~                                  Matsmk              a
3              Epi  ~                                  Matagg              b
4              Epi  ~                                FamScore              c
5              Epi  ~                                  EduPar              d
6              Epi  ~                                n_trauma              e
7              Epi  ~                                     Age               
8              Epi  ~                                 int_dis               
9              Epi  ~                              medication               
10             Epi  ~                          contraceptives               
11             Epi  ~                                cigday_1               
12             Epi  ~                                      V8               
13           group ~1                                                       
14           group  ~                                  Matsmk              f
15           group  ~                                  Matagg              g
16           group  ~                                FamScore              h
17           group  ~                                  EduPar              i
18           group  ~                                n_trauma              j
19           group  ~                                     Age               
20           group  ~                                 int_dis               
21           group  ~                              medication               
22           group  ~                          contraceptives               
23           group  ~                                cigday_1               
24           group  ~                                      V8               
25           group  ~                                     Epi              z
26             Epi ~~                                     Epi               
27           group ~~                                   group               
28          Matsmk ~~                                  Matsmk               
29          Matsmk ~~                                  Matagg               
30          Matsmk ~~                                FamScore               
31          Matsmk ~~                                  EduPar               
32          Matsmk ~~                                n_trauma               
33          Matsmk ~~                                     Age               
34          Matsmk ~~                                 int_dis               
35          Matsmk ~~                              medication               
36          Matsmk ~~                          contraceptives               
37          Matsmk ~~                                cigday_1               
38          Matsmk ~~                                      V8               
39          Matagg ~~                                  Matagg               
40          Matagg ~~                                FamScore               
41          Matagg ~~                                  EduPar               
42          Matagg ~~                                n_trauma               
43          Matagg ~~                                     Age               
44          Matagg ~~                                 int_dis               
45          Matagg ~~                              medication               
46          Matagg ~~                          contraceptives               
47          Matagg ~~                                cigday_1               
48          Matagg ~~                                      V8               
49        FamScore ~~                                FamScore               
50        FamScore ~~                                  EduPar               
51        FamScore ~~                                n_trauma               
52        FamScore ~~                                     Age               
53        FamScore ~~                                 int_dis               
54        FamScore ~~                              medication               
55        FamScore ~~                          contraceptives               
56        FamScore ~~                                cigday_1               
57        FamScore ~~                                      V8               
58          EduPar ~~                                  EduPar               
59          EduPar ~~                                n_trauma               
60          EduPar ~~                                     Age               
61          EduPar ~~                                 int_dis               
62          EduPar ~~                              medication               
63          EduPar ~~                          contraceptives               
64          EduPar ~~                                cigday_1               
65          EduPar ~~                                      V8               
66        n_trauma ~~                                n_trauma               
67        n_trauma ~~                                     Age               
68        n_trauma ~~                                 int_dis               
69        n_trauma ~~                              medication               
70        n_trauma ~~                          contraceptives               
71        n_trauma ~~                                cigday_1               
72        n_trauma ~~                                      V8               
73             Age ~~                                     Age               
74             Age ~~                                 int_dis               
75             Age ~~                              medication               
76             Age ~~                          contraceptives               
77             Age ~~                                cigday_1               
78             Age ~~                                      V8               
79         int_dis ~~                                 int_dis               
80         int_dis ~~                              medication               
81         int_dis ~~                          contraceptives               
82         int_dis ~~                                cigday_1               
83         int_dis ~~                                      V8               
84      medication ~~                              medication               
85      medication ~~                          contraceptives               
86      medication ~~                                cigday_1               
87      medication ~~                                      V8               
88  contraceptives ~~                          contraceptives               
89  contraceptives ~~                                cigday_1               
90  contraceptives ~~                                      V8               
91        cigday_1 ~~                                cigday_1               
92        cigday_1 ~~                                      V8               
93              V8 ~~                                      V8               
94          Matsmk ~1                                                       
95          Matagg ~1                                                       
96        FamScore ~1                                                       
97          EduPar ~1                                                       
98        n_trauma ~1                                                       
99             Age ~1                                                       
100        int_dis ~1                                                       
101     medication ~1                                                       
102 contraceptives ~1                                                       
103       cigday_1 ~1                                                       
104             V8 ~1                                                       
105   directMatsmk :=                                       f   directMatsmk
106   directMatagg :=                                       g   directMatagg
107 directFamScore :=                                       h directFamScore
108   directEduPar :=                                       i   directEduPar
109 directn_trauma :=                                       j directn_trauma
110      EpiMatsmk :=                                     a*z      EpiMatsmk
111      EpiMatagg :=                                     b*z      EpiMatagg
112    EpiFamScore :=                                     c*z    EpiFamScore
113      EpiEduPar :=                                     d*z      EpiEduPar
114    Epin_trauma :=                                     e*z    Epin_trauma
115          total := f+g+h+i+j+(a*z)+(b*z)+(c*z)+(d*z)+(e*z)          total
       est    se       z pvalue ci.lower ci.upper
1    0.597 0.165   3.619  0.000    0.273    0.920
2   -0.055 0.046  -1.192  0.233   -0.146    0.036
3    0.074 0.071   1.046  0.296   -0.065    0.212
4    0.113 0.066   1.706  0.088   -0.017    0.242
5    0.229 0.085   2.683  0.007    0.062    0.396
6   -0.062 0.092  -0.680  0.497   -0.242    0.117
7   -0.088 0.090  -0.973  0.331   -0.265    0.089
8   -0.065 0.049  -1.325  0.185   -0.161    0.031
9   -0.024 0.053  -0.456  0.649   -0.127    0.079
10   0.032 0.048   0.660  0.509   -0.063    0.127
11  -0.052 0.094  -0.552  0.581   -0.236    0.132
12   0.007 0.273   0.026  0.979   -0.527    0.541
13   1.236 0.220   5.606  0.000    0.804    1.668
14  -0.055 0.058  -0.943  0.346   -0.168    0.059
15   0.326 0.088   3.695  0.000    0.153    0.498
16   0.137 0.083   1.644  0.100   -0.026    0.301
17  -0.083 0.111  -0.747  0.455   -0.299    0.134
18   0.108 0.114   0.953  0.341   -0.115    0.331
19  -0.391 0.113  -3.464  0.001   -0.612   -0.170
20   0.145 0.061   2.353  0.019    0.024    0.265
21   0.284 0.066   4.337  0.000    0.156    0.412
22   0.043 0.060   0.722  0.470   -0.074    0.161
23   0.693 0.117   5.945  0.000    0.465    0.922
24   0.419 0.338   1.241  0.215   -0.243    1.082
25  -1.538 0.139 -11.093  0.000   -1.809   -1.266
26   0.025 0.004   6.325  0.000    0.017    0.033
27   0.039 0.006   6.325  0.000    0.027    0.051
28   0.194 0.000      NA     NA    0.194    0.194
29   0.049 0.000      NA     NA    0.049    0.049
30  -0.009 0.000      NA     NA   -0.009   -0.009
31  -0.005 0.000      NA     NA   -0.005   -0.005
32   0.007 0.000      NA     NA    0.007    0.007
33  -0.003 0.000      NA     NA   -0.003   -0.003
34   0.021 0.000      NA     NA    0.021    0.021
35   0.004 0.000      NA     NA    0.004    0.004
36   0.021 0.000      NA     NA    0.021    0.021
37   0.017 0.000      NA     NA    0.017    0.017
38   0.003 0.000      NA     NA    0.003    0.003
39   0.090 0.000      NA     NA    0.090    0.090
40   0.034 0.000      NA     NA    0.034    0.034
41  -0.016 0.000      NA     NA   -0.016   -0.016
42   0.007 0.000      NA     NA    0.007    0.007
43   0.000 0.000      NA     NA    0.000    0.000
44   0.032 0.000      NA     NA    0.032    0.032
45   0.007 0.000      NA     NA    0.007    0.007
46   0.007 0.000      NA     NA    0.007    0.007
47   0.010 0.000      NA     NA    0.010    0.010
48   0.001 0.000      NA     NA    0.001    0.001
49   0.131 0.000      NA     NA    0.131    0.131
50  -0.029 0.000      NA     NA   -0.029   -0.029
51   0.026 0.000      NA     NA    0.026    0.026
52   0.004 0.000      NA     NA    0.004    0.004
53   0.064 0.000      NA     NA    0.064    0.064
54   0.004 0.000      NA     NA    0.004    0.004
55   0.058 0.000      NA     NA    0.058    0.058
56   0.043 0.000      NA     NA    0.043    0.043
57   0.001 0.000      NA     NA    0.001    0.001
58   0.053 0.000      NA     NA    0.053    0.053
59  -0.008 0.000      NA     NA   -0.008   -0.008
60   0.003 0.000      NA     NA    0.003    0.003
61  -0.019 0.000      NA     NA   -0.019   -0.019
62   0.010 0.000      NA     NA    0.010    0.010
63  -0.013 0.000      NA     NA   -0.013   -0.013
64  -0.015 0.000      NA     NA   -0.015   -0.015
65   0.000 0.000      NA     NA    0.000    0.000
66   0.051 0.000      NA     NA    0.051    0.051
67   0.002 0.000      NA     NA    0.002    0.002
68   0.041 0.000      NA     NA    0.041    0.041
69   0.017 0.000      NA     NA    0.017    0.017
70   0.018 0.000      NA     NA    0.018    0.018
71   0.021 0.000      NA     NA    0.021    0.021
72   0.000 0.000      NA     NA    0.000    0.000
73   0.047 0.000      NA     NA    0.047    0.047
74   0.008 0.000      NA     NA    0.008    0.008
75  -0.002 0.000      NA     NA   -0.002   -0.002
76   0.035 0.000      NA     NA    0.035    0.035
77   0.008 0.000      NA     NA    0.008    0.008
78  -0.001 0.000      NA     NA   -0.001   -0.001
79   0.210 0.000      NA     NA    0.210    0.210
80   0.060 0.000      NA     NA    0.060    0.060
81   0.060 0.000      NA     NA    0.060    0.060
82   0.044 0.000      NA     NA    0.044    0.044
83   0.006 0.000      NA     NA    0.006    0.006
84   0.144 0.000      NA     NA    0.144    0.144
85   0.035 0.000      NA     NA    0.035    0.035
86   0.003 0.000      NA     NA    0.003    0.003
87   0.002 0.000      NA     NA    0.002    0.002
88   0.210 0.000      NA     NA    0.210    0.210
89   0.048 0.000      NA     NA    0.048    0.048
90   0.003 0.000      NA     NA    0.003    0.003
91   0.061 0.000      NA     NA    0.061    0.061
92   0.001 0.000      NA     NA    0.001    0.001
93   0.005 0.000      NA     NA    0.005    0.005
94   0.262 0.000      NA     NA    0.262    0.262
95   0.100 0.000      NA     NA    0.100    0.100
96   0.225 0.000      NA     NA    0.225    0.225
97   0.606 0.000      NA     NA    0.606    0.606
98   0.196 0.000      NA     NA    0.196    0.196
99   0.562 0.000      NA     NA    0.562    0.562
100  0.300 0.000      NA     NA    0.300    0.300
101  0.175 0.000      NA     NA    0.175    0.175
102  0.300 0.000      NA     NA    0.300    0.300
103  0.124 0.000      NA     NA    0.124    0.124
104  0.529 0.000      NA     NA    0.529    0.529
105 -0.055 0.058  -0.943  0.346   -0.168    0.059
106  0.326 0.088   3.695  0.000    0.153    0.498
107  0.137 0.083   1.644  0.100   -0.026    0.301
108 -0.083 0.111  -0.747  0.455   -0.299    0.134
109  0.108 0.114   0.953  0.341   -0.115    0.331
110  0.085 0.072   1.185  0.236   -0.056    0.225
111 -0.114 0.109  -1.041  0.298   -0.327    0.100
112 -0.173 0.103  -1.686  0.092   -0.375    0.028
113 -0.352 0.135  -2.608  0.009   -0.617   -0.088
114  0.096 0.141   0.678  0.498   -0.181    0.372
115 -0.025 0.318  -0.077  0.938   -0.648    0.599

    label            lhs edge            rhs           est           std group
1                         int            Epi  5.966198e-01  3.4173727851      
2       a         Matsmk   ~>            Epi -5.522110e-02 -0.1391699349      
3       b         Matagg   ~>            Epi  7.387037e-02  0.1269364033      
4       c       FamScore   ~>            Epi  1.127425e-01  0.2333970612      
5       d         EduPar   ~>            Epi  2.291129e-01  0.3024655748      
6       e       n_trauma   ~>            Epi -6.219034e-02 -0.0802099333      
7                    Age   ~>            Epi -8.796429e-02 -0.1091100155      
8                int_dis   ~>            Epi -6.492649e-02 -0.1704222449      
9             medication   ~>            Epi -2.404003e-02 -0.0523209674      
10        contraceptives   ~>            Epi  3.188491e-02  0.0836930683      
11              cigday_1   ~>            Epi -5.184014e-02 -0.0731867724      
12                    V8   ~>            Epi  7.148704e-03  0.0027707748      
13                        int          group  1.236069e+00  2.5108855961      
14      f         Matsmk   ~>          group -5.464102e-02 -0.0488369513      
15      g         Matagg   ~>          group  3.256616e-01  0.1984595240      
16      h       FamScore   ~>          group  1.371198e-01  0.1006693511      
17      i         EduPar   ~>          group -8.251117e-02 -0.0386303410      
18      j       n_trauma   ~>          group  1.084387e-01  0.0495996737      
19                   Age   ~>          group -3.907101e-01 -0.1718708659      
20               int_dis   ~>          group  1.445479e-01  0.1345567692      
21            medication   ~>          group  2.840974e-01  0.2192791493      
22        contraceptives   ~>          group  4.333056e-02  0.0403355552      
23              cigday_1   ~>          group  6.934013e-01  0.3471686550      
24                    V8   ~>          group  4.194075e-01  0.0576500219      
25      z            Epi   ~>          group -1.537551e+00 -0.5452790982      
26                   Epi  <->            Epi  2.524032e-02  0.8281026557      
27                 group  <->          group  3.879487e-02  0.1600819921      
28                Matsmk  <->         Matsmk  1.935938e-01  1.0000000000      
29                Matsmk  <->         Matagg  4.875000e-02  0.3693241433      
30                Matsmk  <->       FamScore -9.062500e-03 -0.0569887592      
31                Matsmk  <->         EduPar -5.494792e-03 -0.0541843459      
32                Matsmk  <->       n_trauma  7.366071e-03  0.0743497863      
33                Matsmk  <->            Age -3.177083e-03 -0.0333441329      
34                Matsmk  <->        int_dis  2.125000e-02  0.1053910232      
35                Matsmk  <->     medication  4.062500e-03  0.0242997446      
36                Matsmk  <-> contraceptives  2.125000e-02  0.1053910232      
37                Matsmk  <->       cigday_1  1.672656e-02  0.1542372547      
38                Matsmk  <->             V8  2.891537e-03  0.0971189320      
39                Matagg  <->         Matagg  9.000000e-02  1.0000000000      
40                Matagg  <->       FamScore  3.375000e-02  0.3112715087      
41                Matagg  <->         EduPar -1.635417e-02 -0.2365241196      
42                Matagg  <->       n_trauma  7.142857e-03  0.1057402114      
43                Matagg  <->            Age  3.079710e-04  0.0047405101      
44                Matagg  <->        int_dis  3.250000e-02  0.2364027144      
45                Matagg  <->     medication  7.500000e-03  0.0657951695      
46                Matagg  <-> contraceptives  7.500000e-03  0.0545544726      
47                Matagg  <->       cigday_1  1.006250e-02  0.1360858260      
48                Matagg  <->             V8  8.168666e-04  0.0402393217      
49              FamScore  <->       FamScore  1.306250e-01  1.0000000000      
50              FamScore  <->         EduPar -2.911458e-02 -0.3495149022      
51              FamScore  <->       n_trauma  2.633929e-02  0.3236534989      
52              FamScore  <->            Age  3.591486e-03  0.0458878230      
53              FamScore  <->        int_dis  6.375000e-02  0.3849084009      
54              FamScore  <->     medication  4.375000e-03  0.0318580293      
55              FamScore  <-> contraceptives  5.750000e-02  0.3471722832      
56              FamScore  <->       cigday_1  4.326563e-02  0.4856887960      
57              FamScore  <->             V8  7.717159e-04  0.0315547719      
58                EduPar  <->         EduPar  5.312066e-02  1.0000000000      
59                EduPar  <->       n_trauma -7.924107e-03 -0.1526891136      
60                EduPar  <->            Age  2.727582e-03  0.0546490350      
61                EduPar  <->        int_dis -1.885417e-02 -0.1785114035      
62                EduPar  <->     medication  1.005208e-02  0.1147832062      
63                EduPar  <-> contraceptives -1.312500e-02 -0.1242676068      
64                EduPar  <->       cigday_1 -1.475130e-02 -0.2596730517      
65                EduPar  <->             V8 -8.750126e-06 -0.0005610523      
66              n_trauma  <->       n_trauma  5.070153e-02  1.0000000000      
67              n_trauma  <->            Age  1.562500e-03  0.0320439451      
68              n_trauma  <->        int_dis  4.107143e-02  0.3980335009      
69              n_trauma  <->     medication  1.741071e-02  0.2034979577      
70              n_trauma  <-> contraceptives  1.785714e-02  0.1730580439      
71              n_trauma  <->       cigday_1  2.101562e-02  0.3786692420      
72              n_trauma  <->             V8 -4.635661e-04 -0.0304243917      
73                   Age  <->            Age  4.689505e-02  1.0000000000      
74                   Age  <->        int_dis  7.989130e-03  0.0805056484      
75                   Age  <->     medication -1.634964e-03 -0.0198700345      
76                   Age  <-> contraceptives  3.480072e-02  0.3506833348      
77                   Age  <->       cigday_1  8.435575e-03  0.1580445206      
78                   Age  <->             V8 -1.316962e-03 -0.0898732659      
79               int_dis  <->        int_dis  2.100000e-01  1.0000000000      
80               int_dis  <->     medication  6.000000e-02  0.3445843938      
81               int_dis  <-> contraceptives  6.000000e-02  0.2857142857      
82               int_dis  <->       cigday_1  4.393750e-02  0.3890038953      
83               int_dis  <->             V8  5.574778e-03  0.1797788722      
84            medication  <->     medication  1.443750e-01  1.0000000000      
85            medication  <-> contraceptives  3.500000e-02  0.2010075631      
86            medication  <->       cigday_1  3.234375e-03  0.0345360471      
87            medication  <->             V8  2.058179e-03  0.0800493604      
88        contraceptives  <-> contraceptives  2.100000e-01  1.0000000000      
89        contraceptives  <->       cigday_1  4.831250e-02  0.4277382803      
90        contraceptives  <->             V8  2.655222e-03  0.0856272484      
91              cigday_1  <->       cigday_1  6.074961e-02  1.0000000000      
92              cigday_1  <->             V8  1.490410e-03  0.0893623867      
93                    V8  <->             V8  4.578872e-03  1.0000000000      
94                        int         Matsmk  2.625000e-01  0.5966005392      
95                        int         Matagg  1.000000e-01  0.3333333333      
96                        int       FamScore  2.250000e-01  0.6225430175      
97                        int         EduPar  6.062500e-01  2.6303892538      
98                        int       n_trauma  1.964286e-01  0.8723567443      
99                        int            Age  5.621377e-01  2.5958475642      
100                       int        int_dis  3.000000e-01  0.6546536707      
101                       int     medication  1.750000e-01  0.4605661865      
102                       int contraceptives  3.000000e-01  0.6546536707      
103                       int       cigday_1  1.243750e-01  0.5046163860      
104                       int             V8  5.286908e-01  7.8130836675      
    fixed par
1   FALSE   1
2   FALSE   2
3   FALSE   3
4   FALSE   4
5   FALSE   5
6   FALSE   6
7   FALSE   7
8   FALSE   8
9   FALSE   9
10  FALSE  10
11  FALSE  11
12  FALSE  12
13  FALSE  13
14  FALSE  14
15  FALSE  15
16  FALSE  16
17  FALSE  17
18  FALSE  18
19  FALSE  19
20  FALSE  20
21  FALSE  21
22  FALSE  22
23  FALSE  23
24  FALSE  24
25  FALSE  25
26  FALSE  26
27  FALSE  27
28   TRUE   0
29   TRUE   0
30   TRUE   0
31   TRUE   0
32   TRUE   0
33   TRUE   0
34   TRUE   0
35   TRUE   0
36   TRUE   0
37   TRUE   0
38   TRUE   0
39   TRUE   0
40   TRUE   0
41   TRUE   0
42   TRUE   0
43   TRUE   0
44   TRUE   0
45   TRUE   0
46   TRUE   0
47   TRUE   0
48   TRUE   0
49   TRUE   0
50   TRUE   0
51   TRUE   0
52   TRUE   0
53   TRUE   0
54   TRUE   0
55   TRUE   0
56   TRUE   0
57   TRUE   0
58   TRUE   0
59   TRUE   0
60   TRUE   0
61   TRUE   0
62   TRUE   0
63   TRUE   0
64   TRUE   0
65   TRUE   0
66   TRUE   0
67   TRUE   0
68   TRUE   0
69   TRUE   0
70   TRUE   0
71   TRUE   0
72   TRUE   0
73   TRUE   0
74   TRUE   0
75   TRUE   0
76   TRUE   0
77   TRUE   0
78   TRUE   0
79   TRUE   0
80   TRUE   0
81   TRUE   0
82   TRUE   0
83   TRUE   0
84   TRUE   0
85   TRUE   0
86   TRUE   0
87   TRUE   0
88   TRUE   0
89   TRUE   0
90   TRUE   0
91   TRUE   0
92   TRUE   0
93   TRUE   0
94   TRUE   0
95   TRUE   0
96   TRUE   0
97   TRUE   0
98   TRUE   0
99   TRUE   0
100  TRUE   0
101  TRUE   0
102  TRUE   0
103  TRUE   0
104  TRUE   0
############################
############################
Epi_M_all 
############################
############################
lavaan 0.6-7 ended normally after 57 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                         27
                                                      
                                                  Used       Total
  Number of observations                            80          99
                                                                  
Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  Epi ~                                               
    Matsmk     (a)    0.025    0.075    0.330    0.742
    Matagg     (b)    0.132    0.114    1.162    0.245
    FamScore   (c)   -0.102    0.106   -0.956    0.339
    EduPar     (d)   -0.281    0.137   -2.043    0.041
    n_trauma   (e)    0.074    0.147    0.506    0.613
    Age               0.122    0.146    0.836    0.403
    int_dis           0.085    0.079    1.082    0.279
    medication        0.050    0.085    0.589    0.556
    contrcptvs       -0.074    0.078   -0.948    0.343
    cigday_1          0.168    0.151    1.114    0.265
    V8                0.285    0.439    0.649    0.516
  group ~                                             
    Matsmk     (f)    0.002    0.031    0.060    0.952
    Matagg     (g)    0.059    0.047    1.256    0.209
    FamScore   (h)    0.081    0.044    1.838    0.066
    EduPar     (i)   -0.110    0.058   -1.893    0.058
    n_trauma   (j)    0.118    0.061    1.936    0.053
    Age              -0.396    0.060   -6.555    0.000
    int_dis           0.146    0.033    4.440    0.000
    medication        0.263    0.035    7.484    0.000
    contrcptvs        0.079    0.032    2.459    0.014
    cigday_1          0.578    0.063    9.193    0.000
    V8                0.079    0.182    0.437    0.662
    Epi        (z)    1.156    0.046   25.015    0.000

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.288    0.265    1.085    0.278
   .group            -0.014    0.110   -0.127    0.899

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .Epi               0.065    0.010    6.325    0.000
   .group             0.011    0.002    6.325    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    directMatsmk      0.002    0.031    0.060    0.952
    directMatagg      0.059    0.047    1.256    0.209
    directFamScore    0.081    0.044    1.838    0.066
    directEduPar     -0.110    0.058   -1.893    0.058
    directn_trauma    0.118    0.061    1.936    0.053
    EpiMatsmk         0.028    0.086    0.330    0.742
    EpiMatagg         0.153    0.131    1.161    0.246
    EpiFamScore      -0.117    0.123   -0.955    0.340
    EpiEduPar        -0.325    0.159   -2.037    0.042
    Epin_trauma       0.086    0.170    0.506    0.613
    total            -0.025    0.318   -0.077    0.938

               npar                fmin               chisq                  df 
             27.000               0.000               0.000               0.000 
             pvalue      baseline.chisq         baseline.df     baseline.pvalue 
                 NA             261.781              23.000               0.000 
                cfi                 tli                nnfi                 rfi 
              1.000               1.000               1.000               1.000 
                nfi                pnfi                 ifi                 rni 
              1.000               0.000               1.000               1.000 
               logl   unrestricted.logl                 aic                 bic 
             61.906              61.906             -69.811              -5.496 
             ntotal                bic2               rmsea      rmsea.ci.lower 
             80.000             -90.637               0.000               0.000 
     rmsea.ci.upper        rmsea.pvalue                 rmr          rmr_nomean 
              0.000                  NA               0.000               0.000 
               srmr        srmr_bentler srmr_bentler_nomean                crmr 
              0.000               0.000               0.000               0.000 
        crmr_nomean          srmr_mplus   srmr_mplus_nomean               cn_05 
              0.000               0.000               0.000                  NA 
              cn_01                 gfi                agfi                pgfi 
                 NA               1.000               1.000               0.000 
                mfi                ecvi 
              1.000               0.675 

               lhs op                                     rhs          label
1              Epi ~1                                                       
2              Epi  ~                                  Matsmk              a
3              Epi  ~                                  Matagg              b
4              Epi  ~                                FamScore              c
5              Epi  ~                                  EduPar              d
6              Epi  ~                                n_trauma              e
7              Epi  ~                                     Age               
8              Epi  ~                                 int_dis               
9              Epi  ~                              medication               
10             Epi  ~                          contraceptives               
11             Epi  ~                                cigday_1               
12             Epi  ~                                      V8               
13           group ~1                                                       
14           group  ~                                  Matsmk              f
15           group  ~                                  Matagg              g
16           group  ~                                FamScore              h
17           group  ~                                  EduPar              i
18           group  ~                                n_trauma              j
19           group  ~                                     Age               
20           group  ~                                 int_dis               
21           group  ~                              medication               
22           group  ~                          contraceptives               
23           group  ~                                cigday_1               
24           group  ~                                      V8               
25           group  ~                                     Epi              z
26             Epi ~~                                     Epi               
27           group ~~                                   group               
28          Matsmk ~~                                  Matsmk               
29          Matsmk ~~                                  Matagg               
30          Matsmk ~~                                FamScore               
31          Matsmk ~~                                  EduPar               
32          Matsmk ~~                                n_trauma               
33          Matsmk ~~                                     Age               
34          Matsmk ~~                                 int_dis               
35          Matsmk ~~                              medication               
36          Matsmk ~~                          contraceptives               
37          Matsmk ~~                                cigday_1               
38          Matsmk ~~                                      V8               
39          Matagg ~~                                  Matagg               
40          Matagg ~~                                FamScore               
41          Matagg ~~                                  EduPar               
42          Matagg ~~                                n_trauma               
43          Matagg ~~                                     Age               
44          Matagg ~~                                 int_dis               
45          Matagg ~~                              medication               
46          Matagg ~~                          contraceptives               
47          Matagg ~~                                cigday_1               
48          Matagg ~~                                      V8               
49        FamScore ~~                                FamScore               
50        FamScore ~~                                  EduPar               
51        FamScore ~~                                n_trauma               
52        FamScore ~~                                     Age               
53        FamScore ~~                                 int_dis               
54        FamScore ~~                              medication               
55        FamScore ~~                          contraceptives               
56        FamScore ~~                                cigday_1               
57        FamScore ~~                                      V8               
58          EduPar ~~                                  EduPar               
59          EduPar ~~                                n_trauma               
60          EduPar ~~                                     Age               
61          EduPar ~~                                 int_dis               
62          EduPar ~~                              medication               
63          EduPar ~~                          contraceptives               
64          EduPar ~~                                cigday_1               
65          EduPar ~~                                      V8               
66        n_trauma ~~                                n_trauma               
67        n_trauma ~~                                     Age               
68        n_trauma ~~                                 int_dis               
69        n_trauma ~~                              medication               
70        n_trauma ~~                          contraceptives               
71        n_trauma ~~                                cigday_1               
72        n_trauma ~~                                      V8               
73             Age ~~                                     Age               
74             Age ~~                                 int_dis               
75             Age ~~                              medication               
76             Age ~~                          contraceptives               
77             Age ~~                                cigday_1               
78             Age ~~                                      V8               
79         int_dis ~~                                 int_dis               
80         int_dis ~~                              medication               
81         int_dis ~~                          contraceptives               
82         int_dis ~~                                cigday_1               
83         int_dis ~~                                      V8               
84      medication ~~                              medication               
85      medication ~~                          contraceptives               
86      medication ~~                                cigday_1               
87      medication ~~                                      V8               
88  contraceptives ~~                          contraceptives               
89  contraceptives ~~                                cigday_1               
90  contraceptives ~~                                      V8               
91        cigday_1 ~~                                cigday_1               
92        cigday_1 ~~                                      V8               
93              V8 ~~                                      V8               
94          Matsmk ~1                                                       
95          Matagg ~1                                                       
96        FamScore ~1                                                       
97          EduPar ~1                                                       
98        n_trauma ~1                                                       
99             Age ~1                                                       
100        int_dis ~1                                                       
101     medication ~1                                                       
102 contraceptives ~1                                                       
103       cigday_1 ~1                                                       
104             V8 ~1                                                       
105   directMatsmk :=                                       f   directMatsmk
106   directMatagg :=                                       g   directMatagg
107 directFamScore :=                                       h directFamScore
108   directEduPar :=                                       i   directEduPar
109 directn_trauma :=                                       j directn_trauma
110      EpiMatsmk :=                                     a*z      EpiMatsmk
111      EpiMatagg :=                                     b*z      EpiMatagg
112    EpiFamScore :=                                     c*z    EpiFamScore
113      EpiEduPar :=                                     d*z      EpiEduPar
114    Epin_trauma :=                                     e*z    Epin_trauma
115          total := f+g+h+i+j+(a*z)+(b*z)+(c*z)+(d*z)+(e*z)          total
       est    se      z pvalue ci.lower ci.upper
1    0.288 0.265  1.085  0.278   -0.232    0.808
2    0.025 0.075  0.330  0.742   -0.122    0.171
3    0.132 0.114  1.162  0.245   -0.091    0.355
4   -0.102 0.106 -0.956  0.339   -0.310    0.107
5   -0.281 0.137 -2.043  0.041   -0.550   -0.011
6    0.074 0.147  0.506  0.613   -0.214    0.363
7    0.122 0.146  0.836  0.403   -0.164    0.407
8    0.085 0.079  1.082  0.279   -0.069    0.240
9    0.050 0.085  0.589  0.556   -0.116    0.216
10  -0.074 0.078 -0.948  0.343   -0.226    0.079
11   0.168 0.151  1.114  0.265   -0.128    0.464
12   0.285 0.439  0.649  0.516   -0.575    1.144
13  -0.014 0.110 -0.127  0.899   -0.230    0.202
14   0.002 0.031  0.060  0.952   -0.059    0.062
15   0.059 0.047  1.256  0.209   -0.033    0.152
16   0.081 0.044  1.838  0.066   -0.005    0.168
17  -0.110 0.058 -1.893  0.058   -0.224    0.004
18   0.118 0.061  1.936  0.053   -0.001    0.237
19  -0.396 0.060 -6.555  0.000   -0.514   -0.278
20   0.146 0.033  4.440  0.000    0.081    0.210
21   0.263 0.035  7.484  0.000    0.194    0.332
22   0.079 0.032  2.459  0.014    0.016    0.143
23   0.578 0.063  9.193  0.000    0.455    0.702
24   0.079 0.182  0.437  0.662   -0.277    0.436
25   1.156 0.046 25.015  0.000    1.065    1.246
26   0.065 0.010  6.325  0.000    0.045    0.086
27   0.011 0.002  6.325  0.000    0.008    0.015
28   0.194 0.000     NA     NA    0.194    0.194
29   0.049 0.000     NA     NA    0.049    0.049
30  -0.009 0.000     NA     NA   -0.009   -0.009
31  -0.005 0.000     NA     NA   -0.005   -0.005
32   0.007 0.000     NA     NA    0.007    0.007
33  -0.003 0.000     NA     NA   -0.003   -0.003
34   0.021 0.000     NA     NA    0.021    0.021
35   0.004 0.000     NA     NA    0.004    0.004
36   0.021 0.000     NA     NA    0.021    0.021
37   0.017 0.000     NA     NA    0.017    0.017
38   0.003 0.000     NA     NA    0.003    0.003
39   0.090 0.000     NA     NA    0.090    0.090
40   0.034 0.000     NA     NA    0.034    0.034
41  -0.016 0.000     NA     NA   -0.016   -0.016
42   0.007 0.000     NA     NA    0.007    0.007
43   0.000 0.000     NA     NA    0.000    0.000
44   0.032 0.000     NA     NA    0.032    0.032
45   0.007 0.000     NA     NA    0.007    0.007
46   0.007 0.000     NA     NA    0.007    0.007
47   0.010 0.000     NA     NA    0.010    0.010
48   0.001 0.000     NA     NA    0.001    0.001
49   0.131 0.000     NA     NA    0.131    0.131
50  -0.029 0.000     NA     NA   -0.029   -0.029
51   0.026 0.000     NA     NA    0.026    0.026
52   0.004 0.000     NA     NA    0.004    0.004
53   0.064 0.000     NA     NA    0.064    0.064
54   0.004 0.000     NA     NA    0.004    0.004
55   0.058 0.000     NA     NA    0.058    0.058
56   0.043 0.000     NA     NA    0.043    0.043
57   0.001 0.000     NA     NA    0.001    0.001
58   0.053 0.000     NA     NA    0.053    0.053
59  -0.008 0.000     NA     NA   -0.008   -0.008
60   0.003 0.000     NA     NA    0.003    0.003
61  -0.019 0.000     NA     NA   -0.019   -0.019
62   0.010 0.000     NA     NA    0.010    0.010
63  -0.013 0.000     NA     NA   -0.013   -0.013
64  -0.015 0.000     NA     NA   -0.015   -0.015
65   0.000 0.000     NA     NA    0.000    0.000
66   0.051 0.000     NA     NA    0.051    0.051
67   0.002 0.000     NA     NA    0.002    0.002
68   0.041 0.000     NA     NA    0.041    0.041
69   0.017 0.000     NA     NA    0.017    0.017
70   0.018 0.000     NA     NA    0.018    0.018
71   0.021 0.000     NA     NA    0.021    0.021
72   0.000 0.000     NA     NA    0.000    0.000
73   0.047 0.000     NA     NA    0.047    0.047
74   0.008 0.000     NA     NA    0.008    0.008
75  -0.002 0.000     NA     NA   -0.002   -0.002
76   0.035 0.000     NA     NA    0.035    0.035
77   0.008 0.000     NA     NA    0.008    0.008
78  -0.001 0.000     NA     NA   -0.001   -0.001
79   0.210 0.000     NA     NA    0.210    0.210
80   0.060 0.000     NA     NA    0.060    0.060
81   0.060 0.000     NA     NA    0.060    0.060
82   0.044 0.000     NA     NA    0.044    0.044
83   0.006 0.000     NA     NA    0.006    0.006
84   0.144 0.000     NA     NA    0.144    0.144
85   0.035 0.000     NA     NA    0.035    0.035
86   0.003 0.000     NA     NA    0.003    0.003
87   0.002 0.000     NA     NA    0.002    0.002
88   0.210 0.000     NA     NA    0.210    0.210
89   0.048 0.000     NA     NA    0.048    0.048
90   0.003 0.000     NA     NA    0.003    0.003
91   0.061 0.000     NA     NA    0.061    0.061
92   0.001 0.000     NA     NA    0.001    0.001
93   0.005 0.000     NA     NA    0.005    0.005
94   0.262 0.000     NA     NA    0.262    0.262
95   0.100 0.000     NA     NA    0.100    0.100
96   0.225 0.000     NA     NA    0.225    0.225
97   0.606 0.000     NA     NA    0.606    0.606
98   0.196 0.000     NA     NA    0.196    0.196
99   0.562 0.000     NA     NA    0.562    0.562
100  0.300 0.000     NA     NA    0.300    0.300
101  0.175 0.000     NA     NA    0.175    0.175
102  0.300 0.000     NA     NA    0.300    0.300
103  0.124 0.000     NA     NA    0.124    0.124
104  0.529 0.000     NA     NA    0.529    0.529
105  0.002 0.031  0.060  0.952   -0.059    0.062
106  0.059 0.047  1.256  0.209   -0.033    0.152
107  0.081 0.044  1.838  0.066   -0.005    0.168
108 -0.110 0.058 -1.893  0.058   -0.224    0.004
109  0.118 0.061  1.936  0.053   -0.001    0.237
110  0.028 0.086  0.330  0.742   -0.141    0.197
111  0.153 0.131  1.161  0.246   -0.105    0.410
112 -0.117 0.123 -0.955  0.340   -0.358    0.124
113 -0.325 0.159 -2.037  0.042   -0.637   -0.012
114  0.086 0.170  0.506  0.613   -0.248    0.420
115 -0.025 0.318 -0.077  0.938   -0.648    0.599

    label            lhs edge            rhs           est           std group
1                         int            Epi  2.878933e-01  1.0219392454      
2       a         Matsmk   ~>            Epi  2.458188e-02  0.0383932017      
3       b         Matagg   ~>            Epi  1.320287e-01  0.1405993150      
4       c       FamScore   ~>            Epi -1.016065e-01 -0.1303550846      
5       d         EduPar   ~>            Epi -2.807576e-01 -0.2296977532      
6       e       n_trauma   ~>            Epi  7.446002e-02  0.0595151017      
7                    Age   ~>            Epi  1.216014e-01  0.0934749974      
8                int_dis   ~>            Epi  8.529375e-02  0.1387459673      
9             medication   ~>            Epi  5.004597e-02  0.0675007535      
10        contraceptives   ~>            Epi -7.362480e-02 -0.1197642647      
11              cigday_1   ~>            Epi  1.683722e-01  0.1473111227      
12                    V8   ~>            Epi  2.846112e-01  0.0683635565      
13                        int          group -1.403759e-02 -0.0285152046      
14      f         Matsmk   ~>          group  1.850222e-03  0.0016536883      
15      g         Matagg   ~>          group  5.947115e-02  0.0362419628      
16      h       FamScore   ~>          group  8.121866e-02  0.0596283858      
17      i         EduPar   ~>          group -1.102583e-01 -0.0516210609      
18      j       n_trauma   ~>          group  1.179917e-01  0.0539692003      
19                   Age   ~>          group -3.960187e-01 -0.1742060611      
20               int_dis   ~>          group  1.457853e-01  0.1357085942      
21            medication   ~>          group  2.632124e-01  0.2031591838      
22        contraceptives   ~>          group  7.940824e-02  0.0739195455      
23              cigday_1   ~>          group  5.784880e-01  0.2896344441      
24                    V8   ~>          group  7.943604e-02  0.0109189505      
25      z            Epi   ~>          group  1.155893e+00  0.6614668267      
26                   Epi  <->            Epi  6.534223e-02  0.8233432531      
27                 group  <->          group  1.116161e-02  0.0460569256      
28                Matsmk  <->         Matsmk  1.935938e-01  1.0000000000      
29                Matsmk  <->         Matagg  4.875000e-02  0.3693241433      
30                Matsmk  <->       FamScore -9.062500e-03 -0.0569887592      
31                Matsmk  <->         EduPar -5.494792e-03 -0.0541843459      
32                Matsmk  <->       n_trauma  7.366071e-03  0.0743497863      
33                Matsmk  <->            Age -3.177083e-03 -0.0333441329      
34                Matsmk  <->        int_dis  2.125000e-02  0.1053910232      
35                Matsmk  <->     medication  4.062500e-03  0.0242997446      
36                Matsmk  <-> contraceptives  2.125000e-02  0.1053910232      
37                Matsmk  <->       cigday_1  1.672656e-02  0.1542372547      
38                Matsmk  <->             V8  2.891537e-03  0.0971189320      
39                Matagg  <->         Matagg  9.000000e-02  1.0000000000      
40                Matagg  <->       FamScore  3.375000e-02  0.3112715087      
41                Matagg  <->         EduPar -1.635417e-02 -0.2365241196      
42                Matagg  <->       n_trauma  7.142857e-03  0.1057402114      
43                Matagg  <->            Age  3.079710e-04  0.0047405101      
44                Matagg  <->        int_dis  3.250000e-02  0.2364027144      
45                Matagg  <->     medication  7.500000e-03  0.0657951695      
46                Matagg  <-> contraceptives  7.500000e-03  0.0545544726      
47                Matagg  <->       cigday_1  1.006250e-02  0.1360858260      
48                Matagg  <->             V8  8.168666e-04  0.0402393217      
49              FamScore  <->       FamScore  1.306250e-01  1.0000000000      
50              FamScore  <->         EduPar -2.911458e-02 -0.3495149022      
51              FamScore  <->       n_trauma  2.633929e-02  0.3236534989      
52              FamScore  <->            Age  3.591486e-03  0.0458878230      
53              FamScore  <->        int_dis  6.375000e-02  0.3849084009      
54              FamScore  <->     medication  4.375000e-03  0.0318580293      
55              FamScore  <-> contraceptives  5.750000e-02  0.3471722832      
56              FamScore  <->       cigday_1  4.326563e-02  0.4856887960      
57              FamScore  <->             V8  7.717159e-04  0.0315547719      
58                EduPar  <->         EduPar  5.312066e-02  1.0000000000      
59                EduPar  <->       n_trauma -7.924107e-03 -0.1526891136      
60                EduPar  <->            Age  2.727582e-03  0.0546490350      
61                EduPar  <->        int_dis -1.885417e-02 -0.1785114035      
62                EduPar  <->     medication  1.005208e-02  0.1147832062      
63                EduPar  <-> contraceptives -1.312500e-02 -0.1242676068      
64                EduPar  <->       cigday_1 -1.475130e-02 -0.2596730517      
65                EduPar  <->             V8 -8.750126e-06 -0.0005610523      
66              n_trauma  <->       n_trauma  5.070153e-02  1.0000000000      
67              n_trauma  <->            Age  1.562500e-03  0.0320439451      
68              n_trauma  <->        int_dis  4.107143e-02  0.3980335009      
69              n_trauma  <->     medication  1.741071e-02  0.2034979577      
70              n_trauma  <-> contraceptives  1.785714e-02  0.1730580439      
71              n_trauma  <->       cigday_1  2.101562e-02  0.3786692420      
72              n_trauma  <->             V8 -4.635661e-04 -0.0304243917      
73                   Age  <->            Age  4.689505e-02  1.0000000000      
74                   Age  <->        int_dis  7.989130e-03  0.0805056484      
75                   Age  <->     medication -1.634964e-03 -0.0198700345      
76                   Age  <-> contraceptives  3.480072e-02  0.3506833348      
77                   Age  <->       cigday_1  8.435575e-03  0.1580445206      
78                   Age  <->             V8 -1.316962e-03 -0.0898732659      
79               int_dis  <->        int_dis  2.100000e-01  1.0000000000      
80               int_dis  <->     medication  6.000000e-02  0.3445843938      
81               int_dis  <-> contraceptives  6.000000e-02  0.2857142857      
82               int_dis  <->       cigday_1  4.393750e-02  0.3890038953      
83               int_dis  <->             V8  5.574778e-03  0.1797788722      
84            medication  <->     medication  1.443750e-01  1.0000000000      
85            medication  <-> contraceptives  3.500000e-02  0.2010075631      
86            medication  <->       cigday_1  3.234375e-03  0.0345360471      
87            medication  <->             V8  2.058179e-03  0.0800493604      
88        contraceptives  <-> contraceptives  2.100000e-01  1.0000000000      
89        contraceptives  <->       cigday_1  4.831250e-02  0.4277382803      
90        contraceptives  <->             V8  2.655222e-03  0.0856272484      
91              cigday_1  <->       cigday_1  6.074961e-02  1.0000000000      
92              cigday_1  <->             V8  1.490410e-03  0.0893623867      
93                    V8  <->             V8  4.578872e-03  1.0000000000      
94                        int         Matsmk  2.625000e-01  0.5966005392      
95                        int         Matagg  1.000000e-01  0.3333333333      
96                        int       FamScore  2.250000e-01  0.6225430175      
97                        int         EduPar  6.062500e-01  2.6303892538      
98                        int       n_trauma  1.964286e-01  0.8723567443      
99                        int            Age  5.621377e-01  2.5958475642      
100                       int        int_dis  3.000000e-01  0.6546536707      
101                       int     medication  1.750000e-01  0.4605661865      
102                       int contraceptives  3.000000e-01  0.6546536707      
103                       int       cigday_1  1.243750e-01  0.5046163860      
104                       int             V8  5.286908e-01  7.8130836675      
    fixed par
1   FALSE   1
2   FALSE   2
3   FALSE   3
4   FALSE   4
5   FALSE   5
6   FALSE   6
7   FALSE   7
8   FALSE   8
9   FALSE   9
10  FALSE  10
11  FALSE  11
12  FALSE  12
13  FALSE  13
14  FALSE  14
15  FALSE  15
16  FALSE  16
17  FALSE  17
18  FALSE  18
19  FALSE  19
20  FALSE  20
21  FALSE  21
22  FALSE  22
23  FALSE  23
24  FALSE  24
25  FALSE  25
26  FALSE  26
27  FALSE  27
28   TRUE   0
29   TRUE   0
30   TRUE   0
31   TRUE   0
32   TRUE   0
33   TRUE   0
34   TRUE   0
35   TRUE   0
36   TRUE   0
37   TRUE   0
38   TRUE   0
39   TRUE   0
40   TRUE   0
41   TRUE   0
42   TRUE   0
43   TRUE   0
44   TRUE   0
45   TRUE   0
46   TRUE   0
47   TRUE   0
48   TRUE   0
49   TRUE   0
50   TRUE   0
51   TRUE   0
52   TRUE   0
53   TRUE   0
54   TRUE   0
55   TRUE   0
56   TRUE   0
57   TRUE   0
58   TRUE   0
59   TRUE   0
60   TRUE   0
61   TRUE   0
62   TRUE   0
63   TRUE   0
64   TRUE   0
65   TRUE   0
66   TRUE   0
67   TRUE   0
68   TRUE   0
69   TRUE   0
70   TRUE   0
71   TRUE   0
72   TRUE   0
73   TRUE   0
74   TRUE   0
75   TRUE   0
76   TRUE   0
77   TRUE   0
78   TRUE   0
79   TRUE   0
80   TRUE   0
81   TRUE   0
82   TRUE   0
83   TRUE   0
84   TRUE   0
85   TRUE   0
86   TRUE   0
87   TRUE   0
88   TRUE   0
89   TRUE   0
90   TRUE   0
91   TRUE   0
92   TRUE   0
93   TRUE   0
94   TRUE   0
95   TRUE   0
96   TRUE   0
97   TRUE   0
98   TRUE   0
99   TRUE   0
100  TRUE   0
101  TRUE   0
102  TRUE   0
103  TRUE   0
104  TRUE   0
rmd_paths <-paste0(tempfile(c(names(Netlist))),".Rmd")
names(rmd_paths) <- names(Netlist)

for (n in names(rmd_paths)) {
    sink(file = rmd_paths[n])
    cat("  \n",
        "```{r, echo = FALSE}",
            "Netlist[[n]]",
        "```",
        sep = "  \n")
    sink()
}

Interactive SEM plots

Only direct effects with a significant standardized effect of p<0.05 are shown.

    for (n in names(rmd_paths)) {
        cat(knitr::knit_child(rmd_paths[[n]],
                              quiet= TRUE))
        file.remove(rmd_paths[[n]])
    }

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
 [1] grid      parallel  stats4    stats     graphics  grDevices utils    
 [8] datasets  methods   base     

other attached packages:
 [1] plyr_1.8.6                  scales_1.1.1               
 [3] RCircos_1.2.1               compareGroups_4.4.6        
 [5] readxl_1.3.1                RRHO_1.28.0                
 [7] webshot_0.5.2               visNetwork_2.0.9           
 [9] org.Hs.eg.db_3.12.0         AnnotationDbi_1.52.0       
[11] xlsx_0.6.5                  gprofiler2_0.2.0           
[13] BiocParallel_1.24.1         kableExtra_1.3.1           
[15] glmpca_0.2.0                knitr_1.30                 
[17] DESeq2_1.30.0               SummarizedExperiment_1.20.0
[19] Biobase_2.50.0              MatrixGenerics_1.2.0       
[21] matrixStats_0.57.0          GenomicRanges_1.42.0       
[23] GenomeInfoDb_1.26.2         IRanges_2.24.1             
[25] S4Vectors_0.28.1            BiocGenerics_0.36.0        
[27] forcats_0.5.0               stringr_1.4.0              
[29] dplyr_1.0.2                 purrr_0.3.4                
[31] readr_1.4.0                 tidyr_1.1.2                
[33] tibble_3.0.4                tidyverse_1.3.0            
[35] semPlot_1.1.2               lavaan_0.6-7               
[37] viridis_0.5.1               viridisLite_0.3.0          
[39] WGCNA_1.69                  fastcluster_1.1.25         
[41] dynamicTreeCut_1.63-1       ggplot2_3.3.3              
[43] gplots_3.1.1                corrplot_0.84              
[45] RColorBrewer_1.1-2          workflowr_1.6.2            

loaded via a namespace (and not attached):
  [1] coda_0.19-4            bit64_4.0.5            DelayedArray_0.16.0   
  [4] data.table_1.13.6      rpart_4.1-15           RCurl_1.98-1.2        
  [7] doParallel_1.0.16      generics_0.1.0         snow_0.4-3            
 [10] preprocessCore_1.52.1  callr_3.5.1            lambda.r_1.2.4        
 [13] RSQLite_2.2.2          mice_3.12.0            chron_2.3-56          
 [16] bit_4.0.4              xml2_1.3.2             lubridate_1.7.9.2     
 [19] httpuv_1.5.5           assertthat_0.2.1       d3Network_0.5.2.1     
 [22] xfun_0.20              hms_1.0.0              rJava_0.9-13          
 [25] evaluate_0.14          promises_1.1.1         fansi_0.4.1           
 [28] caTools_1.18.1         dbplyr_2.0.0           igraph_1.2.6          
 [31] DBI_1.1.1              geneplotter_1.68.0     tmvnsim_1.0-2         
 [34] Rsolnp_1.16            htmlwidgets_1.5.3      futile.logger_1.4.3   
 [37] ellipsis_0.3.1         crosstalk_1.1.1        backports_1.2.0       
 [40] pbivnorm_0.6.0         annotate_1.68.0        vctrs_0.3.6           
 [43] abind_1.4-5            cachem_1.0.1           withr_2.4.1           
 [46] HardyWeinberg_1.7.1    checkmate_2.0.0        fdrtool_1.2.16        
 [49] mnormt_2.0.2           cluster_2.1.0          mi_1.0                
 [52] lazyeval_0.2.2         crayon_1.3.4           genefilter_1.72.0     
 [55] pkgconfig_2.0.3        nlme_3.1-151           nnet_7.3-15           
 [58] rlang_0.4.10           lifecycle_0.2.0        kutils_1.70           
 [61] modelr_0.1.8           VennDiagram_1.6.20     cellranger_1.1.0      
 [64] rprojroot_2.0.2        flextable_0.6.2        Matrix_1.2-18         
 [67] regsem_1.6.2           carData_3.0-4          boot_1.3-26           
 [70] reprex_1.0.0           base64enc_0.1-3        processx_3.4.5        
 [73] whisker_0.4            png_0.1-7              rjson_0.2.20          
 [76] bitops_1.0-6           KernSmooth_2.23-18     blob_1.2.1            
 [79] arm_1.11-2             jpeg_0.1-8.1           rockchalk_1.8.144     
 [82] memoise_2.0.0          magrittr_2.0.1         zlibbioc_1.36.0       
 [85] compiler_4.0.3         lme4_1.1-26            cli_2.2.0             
 [88] XVector_0.30.0         pbapply_1.4-3          ps_1.5.0              
 [91] htmlTable_2.1.0        formatR_1.7            Formula_1.2-4         
 [94] MASS_7.3-53            tidyselect_1.1.0       stringi_1.5.3         
 [97] lisrelToR_0.1.4        sem_3.1-11             yaml_2.2.1            
[100] OpenMx_2.18.1          locfit_1.5-9.4         latticeExtra_0.6-29   
[103] tools_4.0.3            matrixcalc_1.0-3       rstudioapi_0.13       
[106] uuid_0.1-4             foreach_1.5.1          foreign_0.8-81        
[109] git2r_0.28.0           gridExtra_2.3          farver_2.0.3          
[112] BDgraph_2.63           digest_0.6.27          shiny_1.6.0           
[115] Rcpp_1.0.5             broom_0.7.3            later_1.1.0.1         
[118] writexl_1.3.1          gdtools_0.2.3          httr_1.4.2            
[121] psych_2.0.12           colorspace_2.0-0       rvest_0.3.6           
[124] XML_3.99-0.5           fs_1.5.0               truncnorm_1.0-8       
[127] splines_4.0.3          statmod_1.4.35         xlsxjars_0.6.1        
[130] systemfonts_0.3.2      plotly_4.9.3           xtable_1.8-4          
[133] jsonlite_1.7.2         nloptr_1.2.2.2         futile.options_1.0.1  
[136] corpcor_1.6.9          glasso_1.11            R6_2.5.0              
[139] Hmisc_4.4-2            mime_0.9               pillar_1.4.7          
[142] htmltools_0.5.1.1      glue_1.4.2             fastmap_1.1.0         
[145] minqa_1.2.4            codetools_0.2-18       lattice_0.20-41       
[148] huge_1.3.4.1           gtools_3.8.2           officer_0.3.16        
[151] zip_2.1.1              GO.db_3.12.1           openxlsx_4.2.3        
[154] survival_3.2-7         rmarkdown_2.6          qgraph_1.6.5          
[157] munsell_0.5.0          GenomeInfoDbData_1.2.4 iterators_1.0.13      
[160] impute_1.64.0          haven_2.3.1            reshape2_1.4.4        
[163] gtable_0.3.0