View source: R/lavaan_extract.R

lavaan_extract | R Documentation |

Extract relevant indices from lavaan model through lavaan::parameterEstimates and lavaan::standardizedsolution.

```
lavaan_extract(
fit,
operator = NULL,
lhs_name = "Left-Hand Side",
rhs_name = "Right-Hand Side",
underscores_to_symbol = "→",
diag = NULL,
nice_table = FALSE,
...
)
```

`fit` |
lavaan fit object to extract fit indices from |

`operator` |
Which operator to subselect with. |

`lhs_name` |
Name of first column, referring to the left-hand side expression (lhs). |

`rhs_name` |
Name of first column, referring to the right-hand side expression (rhs). |

`underscores_to_symbol` |
Character to convert underscores to arrows in the first column, like for indirect effects. Default to the right arrow symbol, but can be set to NULL or "_", or to any other desired symbol. It is also possible to provide a vector of replacements if they they are not all the same. |

`diag` |
When extracting covariances ( |

`nice_table` |
Logical, whether to print the table as a rempsyc::nice_table as well as print the reference values at the bottom of the table. |

`...` |
Arguments to be passed to rempsyc::nice_table |

A dataframe, including the indirect effect ("lhs"), corresponding paths ("rhs"), standardized regression coefficient ("std.all"), corresponding p-value, as well as the unstandardized regression coefficient ("est") and its confidence interval ("ci.lower", "ci.upper").

```
x <- paste0("x", 1:9)
(latent <- list(
visual = x[1:3],
textual = x[4:6],
speed = x[7:9]
))
(mediation <- list(
speed = "visual",
textual = "visual",
visual = c("ageyr", "grade")
))
(indirect <- list(
IV = c("ageyr", "grade"),
M = "visual",
DV = c("speed", "textual")
))
HS.model <- write_lavaan(mediation,
indirect = indirect,
latent = latent, label = TRUE
)
cat(HS.model)
library(lavaan)
fit <- sem(HS.model, data = HolzingerSwineford1939)
lavaan_extract(fit, lhs_name = "Indirect Effect", operator = ":=")
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.