| Title: | Unified Econometric Estimation, Specification Testing, and Diagnostics |
|---|---|
| Description: | A unified econometric toolkit providing automated specification testing, robust covariance estimation, and publication-grade academic visualizations. Implements ordinary and weighted least squares with robust, cluster-robust, and heteroskedasticity and autocorrelation consistent (HAC) standard errors; instrumental variables two-stage least squares (2SLS); panel data estimators (within fixed effects, two-way fixed effects, random effects GLS, first differences); binary response models (logit and probit with average marginal effects); tobit censored regression; count models (Poisson and negative binomial); causal inference methods (difference-in-differences, sharp regression discontinuity); quantile regression; dynamic time series models (autoregressive distributed lag, Koyck distributed lag, Prais-Winsten AR(1), error correction models, vector autoregression); and time series unit root batteries (augmented Dickey-Fuller, Phillips-Perron, KPSS, Engle-Granger cointegration, Granger causality, ARCH). Estimation routines integrate comprehensive diagnostic batteries, parameter stability tests, and academic visualizations with zero external package dependencies. |
| Authors: | Md. Abid Siddique Emon [aut, cre] (ORCID: <https://orcid.org/0009-0007-6576-027X>) |
| Maintainer: | Md. Abid Siddique Emon <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-08 11:39:04 UTC |
| Source: | https://github.com/abidsiddique/phoring |
Engle's Lagrange Multiplier test for ARCH effects / volatility clustering in time series models.
arch_test(model, lags = 2, digits = 4)arch_test(model, lags = 2, digits = 4)
model |
|
lags |
Number of squared residual lags to test (default is 2). |
digits |
Number of decimals to display (default is 4). |
An object of class econ_arch.
data(macro_data, package = "phoring") m <- reg(inflation ~ fed_funds, data = macro_data, diagnostics = FALSE) arch_test(m, lags = 2)data(macro_data, package = "phoring") m <- reg(inflation ~ fed_funds, data = macro_data, diagnostics = FALSE) arch_test(m, lags = 2)
Estimates an ARDL(p, q) model and calculates both short-run impact multipliers and long-run cumulative propensity multipliers with delta-method standard errors.
ardl(formula, data, p = 1, q = 1, digits = 4)ardl(formula, data, p = 1, q = 1, digits = 4)
formula |
Model formula |
data |
A data.frame containing the time series. |
p |
Number of autoregressive lags of y (default is 1). |
q |
Number of distributed lags of x (default is 1). |
digits |
Number of decimals to display (default is 4). |
An object of class econ_ardl.
data(macro_data, package = "phoring") ardl(inflation ~ unemployment, data = macro_data, p = 1, q = 1)data(macro_data, package = "phoring") ardl(inflation ~ unemployment, data = macro_data, p = 1, q = 1)
Tests whether regression coefficients are constant across two subsamples (e.g. before/after a policy shock, male vs. female, or high vs. low income).
chow_test(formula, split_by, data = NULL, digits = 4)chow_test(formula, split_by, data = NULL, digits = 4)
formula |
Regression formula (or an existing |
split_by |
A binary variable or condition in |
data |
A data.frame containing the variables (required if formula is used). |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_chow.
data(wage_data, package = "phoring") # Test if wage equation differs by gender chow_test(wage ~ educ + exper, split_by = "female", data = wage_data)data(wage_data, package = "phoring") # Test if wage equation differs by gender chow_test(wage ~ educ + exper, split_by = "female", data = wage_data)
Tests whether two or more non-stationary time series share a stationary long-run equilibrium cointegrating relationship.
coint(formula, data, lags = 1, digits = 4)coint(formula, data, lags = 1, digits = 4)
formula |
Model formula specifying cointegrating regression (e.g., |
data |
A data.frame containing the time series variables. |
lags |
Number of lags for residual ADF test (default is 1). |
digits |
Number of decimal places to display (default is 4). |
An object of class econ_coint.
data(macro_data, package = "phoring") coint(inflation ~ unemployment + fed_funds, data = macro_data)data(macro_data, package = "phoring") coint(inflation ~ unemployment + fed_funds, data = macro_data)
A dataset of 800 individuals designed for Instrumental Variables (2SLS) estimation, based on David Card's (1995) landmark study using geographic proximity to a 4-year college as an exogenous instrument for educational attainment.
college_distancecollege_distance
A data frame with 800 rows and 9 variables:
Hourly wage in US dollars
Years of completed education (endogenous regressor)
Years of potential labor market experience
Years with current employer
Indicator: 1 if grew up near a 4-year college (excluded instrument)
Mother's years of education (excluded instrument)
Father's years of education (excluded instrument)
Indicator: 1 if residing in the South
Indicator: 1 if Black
Modeled after Card (1995), "Using Geographic Variation in College Proximity".
Computes pairwise Pearson correlation coefficients with significance stars.
corr(data, vars = NULL, digits = 3)corr(data, vars = NULL, digits = 3)
data |
A data.frame. |
vars |
Optional character vector of column names. |
digits |
Number of decimal places (default is 3). |
An object of class econ_corr.
data(mtcars) corr(mtcars, vars = c("mpg", "hp", "wt", "qsec"))data(mtcars) corr(mtcars, vars = c("mpg", "hp", "wt", "qsec"))
Fits Poisson or Negative Binomial regression for count data, computes Incidence Rate Ratios (IRR) with 95% confidence intervals, robust standard errors, and conducts Cameron & Trivedi's overdispersion test or Likelihood Ratio test against Poisson.
count_reg(formula, data, model = c("poisson", "negbin"), digits = 4)count_reg(formula, data, model = c("poisson", "negbin"), digits = 4)
formula |
Model formula (e.g., |
data |
A data.frame containing the variables. |
model |
Model type: |
digits |
Number of decimals to display (default is 4). |
An object of class econ_count.
set.seed(42) n <- 300 x1 <- rnorm(n); x2 <- rbinom(n, 1, 0.5) y <- rpois(n, lambda = exp(0.5 + 0.3 * x1 - 0.4 * x2)) df <- data.frame(y, x1, x2) count_reg(y ~ x1 + x2, data = df, model = "poisson") count_reg(y ~ x1 + x2, data = df, model = "negbin")set.seed(42) n <- 300 x1 <- rnorm(n); x2 <- rbinom(n, 1, 0.5) y <- rpois(n, lambda = exp(0.5 + 0.3 * x1 - 0.4 * x2)) df <- data.frame(y, x1, x2) count_reg(y ~ x1 + x2, data = df, model = "poisson") count_reg(y ~ x1 + x2, data = df, model = "negbin")
A balanced panel dataset of 50 counties observed over 4 years (2020-2023), totaling 200 observations. Useful for testing the economic model of crime with Fixed Effects, Random Effects, and entity-clustered standard errors.
crime_panelcrime_panel
A data frame with 200 rows and 6 variables:
County identifier (1 to 50)
Year of observation (2020 to 2023)
Reported crimes per 1,000 residents
Probability of arrest (ratio of arrests to reported offenses)
Police officers per 1,000 residents
County unemployment rate (percentage)
Modeled after Cornwell and Trumbull (1994) panel crime study.
Generates standard summary statistics (Obs, Mean, Std Dev, Min, P25, Median, P75, Max, Missing) for numeric variables in a dataset, or computes a full "Table 1" covariate balance test across two treatment/subsample groups with normalized differences and t-tests.
desc(data, vars = NULL, by = NULL, digits = 3)desc(data, vars = NULL, by = NULL, digits = 3)
data |
A data.frame. |
vars |
Optional character vector of column names to summarize. |
by |
Optional character string specifying a binary grouping column (e.g. treatment, gender) for two-group covariate balance testing ("Table 1"). |
digits |
Number of decimal places to display (default is 3). |
A data.frame of class econ_desc or econ_desc_balance.
data(wage_data, package = "phoring") # Standard descriptive statistics desc(wage_data, vars = c("wage", "educ", "exper")) # Covariate balance table ("Table 1") by gender desc(wage_data, vars = c("wage", "educ", "exper"), by = "female")data(wage_data, package = "phoring") # Standard descriptive statistics desc(wage_data, vars = c("wage", "educ", "exper")) # Covariate balance table ("Table 1") by gender desc(wage_data, vars = c("wage", "educ", "exper"), by = "female")
Computes a complete battery of econometric diagnostic tests for linear models, including Breusch-Pagan, White, Durbin-Watson, Breusch-Godfrey, Ramsey RESET, Multicollinearity (VIF), and Jarque-Bera normality tests.
diagnostics(model, ...)diagnostics(model, ...)
model |
A fitted model object from 'reg()' or 'stats::lm()'. |
... |
Additional arguments. |
An object of class 'econ_diagnostics' containing test statistics, p-values, decisions, and individual VIF values.
data(mtcars) m <- reg(mpg ~ wt + hp + qsec, data = mtcars) diagnostics(m)data(mtcars) m <- reg(mpg ~ wt + hp + qsec, data = mtcars) diagnostics(m)
Fits a Difference-in-Differences (DiD) model with optional control covariates, computes cluster-robust standard errors, and outputs the classic 2x2 pre/post treatment table alongside full regression estimates.
did( formula, data, treat = NULL, post = NULL, time = NULL, cluster = NULL, digits = 4, ... )did( formula, data, treat = NULL, post = NULL, time = NULL, cluster = NULL, digits = 4, ... )
formula |
Model formula specifying outcome, treatment, and post periods,
optionally with control covariates (e.g., |
data |
A data.frame containing the variables. |
treat |
Column name for treatment indicator (optional, automatically inferred from interaction). |
post |
Column name for post-period indicator (optional, automatically inferred from interaction). |
time |
Optional name of time period variable (e.g. |
cluster |
Optional column name for cluster-robust standard errors (recommended: state/unit level). |
digits |
Number of decimals to display (default is 4). |
... |
Additional arguments passed to |
An object of class econ_did containing the DiD effect, 2x2 table, and estimates.
set.seed(42) n <- 400 state <- sample(1:20, n, replace = TRUE) treat <- ifelse(state <= 10, 1, 0) post <- sample(0:1, n, replace = TRUE) x1 <- rnorm(n) y <- 10 + 2 * treat + 1.5 * post + 3.2 * (treat * post) + 0.5 * x1 + rnorm(n, sd = 2) df <- data.frame(y, treat, post, state, x1) did(y ~ treat * post + x1, data = df, cluster = "state")set.seed(42) n <- 400 state <- sample(1:20, n, replace = TRUE) treat <- ifelse(state <= 10, 1, 0) post <- sample(0:1, n, replace = TRUE) x1 <- rnorm(n) y <- 10 + 2 * treat + 1.5 * post + 3.2 * (treat * post) + 0.5 * x1 + rnorm(n, sd = 2) df <- data.frame(y, treat, post, state, x1) did(y ~ treat * post + x1, data = df, cluster = "state")
Tests for first-order autocorrelation in dynamic models containing a lagged dependent variable, where the standard Durbin-Watson d test is biased toward 2 (Durbin, 1970).
durbin_h(model, lag_var = NULL, digits = 4)durbin_h(model, lag_var = NULL, digits = 4)
model |
A fitted |
lag_var |
Optional character name of the lagged dependent variable. If |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_durbin_h.
data(macro_data, package = "phoring") n <- nrow(macro_data) macro_data$inf_lag <- c(NA, macro_data$inflation[-n]) m <- reg(inflation ~ inf_lag + unemployment, data = macro_data[-1, ]) durbin_h(m, lag_var = "inf_lag")data(macro_data, package = "phoring") n <- nrow(macro_data) macro_data$inf_lag <- c(NA, macro_data$inflation[-n]) m <- reg(inflation ~ inf_lag + unemployment, data = macro_data[-1, ]) durbin_h(m, lag_var = "inf_lag")
Implements dynamic time series models, autoregressive distributed lags, serial correlation corrections, error correction models, and vector autoregressions.
Estimates an Error Correction Model based on the Granger Representation Theorem (Engle and Granger, 1987), capturing both short-run dynamic responses and the speed of adjustment towards long-run cointegrating equilibrium.
ecm(formula, data, lags = 1, digits = 4)ecm(formula, data, lags = 1, digits = 4)
formula |
Model formula (e.g., |
data |
A data.frame containing the cointegrated time series. |
lags |
Number of short-run difference lags to include (default is 1). |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_ecm.
data(macro_data, package = "phoring") ecm(inflation ~ unemployment + fed_funds, data = macro_data, lags = 1)data(macro_data, package = "phoring") ecm(inflation ~ unemployment + fed_funds, data = macro_data, lags = 1)
Generates clean, publication-grade academic diagnostic plots with serif typography, L-frame axes, and standardized econometric styling across all models in the package.
econ_plot( x, which = c("all", "resid_fitted", "qq", "scale_location", "cooks", "leverage", "added_var", "component_resid", "dfbetas", "forest", "vif", "histogram", "observed_fitted", "cusum", "cusum_sq", "cusum_squares", "stability", "influence", "influence_plot"), ... ) ## S3 method for class 'econ_reg' plot( x, y = NULL, which = c("all", "resid_fitted", "qq", "scale_location", "cooks", "leverage", "added_var", "component_resid", "dfbetas", "forest", "vif", "histogram", "observed_fitted", "cusum", "cusum_sq", "cusum_squares", "stability", "influence", "influence_plot"), ... )econ_plot( x, which = c("all", "resid_fitted", "qq", "scale_location", "cooks", "leverage", "added_var", "component_resid", "dfbetas", "forest", "vif", "histogram", "observed_fitted", "cusum", "cusum_sq", "cusum_squares", "stability", "influence", "influence_plot"), ... ) ## S3 method for class 'econ_reg' plot( x, y = NULL, which = c("all", "resid_fitted", "qq", "scale_location", "cooks", "leverage", "added_var", "component_resid", "dfbetas", "forest", "vif", "histogram", "observed_fitted", "cusum", "cusum_sq", "cusum_squares", "stability", "influence", "influence_plot"), ... )
x |
An object of class |
which |
Character string or vector specifying which plot(s) to draw:
|
... |
Additional graphical parameters. |
y |
Unused, for compatibility with generic. |
Invisibly returns x.
data(wage_data, package = "phoring") mod <- reg(wage ~ educ + exper, data = wage_data) econ_plot(mod) plot(mod, which = "leverage") plot(mod, which = "cusum_sq")data(wage_data, package = "phoring") mod <- reg(wage ~ educ + exper, data = wage_data) econ_plot(mod) plot(mod, which = "leverage") plot(mod, which = "cusum_sq")
A balanced panel dataset of 40 manufacturing firms observed annually over 5 years (2019-2023), totaling 200 observations. Modeled after the classic Grunfeld investment panel. Ideal for Fixed Effects (Within), Random Effects (GLS), and the Hausman specification test.
firm_investmentfirm_investment
A data frame with 200 rows and 5 variables:
Firm identifier (1 to 40)
Year of observation (2019 to 2023)
Gross corporate capital investment
Market value of the firm
Real value of plant and equipment capital stock
Modeled after Grunfeld (1958) corporate investment panel.
Tests for heteroskedasticity by ordering the sample according to a regressor, omitting central observations, and testing whether the error variance differs significantly between the lower and upper subsamples (Goldfeld and Quandt, 1965).
gq_test(formula, split_by = NULL, data = NULL, omit_fraction = 0.2, digits = 4)gq_test(formula, split_by = NULL, data = NULL, omit_fraction = 0.2, digits = 4)
formula |
Model formula (e.g., |
split_by |
Character name of the explanatory variable to sort by. If |
data |
A data.frame containing the variables (required if formula is used). |
omit_fraction |
Fraction of central observations to omit (default is 0.20, roughly 1/5th). |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_gq.
data(wage_data, package = "phoring") gq_test(wage ~ educ + exper, split_by = "educ", data = wage_data)data(wage_data, package = "phoring") gq_test(wage ~ educ + exper, split_by = "educ", data = wage_data)
Tests whether past values of X forecast Y, and whether past values of Y forecast X.
granger(formula, data, lags = 2, digits = 4)granger(formula, data, lags = 2, digits = 4)
formula |
Model formula specifying bivariate relationship |
data |
A data.frame containing the time series. |
lags |
Number of autoregressive lags to include (default is 2). |
digits |
Number of decimals to display (default is 4). |
An object of class econ_granger.
data(macro_data, package = "phoring") granger(inflation ~ fed_funds, data = macro_data, lags = 2)data(macro_data, package = "phoring") granger(inflation ~ fed_funds, data = macro_data, lags = 2)
A cross-sectional dataset of 506 housing tracts modeled after the classic Boston housing study (Harrison & Rubinfeld, 1978). Ideal for multiple regression, heteroskedasticity testing (Breusch-Pagan, White), and Ramsey RESET functional form tests.
house_priceshouse_prices
A data frame with 506 rows and 7 variables:
Median value of owner-occupied homes in $1,000s
Average number of rooms per dwelling
Per capita crime rate by town
Nitric oxides concentration (parts per 10 million)
Weighted distances to five employment centres
Full-value property-tax rate per $10,000
Pupil-teacher ratio by town school district
Modeled after Harrison and Rubinfeld (1978) hedonic housing study.
Automatically inspects regression functional forms (log-log, log-level, level-log, level-level) and provides human-readable, plain-English economic interpretations for every coefficient, including elasticities, semi-elasticities, percentage effects, and quadratic turning points.
interpret(model, digits = 4)interpret(model, digits = 4)
model |
An |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_interpret containing interpretation summaries.
data(wage_data, package = "phoring") # Quadratic wage equation mod <- reg(wage ~ educ + exper + I(exper^2), data = wage_data) interpret(mod) # Log-log elasticity model data(house_prices, package = "phoring") mod_log <- reg(log(price) ~ log(rooms) + crime, data = house_prices) interpret(mod_log)data(wage_data, package = "phoring") # Quadratic wage equation mod <- reg(wage ~ educ + exper + I(exper^2), data = wage_data) interpret(mod) # Log-log elasticity model data(house_prices, package = "phoring") mod_log <- reg(log(price) ~ log(rooms) + crime, data = house_prices) interpret(mod_log)
Fits a Two-Stage Least Squares (2SLS) instrumental variables regression model, calculates robust or clustered standard errors, and automatically runs diagnostic tests (Weak Instruments First-Stage F, Wu-Hausman Endogeneity, and Sargan Overidentifying Restrictions).
iv( formula, data, se = c("robust", "standard", "cluster"), cluster = NULL, digits = 4, ... )iv( formula, data, se = c("robust", "standard", "cluster"), cluster = NULL, digits = 4, ... )
formula |
Two-part formula separated by |
data |
A data.frame containing the variables in the model. |
se |
Type of standard errors to compute: |
cluster |
Vector or column name indicating cluster grouping. |
digits |
Number of decimal places to display in output tables (default is 4). |
... |
Additional arguments. |
An object of class econ_iv containing 2SLS estimates, diagnostics,
and standard errors.
data(wage_data, package = "phoring") iv(wage ~ exper + educ | exper + mother_educ, data = wage_data) iv(wage ~ exper | educ ~ mother_educ + father_educ, data = wage_data)data(wage_data, package = "phoring") iv(wage ~ exper + educ | exper + mother_educ, data = wage_data) iv(wage ~ exper | educ ~ mother_educ + father_educ, data = wage_data)
Tests competing non-nested econometric models (neither model is a subset of the other), following the specification testing framework of Davidson and MacKinnon (1981).
j_test(model1, model2, data = NULL, digits = 4)j_test(model1, model2, data = NULL, digits = 4)
model1 |
Fitted model object or formula for Model 1. |
model2 |
Fitted model object or formula for Model 2. |
data |
A data.frame containing variables (required if formulas are passed). |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_jtest.
data(wage_data, package = "phoring") # Model 1: Education & Experience vs. Model 2: Tenure & Mother's Education m1 <- reg(wage ~ educ + exper, data = wage_data) m2 <- reg(wage ~ tenure + mother_educ, data = wage_data) j_test(m1, m2)data(wage_data, package = "phoring") # Model 1: Education & Experience vs. Model 2: Tenure & Mother's Education m1 <- reg(wage ~ educ + exper, data = wage_data) m2 <- reg(wage ~ tenure + mother_educ, data = wage_data) j_test(m1, m2)
Estimates geometric distributed lag models using the Koyck transformation (Koyck, 1954), computing the Short-Run Multiplier, Long-Run Multiplier, Rate of Decay, Median Lag, and Mean Lag.
koyck(formula, data, method = c("ols", "iv"), digits = 4)koyck(formula, data, method = c("ols", "iv"), digits = 4)
formula |
Model formula with one explanatory variable (e.g., |
data |
A data.frame containing the time series. |
method |
Estimation method: |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_koyck.
data(macro_data, package = "phoring") koyck(inflation ~ unemployment, data = macro_data, method = "ols") koyck(inflation ~ unemployment, data = macro_data, method = "iv")data(macro_data, package = "phoring") koyck(inflation ~ unemployment, data = macro_data, method = "ols") koyck(inflation ~ unemployment, data = macro_data, method = "iv")
A microeconometric cross-section of 753 married women modeled after Mroz (1987). Ideal for binary choice estimation via Logit, Probit, and computing Average Marginal Effects (AME).
labor_supplylabor_supply
A data frame with 753 rows and 7 variables:
Binary indicator: 1 if woman worked in the labor force, 0 otherwise
Non-wife family household income (in $1,000s)
Years of schooling
Years of past work experience
Age in years
Number of young children under 6 years old
Number of older children between 6 and 18 years old
Annual hours worked (0 for non-working women, ideal for Tobit)
Annual doctor visits (integer count, ideal for Poisson regression)
Modeled after Mroz (1987), "The Sensitivity of an Empirical Model of Married Women's Hours of Work".
Fits logistic regression (Logit) or probit regression (Probit) models, computes robust Huber-White or clustered standard errors, reports odds ratios (for logit), ROC-AUC, classification accuracy, and calculates Average Marginal Effects (AME) with delta-method standard errors.
logit( formula, data, se = c("robust", "standard", "cluster"), cluster = NULL, digits = 4, ... ) probit( formula, data, se = c("robust", "standard", "cluster"), cluster = NULL, digits = 4, ... )logit( formula, data, se = c("robust", "standard", "cluster"), cluster = NULL, digits = 4, ... ) probit( formula, data, se = c("robust", "standard", "cluster"), cluster = NULL, digits = 4, ... )
formula |
Model formula (e.g., |
data |
A data.frame containing the variables. |
se |
Type of standard errors: |
cluster |
Vector or column name for cluster-robust standard errors. |
digits |
Number of decimal places to display (default is 4). |
... |
Additional arguments passed to |
An object of class econ_logit containing index estimates, odds ratios,
average marginal effects (AME), and model diagnostics.
data(mtcars) logit(am ~ mpg + hp, data = mtcars) probit(am ~ mpg + hp, data = mtcars)data(mtcars) logit(am ~ mpg + hp, data = mtcars) probit(am ~ mpg + hp, data = mtcars)
A quarterly macroeconomic time series dataset spanning 120 quarters (1994Q1 to 2023Q4). Designed for time series regressions, serial correlation testing (Durbin-Watson, Breusch-Godfrey), and Newey-West HAC standard errors.
macro_datamacro_data
A data frame with 120 rows and 5 variables:
Calendar quarter (e.g., "1994Q1" to "2023Q4")
Annualized CPI inflation rate (percentage)
Civilian unemployment rate (percentage)
Federal funds effective interest rate (percentage)
Annualized real GDP growth rate (percentage)
Simulated based on US macroeconomic time series dynamics.
A Difference-in-Differences evaluation dataset of 400 fast-food restaurants in New Jersey (treated state) and eastern Pennsylvania (control state) observed before and after New Jersey's minimum wage increase.
min_wagemin_wage
A data frame with 400 rows and 5 variables:
Store identifier (1 to 400)
Fast-food chain name (Burger King, KFC, Roy Rogers, Wendys)
State indicator: 1 if New Jersey (treated), 0 if Pennsylvania (control)
Time period: 1 if after the wage hike, 0 if before
Full-time equivalent employment at the restaurant
Modeled after Card and Krueger (1994) minimum wage study.
Automatically computes Cook's Distance, studentized residuals, and leverage (hat values) for regression models, flagging influential data points that could distort econometric estimates.
outliers(model, top_n = 5, digits = 4)outliers(model, top_n = 5, digits = 4)
model |
An |
top_n |
Number of top influential observations to display (default is 5). |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_outliers.
data(wage_data, package = "phoring") mod <- reg(wage ~ educ + exper, data = wage_data) outliers(mod)data(wage_data, package = "phoring") mod <- reg(wage ~ educ + exper, data = wage_data) outliers(mod)
Fits panel data models (Fixed Effects, Two-Way Fixed Effects, Random Effects, First Differences, Between Estimator, or Pooled OLS) with customizable standard errors (clustered by entity id, White robust, or classical standard) and automatically executes the Hausman test, Breusch-Pagan LM test, and Wooldridge panel autocorrelation test.
panel( formula, data, id, time = NULL, model = c("fe", "twfe", "re", "fd", "between", "pooling"), se = c("cluster", "robust", "standard"), digits = 4, ... )panel( formula, data, id, time = NULL, model = c("fe", "twfe", "re", "fd", "between", "pooling"), se = c("cluster", "robust", "standard"), digits = 4, ... )
formula |
Model formula (e.g., |
data |
A data.frame containing the panel data. |
id |
Column name (or unquoted symbol) indicating the entity/group identifier. |
time |
Column name (or unquoted symbol) indicating the time period (optional, required for TWFE and FD). |
model |
Model type: |
se |
Type of standard errors: |
digits |
Number of decimal places to display (default is 4). |
... |
Additional arguments. |
An object of class econ_panel containing estimates, standard errors,
and panel diagnostics.
data(firm_investment, package = "phoring") # 1. Entity Fixed Effects (Within) panel(inv ~ value + capital, data = firm_investment, id = "firm_id", time = "year", model = "fe") # 2. Two-Way Fixed Effects (Entity + Time FE) panel(inv ~ value + capital, data = firm_investment, id = "firm_id", time = "year", model = "twfe") # 3. Random Effects (GLS) panel(inv ~ value + capital, data = firm_investment, id = "firm_id", time = "year", model = "re")data(firm_investment, package = "phoring") # 1. Entity Fixed Effects (Within) panel(inv ~ value + capital, data = firm_investment, id = "firm_id", time = "year", model = "fe") # 2. Two-Way Fixed Effects (Entity + Time FE) panel(inv ~ value + capital, data = firm_investment, id = "firm_id", time = "year", model = "twfe") # 3. Random Effects (GLS) panel(inv ~ value + capital, data = firm_investment, id = "firm_id", time = "year", model = "re")
Generates an academic publication-grade ARCH volatility suite:
(1) "residuals": Raw regression residuals,
(2) "squared_residuals": Squared residuals (volatility clustering),
(3) "acf_sq": Autocorrelations of squared residuals,
(4) "dist": Residual histogram with fitted normal curve,
(5) "qq": Normal Q-Q plot of residuals,
(6) "rolling_sd": Rolling standard deviation of residuals over time.
## S3 method for class 'econ_arch' plot( x, y = NULL, which = c("all", "residuals", "squared_residuals", "acf_sq", "dist", "qq", "rolling_sd"), ... )## S3 method for class 'econ_arch' plot( x, y = NULL, which = c("all", "residuals", "squared_residuals", "acf_sq", "dist", "qq", "rolling_sd"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade ARDL dynamics suite:
(1) "all": 6-panel comprehensive academic dashboard (Actual vs. Fitted, Residuals, ACF, Multipliers, CUSUM, CUSUM of Squares),
(2) "fit": Actual vs. fitted trajectories over time,
(3) "residuals": ARDL residuals over time,
(4) "acf": Autocorrelation of residuals,
(5) "multipliers": Short-run impact vs. long-run multiplier bar comparison,
(6) "cusum": CUSUM parameter stability test with 5% critical bounds,
(7) "cusum_sq" / "cusum_squares": Brown-Durbin-Evans CUSUM of squares variance & parameter stability test with 5% critical bounds,
(8) "stability": Side-by-side CUSUM and CUSUM of squares stability panel,
(9) "bounds": Pesaran-Shin-Smith (2001) Bounds Testing cointegration diagnostic diagram,
(10) "cumulative_multipliers": Cumulative interim dynamic multiplier curve.
## S3 method for class 'econ_ardl' plot( x, y = NULL, which = c("all", "fit", "residuals", "acf", "multipliers", "cusum", "cusum_sq", "cusum_squares", "stability", "bounds", "cumulative_multipliers"), ... )## S3 method for class 'econ_ardl' plot( x, y = NULL, which = c("all", "fit", "residuals", "acf", "multipliers", "cusum", "cusum_sq", "cusum_squares", "stability", "bounds", "cumulative_multipliers"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade Chow structural stability suite:
(1) "scatter": Outcome vs. predictor scatter showing separate subgroup regression slopes vs. pooled line,
(2) "f_stat": Chow F-statistic comparison vs. 5% critical F value.
## S3 method for class 'econ_chow' plot(x, y = NULL, which = c("all", "scatter", "f_stat"), ...)## S3 method for class 'econ_chow' plot(x, y = NULL, which = c("all", "scatter", "f_stat"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade cointegration diagnostic suite:
(1) "comovement": Normalized series comovement overlay,
(2) "residuals": Cointegrating error-correction residuals with MacKinnon boundary,
(3) "acf_residuals": Autocorrelation of cointegrating residuals,
(4) "scatter_regression": Scatter of outcome vs. predictor with long-run regression line.
## S3 method for class 'econ_coint' plot( x, y = NULL, which = c("all", "comovement", "residuals", "acf_residuals", "scatter_regression"), ... )## S3 method for class 'econ_coint' plot( x, y = NULL, which = c("all", "comovement", "residuals", "acf_residuals", "scatter_regression"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Displays an academic publication-grade correlation matrix heatmap with serif typography, numeric values overlaid, and significance indicators.
## S3 method for class 'econ_corr' plot(x, y = NULL, which = c("all", "heatmap"), ...)## S3 method for class 'econ_corr' plot(x, y = NULL, which = c("all", "heatmap"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string specifying which plot to produce ( |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade count regression diagnostic suite:
(1) "rootogram": Kleiber-Zeileis hanging rootogram of observed vs. expected count frequencies,
(2) "freq_bars": Grouped bar comparison of observed vs. expected counts,
(3) "mean_variance": Binned mean vs. variance curve (testing equidispersion),
(4) "residuals": Pearson residuals vs. fitted counts,
(5) "irr_forest": Incidence Rate Ratio (IRR) forest plot CI.
## S3 method for class 'econ_count' plot( x, y = NULL, which = c("all", "rootogram", "freq_bars", "mean_variance", "residuals", "irr_forest"), ... )## S3 method for class 'econ_count' plot( x, y = NULL, which = c("all", "rootogram", "freq_bars", "mean_variance", "residuals", "irr_forest"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade distribution grid for numeric variables in descriptive summaries:
(1) "histogram": Histograms with fitted kernel density curves,
(2) "boxplot": Standardized boxplots across variables.
## S3 method for class 'econ_desc' plot(x, y = NULL, which = c("all", "histogram", "boxplot"), ...)## S3 method for class 'econ_desc' plot(x, y = NULL, which = c("all", "histogram", "boxplot"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade Love plot showing standardized mean differences
(normalized differences) between treatment and control groups alongside the balance threshold.
## S3 method for class 'econ_desc_balance' plot(x, y = NULL, which = c("all", "love"), ...)## S3 method for class 'econ_desc_balance' plot(x, y = NULL, which = c("all", "love"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string specifying which plot to produce ( |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade summary dashboard of diagnostic test results:
(1) "pvalues": Horizontal bar chart of for all specification tests
(RESET, Breusch-Pagan, White, Jarque-Bera, Durbin-Watson, Breusch-Godfrey) with the 0.05 critical boundary,
(2) "vif": Variance Inflation Factors (VIF) bar chart with 5 and 10 multicollinearity reference lines.
## S3 method for class 'econ_diagnostics' plot(x, y = NULL, which = c("all", "pvalues", "vif"), ...)## S3 method for class 'econ_diagnostics' plot(x, y = NULL, which = c("all", "pvalues", "vif"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade DiD suite:
(1) "trajectory": 2x2 Pre/Post trajectories with treatment effect counterfactual,
(2) "means_ci": 2x2 Cell group means with 95% confidence intervals,
(3) "comparison": DiD estimate comparison vs. naive post-only and pre/post estimates,
(4) "event_study": Group averages over calendar time and event-study dynamics.
## S3 method for class 'econ_did' plot( x, y = NULL, which = c("all", "trajectory", "means_ci", "comparison", "event_study"), ... )## S3 method for class 'econ_did' plot( x, y = NULL, which = c("all", "trajectory", "means_ci", "comparison", "event_study"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Displays standard normal null density with rejection regions and Durbin's h test statistic.
## S3 method for class 'econ_durbin_h' plot(x, y = NULL, which = c("all", "density"), ...)## S3 method for class 'econ_durbin_h' plot(x, y = NULL, which = c("all", "density"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string specifying which plot to produce ( |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade ECM dynamics suite:
(1) "fit": Actual vs. fitted first differences ,
(2) "residuals": ECM dynamic residuals,
(3) "decay_path": Speed of adjustment disequilibrium decay path ,
(4) "acf_residuals": Autocorrelation function of ECM residuals,
(5) "cusum": CUSUM parameter stability test with 5% bounds,
(6) "cusum_sq": CUSUM of squares stability test with 5% bounds,
(7) "stability": Side-by-side CUSUM and CUSUMSQ stability panel.
## S3 method for class 'econ_ecm' plot( x, y = NULL, which = c("all", "fit", "residuals", "decay_path", "acf_residuals", "cusum", "cusum_sq", "cusum_squares", "stability"), ... )## S3 method for class 'econ_ecm' plot( x, y = NULL, which = c("all", "fit", "residuals", "decay_path", "acf_residuals", "cusum", "cusum_sq", "cusum_squares", "stability"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade Goldfeld-Quandt diagnostic plot:
(1) "residuals": Residuals ordered by the sorting variable, highlighting the two subsamples and omitted central observations,
(2) "distribution": Theoretical F-distribution with the GQ test statistic and rejection threshold.
## S3 method for class 'econ_gq' plot(x, y = NULL, which = c("all", "residuals", "distribution"), ...)## S3 method for class 'econ_gq' plot(x, y = NULL, which = c("all", "residuals", "distribution"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade Granger causality suite:
(1) "timeseries": Standardized time series trajectories,
(2) "ccf": Cross-correlation function (CCF) across leads and lags,
(3) "f_stats": Bidirectional F-statistic comparison vs. 5% critical F value.
## S3 method for class 'econ_granger' plot(x, y = NULL, which = c("all", "timeseries", "ccf", "f_stats"), ...)## S3 method for class 'econ_granger' plot(x, y = NULL, which = c("all", "timeseries", "ccf", "f_stats"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Displays the theoretical null distribution (F or Chi-Square) with the rejection region and Wald statistic.
## S3 method for class 'econ_hyp' plot(x, y = NULL, which = c("all", "density"), ...)## S3 method for class 'econ_hyp' plot(x, y = NULL, which = c("all", "density"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string specifying which plot to produce ( |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade 2SLS identification suite:
(1) "first_stage": First-Stage Fit: Endogenous vs. Instrument with -stat,
(2) "second_stage": Second Stage: Outcome vs. Predicted Endogenous ,
(3) "residuals": 2SLS Residuals vs. Fitted values,
(4) "orthogonality": Instrument Exogeneity Check: Residuals vs. Instrument ,
(5) "forest_compare": OLS vs. 2SLS Coefficient Comparison Forest Plot,
(6) "f_stat": First-stage F-statistic vs. Stock-Yogo rule of thumb (F = 10),
(7) "reduced_form": Reduced form regression of on .
## S3 method for class 'econ_iv' plot( x, y = NULL, which = c("all", "first_stage", "second_stage", "residuals", "orthogonality", "forest_compare", "f_stat", "reduced_form"), ... )## S3 method for class 'econ_iv' plot( x, y = NULL, which = c("all", "first_stage", "second_stage", "residuals", "orthogonality", "forest_compare", "f_stat", "reduced_form"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade J-test comparison bar chart showing the t-statistics
for competing non-nested models against the critical thresholds.
## S3 method for class 'econ_jtest' plot(x, y = NULL, which = c("all", "bars"), ...)## S3 method for class 'econ_jtest' plot(x, y = NULL, which = c("all", "bars"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string specifying which plot to produce ( |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade Koyck distributed lag suite:
(1) "lag_weights": Geometric lag decay weights across horizons,
(2) "cumulative": Cumulative interim multipliers approaching long-run effect,
(3) "actual_fitted": Actual vs. fitted values over time,
(4) "acf_residuals": Autocorrelation function of Koyck residuals.
## S3 method for class 'econ_koyck' plot( x, y = NULL, which = c("all", "lag_weights", "cumulative", "actual_fitted", "acf_residuals", "cusum", "cusum_sq", "cusum_squares", "stability"), horizons = 12, ... )## S3 method for class 'econ_koyck' plot( x, y = NULL, which = c("all", "lag_weights", "cumulative", "actual_fitted", "acf_residuals", "cusum", "cusum_sq", "cusum_squares", "stability"), horizons = 12, ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
horizons |
Integer specifying the number of lag horizons to plot (default 12). |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade classification and link diagnostics suite:
(1) "scurve": S-Curve sigmoid probability curve vs. linear predictor ,
(2) "roc": Receiver Operating Characteristic (ROC) curve with AUC annotation,
(3) "distribution": Class separation boxplots of predicted probabilities by observed class,
(4) "residuals": Deviance residuals vs. predicted probabilities,
(5) "calibration": Hosmer-Lemeshow decile calibration plot with 45-degree reference line,
(6) "thresholds": Sensitivity & Specificity curves vs. cutoff with Youden's optimal threshold,
(7) "marginal": Marginal probability curve across continuous predictor,
(8) "odds_ratio": Odds ratios forest plot (for logit) with 95% CIs on log scale,
(9) "confusion": Confusion matrix classification tile heatmap at threshold 0.5.
## S3 method for class 'econ_logit' plot( x, y = NULL, which = c("all", "scurve", "roc", "distribution", "residuals", "calibration", "thresholds", "marginal", "odds_ratio", "confusion"), ... )## S3 method for class 'econ_logit' plot( x, y = NULL, which = c("all", "scurve", "roc", "distribution", "residuals", "calibration", "thresholds", "marginal", "odds_ratio", "confusion"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade outlier influence suite:
(1) "influence": Influence bubble plot (Studentized residuals vs. Leverage, bubble size = Cook's D),
(2) "cooks": Cook's distance index barplot with 4/n threshold.
## S3 method for class 'econ_outliers' plot(x, y = NULL, which = c("all", "influence", "cooks"), ...)## S3 method for class 'econ_outliers' plot(x, y = NULL, which = c("all", "influence", "cooks"), ...)
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade panel diagnostics suite or individual plots:
(1) "between": Between-entity variation in group means with between regression line,
(2) "within": Within-entity demeaned scatter with within regression slope,
(3) "spaghetti": Entity trajectories over time with mean trend,
(4) "fe_dist": Distribution of estimated individual fixed effects ,
(5) "heterogeneity": Individual entity residual boxplots,
(6) "residuals": Panel residuals vs. fitted values with LOESS smoother,
(7) "ar_residual": Residual vs. lagged within-entity residual vs (Wooldridge AR(1) test),
(8) "time_effects": Period mean residuals CI across time.
## S3 method for class 'econ_panel' plot( x, y = NULL, which = c("all", "between", "within", "spaghetti", "fe_dist", "heterogeneity", "residuals", "ar_residual", "time_effects"), ... )## S3 method for class 'econ_panel' plot( x, y = NULL, which = c("all", "between", "within", "spaghetti", "fe_dist", "heterogeneity", "residuals", "ar_residual", "time_effects"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade serial correlation correction suite:
(1) "fitted": Actual vs. FGLS fitted values,
(2) "residuals": Transformed quasi-differenced residuals,
(3) "acf": Autocorrelation function of transformed residuals,
(4) "ar_scatter": vs. scatter comparing OLS vs. FGLS residuals with slope.
## S3 method for class 'econ_prais' plot( x, y = NULL, which = c("all", "fitted", "residuals", "acf", "ar_scatter", "cusum", "cusum_sq", "cusum_squares", "stability"), ... )## S3 method for class 'econ_prais' plot( x, y = NULL, which = c("all", "fitted", "residuals", "acf", "ar_scatter", "cusum", "cusum_sq", "cusum_squares", "stability"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade quantile process suite:
(1) "process": Coefficient path across quantiles with 95% pointwise CI band,
alongside the horizontal OLS benchmark estimate and 95% confidence interval,
(2) "loss": Total check-loss across quantiles ,
(3) "fitted_scatter": Scatter of outcome vs. predictor with fitted quantile lines.
## S3 method for class 'econ_qreg' plot( x, y = NULL, var = NULL, which = c("all", "process", "loss", "fitted_scatter"), ... )## S3 method for class 'econ_qreg' plot( x, y = NULL, var = NULL, which = c("all", "process", "loss", "fitted_scatter"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
var |
Character string specifying which coefficient to plot. Defaults to first non-intercept predictor. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade RDD identification suite:
(1) "binned_rd": Binned RD scatter plot with local polynomial fits and 95% confidence bands,
(2) "density": Running variable density histogram with discontinuity check around cutoff,
(3) "bandwidth_sensitivity": Point estimate CI across bandwidths,
(4) "placebo": Placebo cutoff falsification test.
## S3 method for class 'econ_rdd' plot( x, y = NULL, which = c("all", "binned_rd", "density", "bandwidth_sensitivity", "placebo"), ... )## S3 method for class 'econ_rdd' plot( x, y = NULL, which = c("all", "binned_rd", "density", "bandwidth_sensitivity", "placebo"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade Tobit diagnostic suite:
(1) "observed_hist": Observed histogram highlighting censoring pile-up,
(2) "pred_observed": Observed vs. unconditional predicted ,
(3) "mcdonald_moffitt": McDonald-Moffitt marginal decomposition (extensive vs. intensive margin),
(4) "qq_resid": Normal Q-Q plot of residuals for uncensored observations,
(5) "residuals": Censored residuals vs. linear index.
## S3 method for class 'econ_tobit' plot( x, y = NULL, which = c("all", "observed_hist", "pred_observed", "mcdonald_moffitt", "qq_resid", "residuals"), ... )## S3 method for class 'econ_tobit' plot( x, y = NULL, which = c("all", "observed_hist", "pred_observed", "mcdonald_moffitt", "qq_resid", "residuals"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade time-series stationarity suite:
(1) "levels": Series levels over time,
(2) "diffs": First differences over time,
(3) "acf_levels": Autocorrelation of levels,
(4) "acf_diffs": Autocorrelation of first differences,
(5) "pacf": Partial autocorrelations of levels and differences,
(6) "dashboard": Test statistic dashboard (ADF, PP, KPSS vs. 5% critical values).
## S3 method for class 'econ_unit_root' plot( x, y = NULL, which = c("all", "levels", "diffs", "acf_levels", "acf_diffs", "pacf", "dashboard"), ... )## S3 method for class 'econ_unit_root' plot( x, y = NULL, which = c("all", "levels", "diffs", "acf_levels", "acf_diffs", "pacf", "dashboard"), ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
... |
Additional graphical parameters. |
Invisibly returns x.
Generates an academic publication-grade VAR dynamics suite:
(1) "stability": Inverse roots of companion matrix characteristic polynomial on the complex unit circle,
(2) "irf": Orthogonalized Impulse Response Functions (IRF) grid across horizons,
(3) "fevd": Forecast Error Variance Decomposition (FEVD) stacked bars,
(4) "residuals": Residuals across equations over time,
(5) "correlation": Innovation covariance/correlation heatmap,
(6) "acf": Autocorrelation function of residuals for each equation,
(7) "granger": Granger causality p-value heatmap matrix.
## S3 method for class 'econ_var' plot( x, y = NULL, which = c("all", "stability", "irf", "fevd", "residuals", "correlation", "acf", "granger"), horizons = 10, ... )## S3 method for class 'econ_var' plot( x, y = NULL, which = c("all", "stability", "irf", "fevd", "residuals", "correlation", "acf", "granger"), horizons = 10, ... )
x |
An object of class |
y |
Unused, for compatibility with generic. |
which |
Character string or vector specifying which plot to produce: |
horizons |
Number of horizons for IRF and FEVD (default 10). |
... |
Additional graphical parameters. |
Invisibly returns x.
Fits Feasible Generalized Least Squares (FGLS) to correct for first-order AR(1) serial correlation (Prais and Winsten, 1954; Cochrane and Orcutt, 1949), using Prais-Winsten (retaining the first observation) or Cochrane-Orcutt transformation until convergence.
prais_winsten( formula, data, method = c("prais", "cochrane"), max_iter = 50, tol = 1e-04, digits = 4 )prais_winsten( formula, data, method = c("prais", "cochrane"), max_iter = 50, tol = 1e-04, digits = 4 )
formula |
Model formula (e.g., |
data |
A data.frame containing time series variables. |
method |
Either |
max_iter |
Maximum iterations for rho convergence (default is 50). |
tol |
Convergence tolerance (default is 1e-4). |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_prais.
data(macro_data, package = "phoring") prais_winsten(inflation ~ fed_funds + unemployment, data = macro_data)data(macro_data, package = "phoring") prais_winsten(inflation ~ fed_funds + unemployment, data = macro_data)
Estimates quantile regressions for single or multiple conditional quantiles (e.g., 10th, 25th, median 50th, 75th, 90th percentiles), allowing researchers to analyze how economic covariates impact different parts of the outcome distribution beyond the conditional mean.
qreg( formula, data, tau = c(0.1, 0.25, 0.5, 0.75, 0.9), se = c("robust", "classical"), digits = 4 )qreg( formula, data, tau = c(0.1, 0.25, 0.5, 0.75, 0.9), se = c("robust", "classical"), digits = 4 )
formula |
Model formula (e.g., |
data |
A data.frame containing the variables. |
tau |
Quantile(s) to estimate, between 0 and 1 (default is |
se |
Standard error type: |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_qreg.
data(wage_data, package = "phoring") # Estimate median regression (tau = 0.5) qreg(wage ~ educ + exper, data = wage_data, tau = 0.5) # Estimate full distribution quantiles (10%, 25%, 50%, 75%, 90%) q_all <- qreg(wage ~ educ + exper, data = wage_data, tau = c(0.25, 0.5, 0.75))data(wage_data, package = "phoring") # Estimate median regression (tau = 0.5) qreg(wage ~ educ + exper, data = wage_data, tau = 0.5) # Estimate full distribution quantiles (10%, 25%, 50%, 75%, 90%) q_all <- qreg(wage ~ educ + exper, data = wage_data, tau = c(0.25, 0.5, 0.75))
Estimates causal treatment effects at a policy cutoff using Sharp Regression Discontinuity (SRD) with local linear regression, optimal bandwidth selection, triangular/uniform kernel weights, and robust standard errors.
rdd( formula, data, cutoff = 0, bandwidth = NULL, kernel = c("triangular", "uniform"), digits = 4 )rdd( formula, data, cutoff = 0, bandwidth = NULL, kernel = c("triangular", "uniform"), digits = 4 )
formula |
Model formula where the first RHS variable is the running variable
(e.g., |
data |
A data.frame containing the variables. |
cutoff |
Threshold value of the running variable that determines treatment (default is 0). |
bandwidth |
Bandwidth window around the cutoff. If |
kernel |
Kernel weighting function: |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_rdd.
set.seed(42) n <- 500 x <- runif(n, -2, 2) d <- as.numeric(x >= 0) y <- 2 + 3 * d + 1.5 * x + 0.8 * d * x + rnorm(n, sd = 0.5) df <- data.frame(y = y, score = x) rdd(y ~ score, data = df, cutoff = 0)set.seed(42) n <- 500 x <- runif(n, -2, 2) d <- as.numeric(x >= 0) y <- 2 + 3 * d + 1.5 * x + 0.8 * d * x + rnorm(n, sd = 0.5) df <- data.frame(y = y, score = x) rdd(y ~ score, data = df, cutoff = 0)
Fits an Ordinary Least Squares (OLS) or Weighted Least Squares (WLS) regression model, calculates robust (HC0-HC3), clustered, or HAC standard errors, and automatically runs and prints a complete battery of econometric diagnostic tests.
reg( formula, data, se = c("robust", "standard", "cluster", "hac", "HC0", "HC1", "HC2", "HC3"), cluster = NULL, lag = NULL, weights = NULL, digits = 4, diagnostics = TRUE, ... )reg( formula, data, se = c("robust", "standard", "cluster", "hac", "HC0", "HC1", "HC2", "HC3"), cluster = NULL, lag = NULL, weights = NULL, digits = 4, diagnostics = TRUE, ... )
formula |
An object of class |
data |
A data.frame containing the variables in the model. |
se |
Type of standard errors to compute: |
cluster |
Vector or column name indicating cluster grouping for clustered standard errors. |
lag |
Number of lags for Newey-West HAC standard errors (optional, defaults to automatic rule). |
weights |
Optional weights vector or column name for Weighted Least Squares (WLS). |
digits |
Number of decimal places to display in output tables (default is 4). |
diagnostics |
Logical: whether to automatically compute and display diagnostic tests (default is TRUE). |
... |
Additional arguments passed to |
An object of class econ_reg containing the regression results,
standard errors, coefficient table, model statistics, and diagnostic tests.
data(mtcars) reg(mpg ~ wt + hp + qsec, data = mtcars) reg(mpg ~ wt + hp, data = mtcars, cluster = "cyl")data(mtcars) reg(mpg ~ wt + hp + qsec, data = mtcars) reg(mpg ~ wt + hp, data = mtcars, cluster = "cyl")
Tests linear hypotheses of model parameters using the robust or clustered covariance matrix from the estimated model. Supports interaction terms, factor levels, polynomial terms, and multi-parameter restrictions.
test_hyp(model, hypothesis, ...)test_hyp(model, hypothesis, ...)
model |
A fitted model object from |
hypothesis |
Character vector of linear restrictions (e.g., |
... |
Additional arguments. |
An object of class econ_hyp containing the Wald test statistic,
degrees of freedom, and p-value.
data(mtcars) m <- reg(mpg ~ wt + hp + qsec, data = mtcars) test_hyp(m, "wt + hp = 0") test_hyp(m, c("wt = 0", "hp = 0"))data(mtcars) m <- reg(mpg ~ wt + hp + qsec, data = mtcars) test_hyp(m, "wt + hp = 0") test_hyp(m, c("wt = 0", "hp = 0"))
Provides a comprehensive suite for time series econometrics: 1. 'unit_root()': Multi-test stationarity battery (ADF, Phillips-Perron, KPSS). 2. 'coint()': Engle-Granger two-step cointegration test. 3. 'granger()': Bidirectional Granger causality test. 4. ‘arch_test()': Engle’s ARCH LM test for volatility clustering. 5. 'ardl()': Autoregressive Distributed Lag model with short-run and long-run multipliers.
Fits a Tobit regression model (left-censored at 0 or a user-specified threshold), calculates robust or standard standard errors, and automatically produces the McDonald-Moffitt decomposition of marginal effects.
tobit(formula, data, left = 0, se = c("robust", "standard"), digits = 4)tobit(formula, data, left = 0, se = c("robust", "standard"), digits = 4)
formula |
Model formula (e.g., |
data |
A data.frame containing the variables. |
left |
Left-censoring cutoff point (default is 0). |
se |
Type of standard errors: |
digits |
Number of decimal places to display (default is 4). |
An object of class econ_tobit.
data(labor_supply, package = "phoring") labor_supply$hours <- pmax(labor_supply$hours, 0) tobit(hours ~ educ + exper + age, data = labor_supply, left = 0)data(labor_supply, package = "phoring") labor_supply$hours <- pmax(labor_supply$hours, 0) tobit(hours ~ educ + exper + age, data = labor_supply, left = 0)
Executes Augmented Dickey-Fuller (ADF), Phillips-Perron (PP), and KPSS tests simultaneously with MacKinnon response surface p-values.
unit_root(x, lags = NULL, type = c("trend", "drift", "none"), digits = 4)unit_root(x, lags = NULL, type = c("trend", "drift", "none"), digits = 4)
x |
A numeric vector or time series. |
lags |
Number of lags for ADF test (optional; automatically selected by AIC if NULL). |
type |
Model specification: |
digits |
Number of decimals to display (default is 4). |
An object of class econ_unit_root.
data(macro_data, package = "phoring") unit_root(macro_data$inflation, type = "trend") unit_root(macro_data$unemployment, type = "drift")data(macro_data, package = "phoring") unit_root(macro_data$inflation, type = "trend") unit_root(macro_data$unemployment, type = "drift")
Fits a Vector Autoregression system (Sims, 1980) for multiple time series, computing system equation estimates, information criteria (AIC, BIC), and pairwise Granger causality summary matrices.
var_model(data, vars, p = 1, digits = 4)var_model(data, vars, p = 1, digits = 4)
data |
A data.frame containing numeric time series variables. |
vars |
Character vector of column names to include in the VAR system. |
p |
Lag order (default is 1). |
digits |
Number of decimal places to format (default is 4). |
An object of class econ_var.
data(macro_data, package = "phoring") var_model(macro_data, vars = c("inflation", "unemployment", "fed_funds"), p = 1)data(macro_data, package = "phoring") var_model(macro_data, vars = c("inflation", "unemployment", "fed_funds"), p = 1)
A simulated labor economics dataset modeled after the Mincerian wage equation and empirical labor economics literature. Includes individual characteristics, parental education instruments, firm identifiers for clustering, and panel time periods.
wage_datawage_data
A data frame with 600 observations and 11 variables:
Hourly wage in US dollars
Years of education
Years of labor market experience
Years with current employer
Indicator variable: 1 if female, 0 if male
Indicator variable: 1 if married, 0 otherwise
Mother's years of education (instrument for educ)
Father's years of education (instrument for educ)
Firm identifier for clustering and panel analysis
Year of observation (2020-2023)
Indicator variable: 1 if in labor force / high wage, 0 otherwise
Simulated based on standard labor econometrics specifications.
Compiles multiple econometric models into a single publication-quality table with standard errors in parentheses and significance stars, and exports directly to Microsoft Word (.docx/.doc), HTML, or Markdown.
word_table( ..., labels = NULL, file = NULL, title = "Regression Results", format = c("text", "html", "word"), digits = 3 )word_table( ..., labels = NULL, file = NULL, title = "Regression Results", format = c("text", "html", "word"), digits = 3 )
... |
One or more fitted model objects (from |
labels |
Optional character vector of custom column labels for each model
(e.g., |
file |
Optional filename for export (e.g., |
title |
Title for the table. |
format |
Output display format: |
digits |
Number of decimal places to format (default is 3). |
A list of the input models (invisibly).
data(mtcars) m1 <- reg(mpg ~ wt, data = mtcars) m2 <- reg(mpg ~ wt + hp, data = mtcars) word_table(m1, m2, labels = c("Simple OLS", "Multiple OLS"))data(mtcars) m1 <- reg(mpg ~ wt, data = mtcars) m2 <- reg(mpg ~ wt + hp, data = mtcars) word_table(m1, m2, labels = c("Simple OLS", "Multiple OLS"))