Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: ML Program and ML Maximize Help


From   Greg Evans <[email protected]>
To   [email protected]
Subject   st: ML Program and ML Maximize Help
Date   Mon, 08 Sep 2008 14:41:23 -0400

Hello All,
This is my first post to the listserv so please excuse any errors in my attempt to ask my question. And thank you in advance for your help.

I am trying to write a maximum likelihood program to run on a panel dataset and am getting a "varlist required" error message. The error comes at the end of the code so all steps seem to run until the ml maximize step.

I am following from the "ML Maximum Likelihood Estimation with Stata" Third Edition book (authors William Gould, Jeffrey Pitblado, and William Sribney). Since the error comes at the end, after the ml maximize statement, I'm assuming the error is telling me I need a varlist in the ml maximize statement, but I could be wrong. Based on the book, it does not appear that I need to specify variables in the ml maximize statement. The variables, it would seem, are to be specified in the ml model statement, not the ml maximize statement.

Here is the text of the code:

clear
set mem 100m
set more off

use "G:\Dissertation Data\TSP Stock Data\ile.dta"

global stock

program define lesmond
version 10.1
args todo b lnf
tempvar alpha1 alpha2 beta sigma last
mleval `alpha1' = `b', eq(1)
mleval `alpha2' = `b', eq(2)
mleval `beta' = `b', eq(3)
mleval `sigma' = `b', eq(4)
// MY_panel contains the panel ID
local by $stock
sort `by'
local ri_r $ML_y1
quietly {
by `by': gen `last' = _n==_N

mlsum `lnf'= = -ln(`sigma') - (1/(2*`sigma'^2))*($ML_y1 + `alpha1' - `beta')^2 if $ML_y1 < 0
replace `lnf' = -ln(`sigma') - (1/(2*`sigma'^2))*($ML_y1 + `alpha2' - `beta')^2 if $ML_y1 > 0
replace `lnf' = ln(normal(`alpha2'-`beta')/`sigma') - normal(`alpha1'-`beta')/`sigma') if $ML_y1=0
if `last' == 1
}
end


ml model d0 lesmond (alpha1:) (alpha2:) (beta: ri_r=li_r, nocons) (sigma:)

ml maximize

--
~~~~~~~~~~~~~~~~~~~~~
Greg Evans
University of Georgia
Choose Happy!
*
* 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