Learn R Programming

kutils (version 0.93)

cfaTable: Creates Confirmatory Factor Analysis Tables

Description

Creates LaTeX markup for confirmatory factor analysis output tables in the style of the American Psychological Association(APA). Input objects should be created by the "lavaan" package.

Usage

cfaTable(object, file = NULL, params = c("loadings", "intercepts"),
  fit = c("chi-square", "cfi", "tli", "rmsea"), names_fit = fit,
  standardized = FALSE, names_upper = TRUE, single_spaced = TRUE,
  type = "latex")

Arguments

object
A cfa object from lavaan
file
Character string for file name. Default is NULL, meaning no output file.
params
Measurement parameters to be included. Valid values are "loadings", "intercepts", "residuals", "latentvariances", and "thresholds". See Details.
fit
A vector of fit measures that to be included. Listing "chi-square" will do special formatting to the chi-square value in the note. Any other measures listed must correspond to measures found in fitMeasures(object).
names_fit
Names for the fit measures requested by the fit parameter. Must have same number of elements as fit. For example, fit = c("cfi.scaled", "tli.scaled"), names_fit = c("CFI", "TLI").
standardized
Should standarized results be presented along with unstandardized? Default is FALSE. See Details.
names_upper
Should the names of the model fit parameters be forced to be uppercase. The default is TRUE. This will also affect whatever is specified in names_fit.
single_spaced
Default = TRUE. If a double-spaced table is needed, set single_spaced = FALSE.
type
Type of output table ("latex" or "html"). Defaults to "latex".

Value

CFA table of desired type.

Details

The argument params determines the inclusion of estimate sections.
  • "loadings" are the factor loadings in the model.
  • "intercepts" are the indicator variable intercepts.
  • "residuals" are the indicator variable residual variances.
  • "latentvariances" are the latent variable variances and covariances.
  • "thresholds" arise in latent response variates (non-numeric indicator data).

The stantardized parameter regulates the number of columns to be included. standardized=FALSE implies there will be four columns:

  1. the estimate
  2. the standard error
  3. the z-value, and
  4. the p-value.

When standardized = TRUE, the columns are:

  1. the parameter estimates,
  2. the standard errors,
  3. standardized parameter estimates, and
  4. standardized standard errors.

The standardized parameters are obtained by updating the output with the options std.lv = TRUE and std.ov = TRUE. If these options were used when originally creating output, setting standardized = TRUE will yield two identical sets of two columns.

Examples

Run this code
## These run longer than 5 seconds
require(lavaan)
HS.model <- ' visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9 '
output1 <- cfa(HS.model, data = HolzingerSwineford1939, std.lv = TRUE)
cfaTable(output1, fit = "rmsea",
standardized = TRUE, params = c("loadings", "latentvariances"),
type = "latex")

## Example with file output
## cfaTable(output1, file = "exampleTable.tex", fit = "rmsea",
## standardized = TRUE, params = c("loadings", "latentvariances"),
## type = "latex")

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"
output2 <- cfa(testmodel, data = dat, ordered = colnames(dat),
    std.lv = FALSE)
cfaTable(output2,
    params = c("loadings", "thresholds", "residuals"),
    fit = c("tli", "chi-square"),
    names_fit = c("TLI", "chi-square"), type = "latex")

## Example with file output
## cfaTable(output, file = "catTable.tex",
##    params = c("loadings", "thresholds", "residuals"),
##    fit = c("tli", "chi-square"),
##    names_fit = c("TLI", "chi-square"), type = "latex")

Run the code above in your browser using DataLab