\begin{Schunk}
\begin{Sinput}
 # if nesting is not specified, the diff is not reported
 compareLavaan(list("CFA" = cfa3, "SEM" = mediat.out.2), nesting = "CFA > SEM", fitmeas = c("chisq", "df", "pvalue", "rmsea", "cfi", "bic"),  type="latex")
\end{Sinput}
% latex table generated in R 3.6.0 by xtable 1.8-4 package
% Thu Jun  6 10:21:16 2019
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrlll}
  \hline
 & $\chi^{2}$ & df & \textit{p}-value & rmsea & cfi & bic & $\Delta\chi^{2}$ & $\Delta df$ & \textit{p} \\ 
  \hline
CFA & 106.85 & 80.00 & 0.02 & 0.03 & 0.99 & 7635.83 & - & - & - \\ 
  SEM & 109.15 & 83.00 & 0.03 & 0.03 & 0.99 & 7620.31 & 2.305a & 3 & 0.512 \\ 
   \hline
\multicolumn{4}{l}{a = SEM vs CFA} \\
 \hline
\end{tabular}
\end{table}\end{Schunk}
\begin{Schunk}
\begin{Sinput}
 mediat.mod.3 <- '
  ## measurement model
  Agency =~ Agency1 + Agency2 + Agency3
  Intrinsic =~ Intrin1 + Intrin2 + Intrin3
  Extrinsic =~ Extrin1 + Extrin2 + Extrin3
  Positive =~ PosAFF1 + PosAFF2 + PosAFF3
  Negative =~ NegAFF1 + NegAFF2 + NegAFF3
  ## structural model
  Positive ~ b1*Intrinsic + Agency
  Negative ~ b2*Extrinsic
  Intrinsic ~ a1*Agency
  Extrinsic ~ a2*Agency
  Intrinsic ~~ Extrinsic
  ## define mediation parameters (indirect effects)
  c1 := a1 * b1
  c2 := a2 * b2
  c1 == c2
  '
\end{Sinput}
\end{Schunk}
