Description Usage Arguments Details Value Author(s) Examples
Creates LaTeX markup for structural equation modeling output
tables in the style of the American Psychological
Association(APA). Input objects should be created by the
"lavaan
" package.
1 2 3 4 5 6 7 | semTable(object, file = NULL, paramSets = "all", paramSetLabels,
columns = c(est = "Estimate", se = "SE", z = "z", p = "p"),
columnLabels, fits = c("chisq", "cfi", "tli", "rmsea"),
fitLabels = toupper(fits), varLabels = NULL, groups = NULL,
type = "latex", table.float = FALSE, caption = NULL,
label = NULL, longtable = FALSE, print.results = TRUE,
centering = "siunitx", alpha = c(0.05, 0.01, 0.001))
|
object |
A lavaan object (e.g., returned by cfa() or sem()),
or a named list of lavaan objects, e.g., |
file |
Base name for output file. This function will insert suffix, either "tex", "html" and "csv". |
paramSets |
Parameter sets to be included for each fitted
object. Valid values of the vector are |
paramSetLabels |
Named vector, used to supply alternative
pretty printing labels for parameter sets. The default values
are |
columns |
A vector naming estimates to appear for each model.
The allowed columns are "est", "se", "z", "p", "rsquare",
"estse", "eststars", "estsestars". The first 5 have the usual
meanings, while "estse" (can also be written |
columnLabels |
A named vector of "pretty labels" for the
headings in the table. The default labels are |
fits |
Summary indicators to be included. May be a list, one
for each model provided, otherwise the same fit indicators
will be presented for each model. Any of the fit indicators
provided by |
fitLabels |
Labels for some or all of the fit measures
requested by the fits parameter, e.g. |
varLabels |
Named vector of labels to replace variable names in column 1 of SEM table. |
groups |
All groups will be printed, unless a subset is requested here. Estimates for all groups will be displayed side by side. If ONLY SOME groups should be included, then specify groups as either names of fit objects or as integers for elements of the groups vector. |
type |
Choose "latex", "html", or "csv" |
table.float |
If TRUE, create a LaTeX floating table object in which the tabular created here will reside. Default is FALSE. |
caption |
Caption for table (if table.float=TRUE) or longtable output. Ignored otherwise. |
label |
LaTeX label for this object (for cross-references). Only used if table.float = TRUE or longtable = TRUE. |
longtable |
If TRUE, use longtable for LaTeX
documents. Default is FALSE. If true, |
print.results |
If TRUE, marked up result will be displayed
within the session. Otherwise, result is returned silently and
user can use |
centering |
Default "siunitx". For method used in previous editions, replace with "none". |
alpha |
Thresholds for p-values that determine number of
stars. Defaults as |
The argument paramSets determines the inclusion of estimate sections. One can specify "all", which means that all types of parameters that we can find in the fitted model are presented. Otherwise, a subset of parameter sets can be chosen by the user.
"composites" are predictor coefficients in formative constructs
"loadings" are the factor loadings in the model.
"slopes" are the regression slopes in the model.
"intercepts" are the estimated constants in the measurement models.
"residualvariances" are the observed variable residual variances.
"residualcovariances" are the observed covariances among residuals of observed variables.
"latentvariances" are the variances of unobserved variables.
"latentcovariances" are the covariances between unobserved variables.
"latentmeans" are means of unobserved variables
"thresholds" arise in latent response variates (non-numeric indicator data).
"constructed" are parameters that are calculated from a formula in the model specification, such as an indirect path c=a*b.
"fits" the summary indicators of the mismatch between the theoretical and observed covariance matrices, such as RMSEA, CLI, TFI. While the fits are not technically parameters, they are displayed in the same block style as parameters
The columns parameter is used to specify different columns, while columnLabels will alter the displayed labels for them.
Markup for SEM table. Includes an attribute "markedResults", which can be converted to other markup formats by the function markupConvert.
Ben Kite <bakite@ku.edu> Paul Johnson <pauljohn@ku.edu>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## Most of the examples were moved to the semTable vignette
require(lavaan)
tempdir <- tempdir()
## The example from lavaan's docs
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9'
fit1 <- cfa(HS.model, data = HolzingerSwineford1939,
std.lv = TRUE, meanstructure = TRUE)
## Try a LaTeX file first
fit1.t1 <- semTable(fit1, columns = c("estse", "p"),
fits = c("chisq", "rmsea"), file = file.path(tempdir, "fit1.t1"),
varLabels = c("x1" = "hello"), type = "latex", print.results = FALSE)
## If you have a working version of pdflatex in your system path,
if (interactive()) testtable("fit1.t1.tex", tempdir)
model <- "factor =~ .7*y1 + .7*y2 + .7*y3 + .7*y4
y1 | -1*t1 + 1*t2
y2 | -.5*t1 + 1*t2
y3 | -.2*t1 + 1*t2
y4 | -1*t1 + 1*t2"
dat <- simulateData(model, sample.nobs = 300)
testmodel <- "ExampleFactor =~ y1 + y2 + y3 + y4"
fit4 <- cfa(testmodel, data = dat, ordered = colnames(dat),
std.lv = FALSE)
fit4.t1 <- semTable(fit4, paramSets = c("loadings", "thresholds",
"residualvariances"), fits = c("tli", "chisq"),
fitLabels = c(tli = "TLI", chisq = "chisq"), type = "html",
file=file.path(tempdir, "fit4.t1") )
if(interactive()) browseURL(attr(fit4.t1, "file"))
fit4.t2 <- semTable(fit4, fits = c("rmsea", "cfi", "chisq"),
fitLabels = c(rmsea = "Root M.SQ.E.A", cfi = "CompFitIdx", chisq = "chisq"),
type = "latex", file=file.path(tempdir, "fit4.t2"))
if (interactive()) testtable("fit4.t2.tex", tempdir)
|
Loading required package: lavaan
This is lavaan 0.6-7
lavaan is BETA software! Please report any bugs.
<table style="padding-right:20px;padding-left:20px;">
<tr><td></td><td colspan = '4'; align = 'center'>Model</td></tr>
<tr><td></td><td colspan = '1'; align = 'center'>Estimate</td><td colspan = '1'; align = 'center'>Std. Err.</td><td colspan = '1'; align = 'center'>z</td><td colspan = '1'; align = 'center'>p</td></tr>
<tr><td></td><td colspan = '4'; align = 'center'><span style="text-decoration: underline;">Factor Loadings</span></td></tr> <tr><td colspan = '1'; align = 'left'><span style="text-decoration: underline;">ExampleFactor</span></td></tr>
<tr><td>y1</td><td>1.00<sup>+</sup></td><td></td><td></td><td></td></tr>
<tr><td>y2</td><td>0.83</td><td>0.12</td><td>6.96</td><td>.000</td></tr>
<tr><td>y3</td><td>1.02</td><td>0.11</td><td>9.53</td><td>.000</td></tr>
<tr><td>y4</td><td>1.00</td><td>0.12</td><td>8.58</td><td>.000</td></tr>
<tr><td></td><td colspan = '4'; align = 'center'><span style="text-decoration: underline;">Residual Variances</span></td></tr>
<tr><td>y1</td><td>0.50<sup>+</sup></td><td></td><td></td><td></td></tr>
<tr><td>y2</td><td>0.66<sup>+</sup></td><td></td><td></td><td></td></tr>
<tr><td>y3</td><td>0.48<sup>+</sup></td><td></td><td></td><td></td></tr>
<tr><td>y4</td><td>0.50<sup>+</sup></td><td></td><td></td><td></td></tr>
<tr><td></td><td colspan = '4'; align = 'center'><span style="text-decoration: underline;">Thresholds</span></td></tr>
<tr><td>y1(1)</td><td>-0.94</td><td>0.09</td><td>-11.01</td><td>.000</td></tr>
<tr><td>y1(2)</td><td>1.04</td><td>0.09</td><td>11.70</td><td>.000</td></tr>
<tr><td>y2(1)</td><td>-0.51</td><td>0.08</td><td>-6.77</td><td>.000</td></tr>
<tr><td>y2(2)</td><td>1.04</td><td>0.09</td><td>11.70</td><td>.000</td></tr>
<tr><td>y3(1)</td><td>-0.25</td><td>0.07</td><td>-3.45</td><td>.001</td></tr>
<tr><td>y3(2)</td><td>1.05</td><td>0.09</td><td>11.80</td><td>.000</td></tr>
<tr><td>y4(1)</td><td>-0.99</td><td>0.09</td><td>-11.41</td><td>.000</td></tr>
<tr><td>y4(2)</td><td>1.07</td><td>0.09</td><td>11.89</td><td>.000</td></tr>
<tr><td></td><td colspan = '4'; align = 'center'><span style="text-decoration: underline;">Fit Indices</span></td></tr>
<tr><td>TLI</td><td>1.02</td><td></td><td></td><td></td></tr>
<tr><td>chisq</td><td>0.03</td><td></td><td></td><td></td></tr>
<tr><td>Scaled χ<sup>2</sup></td><td>0.07(2)</td><td></td><td></td><td>.966</td></tr>
<tr><td colspan = '5'; align = 'left'><sup>+</sup>Fixed parameter</td></tr>
</table><br>
\begin{tabular}{@{}r*{4}{S[
input-symbols = ( ) +,
group-digits = false,
table-number-alignment = center,
%table-space-text-pre = (,
table-align-text-pre = false,
table-align-text-post = false,
table-space-text-post = {***},
parse-units = false]}@{}}
& \multicolumn{4}{c}{Model}\tabularnewline \hline
& \multicolumn{1}{c}{Estimate}& \multicolumn{1}{c}{Std. Err.}& \multicolumn{1}{c}{z}& \multicolumn{1}{c}{p}\tabularnewline\hline
& \multicolumn{4}{c}{\underline{Factor Loadings}}\tabularnewline \multicolumn{1}{l}{\underline{ExampleFactor}}\tabularnewline
y1& 1.00$^+$& & & \tabularnewline
y2& 0.83& 0.12& 6.96& .000\tabularnewline
y3& 1.02& 0.11& 9.53& .000\tabularnewline
y4& 1.00& 0.12& 8.58& .000\tabularnewline
& \multicolumn{4}{c}{\underline{Intercepts}}\tabularnewline
y1& 0.00$^+$& & & \tabularnewline
y2& 0.00$^+$& & & \tabularnewline
y3& 0.00$^+$& & & \tabularnewline
y4& 0.00$^+$& & & \tabularnewline
& \multicolumn{4}{c}{\underline{Residual Variances}}\tabularnewline
y1& 0.50$^+$& & & \tabularnewline
y2& 0.66$^+$& & & \tabularnewline
y3& 0.48$^+$& & & \tabularnewline
y4& 0.50$^+$& & & \tabularnewline
& \multicolumn{4}{c}{\underline{Latent Intercepts}}\tabularnewline
ExampleFactor& 0.00$^+$& & & \tabularnewline
& \multicolumn{4}{c}{\underline{Latent Variances}}\tabularnewline
ExampleFactor& 0.50& 0.08& 6.19& .000\tabularnewline
& \multicolumn{4}{c}{\underline{Thresholds}}\tabularnewline
y1(1)& -0.94& 0.09& -11.01& .000\tabularnewline
y1(2)& 1.04& 0.09& 11.70& .000\tabularnewline
y2(1)& -0.51& 0.08& -6.77& .000\tabularnewline
y2(2)& 1.04& 0.09& 11.70& .000\tabularnewline
y3(1)& -0.25& 0.07& -3.45& .001\tabularnewline
y3(2)& 1.05& 0.09& 11.80& .000\tabularnewline
y4(1)& -0.99& 0.09& -11.41& .000\tabularnewline
y4(2)& 1.07& 0.09& 11.89& .000\tabularnewline
& \multicolumn{4}{c}{\underline{Fit Indices}}\tabularnewline
Root M.SQ.E.A& 0.00& & & \tabularnewline
CompFitIdx& 1.00& & & \tabularnewline
chisq& 0.03& & & \tabularnewline
Scaled $\chi^{2}(\mathrm{df})$& 0.07(2)& & & .966\tabularnewline
\hline\multicolumn{5}{l}{$^+$Fixed parameter}\tabularnewline
\end{tabular}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.