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, statalist.org is already up and running.


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

st: programming in stata - problems with optimize


From   "A.J van der Vlist" <vlist001@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: programming in stata - problems with optimize
Date   Fri, 22 Jul 2011 22:19:00 +0200

Dear Statalisters,
 
I encouter problems in optimizing function f:
 
I would like to solve for mu:
 
 sum over i {  Nx_i' * (mu - Xbeta_i) } = Sk 
 
Nx = [n x 1] , vector of {1/n}'s  in order to sum over i
mu = parameter 
Xbeta = [n x 1] vector of fitted values
Sk = scalar
 
This is what I tried:
 
scalar Sk1=Sm1_SRA
mata:
X=st_data(.,"Xbeta")
Nx=st_data(.,"Nxi")
void mymodelb(todo, mu2, f, g, H)
{
external Nx, X 
hlp=(mu2 :- X)
f = (Nx' * normal(hlp)) - Sk1 
}
S = optimize_init()
optimize_init_evaluator(S, &mymodelb())
optimize_init_params(S, 0)
mu2 = optimize(S)
problem:
 
1) I get problems when running with Sk1 in f
2) when I substitute for Sk1 =0.501 in f the code will give a result - yet unreasonable high +e11
 
Suggestions are very welcome.
 
Arno 		 	   		  
*
*   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   |   Site index