sim_tv_DGP {PAGFL} | R Documentation |
Simulate a Time-varying Panel With a Group Structure in the Slope Coefficients
Description
Construct a time-varying panel data set subject to a group structure in the slope coefficients with optional AR(1)
innovations.
Usage
sim_tv_DGP(
N = 50,
n_periods = 40,
intercept = TRUE,
p = 1,
n_groups = 3,
d = 3,
dynamic = FALSE,
group_proportions = NULL,
error_spec = "iid",
locations = NULL,
scales = NULL,
polynomial_coef = NULL,
sd_error = 1,
DGP = lifecycle::deprecated()
)
Arguments
N |
the number of cross-sectional units. Default is 50.
|
n_periods |
the number of simulated time periods T . Default is 40.
|
intercept |
logical. If TRUE , a time-varying intercept is generated.
|
p |
the number of simulated explanatory variables
|
n_groups |
the number of groups K . Default is 3.
|
d |
the polynomial degree used to construct the time-varying coefficients.
|
dynamic |
Logical. If TRUE , the panel includes one stationary autoregressive lag of yit as a regressor. Default is FALSE .
|
group_proportions |
a numeric vector of length n_groups indicating size of each group as a fraction of N . If NULL , all groups are of size N/K . Default is NULL .
|
error_spec |
options include
"iid" for iid errors.
"AR" for an AR(1) error process with an autoregressive coefficient of 0.5.
Default is "iid" .
|
locations |
a p×K matrix of location parameters of a logistic distribution function used to construct the time-varying coefficients. If left empty, the location parameters are drawn randomly. Default is NULL .
|
scales |
a p×K matrix of scale parameters of a logistic distribution function used to construct the time-varying coefficients. If left empty, the location parameters are drawn randomly. Default is NULL .
|
polynomial_coef |
a p×d×K array of coefficients for a the polynomials used to construct the time-varying coefficients. If left empty, the location parameters are drawn randomly. Default is NULL .
|
sd_error |
standard deviation of the cross-sectional errors. Default is 1.
|
DGP |
the data generating process. Options are
- 1
generates a trend only.
- 2
simulates a trend and an additional exogenous explanatory variable.
- 1
draws a dynamic panel data model with one AR lag.
|
Details
The scalar dependent variable yit
is generated according to the following time-varying grouped panel data model
yit=γi+βit′xit+uit,i=1,…,N,t=1,…,T,
where γi
is an individual fixed effect and xit
is a p×1
vector of explanatory variables.
The coefficient vector βi={βi1′,…,βiT′}′
is subject to the group pattern
βi(Tt)=∑k=1Kαk(Tt)1{i∈Gk},
with ∪k=1KGk={1,…,N}
, Gk∩Gj=∅
and supv∈[0,1](∥αk(v)−αj(v)∥)=0
for any k=j
, k=1,…,K
. The total number of groups K
is determined by n_groups
.
The predictors are simulated as:
xit,j=0.2γi+eit,j,γi,eit,j∼i.i.d.N(0,1),j={1,…,p},
where eit,j
denotes a series of innovations. γi
and ei
are independent of each other.
The errors uit
feature a iid
standard normal distribution.
In case locations = NULL
, the location parameters are drawn from ∼U[0.3,0.9]
.
In case scales = NULL
, the scale parameters are drawn from ∼U[0.01,0.09]
.
In case polynomial_coef = NULL
, the polynomial coefficients are drawn from ∼U[−20,20]
and normalized so that all coefficients of one polynomial sum up to 1.
The final coefficient function follows as αk(t/T)=3∗F(t/T,location,scale)+∑j=1daj(t/T)j
, where F(⋅,location,scale)
denotes a cumulative logistic distribution function and aj
reflects a polynomial coefficient.
Value
A list holding
alpha |
a T×p×K array of group-specific time-varying parameters
|
beta |
a T×p×N array of individual time-varying parameters
|
groups |
a vector indicating the group memberships (g1,…,gN) , where gi=k if i∈ group k .
|
y |
a NT×1 vector of the dependent variable, with y=(y1,…,yN)′ , yi=(yi1,…,yiT)′ and the scalar yit .
|
X |
a NT×p matrix of explanatory variables, with X=(x1,…,xN)′ , xi=(xi1,…,xiT)′ and the p×1 vector xit .
|
data |
a NT×(p+1) data.frame of the outcome and the explanatory variables.
|
Author(s)
Paul Haimerl
Examples
# Simulate a time-varying panel subject to a time trend and a group structure
sim <- sim_tv_DGP(N = 20, n_periods = 50, intercept = TRUE, p = 1)
y <- sim$y
[Package
PAGFL version 1.1.1
Index]