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]
Re: st: Mata, receiving conformability error in maximising the logistic log-likelihood function
From
Christophe Kolodziejczyk <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Mata, receiving conformability error in maximising the logistic log-likelihood function
Date
Mon, 31 Mar 2014 12:20:32 +0200
Dear Elya
When b is a scalar b*x is comformable.
But if b is a 1 x 2 (row)vector and x is a N x 2 matrix, then
b*x is not.
try rather x*b' instead
Best
Christophe
2014-03-31 8:59 GMT+02:00 Eilya Torshizian <[email protected]>:
> Dear Statalisters,
>
> I am writing a very simple mata code for maximising a logistic log-likelihood function. I aim at estimating the "y = xb" regression function, where y is a binary variable. The following code works fine if the independent variable (x) would be a single column vector, i.e. x=[.,1]:
>
> void LOG(todo, b, y, x, LOG, g,H)
> {
> LOG = y:*(-ln(1:+exp(b*x))) :+ (1 :- y):*(b*x :- ln(1:+exp(b*x)))
> }
> p = J(1,cols(x),1)
> i=optimize_init()
> optimize_init_evaluator(i, &LOG())
> optimize_init_evaluatortype(i, "gf0")
> optimize_init_params(i,p)
> optimize_init_technique(i,"nr")
> optimize_init_argument(i,1,y)
> optimize_init_argument(i,2,x)
> optimize(i)
>
> However, if x would be [.,2] I will get a conformability error. I would appreciate your help.
>
> Thanks for your time,
> Eilya.
>
>
> *
> * 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/
--
Christophe Kolodziejczyk
Research Fellow
AKF, Anvendt KommunalForskning
Danish Institute of Governmental Research
Købmagergade 22
DK-1150 København K
*
* 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/