Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
Hi there, I am trying to use DOFOR with labels or variables' names.
In the simplest case, I have two series named deUK and deJP which I intend to use as dependent variables. My regressors are named bUK and bJP.
Since 'UK' and 'JP' are recurring in my variables' names, I would like to implement something doing the following. All in one step:
I need to do a dofor loop for different series: aggregate, Agric, Food and Soda.
i.e. I need to repeat the linear regression below for Agric, Food and Soda,
I need to do a dofor loop for different series: aggregate, Agric, Food and Soda.
i.e. I need to repeat the linear regression below for Agric, Food and Soda,
dofor s = aggregate Agric Food Soda
linreg(robusterrors,lags=13,lwindow=neweywest) s
# constant s{1 to nlag} oil{1 to nlag} o1{1 to nlag}
exclude
# o1{1 to nlag}
display ' specification for 2-period, nw errors'
linreg(robusterrors,lags=13,lwindow=neweywest) s
# constant s{2 to nlag+1} oil{2 to nlag+1} o1{2 to nlag+1}
exclude
# o1{2 to nlag+1}
end door
Why are you doing Newey-West with 13 lags on the first regression? That should have serially uncorrelated errors.
Some programming languages use a ; to indicate that a line is done, and keep running a single logical line until they see it. RATS uses the alternative of using a symbol ($ in our case) as the end of a line that isn't done. So you want
dofor s = aggregate agriculture Food Soda Beer Smoke Toys Fun Books Hshld Clths $
Hlth MedEq Drugs Chems Rubbr Txtls BldMt Cnstr Steel FabPr Mach ElcEq $
Autos Aero Ships Guns Gold Mines Coal Oil Util Telcm PerSv BusSv Hardw $
Softw Chips LabEq Paper Boxes Trans Whlsl Rtail Meals Banks Insur RlEst $
Fin Other
report(action=define)
dofor s = aggregate agriculture Food Soda Beer Smoke Toys Fun Books Hshld Clths $
Hlth MedEq Drugs Chems Rubbr Txtls BldMt Cnstr Steel FabPr Mach ElcEq $
Autos Aero Ships Guns Gold Mines Coal Oil Util Telcm PerSv BusSv Hardw $
Softw Chips LabEq Paper Boxes Trans Whlsl Rtail Meals Banks Insur RlEst $
Fin Other
report(row=new,atcol=1) %l(s)
do h=0,11
do the calculation for that horizon
report(row=current,atcol=h+2) whatever_the_pvalue_is_for_h
end do h
end do s
report(action=show,format=xls)
This will prompt you for the name of the Excel file you want to create. You could also put in an
open copy mytable.xls
command and use UNIT=COPY, or you could just do ACTION=SHOW without the FORMAT=XLS, and it will put the table up on the screen. You can then copy and paste the whole thing into Excel.