Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Adding -nocons- to -mlbeta-


From   "Clive Nicholas" <Clive.Nicholas@newcastle.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: Adding -nocons- to -mlbeta-
Date   Tue, 24 May 2005 20:48:18 +0100 (BST)

All,

Hello again! Nice to be back...

I have a query about a user-written program called -mlbeta-, which runs
maximum-likelihood beta-distributed regression models. These models have
been shown to be sometimes more suitable than OLS models when the response
variable is a proportion between 0 and 1 (Paolino 2001). They model the
impact of the control variables not just on the mean of the response, but
also on its variance. If you're not familar with it, the code is presented
below:

program define mlbeta, rclass

version 8
syntax varlist [if][in] [,DIspersion(varlist)] [,Robust] [,svy] [,nocons]
tokenize `varlist'
marksample touse
if "`svy'"!=""{
	svymarkout `touse'
}
local lhs "`1'"
mac shift
local rhs "`*'"
ml model lf mlbeta_ll (`lhs'=`rhs') (`dispersion') `if' `in', `robust'
`svy' `nocons'
ml search
ml maximize
tempvar error
quietly {
	predict `error' if e(sample)
	replace `error' = exp(`error')/(1+exp(`error'))
	replace `error' = (`lhs' - `error')^2
	su `error', meanonly
}
	display in green _n "Mean squared error: " in yellow `r(mean)'
end

This code was first presented in a pre-publication draft to Buckley
(2003). There is the mlbeta_ll.ado file which calculates the
log-likelihood, but isn't relevant to this post. To download -mlbeta-,
type:

. net from http://www2.bc.edu/~bucklesj

There is, however, something which is not officially part of -mlbeta-: the
addition of the -nocons- option. I wanted the routine to be able to
include my choice of constants in the model, typically mutually-exclusive
dummy variables, in much the same way as is handled by -reg-. I was
advised by -mlbeta-'s author to try adding -nocons- to the code to get
what I wanted, as, unlike -hascons-, this should work with -ml-'s
estimating routines. As you can see from the code, it was added in exactly
the same way as the -robust- option, which _is_ part of -mlbeta-.
Unfortunately, -mlbeta- completely ignores -nocons-:

. mlbeta sqgovote conadmin labadmin sqgpchg sqbeldm weakgovt, robust nocons
note: labadmin dropped due to collinearity
initial:       log pseudolikelihood =  58.897248

[...]

Iteration 5:   log pseudolikelihood =   218.1697

                                                Number of obs   =        118
                                                Wald chi2(4)    =      59.30
Log pseudolikelihood =   218.1697               Prob > chi2     =     0.0000
----------------------------------------------------------------------------
           |               Robust
  sqgovote |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-----------+----------------------------------------------------------------
eq1        |
  conadmin |  -.0765583    .112732    -0.68   0.497    -.2975089    .1443923
   sqgpchg |   .8231001    .136534     6.03   0.000     .5554984    1.090702
   sqbeldm |  -.9002064   .1771583    -5.08   0.000     -1.24743   -.5529826
  weakgovt |   .1150282   .1120976     1.03   0.305    -.1046791    .3347354
     _cons |   -2.49654   .2900482    -8.61   0.000    -3.065024   -1.928056
-----------+----------------------------------------------------------------
eq2        |
     _cons |   3.069133    .369329     8.31   0.000     2.345261    3.793004
----------------------------------------------------------------------------
Mean squared error: .006385

Were -nocons- to work, both -conadmin- and -labadmin- (a pair of
mutually-exclusive dummy variables) would be included, as it is when using
-reg-:

. reg sqgovote conadmin labadmin sqgpchg sqbeldm weakgovt, robust nocons

Regression with robust standard errors               Number of obs =     118
                                                     F(  5,   113) =   19.93
                                                     Prob > F      =  0.0000
                                                     R-squared     =  0.4408
                                                     Root MSE      =  .08152
----------------------------------------------------------------------------
           |               Robust
  sqgovote |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-----------+----------------------------------------------------------------
  conadmin |   .0666841   .0267032     2.50   0.014     .0137803    .1195878
  labadmin |   .0744811   .0283499     2.63   0.010     .0183148    .1306475
   sqgpchg |   .0548743   .0155478     3.53   0.001     .0240714    .0856773
   sqbeldm |  -.0588733   .0154754    -3.80   0.000    -.0895328   -.0282139
  weakgovt |   .0164249   .0159273     1.03   0.305    -.0151299    .0479797
----------------------------------------------------------------------------

If anybody out there can shed some light as to what I'm missing, I'd be
very grateful to you.

CLIVE NICHOLAS        |t: 0(044)7903 397793
Politics              |e: clive.nicholas@ncl.ac.uk
Newcastle University  |http://www.ncl.ac.uk/geps

References:

Buckley J (2003) "Estimation of Models With Beta-Distributed Dependent
Variables: A Replication and Extension to Paolino's Study" POLITICAL
ANALYSIS 11(2): 204-5.

Paolino P (2001) "Maximum Likelihood Estimation of Models With
Beta-Distriuted Dependent Variables" POLITICAL ANALYSIS 9(4): 325-46.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index