Statalist


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

Re: st: ml with mata code, conformability error


From   "Stas Kolenikov" <skolenik@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: ml with mata code, conformability error
Date   Wed, 13 Aug 2008 09:33:25 -0500

Put something like

printf("1")

printf("2")

scattered throughout the program, to see which fragment breaks down.
It is very hard to tell just looking at your code where the problem
is. If that's a multinomial logit, why not use the official Stata
command?

On 8/13/08, Changwoo Lee <pfak2121@bu.edu> wrote:
> 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/
>


-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.
*
*   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