Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exporting vecrank test to Latex

    Hi all,
    Is there a way to export Johansen's test for cointegration (code: vecrank) from stata into latex?
    Many Thanks,
    Vishna

  • #2
    This is an example provided by Bjarte Aagnes from this thread: https://www.statalist.org/forums/for...a-vecrank-test. I use estout from SSC to output the resulting matrix.

    Code:
    webuse balance2 , clear
    
    tempfile res
    
    qui {
        log using `res' , text replace
        noi vecrank y i c
        log close
    }
    
    insheet using `res' , clear
    
    keep if sum(strpos(v1,"5%"))
    drop if regexm(v1,"^-*$")
    
    ********************************************************************************
    
    local notcomplete 2
    
    split v1 if _n > `notcomplete' , gen(c)
    
    replace v1 = " " * ( 79 - length(v1) ) + v1
    
    forvalues n = 1/`notcomplete' {
    
        foreach w in `=v1[`n']' {
            
            loc c = -1 + int( .1*(1+strpos("`=v1[`n']'"," `w'") + .5*length("`w'")))
            replace c`c' = c`c' + "`w'" if _n == `n'    
        }
    }
    
    ********************************************************************************
    
    drop v1
    
    scalar vns = "" /* to contain list of column names */
    
    foreach c of varlist c* {
    
        lab var `c' "`=trim(itrim(`c'[1] + " " + `c'[2] + " " + `c'[3]))'"    
        scalar vns = scalar(vns) + `""`: var lab `c''" "'
    }
    
    drop if mi(real(c1))
    destring * , replace
    
    mkmat c* , matrix(res)
    matrix colnames res = `=scalar(vns)'
    
    esttab matrix(res) using myfile.tex, replace mlab(none) coeflab(none) substitute(% "\%" .& " &" .\\ " \\")
    Res.:

    Code:
    . esttab matrix(res), mlab(none) coeflab(none) tex substitute(% "\%" .& " &" .\\ " \\")
    
    \begin{tabular}{l*{6}{c}}
    \hline\hline
                &maximum rank&       parms&          LL&  eigenvalue&trace statistic&5\% critical value\\
    \hline
                &           0&          12&    1248.338&            &     32.4539&       29.68\\
                &           1&          17&    1255.498&       .1413&     18.1344&       15.41\\
                &           2&          20&    1260.701&       .1048&      7.7277&        3.76\\
                &           3&          21&    1264.565&      .07892&            &            \\
    \hline\hline
    \end{tabular}
    Last edited by Andrew Musau; 31 Mar 2023, 12:25.

    Comment

    Working...
    X