| Title: | Multiple Granger Causality Tests for Time Series and Panel Data |
|---|---|
| Description: | Comprehensive suite of Granger causality tests for time series and panel data. For time series: Toda-Yamamoto (1995) <doi:10.1016/0304-4076(94)01616-8>, Fourier-based tests with single frequency (Enders and Jones, 2016) <doi:10.1515/snde-2014-0101> and cumulative frequencies (Nazlioglu et al., 2019) <doi:10.1080/1540496X.2018.1434072>, quantile causality tests (Cai et al., 2023) <doi:10.1016/j.frl.2023.104327>, and Bootstrap Fourier Granger Causality in Quantiles (Cheng et al., 2021) <doi:10.1007/s12076-020-00263-0>. For panel data: Panel Fourier Toda-Yamamoto (Yilanci and Gorus, 2020) <doi:10.1007/s11356-020-10092-9> and Panel Quantile Causality tests (Wang and Nguyen, 2022) <doi:10.1080/1331677X.2021.1948436>, as well as Group-Mean and Pooled Fully Modified OLS estimators for panel cointegrating polynomial regressions (Wagner and Reichold, 2023) <doi:10.1080/07474938.2023.2178141>. All tests include bootstrap inference for robust p-values. |
| Authors: | Muhammad Alkhalaf [aut, cre, cph]
|
| Maintainer: | Muhammad Alkhalaf <[email protected]> |
| License: | GPL-3 |
| Version: | 1.1.7 |
| Built: | 2026-10-31 07:23:21 UTC |
| Source: | https://github.com/muhammedalkhalaf/caustests |
Performs various Granger causality tests including Toda-Yamamoto, Fourier-based tests (single and cumulative frequency), and quantile causality tests with bootstrap inference.
caustests( data, test, pmax = 8, ic = 1, nboot = 1000, kmax = 3, dmax = NULL, quantiles = seq(0.1, 0.9, 0.1), verbose = TRUE )caustests( data, test, pmax = 8, ic = 1, nboot = 1000, kmax = 3, dmax = NULL, quantiles = seq(0.1, 0.9, 0.1), verbose = TRUE )
data |
A data frame or matrix with time series variables (columns). |
test |
Integer 1-7 specifying the test type:
|
pmax |
Maximum lag order for model selection (default: 8). |
ic |
Information criterion: 1 for AIC, 2 for SBC/BIC (default: 1). |
nboot |
Number of bootstrap replications (default: 1000). |
kmax |
Maximum Fourier frequency (default: 3, used for tests 2-5, 7). |
dmax |
Extra lags for Toda-Yamamoto augmentation. If NULL, automatically set to 0 for tests 2, 4 (differences) and 1 for tests 1, 3, 5, 6, 7 (levels). |
quantiles |
Numeric vector of quantiles for tests 6-7 (default: seq(0.1, 0.9, 0.1)). |
verbose |
Logical; print progress messages (default: TRUE). |
The package implements seven Granger causality tests:
Test 1: Toda-Yamamoto (1995) Standard Granger causality in levels using VAR with extra lags equal to the maximum integration order (dmax). This approach is robust to unknown integration and cointegration properties.
Tests 2-3: Single Fourier Frequency Incorporate a single Fourier frequency to capture smooth structural breaks. Test 2 uses first differences, Test 3 uses levels (Toda-Yamamoto style).
Tests 4-5: Cumulative Fourier Frequency Use cumulative Fourier frequencies (1 to k) for more flexible break patterns. Test 4 uses first differences, Test 5 uses levels.
Test 6: Quantile Toda-Yamamoto Extends Toda-Yamamoto to quantile regression, allowing causality analysis across different quantiles of the conditional distribution.
Test 7: Bootstrap Fourier Granger Causality in Quantiles (BFGC-Q) Combines Fourier flexibility with quantile regression for robust inference under structural breaks and across quantiles.
An object of class "caustests" containing:
results |
Data frame with test results for each direction |
test |
Test number used |
test_name |
Name of the test |
pmax |
Maximum lag considered |
ic |
Information criterion used |
nboot |
Number of bootstrap replications |
kmax |
Maximum Fourier frequency |
dmax |
Augmentation lags |
quantiles |
Quantiles used (for tests 6-7) |
quantile_results |
Detailed quantile results (for tests 6-7) |
quantreg_warnings |
For tests 6-7, a data frame with one row per
direction and quantile giving the number of quantile regression fits
(observed sample plus bootstrap replications) for which
|
Toda, H. Y. and Yamamoto, T. (1995). Statistical inference in vector autoregressions with possibly integrated processes. Journal of Econometrics, 66(1-2), 225-250. doi:10.1016/0304-4076(94)01616-8
Enders, W. and Jones, P. (2016). Grain prices, oil prices, and multiple smooth breaks in a VAR. Studies in Nonlinear Dynamics & Econometrics, 20(4), 399-419. doi:10.1515/snde-2014-0101
Nazlioglu, S., Gormus, N. A. and Soytas, U. (2016). Oil prices and real estate investment trusts (REITs): Gradual-shift causality and volatility transmission analysis. Energy Economics, 60, 168-175. doi:10.1016/j.eneco.2016.09.009
Nazlioglu, S., Soytas, U. and Gormus, N. A. (2019). Oil prices and monetary policy in emerging markets: Structural shifts in causal linkages. Emerging Markets Finance and Trade, 55(1), 105-117. doi:10.1080/1540496X.2018.1434072
Cai, Y., Chang, T., Xiang, Y. and Chang, H. L. (2023). Testing Granger causality in quantiles between the stock and the foreign exchange markets of Japan. Finance Research Letters, 58, 104327. doi:10.1016/j.frl.2023.104327
Cheng, S. C., Hsueh, H. P., Ranjbar, O., Wang, M. C. and Chang, T. (2021). Bootstrap Fourier Granger causality test in quantiles and the asymmetric causal relationship between CO2 emissions and economic growth. Letters in Spatial and Resource Sciences, 14, 31-49. doi:10.1007/s12076-020-00263-0
# Load example data data(caustests_data) # Test 1: Toda-Yamamoto test result1 <- caustests(caustests_data, test = 1, nboot = 199) print(result1) summary(result1) # Test 3: Single Fourier Toda-Yamamoto result3 <- caustests(caustests_data, test = 3, kmax = 2, nboot = 199) print(result3) # Test 6: Quantile causality (fewer quantiles for speed) result6 <- caustests(caustests_data, test = 6, quantiles = c(0.25, 0.50, 0.75), nboot = 199) print(result6)# Load example data data(caustests_data) # Test 1: Toda-Yamamoto test result1 <- caustests(caustests_data, test = 1, nboot = 199) print(result1) summary(result1) # Test 3: Single Fourier Toda-Yamamoto result3 <- caustests(caustests_data, test = 3, kmax = 2, nboot = 199) print(result3) # Test 6: Quantile causality (fewer quantiles for speed) result6 <- caustests(caustests_data, test = 6, quantiles = c(0.25, 0.50, 0.75), nboot = 199) print(result6)
A simulated dataset containing three time series variables for demonstrating Granger causality tests. The data includes one dependent variable (Y) and two potential causal variables (X1, X2) with known causal relationships.
caustests_datacaustests_data
A data frame with 200 observations and 3 variables:
Dependent variable, generated as AR(2) plus causal effects from X1
First explanatory variable, AR(1) process
Second explanatory variable, independent AR(1) process
The data generating process is:
X1 and X2 are independent AR(1) processes
Y depends on its own lags plus lagged values of X1 (but not X2)
This creates a true causal relationship from X1 to Y
There is no true causality from X2 to Y or from Y to X1/X2
This allows users to verify that the causality tests correctly identify the causal direction X1 to Y while finding no significant causality in other directions (with appropriate sample sizes and test settings).
Simulated data for package demonstration
data(caustests_data) head(caustests_data) summary(caustests_data) # Check correlations cor(caustests_data)data(caustests_data) head(caustests_data) summary(caustests_data) # Check correlations cor(caustests_data)
Returns the Grunfeld (1958) balanced panel dataset for examples.
grunfeld_cmg()grunfeld_cmg()
A data frame with columns firm, year,
invest, and mvalue.
dat <- grunfeld_cmg() head(dat)dat <- grunfeld_cmg() head(dat)
Returns a small balanced panel dataset (subset of Grunfeld 1958) for use in examples and testing.
grunfeld_panel()grunfeld_panel()
A data frame with columns firm, year,
invest, and mvalue.
dat <- grunfeld_panel() head(dat)dat <- grunfeld_panel() head(dat)
Creates diagnostic plots for quantile causality tests (tests 6-7).
## S3 method for class 'caustests' plot(x, which = 1, type = "both", ...)## S3 method for class 'caustests' plot(x, which = 1, type = "both", ...)
x |
An object of class |
which |
Which direction to plot (default: 1, first direction). |
type |
Plot type: "wald" for Wald statistics, "pval" for p-values, or "both" (default). |
... |
Additional arguments passed to |
Invisibly returns the plotted data.
data(caustests_data) result <- caustests(caustests_data, test = 6, quantiles = c(0.25, 0.50, 0.75), nboot = 199) plot(result)data(caustests_data) result <- caustests(caustests_data, test = 6, quantiles = c(0.25, 0.50, 0.75), nboot = 199) plot(result)
Print Method for xtpcaus Objects
## S3 method for class 'xtpcaus' print(x, ...)## S3 method for class 'xtpcaus' print(x, ...)
x |
An object of class |
... |
Additional arguments (ignored). |
Invisibly returns x.
Print Method for xtpcmg Objects
## S3 method for class 'xtpcmg' print(x, ...)## S3 method for class 'xtpcmg' print(x, ...)
x |
An object of class |
... |
Additional arguments (ignored). |
Invisibly returns x.
Summary Method for xtpcaus Objects
## S3 method for class 'xtpcaus' summary(object, ...)## S3 method for class 'xtpcaus' summary(object, ...)
object |
An object of class |
... |
Additional arguments (ignored). |
Invisibly returns object.
Summary Method for xtpcmg Objects
## S3 method for class 'xtpcmg' summary(object, ...)## S3 method for class 'xtpcmg' summary(object, ...)
object |
An object of class |
... |
Additional arguments (ignored). |
Invisibly returns object.
Tests whether x Granger-causes y in a balanced panel using
either the Panel Fourier Toda-Yamamoto (PFTY) test or the Panel Quantile
Causality (PQC) test.
xtpcaus( data, y, x, panel_id, time_id, test = c("pfty", "pqc"), pmax = 4L, dmax = 1L, nboot = 499L, kmax = 3L, ic = c("aic", "bic"), quantiles = c(0.1, 0.25, 0.5, 0.75, 0.9), seed = -1L )xtpcaus( data, y, x, panel_id, time_id, test = c("pfty", "pqc"), pmax = 4L, dmax = 1L, nboot = 499L, kmax = 3L, ic = c("aic", "bic"), quantiles = c(0.1, 0.25, 0.5, 0.75, 0.9), seed = -1L )
data |
A data frame in long format. |
y |
Character. Name of the dependent (caused) variable. |
x |
Character. Name of the independent (causing) variable. |
panel_id |
Character. Name of the panel identifier variable. |
time_id |
Character. Name of the time variable. |
test |
Character. Test type: |
pmax |
Integer. Maximum lag order for selection. Default is |
dmax |
Integer. Maximum integration order for Toda-Yamamoto
augmentation. Default is |
nboot |
Integer. Number of bootstrap replications. Minimum 99.
Default is |
kmax |
Integer. Maximum Fourier frequency (PFTY only). Default is
|
ic |
Character. Information criterion: |
quantiles |
Numeric vector. Quantile grid for PQC test (values strictly
between 0 and 1). Default is
|
seed |
Integer. Random seed for bootstrap. |
PFTY specification. For each unit i the test regression is
with p_i in 1..pmax and f_i in 1..kmax chosen
jointly by the information criterion. The null hypothesis restricts the
first p_i lags of x. The individual Wald statistic uses the
residual variance RSS / n with n = T - p_i - dmax the
effective sample (the normalisation of the Stata command caustests).
kmax = 0 omits the Fourier terms; dmax = 0 omits the
Toda-Yamamoto augmentation. With kmax = 0 and dmax = 0 the
regression is the plain VAR(p) of Dumitrescu and Hurlin (2012, eq. 1) with
a unit-specific lag order K_i = p_i.
Degrees of freedom. A lag order p is admissible only when
the unrestricted regression keeps at least 5 residual degrees of freedom,
T - (p + dmax) - k >= 5 with k = 2 (p + dmax) + 1 + 2 I(kmax > 0)
regressors. Lag orders that violate this bound are not considered (a
warning says so); if no lag order is admissible the function stops. This
bound implies the condition T_i > 5 + 2 K_i of Dumitrescu and Hurlin
(2012, eq. 10) for the existence of the second moments of the Wald
statistic.
Dumitrescu and Hurlin (2012) statistics. Only for the plain
specification (kmax = 0 and dmax = 0) the function reports the
standardised statistics of Dumitrescu and Hurlin (2012). They are built
from the individual Wald statistics with the unbiased residual variance
RSS / (T_i - 2 K_i - 1) (the paper's main definition), where
T_i = T - p_i is the effective sample of unit i:
Z-bar is eq. (9) with the asymptotic moments K_i and
2 K_i, and Z-tilde is eq. (26) with the fixed-T moments of
eq. (21) and (22),
When the selected lag orders differ across units the moments are averaged
over units: Z-bar uses the averaged asymptotic moments of eq. (11) of the
paper (mean of K_i and of 2K_i), Z-tilde the averaged fixed-T moments of
eq. (33). Both p-values are one-sided (upper
tail), the decision rule of the paper. Z-tilde is the statistic to
use at fixed T; Z-bar requires T to grow before N and is oversized
in short panels (the paper's Table 1). For the Fourier or Toda-Yamamoto
augmented specification the Wald statistics come from a different
regression with a data-selected frequency, the moments of eq. (21) and (22)
do not apply, and zbar, ztilde and their p-values are
NA; inference then rests on the bootstrap Fisher p-value.
Bootstrap. The bootstrap is a residual bootstrap under the null
built on Dumitrescu and Hurlin (2012, Section 6.2, steps 3 to 7). For
each unit the model is re-estimated without the tested lags of x
(restricted model) and its residuals are kept. In each replication a
sequence of time indices is drawn with replacement from the periods common
to all units and the same sequence is used for every unit (block of size 1
in time and size N in the cross-section), so that cross-sectional
dependence of the residuals is preserved. A bootstrap series is generated
recursively from the restricted model (intercept, autoregressive part,
unrestricted lags of x, Fourier terms, resampled residuals; the
observed first p_i + dmax values are the initial conditions), and
the whole procedure, selection of the lag order and frequency included, is
repeated on it. The paper's step 5 holds the lagged values of y
fixed; the recursive construction is used here so that the selection step
can be repeated, since the selection on the observed data inflates the
Wald statistics in short panels. When there is a single candidate
(pmax = 1 and kmax <= 1) the selection is skipped. The
individual bootstrap p-values are combined by the Fisher statistic of
Emirmahmutoglu and Kose (2011), -2 sum log p_i on 2 N
degrees of freedom. For the plain specification the bootstrap
distribution of Z-tilde is also recorded and ztilde_boot_pv
is the one-sided bootstrap p-value. Bootstrap regressions that are
singular or non-finite are dropped with a warning giving their number.
In Monte Carlo experiments under the null with N = 10, pmax = 1, dmax = 1,
kmax = 3 and nominal size 5 percent, the bootstrap Fisher test rejected
about 12 percent at T = 20 and 9 percent at T = 50 (independent normal
errors), while the plain specification was at nominal size; the
selection of the Fourier frequency on short panels is absorbed only in
part. For the Dumitrescu and Hurlin statistics use the plain
specification.
Singular regressions. If the regressor matrix of a unit is
singular for every admissible lag order (for example x constant or
identical to y), its Wald statistic is NA, a warning names
the unit and the unit is excluded from the panel statistics; N_used
gives the number of units that enter them.
Input checks. Missing values in y, x,
panel_id or time_id stop the function with the count and the
row positions. Every unit must be observed at the same set of time values
exactly once; duplicated or misaligned rows stop the function.
Random numbers. When seed >= 0 the bootstrap uses that
seed in a local RNG scope: the state of the global random number generator
is saved before and restored after the call.
An object of class "xtpcaus" containing:
Character. "pfty" or "pqc".
Integer. Number of panel units.
Integer. Number of time periods.
Integer. Number of bootstrap replications.
Character. Name of the y variable.
Character. Name of the x variable.
For PFTY:
Numeric. Fisher panel statistic, -2 sum log p_i
over the bootstrap p-values of the units that enter the panel
statistics.
Integer. Degrees of freedom (2 N_used).
Numeric. Fisher p-value.
Integer. Number of units entering the panel statistics (units with a singular regression are excluded).
Numeric. Average individual Wald statistic (variance
normalisation RSS / n).
Numeric. Average individual Wald statistic with the
unbiased variance RSS / (T_i - 2 K_i - 1) (Dumitrescu and
Hurlin 2012, eq. 4). NA unless kmax = 0 and
dmax = 0.
Numeric. Dumitrescu and Hurlin (2012) Z-bar statistic,
eq. (9), with asymptotic moments. NA unless kmax = 0
and dmax = 0.
Numeric. One-sided (upper tail) asymptotic p-value of
zbar.
Numeric. Dumitrescu and Hurlin (2012) Z-tilde statistic,
eq. (26), with the fixed-T moments of eq. (21) and (22). NA
unless kmax = 0 and dmax = 0.
Numeric. One-sided (upper tail) asymptotic p-value of
ztilde.
Numeric. One-sided bootstrap p-value of
ztilde from the cross-sectional block bootstrap. NA
unless kmax = 0 and dmax = 0.
Numeric vector. Individual Wald statistics (length N;
NA for a unit with a singular regression).
Numeric vector. Individual Wald statistics with the
unbiased variance (length N). NA unless kmax = 0 and
dmax = 0.
Numeric vector. Asymptotic chi-squared p-values of the
individual Wald statistics (ind_wald) with ind_lags
degrees of freedom (length N). Not used for the panel statistics; the
bootstrap p-values are the basis of inference.
Integer vector. Selected Fourier frequencies (length N;
0 when kmax = 0).
Numeric vector. Bootstrap p-values (length N).
Integer vector. Selected lag orders (length N).
Integer vector. Residual degrees of freedom of the unrestricted regressions (length N).
For PQC:
Numeric vector. Quantiles tested.
Numeric vector. Wald statistics per quantile (x to y).
Numeric vector. Bootstrap p-values per quantile (x to y).
Numeric vector. Wald statistics per quantile (y to x).
Numeric vector. Bootstrap p-values per quantile (y to x).
Numeric. Sup-Wald statistic for x to y.
Numeric. Sup-Wald statistic for y to x.
Integer. Selected optimal lag.
Chuang, C.C., Kuan, C.M. and Lin, H.Y. (2009). Causality in quantiles and dynamic stock return-volume relations. Journal of Banking and Finance, 33(7), 1351–1360. doi:10.1016/j.jbankfin.2009.02.013
Dumitrescu, E.I. and Hurlin, C. (2012). Testing for Granger non-causality in heterogeneous panels. Economic Modelling, 29(4), 1450–1460. doi:10.1016/j.econmod.2012.02.014
Emirmahmutoglu, F. and Kose, N. (2011). Testing for Granger causality in heterogeneous mixed panels. Economic Modelling, 28(3), 870–876. doi:10.1016/j.econmod.2010.10.018
Toda, H.Y. and Yamamoto, T. (1995). Statistical inference in vector autoregressions with possibly integrated processes. Journal of Econometrics, 66(1–2), 225–250. doi:10.1016/0304-4076(94)01616-8
Wang, K.M. and Nguyen, T.B. (2022). A quantile panel-type analysis of income inequality and healthcare expenditure. Economic Research, 35(1), 873–893. doi:10.1080/1331677X.2021.1948436
Yilanci, V. and Gorus, M.S. (2020). Does economic globalization have predictive power for ecological footprint. Environmental Science and Pollution Research, 27, 40552–40562. doi:10.1007/s11356-020-10092-9
dat <- grunfeld_panel() # PFTY test (quick with few bootstrap reps) res <- xtpcaus(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", test = "pfty", pmax = 2L, dmax = 1L, nboot = 99L, kmax = 2L, seed = 42L) print(res) # Plain VAR(p) specification with the Dumitrescu and Hurlin (2012) # Z-bar and Z-tilde statistics res_dh <- xtpcaus(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", test = "pfty", pmax = 2L, dmax = 0L, nboot = 99L, kmax = 0L, seed = 42L) print(res_dh) # PQC test res2 <- xtpcaus(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", test = "pqc", pmax = 2L, nboot = 99L, quantiles = c(0.25, 0.50, 0.75), seed = 42L) print(res2)dat <- grunfeld_panel() # PFTY test (quick with few bootstrap reps) res <- xtpcaus(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", test = "pfty", pmax = 2L, dmax = 1L, nboot = 99L, kmax = 2L, seed = 42L) print(res) # Plain VAR(p) specification with the Dumitrescu and Hurlin (2012) # Z-bar and Z-tilde statistics res_dh <- xtpcaus(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", test = "pfty", pmax = 2L, dmax = 0L, nboot = 99L, kmax = 0L, seed = 42L) print(res_dh) # PQC test res2 <- xtpcaus(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", test = "pqc", pmax = 2L, nboot = 99L, quantiles = c(0.25, 0.50, 0.75), seed = 42L) print(res2)
Estimates a polynomial cointegrating regression in a panel using either Group-Mean FM-OLS (Wagner and Reichold 2023) or Pooled FM-OLS (de Jong & Wagner 2022). Models the long-run relationship:
xtpcmg( data, y, x, panel_id, time_id, model = c("mg", "pmg"), q = 2L, controls = NULL, trend = 1L, kernel = "ba", bw = "And91", effects = "oneway", corr_rob = FALSE )xtpcmg( data, y, x, panel_id, time_id, model = c("mg", "pmg"), q = 2L, controls = NULL, trend = 1L, kernel = "ba", bw = "And91", effects = "oneway", corr_rob = FALSE )
data |
A data frame in long format. |
y |
Character. Name of the dependent variable. |
x |
Character. Name of the polynomial (I(1)) regressor. |
panel_id |
Character. Name of the panel identifier variable. |
time_id |
Character. Name of the time variable. |
model |
Character. Estimator: |
q |
Integer. Polynomial degree: |
controls |
Character vector. Names of additional I(1) control
variables. Default is |
trend |
Integer. Deterministic trend type: |
kernel |
Character. HAC kernel: |
bw |
Character or numeric. Bandwidth for HAC estimation. |
effects |
Character. For Pooled FM-OLS: |
corr_rob |
Logical. For Group-Mean FM-OLS: if |
where and are I(1) processes.
An object of class "xtpcmg" with elements:
coefficients (named numeric vector),
vcov (variance-covariance matrix),
se (standard errors),
tstat (t-statistics),
pvalue (two-sided p-values),
model (estimator type: mg or pmg),
q (polynomial degree),
N (number of panel units),
TT (number of time periods),
y (dependent variable name),
x (polynomial variable name),
tp (turning point estimate, quadratic models only),
tp_se (delta-method SE for turning point),
tp_lo and tp_hi (95% CI bounds),
ind_coef (individual FM-OLS estimates, MG model),
swamy_s and swamy_p (Swamy slope homogeneity test).
Andrews, D.W.K. (1991). Heteroskedasticity and autocorrelation consistent covariance matrix estimation. Econometrica, 59(3), 817–858. doi:10.2307/2938229
de Jong, R.M. and Wagner, M. (2022). Panel cointegrating polynomial regressions. Annals of Applied Statistics, 16(1), 416–442.
Wagner, M. and Reichold, K. (2023). Panel cointegrating polynomial regressions. Econometric Reviews, 42(9–10), 782–827. doi:10.1080/07474938.2023.2178141
dat <- grunfeld_cmg() # Group-Mean FM-OLS (quadratic EKC-type model) res <- xtpcmg(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", model = "mg", q = 2L) print(res) summary(res) # Pooled FM-OLS res2 <- xtpcmg(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", model = "pmg", q = 2L) print(res2)dat <- grunfeld_cmg() # Group-Mean FM-OLS (quadratic EKC-type model) res <- xtpcmg(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", model = "mg", q = 2L) print(res) summary(res) # Pooled FM-OLS res2 <- xtpcmg(dat, y = "invest", x = "mvalue", panel_id = "firm", time_id = "year", model = "pmg", q = 2L) print(res2)