% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diagnostics.R
\name{bw_ratio}
\alias{bw_ratio}
\title{Between/Within Variance Ratio for Time-Invariant Variables}
\usage{
bw_ratio(data, variables, id)
}
\arguments{
\item{data}{A data frame containing the panel data.}

\item{variables}{A character vector of variable names to analyze.}

\item{id}{Character string naming the panel identifier variable.}
}
\value{
A data frame with columns:
\describe{
\item{variable}{Variable name}
\item{sd_between}{Between-panel standard deviation}
\item{sd_within}{Within-panel standard deviation}
\item{bw_ratio}{Ratio of between to within SD}
}
}
\description{
Computes the between-panel and within-panel standard deviations for
specified variables, along with their ratio. This diagnostic helps assess
whether FEVD/FEF methods may improve upon standard FE estimation.
}
\details{
For truly time-invariant variables, the within-panel SD should be zero
(or near-zero due to numerical precision), giving an infinite ratio.

According to Plümper and Troeger (2007), FEVD/FEF methods tend to improve
upon standard FE when:
\itemize{
\item The between/within ratio exceeds approximately 1.7
\item The correlation between z and the unobserved unit effect is not too high
}
}
\examples{
# Create example data
set.seed(42)
N <- 50
T <- 5
id <- rep(1:N, each = T)
z_invariant <- rep(rnorm(N), each = T)  # Truly time-invariant
z_slow <- rep(rnorm(N), each = T) + rnorm(N * T, sd = 0.1)  # Slowly varying
x_varying <- rnorm(N * T)  # Time-varying

data <- data.frame(id = id, z_inv = z_invariant,
                   z_slow = z_slow, x = x_varying)

bw_ratio(data, c("z_inv", "z_slow", "x"), id = "id")

}
\references{
Plumper, T., & Troeger, V. E. (2007). Efficient Estimation of Time-Invariant
and Rarely Changing Variables in Finite Sample Panel Analyses with Unit Fixed
Effects. \emph{Political Analysis}, 15(2), 124-139.
\doi{10.1093/pan/mpm002}
}
