* Reproduces results in Footnote 2
***********
* test for unit root in logged deflated COGS series
clear all
cap log close
log using unitroot.txt, text replace 


use "cogs_deflated_unitroot.dta", clear

gen lcogsqd= log(cogsqd)
egen g = group(gvkey_code)

tempfile results
tempname hold
postfile `hold' g pvalue test_stat  using `results'
qui levelsof g, local(levels)
foreach l of local levels {
	cap qui dfuller  lcogsqd if g == `l'
	cap post `hold' (`l') (r(p)) (r(Zt))
	}
postclose `hold'
use `results', clear
save unitroot_log.dta, replace
sum pvalue
count if pvalue>=0.1 & pvalue<=1


* test for unit root in logged differenced deflated series
use "cogs_deflated_unitroot.dta", clear

egen g = group(gvkey_code)

tempfile results
tempname hold
postfile `hold' g pvalue test_stat  using `results'
qui levelsof g, local(levels)
foreach l of local levels {
	cap qui dfuller  ld_cogsqd if g == `l'
	cap post `hold' (`l') (r(p)) (r(Zt))
	}
postclose `hold'
use `results', clear
save unitroot_logdiff.dta, replace
sum pvalue
count if pvalue>=0.1 & pvalue<=1



log close
