I hope you can help me. I've been trying and trying on my own to find a solution to this problem but I gave up.
Here is the problem: I have a local varlist in which are listed all the variables I need to regress one by one on a set of variables list in another local varlist. To do this, I set up a loop, in which I need to nest two subconditions, namely if the X (set of dependant) belongs to certain variables and if the v belongs to certain other variables (set of regressors), do something.
The code is the following
Code:
local indep "Business_Climat Consumer_Confid ECB_Deposit_Rat ECB_Refinancing Economic_Sentim GDP_Flash_Estim GDP_Flash_Preli GDP_Revised_QQ GDP_Revised_YY HICPX_FEAT_Fin_ HICPX_FEAT_Fina HICPX_FE_Flash_ HICP_Final_MM HICP_Final_YY HICP_Flash_YY Ind_Prod_MM Ind_Prod_YY Industrial_Sent Markit_Comp_Fin Markit_Comp_Fla Markit_Mfg_Fina Markit_Mfg_Flas Markit_Serv_Fin Markit_Serv_Fla MoneyM3_Annual_ PPI_MM PPI_YY Retail_Sales_YY Sentix_Index Services_Sentim Unemployment_Ra" local country "CNY KOR IND TUR ZAF RUS BRA MEX ARG CHL US CAN UK EU DEU FR ITA JPN AUS HKG" local row=1 foreach X of local country { foreach v of local indep { if inlist(`"`X'"',"CNY" "KOR" "IND" "HKG") { sort Date gen ret`X'_f= ret`X'[_n+1] replace ret`X'_f=ret`X'[_n+3] if dow==5 if `v'==Consumer_Confid | `v'==ECB_Deposit_Rat | `v'==ECB_Refinancing { quietly regress ret`X'_f surpref`v' } } drop ret`X'_f } else if inlist(`"`X'"',"JPN" "AUS") { sort Date gen ret`X'_f= ret`X'[_n+1] replace ret`X'_f=ret`X'[_n+3] if dow==5 quietly regress ret`X'_f surpref`v' drop ret`X'_f } else { sort Date quietly regress ret`X' surpref`v' } } }
Your help will be really much appreciated.
Many thanks in advance
Federica
0 Response to Nested regression with string variables
Post a Comment