Learn R Programming

xtvfreg (version 1.1.0)

comparison_table: Create comparison table across groups

Description

Create comparison table across groups

Usage

comparison_table(object, equation = "mean", output = "data.frame", ...)

Value

A formatted table (type depends on output parameter)

Arguments

object

An object of class "xtvfreg"

equation

Character; "mean" or "variance"

output

Character; "data.frame", "kable", or "gt"

...

Additional arguments passed to formatting functions

Examples

Run this code
# Create small simulated dataset
set.seed(456)
n_id <- 30
n_time <- 4
panel_data <- data.frame(
  id = factor(rep(1:n_id, each = n_time)),
  group = factor(rep(c("A", "B"), length.out = n_id * n_time)),
  x = rnorm(n_id * n_time)
)
panel_data$m_x <- ave(panel_data$x, panel_data$id, FUN = mean)
panel_data$d_x <- panel_data$x - panel_data$m_x
panel_data$y <- 1 + panel_data$m_x + rnorm(n_id * n_time)

result <- xtvfreg(
  formula = y ~ 1,
  data = panel_data,
  group = "group",
  panel_id = "id",
  mean_vars = c("m_x", "d_x"),
  var_vars = "m_x",
  verbose = FALSE
)

# Create comparison table
comparison_table(result, equation = "mean")

Run the code above in your browser using DataLab