stata极大似然估计示例
时间: 2024-02-05 16:02:52 浏览: 94
以下是一个stata极大似然估计的示例:
```stata
// 导入数据
sysuse auto
// 定义对数似然函数
program define logit
version 14
syntax varlist [if] [in], ///
[fweights(string)] [iweights(string)] ///
[offset(string)] [ll(real scalar)]
tempname b
quietly replace `ll' = 0
qui {
logistic `varlist' `if' `in' `fweights' `iweights' `offset', nocons
matrix `b' = e(b)
replace `ll' = ln(e(exp(1))) if e(sample)
}
return scalar ll = `ll'
end
// 进行极大似然估计
logit foreign weight length
// 查看结果
estimates table
```
阅读全文