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

From |
Bob Hammond <robert_hammond@ncsu.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Using for within Mata optimize to loop over observations |

Date |
Mon, 16 Feb 2009 15:17:57 -0500 |

All,

Thanks in advance for any thoughts, Bob >>>>>>>>>>> clear clear mata set obs 10 gen double z = runiform() gen double x = . gen double x2 = . mata: function myfunc(x,z) return(-2*(x-z)) for(i=1;i<=st_nobs();i++) { z = st_data(i,"z") rc = mm_root(x = ., &myfunc(), 0, 1, 0, 1000, z) st_store(i,"x",x) } void eval0(todo, x, v, g, H)

v = -(x-z)^2 } for(i=1;i<=st_nobs();i++) { S = optimize_init() optimize_init_evaluator(S, &eval0()) optimize_init_params(S, 0) x = optimize(S) st_store(i,"x2",x) } end list -- ------------------------------------------------------------------------ Bob Hammond Department of Economics North Carolina State University Office: (919) 513-2871 Fax: (919) 515-7873 http://www4.ncsu.edu/~rghammon/ * * 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/

- Prev by Date:
**Re: st: Left-justify labels for categories, using -graph hbar- ?** - Next by Date:
**Re: st: Mata version control** - Previous by thread:
**st: Retaining factors of a principal axis analysis using eigenvalues** - Next by thread:
**st: Using for within Mata optimize to loop over observations** - Index(es):

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