Skip to content

Instantly share code, notes, and snippets.

Benjamin Daniels bbdaniels

Block or report user

Report or block bbdaniels

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bbdaniels
bbdaniels / power-curve.do
Last active Feb 11, 2020
Make simple power curves for binary variables
View power-curve.do
tempname a b c
tw (function 1.4*sqrt((2/x)+(2/x)) , range(300 600) lc(red)) ///
(function 1.4*sqrt((3/x)+(3/(2*x))) , range(300 600) lc(red) lp(dash)) ///
(function sqrt(1/x) , range(300 600) lc(black) ) ///
, yscale(r(0)) ytit(" ") xtit("Number of Providers") ///
title("Within Case") ///
ylab(0 .05 "5p.p." .1 "10p.p." .15 "15p.p." .2 "20p.p.") ///
legend(on c(1) pos(9) ///
order( ///
@bbdaniels
bbdaniels / Edgeworth-box.do
Created Jan 23, 2020
Edgeworth box in Stata
View Edgeworth-box.do
clear
set obs 100
gen y = runiform() * 3
gen x = runiform() * 3
tw ///
(scatter x y) ///
(scatter x y , m(none) yaxis(2) xaxis(2)) ///
@bbdaniels
bbdaniels / regression-table.do
Created Jan 13, 2020
Create generic regression table using built-in commands.
View regression-table.do
// Demo code for creating simple regression table
sysuse auto.dta, clear
// Run regressions
reg price weight
su price if e(sample)
estadd scalar mean = r(mean)
est sto reg1
@bbdaniels
bbdaniels / Simulation: Big effects from small RCTs
Last active Jan 13, 2020
Simulation: Big and small effects from RCTs
View Simulation: Big effects from small RCTs
// Simulation 1: Big effects from small RCTs
cap mat drop results
qui forv iter = 1/1000 {
clear
set obs 10000
gen x = rnormal() > 0
gen e = rnormal() * 4
View One.do
*Part I*
*** Setup
clear all //clear any open datasets
cls //clear the screen
version 15
set more off
set linesize 255
*** Generating a random varibale
set obs 100000
@bbdaniels
bbdaniels / loop-over-letters.do
Created Jan 9, 2020
Loop over letters in Stata (such as for putexcel)
View loop-over-letters.do
forv i = 1/26 {
local theLetter : word `i' of `c(ALPHA)'
di "`theLetter'"
}
@bbdaniels
bbdaniels / wage-premium.do
Last active Jan 8, 2020
Mincer regression for Econ lecture
View wage-premium.do
clear // Reset the work space
set obs 100000 // Create empty units of observation
set seed 837169 // Fix randomization start point
// Generate ability scores 0-100
gen theta = 100*runiform()
// Fix parameters
local a = 100
local b = 2
@bbdaniels
bbdaniels / ritest-demo.do
Last active Oct 23, 2019
Demo example for [ritest] in Stata
View ritest-demo.do
// [ritest] example
// Create randomization program ------------------------------------------------
cap prog drop my_randomization
prog def my_randomization
syntax , [*]
// Must drop the variable for [ritest]. Make sure to keep it saved somewhere
cap drop treatment
View .gitignore
########################################################################
#
# .gitignore DIME template
# https://github.com/worldbank/DIMEwiki/tree/master/Topics/GitHub
#
# We recommend that you create a .gitignore file using GitHub's tools and
# replace the content of that file with the content of this file. Otherwise
# you have to rename this file .gitignore. But if you rename the fine in a
@bbdaniels
bbdaniels / stata-section-head.do
Last active Jan 8, 2020
Stata section header
View stata-section-head.do
// ---------------------------------------------------------------------------------------------
// Figures
You can’t perform that action at this time.