Hi all,

I estimated a VAR model using the standard var-command and want to run a function called varmodtest afterwards. The function simply exploits the "modtest" command and merges different specification test results into a matrix which is passed back.

<hansl>
function matrix varmodtest (scalar order "Lag length")
    #Serial correlation
    modtest order --autocorr --quiet
    matrix OUTSC = $pvalue' | $test'
   
    return OUTSC
end function

var 2 LRM IBO
matrix A = varmodtest(4)
<\hansl>

But I obtain the error:
"Can't do this: no model has been estimated yet
Data error
*** error in function varmodtest"

How can the function grab information from the previous VAR estimation?

Thanks in advance!
Artur