2013-08-05 78 views
1

ADO文件使用最大似然的,我想了解在Stata使用最大似然(我目前使用book第三版古尔德等人为此)。特别是,我专注于用户程序craggit。命令的细节可以在Stata article中找到。当使用view source craggit.ado时,我可以看到ado文件中的所有代码。在ADO文件[下面详细说明],我看到ml使用lf方法,但不通在文件中我看到的最大似然命令(probittruncreg在文章中指定)。请让我知道我是否缺少一些东西。在塔塔

program craggit 
     version 9.2 
     if replay() { 
       if ("`e(cmd)'" != "craggit") error 301 
       Replay `0' 
     } 
     else { 

     //Checking data structure 

     syntax varlist [fweight pweight] [if] [in], SECond(varlist) [ /// 
       Level(cilevel) CLuster(varname) HETero(varlist) *  /// 
     ] 
     gettoken lhs1 rhs1 : varlist  
     gettoken lhs2 rhs2 : second 
     marksample touse 
     quietly sum `lhs1' if `touse' 
     local minval1 = r(min) 

     quietly sum `lhs2' if `touse' 
     local minval2 = r(min) 
     if `minval1'<0 | `minval2'<0 { 
       di "{error:A dependant variable is not truncated at 0: {help craggit} is 
> not appropriate}" 
     } 

     else Estimate `0' 

     } 
end 

program Estimate, eclass sortpreserve 
     di "" 
     di "{text:Estimating Cragg's tobit alternative}" 
     di "{text:Assumes conditional independence}" 
     syntax varlist [fweight pweight] [if] [in], SECond(varlist) [ /// 
       Level(cilevel) CLuster(varname) HETero(varlist) *  /// 
     ]  

     mlopts mlopts, `options' 
     gettoken lhs1 rhs1 : varlist 
     gettoken lhs2 rhs2 : second 
     if "`cluster'" != "" { 
       local clopt cluster(`cluster') 
     } 

     //mark the estimation subsample 
     marksample touse 

     //perform estimation using ml 
     ml model lf craggit_ll           /// 
       (Tier1: `lhs1' = `rhs1')        /// 
       (Tier2: `lhs2' = `rhs2')        /// 
       (sigma: `hetero')          /// 
       [`weight'`exp'] if `touse', `clopt' `mlopts'   /// 
       maximize 
     ereturn local cmd craggit 

     Replay, `level' 
end 

program Replay 
     syntax [, Level(cilevel) *] 
     ml display, level(`level') 
end 

回答

2

的数似然函数计算文件craggit_ll.ado的,这样就看你需要输入viewsource craggit_ll.ado

后面在一个单独的文件中存储的对数似然评估程序的逻辑是在craggit.ado文件中定义的,除了非常第一个所有的程序,是本地存储在该文件中的命令,所以ml不会能够看到它。通过将其存储在单独的文件中,craggit_ll命令将变为全局,并且ml将能够使用它。

+0

非常感谢澄清。 – Metrics