Description Usage Arguments Value Examples
This function takes the output of result_table
and transforms it into latex-code to be used in a rmarkdown file. There are two ways to specify which relationship or effect should be printed: 1) If the relationships are labelled in the result table that is passed to the function, the argument var_label
can be used to specify which effect should be printed; 2) If the result table does not contain an labels, the argument var_predict
can be used to specify the predictor variable of the effect that should be printed. Alternatively, it also takes output of anova_stats
and transforms it into latex-code.
1 2 3 4 5 6 7 8 9 10 11 12 |
object |
A dataframe resulting from |
var_label |
A character value indicating which coefficient should be printed (draws from the label column in the dataframe). |
var_predict |
Predictor variable that should be printed. |
b |
Should the unstandardized effect be printed? |
se |
Should the standard error be printed? |
ci |
Should the confidence intervals (if bayesian: high credibility intervals) be printed? |
p |
Should the p-value be printed? |
beta |
Should the standarized coefficient be printed? |
anova_effect |
Which effect size should be reported (e.g., "cohens.f", "etasq", or "partial.etasq") |
A string representing a latex code that can be used in inline reporting in Rmarkdown documents.
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | ## Example 1: Reporting effects from a structural equation modelling
library(lavaan)
# Estimate the structural equation model
model <- '
# latent variables
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + y2 + y3 + y4
dem65 =~ y5 + y6 + y7 + y8
# regressions
dem60 ~ ind60
dem65 ~ ind60 + dem60
# residual covariances
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8
'
# Fitting model
fit <- sem(model,
data = PoliticalDemocracy)
# First step (print = TRUE is mandatory!)
results <- result_table(fit,
sem_regressions = TRUE,
new_labels = c("H1", "H2", "H3"),
print = TRUE)
# Second step
print_coeff(results,
var_label = "H1")
print_coeff(results, "H2",
se = FALSE,
beta = TRUE)
## Example 2: Reporting effects from a multilevel model
# Estimate the multilevel model
model <- lmerTest::lmer(Reaction ~ 1 + Days + (1 | Subject),
data = sleepstudy)
# First step (print = TRUE is mandatory!)
results <- result_table(model, print = TRUE)
# Second step
print_coeff(results,
var_predict = "Days",
ci = FALSE,
p = FALSE)
## Example 3: Reporting effects from a Bayesian multilevel model
# Estimate the Bayesian multilevel model (using "brms")
model_bayes <- brms::brm(Reaction ~ 1 + Days + (1 | Subject),
data = sleepstudy,
chains = 1)
# First step (print = TRUE is mandatory!)
results_bayes <- result_table(model_bayes, print = TRUE)
# Second step
print_coeff(results_bayes,
var_predict = "b_Days")
## Example 4: Reporting results from ANOVAs
x <- rep(c(1,0), 50)
y <- 2*x + rnorm(100, 0, 1)
# First step
m <- aov(y ~ x)
# Second step (sjstats::anova_stats() needs to be used)
print_coeff(sjstats::anova_stats(m),
var_predict = "x",
anova_effect = "etasq")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.