Bookmark and Share

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: Mata, receiving conformability error in maximising the logistic log-likelihood function


From   Eilya Torshizian <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Mata, receiving conformability error in maximising the logistic log-likelihood function
Date   Mon, 31 Mar 2014 06:59:41 +0000

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index