Difference between revisions of "MatchingLBO.do"
Yimengtang (talk | contribs) |
Yimengtang (talk | contribs) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
==Attempt 1== | ==Attempt 1== | ||
− | use STATApredictLBO.dta, clear | + | use STATApredictLBO.dta, clear <br> |
− | rename nopatents case_nopatents | + | rename nopatents case_nopatents <br> |
− | rename logitpw case_logitpw | + | rename logitpw case_logitpw <br> |
− | rename gvkey case_gvkey | + | rename gvkey case_gvkey <br> |
− | /*industry, year, and no. of patents*/ | + | /*industry, year, and no. of patents*/ <br> |
− | joinby industrygroup3 year using STATApredictLBO.dta | + | joinby industrygroup3 year using STATApredictLBO.dta <br> |
− | gen a = nopatents*0.95 | + | gen a = nopatents*0.95 <br> |
− | gen b = nopatents*1.05 | + | gen b = nopatents*1.05 <br> |
− | gen delta=abs(logitpw-case_logitpw) | + | gen delta=abs(logitpw-case_logitpw) <br> |
− | drop if case_nopatents > b | case_nopatents < a | + | drop if case_nopatents > b | case_nopatents < a <br> |
− | // GENERATE SOME RANDOM NUMBERS TO RANDOMLY BREAK ANY TIES | + | // GENERATE SOME RANDOM NUMBERS TO RANDOMLY BREAK ANY TIES <br> |
− | // ON CLOSENESS OF MATCH OF MARKET VALUE | + | // ON CLOSENESS OF MATCH OF MARKET VALUE <br> |
− | set seed | + | set seed 0.5 <br> |
− | gen double shuffle1 = runiform() | + | gen double shuffle1 = runiform() <br> |
− | gen double shuffle2 = runiform() | + | gen double shuffle2 = runiform() <br> |
− | by case_gvkey (delta shuffle1 shuffle2), sort: keep if _n == 1 | + | by case_gvkey (delta shuffle1 shuffle2), sort: keep if _n == 1 <br> |
− | drop delta shuffle1 shuffle2 | + | drop delta shuffle1 shuffle2 <br> |
− | + | Error op. sys. refuses to provide memory | |
+ | |||
+ | ==Attempt 2== | ||
+ | foreach x of varlish matchfilter{ | ||
+ | if x==1{ | ||
+ | foreach matchfilter[_n]==0{ | ||
+ | if year[_n]==year[_x] & industrygroup3[_n]==industrygroup3[_x]{ | ||
+ | if nopatents[_n]/nopatents[_x]<1.1 | nopatents[_n]/nopatents[_x]>1/1.1{ | ||
+ | gen delta=abs(logitpw[_n]-logitpw[_x] | ||
+ | m=gvkey[_min(delta)]} | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | Error invalid syntax | ||
+ | Possible reasons: 1. use of _n and x 2. if loop |
Latest revision as of 16:45, 25 October 2016
This do file aims to match companies with the closest propensity score based on industry, year, and number of patents from STATApredictLBO.dta.
Attempt 1
use STATApredictLBO.dta, clear
rename nopatents case_nopatents
rename logitpw case_logitpw
rename gvkey case_gvkey
/*industry, year, and no. of patents*/
joinby industrygroup3 year using STATApredictLBO.dta
gen a = nopatents*0.95
gen b = nopatents*1.05
gen delta=abs(logitpw-case_logitpw)
drop if case_nopatents > b | case_nopatents < a
// GENERATE SOME RANDOM NUMBERS TO RANDOMLY BREAK ANY TIES
// ON CLOSENESS OF MATCH OF MARKET VALUE
set seed 0.5
gen double shuffle1 = runiform()
gen double shuffle2 = runiform()
by case_gvkey (delta shuffle1 shuffle2), sort: keep if _n == 1
drop delta shuffle1 shuffle2
Error op. sys. refuses to provide memory
Attempt 2
foreach x of varlish matchfilter{
if x==1{ foreach matchfilter[_n]==0{ if year[_n]==year[_x] & industrygroup3[_n]==industrygroup3[_x]{ if nopatents[_n]/nopatents[_x]<1.1 | nopatents[_n]/nopatents[_x]>1/1.1{ gen delta=abs(logitpw[_n]-logitpw[_x] m=gvkey[_min(delta)]} } } }
Error invalid syntax
Possible reasons: 1. use of _n and x 2. if loop