*! version 1.0 2025/01/08
help simufealso see: scatterfit
Yujun Lian, arlionn@163.com

Title

simufe -- Simulate panel data with fixed effects and generate scatter plots with optional fitting lines.

Quick examples

. simufe

. simufe, n(2) rho(0)

. simufe, n(3) rho(-1) t(500)

. simufe, n(20) rho(0)

. simufe, n(20) rho(-2)

. simufe, n(20) rho(-1) t(50) gap(0)

. simufe, n(30) rho(-0.8) sigmae(0.5) t(40)

Syntax

simufe
[, options
]

options Description

Panel Data Settings

n(int 5) Number of individuals (default: 5)
t(int 20) Number of time periods (default: 20)
rho(real -1) Correlation between x and individual effects (default: -1)
gap(real 5) Gap between individual effects (default: 5)

Model Parameters

betax(real 0.5) Coefficient of x in the model (default: 0.5)
sigmax(real 2) Standard deviation of x's random component (default: 2)
sigmae(real 1) Standard deviation of the error term (default: 1)

Random Seed

seed(int 135) Random seed for reproducibility (default: 135)

Plot Options

noplot Suppress the scatter plot
onefit Plot a single fitting line instead of by-group lines

Save Data

saving(string) Save the generated dataset to the specified file

Description

simufe is a Stata program that simulates panel data with fixed effects and generates scatter plots with optional fitting lines. The data generating process (DGP) is as follows:

1. Individual fixed effects ai are generated as ai = id * gap, where id is the individual identifier and gap is the gap between individual effects.

2. The explanatory variable x is generated as x = rho * ai + u_x, where u_x is a random component with standard deviation sigmax.

3. The error term e is generated from a normal distribution with standard deviation sigmae.

4. The dependent variable y is generated as y = ai + betax * x + e.

The program also provides options to suppress the scatter plot, plot a single fitting line, and save the generated dataset to a file.

Examples

basic usage

Simulate panel data with default settings and plot the scatter plot:

. simufe

Simulate data to explain dummy variables:

. simufe, n(2) rho(0) seed(23579)

Simulate panel data with 3 individuals and 500 time periods:

. simufe, n(3) t(500)

Simulate panel data without individual effects:

. simufe, n(20) rho(-1) t(50) gap(0)

special usage

Simulate panel data with a larger gap between individual effects and save the dataset:

. simufe, n(20) gap(10) saving(mydata.dta)

Simulate panel data with a single fitting line instead of by-group lines:

. simufe, n(10) onefit

Simulate data and suppress the plot:

. simufe, noplot

Author

Yujun Lian (连玉君) Lingnan College, Sun Yat-Sen University, China.

E-mail: arlionn@163.com

Blog: lianxh.cn

Also see

Online:
scatterfit (if installed),
panel data (Stata manual)