Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Defining a matrix in ml program
From
Cyrus Levy <[email protected]>
To
statalist <[email protected]>
Subject
st: Defining a matrix in ml program
Date
Sun, 10 Mar 2013 14:38:56 -0400
In the ml program below, I want to define a matrix based on parameter
equations and use that matrix later in lnL. But "ml check" command
returns an error in the line where I define the matrix MT. I am
wondering if it is possible or not at all to create matrices in Stata
based on ml parameters in this context. If yes, what is wrong with my
code and how can I fix it?
sysuse auto, clear
capture program drop maxauto
program maxauto
version 12
args todo b lnf
tempvar b1x b0 sigma eta1 eta2 eta3 eta4
mleval `b1x' = `b', eq(1)
mleval `b0' = `b', eq(2)
mleval `sigma' = `b', eq(3)
mleval `eta1' = `b', eq(4)
mleval `eta2' = `b', eq(5)
mleval `eta3' = `b', eq(6)
mleval `eta4' = `b', eq(7)
tempname MT
matrix define `MT' = [`eta1', `eta2'\ `eta3', `eta4']
// tempvar res epsilon
// quietly gen double `epsilon' = $ML_y2 - `b0'
// quietly gen double `res' = $ML_y1 - `epsilon'*(1-exp(-`b1x'))
// mlsum `lnf' = -0.5*ln(2*_pi)-ln(`sigma')-0.5*`res'^2/`sigma'^2
end
ml model d0 maxauto (b1: rep78 = headroom, nocons) (b0: ) (sigma: )
(eta1: ) (eta2: ) (eta3: ) (eta4: )
ml check
ml max
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/