stata

Ado file return matrix


I'm trying to write an ado file that return my matrix

prog drop EM
program define EM, eclass
matrix P0 = (.9, 0.09,0.01 \ 0.1, 0.8, 0.1 \ 0.05, 0.15, 0.8)
return P0
end

EM

The error I got is invalid syntax. How to solve this? Thank you.


Solution

  • There are two errors that I can see.

    Your program needs to be r-class to use return, not e-class.

    You need to declare

    return matrix P0 = P0