Statalist


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

st: re: passing a scalar argument to an ML evaluator


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: passing a scalar argument to an ML evaluator
Date   Sun, 14 Feb 2010 14:42:59 -0500

<>
Laszlo asks:

My example: I want to code up the estimation of a truncated lognormal
model. The point of truncation should be a simple scalar my evaluator
uses. But how do I need to define that in my -ml model-, and how can
use it in the evaluator ado?


No need to pass anything, as currently defined scalars are visible to all programs:

program drop _all
program mynormal_lf_scalar 
	version 11 
	args lnf mu sigma 
	quietly replace `lnf' = ///
	myscalar * ln(normalden($ML_y1, `mu', `sigma' )) 
end

sysuse auto, clear
scalar myscalar = 1
ml model lf mynormal_lf_scalar /// 
(mpg = weight displacement) /sigma
ml maximize
 
scalar myscalar = 2
ml model lf mynormal_lf_scalar /// 
(mpg = weight displacement) /sigma
ml maximize



Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
                              An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index