使用方式+案例+参考来源
将这两个文件放到stata的ado文件夹下的base文件夹中就可以了。然后在stata命令窗口中输入help xtarsim,就能显示该命令的使用方法。
1.使用方式
- ---------------------------------------------------------------------------------------------
- help for xtarsim
- ---------------------------------------------------------------------------------------------
- Simulate panel dataset
- xtarsim newdepvar newindepvar newindeffect newtimeffect , nid(#) time(#)
- gamma(real) beta(real) rho(real) snratio(real) [sigma(real)
- oneway(effect_type load) twoway(effect_type load) unbd(N_1 T_1) seed(#)]
- xtarsim creates panel datasets for use in Monte Carlo experiments as pseudo-random
- realizations from (possibly) dynamic twoway linear panel data models.
- Description
- xtarsim creates a dataset from the following general panel data model
- y[i,t] = y[i,t-1]gamma + x[i,t]beta + u[i] + u[t] + e[i,t]
- x[i,t] = x[i,t-1]rho + v[i,t] i={1,...,N}; t={1,...,T},
- where
- gamma, beta and rho are real numbers chosen by the user.
- e[i,t] are iid Normal(0,sigma^2), with sigma chosen by the user.
- v[i,t] are iid Normal(0,sigma_v^2), with sigma_v being uniquely determined once
- choosing the model parameters and the signal to noise ratio of the y[i,t] regression.
- Attention should be paid to supply parameter values that ensure a finite positive
- variance for v[i,t]. When this does not happen an error message is issued by xtarsim.
- e[i,t] and v[i,t] are not correlated, so that x[i,t] is a strictly exogenous regressor
- in the first equation of the model.
- u[i] and u[t] are, respectively, the individual and time effects, and may or may not be
- correlated with x[i,t].
- If correlated, individual effects are determined as u[i]=load_1*(1-gamma)*(1+x[i]-x),
- where x[i] and x, respectively, are the group mean and the overall mean of x[i,t], and
- load_1 is a load factor chosen by the user. Correlated time effects, instead, are
- determined as contrasts to the first period, u[t]=load_2*(1-gamma)*(x[t]-x[1]), where
- again load_2 is a load factor chosen by the user. Such normalisation is convenient in
- that the constant term in xtreg, in its one-way fixed effect version as well as two-way
- fixed effect version excluding the first time indicator, can be interpreted as an
- estimate for load_1*(1-gamma) (see the example file static2way_bias.do available for
- download). If not correlated, both effects are taken to be iid
- Normal(0,load^2*(1-gamma)^2) with a specific load factor for each effect.
- Following Kiviet (1995) start-up values y[i,0] and x[i,0] are obtained according to the
- model using the McLeod and Hipel (1978) procedure. This avoids wasting random numbers
- in generating start-up values and also small-sample non-stationarity problems. This
- procedure has been also applied by Bun and Kiviet (2003), Bruno (2005a) and (2005b).
2.案例
- Examples
- (Create a panel from a static one-way random effect Data Generation Process (DGP))
- . xtarsim y x eta, n(200) t(10) g(0) b(.8) r(.2) sn(9) seed(1234)
- . describe
- . xtdes
- (Create a panel from a dynamic one-way fixed effect DGP)
- . xtarsim y x eta, n(200) t(10) g(.2) b(.8) r(.2) one(corr 1) sn(9) seed(1234)
- . xtdes
- (Demonstrate, on this dataset, the expected good perfomance of the basic Arellano-Bond
- estimator in terms of estimation error and specification tests)
- . xtabond y x,noco
- (Create a panel from a dynamic two-way fixed effect DGP)
- . xtarsim y x eta theta, n(200) t(10) g(.2) b(.8) r(.2) two(corr 5) sn(9)
- seed(1234)
- . describe
- . xtdes
- (Demonstrate, on this dataset, the expected poor perfomance of the basic Arellano-Bond
- estimator in terms of estimation error and specification tests)
- . xtabond y x,noco
- (Demonstrate the expected better perfomance of the two-way Arellano-Bond estimator)
- . tab tvar,gen(time)
- . xtabond y x time*,noco
- (Make the foregoing dataset unbalanced: the last 5 time observations are missing for
- the first 50 individuals in the sample)
- . xtarsim y x eta theta, n(200) t(10) g(.2) b(.8) r(.2) two(corr 5) sn(9) unbd(50
- 5) seed(1234)
- . xtdes
- For examples of xtarsim in Monte Carlo experiments download the do files dyn_bias.do
- and static2way_bias.do. The former, upon setting up a dynamic one-way random effect
- DGP, estimates the unconditional small-sample biases of the dynamic one-way fixed
- effect and random effect estimators by 1000 Monte Carlo simulations. The latter sets up
- a static two-way fixed effect DGP and estimates the unconditional small-sample biases
- of the one-way and two-way fixed effect estimators using 1000 Monte Carlo simulations.
3、参考
点击:STATA 蒙特卡洛模拟程序包



雷达卡




京公网安备 11010802022788号







