Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: ml with mata code, conformability error


From   "Changwoo Lee" <pfak2121@bu.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: ml with mata code, conformability error
Date   Wed, 13 Aug 2008 09:34:41 -0400

Hi all,

I have two mata function code to use ml. one  works but the other does not
work. I wonder why the second  code do not work.
This is the part of my first function code with mata. When I use this code
with ml, it works

******************************************
y1 = *(findexternal("y1e"))

st_view(xb1, ., xb1e)

p0 = 1:/(1 :+ (exp(xb1 :+ rnd1)))
p1 = p0:*exp(xb1 :+ rnd1)
llogit = (1:-y1):* p0 :+ y1:*p1

L = (rowsum(llogit))/S
L=rowmax((L , J(N,1,smallestdouble())))
vlnL = ln(L)
******************************************

This is second one. Whenever I run ml with this function, the conformability
error appear. Could you let me know any problem with that?

******************************************
y1 = *(findexternal("y1e"))
y21 = *(findexternal("y21e"))
y22 = *(findexternal("y22e"))
y23 = *(findexternal("y23e"))

st_view(xb1, ., xb1e)
st_view(xb21, ., xb21e)
st_view(xb22, ., xb22e)
st_view(xb23, ., xb23e)

L1=st_numscalar(lambda1)
L2=st_numscalar(lambda2)
L3=st_numscalar(lambda3)


p20 = 1:/(1 :+ (exp(xb21 :+ L1:*rnd1) + exp(xb22 :+ L2:*rnd1) + exp(xb23 :+
L3:*rnd1)))
p21 = p20:*exp(xb21 :+ L1:*rnd1)
p22 = p20:*exp(xb22 :+ L2:*rnd1)
p23 = p20:*exp(xb23 :+ L3:*rnd1)
mnl = (1:-(y21+y22+y23)):* p20 :+ y21:*p21 :+ y22:*p22 :+ y23:*p23

dd= (2:*y1:-1)
mu = xb1 :+ rnd1
logit = invlogit(dd:*mu)

mnllogit = logit :* mnl
L = (rowsum(mnllogit))/S
L=rowmax((L , J(N,1,smallestdouble())))
vlnL = ln(L)
*******************************************
Thanks,
Changwoo Lee
Ph.D Candidate in Economics
Boston University

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index