| make_plpr_data | R Documentation |
xtdml PackageGenerates data from a partially linear panel regression model with fixed
effects, following the setting of Clarke and Polselli (2025) but with a
tunable data-generating process designed to expose the differences among
the panel data approaches implemented in xtdml.
The DGP is defined as
Y_{it} = 1 + \theta_0 D_{it} + g_0(X_{it}) + \alpha_i + U_{it},
D_{it} = m_0(X_{it}) + \gamma_i + V_{it},
where U_{it} and V_{it} are AR(1) idiosyncratic errors with
persistence \phi_e and stationary unit variance; \alpha_i is
the outcome-side fixed effect; and \gamma_i is the treatment-side
fixed effect. The two fixed effects are constructed as
\alpha_i = \sigma_\alpha (\rho F_i + \sqrt{1-\rho^2} E_i),
\gamma_i = \sigma_\gamma \left(\rho_\gamma \frac{\alpha_i}{\sigma_\alpha} + \sqrt{1-\rho_\gamma^2} H_i\right),
where F_i, E_i, H_i \sim \mathcal{N}(0,1) are mutually independent
unit-level draws. The parameter \rho controls the correlation
between \alpha_i and the individual mean of the covariates
\bar{X}_i, while \rho_\gamma controls the correlation between
the outcome- and treatment-side fixed effects: \rho_\gamma = 0
corresponds to uncorrelated random effects and \rho_\gamma = 1 to a
strict fixed-effects specification.
Covariates follow a unit-level AR(1) process with persistence \phi_x:
X_{it,j} = F_i + \phi_x (X_{i,t-1,j} - F_i) + \eta_{itj}, \quad \eta_{itj} \sim \mathcal{N}(0,1),
initialised from the stationary marginal at t = 1. Higher \phi_x
produces more persistent within-unit variation, which preserves signal in
the first-differenced covariates and favours the FD-exact approach.
The nuisance functions are smooth polynomial and trigonometric functions of the first four covariates:
m_0(X_{it}) = 0.5 \sin(X_{it,1}) + 0.3 X_{it,2} + 0.1 (X_{it,3}^2 - 1) + 0.15 X_{it,1} X_{it,4},
g_0(X_{it}) = 0.4 \cos(X_{it,1}) + 0.5 X_{it,3} + 0.1 (X_{it,4}^2 - 1) + 0.15 X_{it,2} X_{it,3}.
These forms are smooth (no threshold indicators) and can be recovered by tree-based, penalised, and neural learners at moderate sample sizes.
make_plpr_data(
n_obs = 500,
t_per = 8,
dim_x = 10,
theta = 0.5,
rho = 0.7,
rho_gamma = 0,
phi_x = 0.4,
phi_e = 0,
sigma_a = 2,
sigma_g = 1,
seed = NULL
)
n_obs |
( |
t_per |
( |
dim_x |
( |
theta |
( |
rho |
( |
rho_gamma |
( |
phi_x |
( |
phi_e |
( |
sigma_a |
( |
sigma_g |
( |
seed |
( |
A data.frame with n_obs * t_per rows and the following columns:
idunit identifier, integer in \{1, \ldots, n\_obs\}.
timetime identifier, integer in \{1, \ldots, t\_per\}.
X1, X2, ..., X<dim_x>covariates.
youtcome variable.
dtreatment variable.
# Default: uncorrelated random effects, IID errors
df <- make_plpr_data(n_obs = 500, t_per = 8, dim_x = 10,
theta = 0.5, rho_gamma = 0, seed = 1234)
# Strict fixed effects with persistent errors: FD-exact should be efficient
df_fd <- make_plpr_data(n_obs = 500, t_per = 8, dim_x = 10,
theta = 0.5, rho_gamma = 1,
phi_e = 0.8, phi_x = 0.7, seed = 1234)
# Correlated fixed effects, IID errors: pooled PLR is biased; CRE/WG efficient
df_cre <- make_plpr_data(n_obs = 500, t_per = 8, dim_x = 10,
theta = 0.5, rho_gamma = 0.5,
phi_e = 0, phi_x = 0.4, seed = 1234)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.