Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Defining a matrix in ml program

From   Cyrus Levy <>
To   statalist <>
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

ml model d0 maxauto (b1: rep78 = headroom, nocons) (b0: ) (sigma: )
(eta1: ) (eta2: ) (eta3: ) (eta4: )
ml check
ml max
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index