RATS output and LaTeX
RATS output and LaTeX
I did not find an appropriate thread so I post this here. Sorry if this is misplaced.
I know that other software (e.g. Stata) have packages enabling the user to "translate" regression output into LaTeX tables. Is there any equivalent package for RATS? If not, did you ever think of inventing such a module? It might be very useful since many economists use RATS and they normally write documents with LaTeX.
I know that other software (e.g. Stata) have packages enabling the user to "translate" regression output into LaTeX tables. Is there any equivalent package for RATS? If not, did you ever think of inventing such a module? It might be very useful since many economists use RATS and they normally write documents with LaTeX.
-
jonasdovern
- Posts: 97
- Joined: Sat Apr 11, 2009 10:30 am
Re: RATS output and LaTeX
Hallo Anna,
I once wrote a little procedure that produces Latex-Code to display a data matrix as a Latex-Table. This is not able to display regression output as you asked for. But it might be a starting point for you - or others - to write your own procedure. Best, Jonas
I once wrote a little procedure that produces Latex-Code to display a data matrix as a Latex-Table. This is not able to display regression output as you asked for. But it might be a starting point for you - or others - to write your own procedure. Best, Jonas
Code: Select all
procedure textable datamat
*
type rec[real] datamat
*
option vec[str] rowlabels
option vec[str] collabels
option string header
option choice hposition 1 above below
option string texlabel 'tRATStable'
option string format '*.##'
option rec[real] tstat
option switch lines 0
option choice position 1 none here top bottom
option switch stars 0
*
local integer nrows ncols c r
local string coldesign temp pos starstring
*
* Check inputs
*
if (%defined(collabels).and..not.%defined(rowlabels)).or.(%defined(rowlabels).and..not.%defined(collabels)) {
disp 'Please define either labels for rows AND columns or do not specify any labels at all!'
return
}
if (%defined(collabels)).and.((%rows(collabels)<>%cols(datamat)).or.(%rows(rowlabels)<>%rows(datamat))) {
disp 'The dimension of at least one of your vectors with labels does not match the dimension of your data matrix!'
return
}
if %defined(tstat).and.(%rows(tstat)<>%rows(datamat).or.%cols(tstat)<>%cols(datamat)) {
disp 'Data matrix and matrix with t-statistics do not have the same dimension!'
return
}
*
* Get relevant information and construct help-objects
*
comp nrows = %rows(datamat), ncols = %cols(datamat)
if %defined(rowlabels) {
if lines
comp coldesign = 'l|'+%strrep('c',ncols)
else
comp coldesign = 'l'+%strrep('c',ncols)
}
else
comp coldesign = %strrep('c',ncols)
*
if position==1
comp pos = ''
if position==2
comp pos ='[!h]'
if position==3
comp pos ='[!t]'
if position==4
comp pos ='[!b]'
*
* Write TeX-Code to a separate window
*
open(window) codewin 'Code for TeX-Table'
*
change output codewin
*
disp '\begin{table}'+pos
if hposition==1 {
if %defined(header)
disp @@3 '\caption{'+header+'}'
}
disp @@3 '\label{'+texlabel+'}'
disp @@3 '\centering'
disp @@3 '\begin{tabular}{'+coldesign+'}'
disp @@6 '\hline'
disp @@6 '\hline'
if %defined(collabels) {
comp temp = ' '
do c=1,ncols
comp temp = temp+' & '+collabels(c)
end do c
comp temp = temp+' \\'
disp @@6 temp
}
if lines
disp @@6 '\hline'
do r=1,nrows
* Data rows
if %defined(rowlabels)
comp temp = rowlabels(r)+' & '
else
comp temp = ''
do c=1,ncols-1
comp temp = temp+%strval(datamat(r,c),format)+' & '
end do c
comp temp = temp+%strval(datamat(r,ncols),format)+' \\'
disp @@6 temp
* t-statistics
if %defined(tstat) {
if %defined(rowlabels)
comp temp = 't-stat & '
else
comp temp = ''
do c=1,ncols-1
if .not.stars
comp temp = temp+'('+%strval(tstat(r,c),'*.#')+') & '
else {
if abs(tstat(r,c))<1.65
comp starstring = ''
else if abs(tstat(r,c))<1.96
comp starstring = '*'
else if abs(tstat(r,c))<2.58
comp starstring = '**'
else
comp starstring = '***'
comp temp = temp+'($'+%strval(tstat(r,c),'*.#')+'^{'+starstring+'}$) & '
}
end do c
if .not.stars
comp temp = temp+'('+%strval(tstat(r,ncols),'*.#')+') \\'
else {
if abs(tstat(r,ncols))<1.65
comp starstring = ''
else if abs(tstat(r,ncols))<1.96
comp starstring = '*'
else if abs(tstat(r,ncols))<2.58
comp starstring = '**'
else
comp starstring = '***'
comp temp = temp+'($'+%strval(tstat(r,ncols),'*.#')+'^{'+starstring+'}$) \\'
}
disp @@6 temp
}
end do r
disp @@6 '\hline'
disp @@6 '\hline'
disp @@3 '\end{tabular}'
if hposition==2 {
if %defined(header)
disp @@3 '\caption{'+header+'}'
}
disp '\end{table}'
*
change output screen
*
end procedure
Re: RATS output and LaTeX
With version 7.3, RATS now supports exporting the contents of any "report" window in TeX format.
For example, you can use the WINDOW option on instructions like FORECAST, PRINT, REPORT, STATISTICS, etc., to display the output to a report window. You can then use File-Export... to export the information to a file in a variety of formats, with TeX now being among the supported formats.
For example, you can use the WINDOW option on instructions like FORECAST, PRINT, REPORT, STATISTICS, etc., to display the output to a report window. You can then use File-Export... to export the information to a file in a variety of formats, with TeX now being among the supported formats.
Re: RATS output and LaTeX
This has been further enhanced with version 8. For one thing, there's now a Copy-->TeX on the Edit menu (and a corresponding toolbar icon) which copies a TeX tabular environment to the clipboard. This makes it quite a bit easier to get the information into a TeX editor since the "Paste" operation in the editor will usually grab the standard delimited text copy in the clipboard. By copying only the Tex version out of RATS, you get the proper behavior. This is what you get by copying the regression table produced out of the adaptive.prg (now adaptive.rpf) example file.moderator wrote:With version 7.3, RATS now supports exporting the contents of any "report" window in TeX format.
For example, you can use the WINDOW option on instructions like FORECAST, PRINT, REPORT, STATISTICS, etc., to display the output to a report window. You can then use File-Export... to export the information to a file in a variety of formats, with TeX now being among the supported formats.
Code: Select all
\newcolumntype{.}{D{.}{.}{-1}}
\begin{tabular}{. . . . . . }
\multicolumn{1}{c}{} & \multicolumn{1}{l}{Variable} & \multicolumn{1}{c}{Coeff} & \multicolumn{1}{c}{Std Error} & \multicolumn{1}{c}{ T-Stat} & \multicolumn{1}{c}{Signif}\\
\multicolumn{1}{l}{1.} & \multicolumn{1}{l}{SQFT} & \multicolumn{1}{r}{ 0.242854} & \multicolumn{1}{r}{ 0.077900} & \multicolumn{1}{r}{ 3.11750} & \multicolumn{1}{r}{0.00182390}\\
\multicolumn{1}{l}{2.} & \multicolumn{1}{l}{YARD} & \multicolumn{1}{r}{ 0.007773} & \multicolumn{1}{r}{ 0.002060} & \multicolumn{1}{r}{ 3.77285} & \multicolumn{1}{r}{0.00016139}\\
\multicolumn{1}{l}{3.} & \multicolumn{1}{l}{POOL} & \multicolumn{1}{r}{ 31.014472} & \multicolumn{1}{r}{ 17.314004} & \multicolumn{1}{r}{ 1.79129} & \multicolumn{1}{r}{0.07324611}\\
\multicolumn{1}{l}{4.} & \multicolumn{1}{l}{LAJOLLA} & \multicolumn{1}{r}{ 102.256649} & \multicolumn{1}{r}{ 15.846660} & \multicolumn{1}{r}{ 6.45288} & \multicolumn{1}{r}{0.00000000}\\
\multicolumn{1}{l}{5.} & \multicolumn{1}{l}{BATHS} & \multicolumn{1}{r}{ 25.893292} & \multicolumn{1}{r}{ 22.196190} & \multicolumn{1}{r}{ 1.16656} & \multicolumn{1}{r}{0.24338619}\\
\multicolumn{1}{l}{6.} & \multicolumn{1}{l}{FIREPL} & \multicolumn{1}{r}{ 28.777792} & \multicolumn{1}{r}{ 18.100197} & \multicolumn{1}{r}{ 1.58992} & \multicolumn{1}{r}{0.11185376}\\
\multicolumn{1}{l}{7.} & \multicolumn{1}{l}{IRREG} & \multicolumn{1}{r}{ 45.311789} & \multicolumn{1}{r}{ 20.222589} & \multicolumn{1}{r}{ 2.24065} & \multicolumn{1}{r}{0.02504861}\\
\multicolumn{1}{l}{8.} & \multicolumn{1}{l}{SPRINK} & \multicolumn{1}{r}{ 48.618835} & \multicolumn{1}{r}{ 14.870864} & \multicolumn{1}{r}{ 3.26940} & \multicolumn{1}{r}{0.00107775}\\
\multicolumn{1}{l}{9.} & \multicolumn{1}{l}{VIEW} & \multicolumn{1}{r}{ 28.937609} & \multicolumn{1}{r}{ 15.991109} & \multicolumn{1}{r}{ 1.80961} & \multicolumn{1}{r}{0.07035688}\\
\multicolumn{1}{l}{10.} & \multicolumn{1}{l}{LSQFT} & \multicolumn{1}{r}{ -964.002131} & \multicolumn{1}{r}{ 394.273886} & \multicolumn{1}{r}{ -2.44501} & \multicolumn{1}{r}{0.01448496}\\
\multicolumn{1}{l}{11.} & \multicolumn{1}{l}{LYARD} & \multicolumn{1}{r}{ -95.490573} & \multicolumn{1}{r}{ 47.917554} & \multicolumn{1}{r}{ -1.99281} & \multicolumn{1}{r}{0.04628227}\\
\multicolumn{1}{l}{12.} & \multicolumn{1}{l}{Constant} & \multicolumn{1}{r}{ 2997.279347} & \multicolumn{1}{r}{ 1168.200087} & \multicolumn{1}{r}{ 2.56572} & \multicolumn{1}{r}{0.01029606}\\
\end{tabular}Code: Select all
\newcolumntype{.}{D{.}{.}{-1}}
\begin{tabular}{. . . . . . }
\multicolumn{1}{c}{} & \multicolumn{1}{l}{Variable} & \multicolumn{1}{c}{Coeff} & \multicolumn{1}{c}{Std Error} & \multicolumn{1}{c}{ T-Stat} & \multicolumn{1}{c}{Signif}\\
\multicolumn{1}{l}{1.} & \multicolumn{1}{l}{SQFT} & \multicolumn{1}{r}{ 0.243} & \multicolumn{1}{r}{ 0.078} & \multicolumn{1}{r}{ 3.118} & \multicolumn{1}{r}{ 0.002}\\
\multicolumn{1}{l}{2.} & \multicolumn{1}{l}{YARD} & \multicolumn{1}{r}{ 0.008} & \multicolumn{1}{r}{ 0.002} & \multicolumn{1}{r}{ 3.773} & \multicolumn{1}{r}{ 0.000}\\
\multicolumn{1}{l}{3.} & \multicolumn{1}{l}{POOL} & \multicolumn{1}{r}{ 31.014} & \multicolumn{1}{r}{ 17.314} & \multicolumn{1}{r}{ 1.791} & \multicolumn{1}{r}{ 0.073}\\
\multicolumn{1}{l}{4.} & \multicolumn{1}{l}{LAJOLLA} & \multicolumn{1}{r}{ 102.257} & \multicolumn{1}{r}{ 15.847} & \multicolumn{1}{r}{ 6.453} & \multicolumn{1}{r}{ 0.000}\\
\multicolumn{1}{l}{5.} & \multicolumn{1}{l}{BATHS} & \multicolumn{1}{r}{ 25.893} & \multicolumn{1}{r}{ 22.196} & \multicolumn{1}{r}{ 1.167} & \multicolumn{1}{r}{ 0.243}\\
\multicolumn{1}{l}{6.} & \multicolumn{1}{l}{FIREPL} & \multicolumn{1}{r}{ 28.778} & \multicolumn{1}{r}{ 18.100} & \multicolumn{1}{r}{ 1.590} & \multicolumn{1}{r}{ 0.112}\\
\multicolumn{1}{l}{7.} & \multicolumn{1}{l}{IRREG} & \multicolumn{1}{r}{ 45.312} & \multicolumn{1}{r}{ 20.223} & \multicolumn{1}{r}{ 2.241} & \multicolumn{1}{r}{ 0.025}\\
\multicolumn{1}{l}{8.} & \multicolumn{1}{l}{SPRINK} & \multicolumn{1}{r}{ 48.619} & \multicolumn{1}{r}{ 14.871} & \multicolumn{1}{r}{ 3.269} & \multicolumn{1}{r}{ 0.001}\\
\multicolumn{1}{l}{9.} & \multicolumn{1}{l}{VIEW} & \multicolumn{1}{r}{ 28.938} & \multicolumn{1}{r}{ 15.991} & \multicolumn{1}{r}{ 1.810} & \multicolumn{1}{r}{ 0.070}\\
\multicolumn{1}{l}{10.} & \multicolumn{1}{l}{LSQFT} & \multicolumn{1}{r}{ -964.002} & \multicolumn{1}{r}{ 394.274} & \multicolumn{1}{r}{ -2.445} & \multicolumn{1}{r}{ 0.014}\\
\multicolumn{1}{l}{11.} & \multicolumn{1}{l}{LYARD} & \multicolumn{1}{r}{ -95.491} & \multicolumn{1}{r}{ 47.918} & \multicolumn{1}{r}{ -1.993} & \multicolumn{1}{r}{ 0.046}\\
\multicolumn{1}{l}{12.} & \multicolumn{1}{l}{Constant} & \multicolumn{1}{r}{ 2997.279} & \multicolumn{1}{r}{ 1168.200} & \multicolumn{1}{r}{ 2.566} & \multicolumn{1}{r}{ 0.010}\\
\end{tabular}