Skip to content

Instantly share code, notes, and snippets.

@vapniks
vapniks / reshape_world-bank_data.do
Created April 11, 2018 04:14
This file reshapes world bank data that has been downloaded into stata using the wbopendata command.
/* This file reshapes world bank data that has been downloaded into stata using the wbopendata command. */
/* It will reshape from wide to long format that can be used in panel data models */
/* First read the file into Stata, e.g: */
/* (replace this command if necessary) */
/* wbopendata, topics(2 - Aid Effectiveness) clear */
use
/* and then, issue the following commands */
drop indicatorcode /* replace this with the name of the appropriate variable */
REGRESSION TEST:
./test/cases
Using executable: ./mlr
PASS ./test/cases/auxents
FAIL ./test/cases/chaining
PASS ./test/cases/cli-csv-rs-environment-defaults
PASS ./test/cases/cli-getoptish
PASS ./test/cases/cli-help
PASS ./test/cases/cli-mfrom
@vapniks
vapniks / fixef_of_time_invariant_vars.R
Created August 24, 2023 14:47
Extract fixed effects and match with values of time invariant variables, for testing time invariant effects.
## Function to extract fixed effects from plm or fixest model, and match with values of time invariant variables.
## Arguments:
## model = a plm or fixest fixed effects model object
## factors = either a data.frame/pdata.frame/data.table object containing time-invariant variables and a panel index variable,
## or in the case that the model arg is a plm object, factors can be a vector of names of time-invariant variables
## that will be extracted from the model object (along with the panel index).
## idvar = the name of the panel index variable; by default this will be set to the name of the model index if model is
## a plm object, or the name of the factors index if factors is a pdata.frame index. Otherwise if model is a fixest
## object then idvar must specify a variable in factors (a data.frame object).
## For example of usage see code after this function.