Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Martin Nybom <martin.nybom@sofi.su.se> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Maximum likelihood estimation of a probit with free variance and constrained coefficient |

Date |
Wed, 07 Mar 2012 11:49:46 +0100 |

Hello,

************************ clear all program define syndata version 12.0 args obs qui { set obs `obs' gen x1 = uniform()*4 gen x2 = uniform()*2 - 1 gen e = logit(uniform()) scalar b0 = -2 scalar b1 = 1 scalar b2 = 2 gen y_1 = scalar(b0) + scalar(b1)*x1 + scalar(b2)*x2 + e gen pr_y = invlogit(scalar(b0) + scalar(b1)*x1 + scalar(b2)*x2 + e) gen y = (pr_y>=0.5) } end ************************* And then the ml code proceeds as follows: ************************* syndata 1000 set more off constraint define 1 x2 = 2 global ML_y1 `y' cap program drop probit2_lf program define probit2_lf version 12.0 args lnf xb sigma tempvar lnlj qui { gen double `lnlj' = ln(normal( `xb'/`sigma')) if $ML_y1 == 1 replace `lnlj' = ln(normal(-`xb'/`sigma')) if $ML_y1 == 0 replace `lnf' = `lnlj' } end ml model lf probit2_lf (y = x1 x2) /sigma, constraints(1) ml maximize ***************************

Thanks for your consideration! Martin Nybom -- Martin Nybom Institute for Social Research Stockholm University * * 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/

**Follow-Ups**:**Re: st: Maximum likelihood estimation of a probit with free variance and constrained coefficient***From:*Stas Kolenikov <skolenik@gmail.com>

- Prev by Date:
**Re: st: How to convert Daily data with gaps to weekly?** - Next by Date:
**st: generating variables based on the co-occurrence of ids in groups over time** - Previous by thread:
**st: Getting number of files via -fs-** - Next by thread:
**Re: st: Maximum likelihood estimation of a probit with free variance and constrained coefficient** - Index(es):