*granger causality
set more off
tsset cnum obs_number , format(%tq)
local vari "lnpetrol lnchinaimp"
foreach y of num 1/56 {
foreach x of local vari {
disp `y'
var bp_level `x' if cnum==`y' , lags(1/4)
vargranger
}
}
**1st differenced
foreach y of num 1/56 {
foreach x of local vari {
gen d`x' = `x'-`x'[_n-1]
disp `y'
var dbp_level d`x' if cnum==`y' , lags(1/4)
vargranger
drop d`x'
}
}
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/