tw_sim: Run Monte Carlo Simulations on Panel Data

View source: R/twsim2.R

tw_simR Documentation

Run Monte Carlo Simulations on Panel Data

Description

Use this function to run your own Monte Carlo experiments on panel data.

Usage

tw_sim(
  iter = 1000,
  cores = 1,
  parallel = FALSE,
  arg = "cross.eff.mean",
  range1 = c(-1, 1),
  range2 = NULL,
  models = c("randomfx", "wfe"),
  ...
)

Arguments

iter

The number of Monte Carlo simulations to run. This effects the precision of the estimates.

cores

The number of cores to run the simulations in parallel.

parallel

whether to use parallel processing if cores>1.

arg

A character value of which model parameter from link{tw_data} to vary across simulations.

models

A list of additional models besides fixed effects models to fit to the data.

...

All additional parameters to pass on to link{tw_data}, such as average effects in case or cross-sectional dimensions of the data.

at

A numeric sequence giving the range of values of the arg parameter to vary across.

Details

The tw_sim function acts as a frontend to the link{tw_data} function that generates panel data given a set of parameters. The arguments are fairly self-explanatory, and any underlying panel data parameters are passed on to link{tw_data}, so review that help site for more information. The simulation works by passing a character value of one of the parameters from the link{tw_data} function to the arg option, such as cross.eff.mean for varying cross-sectional effects. The at option must take a numeric vector giving the range of values to iterate over, such as seq(-1,1,by=.1) to test values of cross.eff.mean from -1 to 1 in increments of .1.

Value

This function returns a data.frame with the two-way fixed effects coefficient, both case (over-time) and cross-sectional 1-way fixed effects estimates, pooled OLS model estimates, and a random-effects estimate. Each row of the data.frame represents one sample of panel data drawn from link{tw_data}. This data can then be plotted with the tw_plot function to see results of the simulation.

Examples

## Not run: 
 ex_sim <- tw_sim(iter=150,arg='case.eff.mean',at=seq(-5,5,by=.1))


## End(Not run)


saudiwin/twofe_sim documentation built on Feb. 6, 2024, 11:31 a.m.