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

st: Re: Programming question


From   "Anthony Gichangi" <[email protected]>
To   <[email protected]>
Subject   st: Re: Programming question
Date   Fri, 24 Oct 2003 12:03:04 +0200

Hi Antonio,
Your estimation of the variance has some errors. If you make
it like this

gen v= ((ntcrimes/pop)*((pop-ntcrimes)/pop))/(pop*(normden(lpe1)^2))

you should get the appropriate results..

You can see how i  reproduced the results below
clear
set obs 500000
generate x1 = abs(invnorm(uniform()))
generate x2 = abs(invnorm(uniform()))
generate lp = 1 + .5*x1 - .25*x2
generate mu = exp(lp)
rndpoix mu
rename xp ntcrimes
gen pop = round(100*uniform())+ ntcrimes
gen double p=ntcrimes/pop
gen double lpe1 =invnorm(p)
gen v= ((ntcrimes/pop)*((pop-ntcrimes)/pop))/(pop*(normden(lpe1)^2))
gprobit ntcrimes pop x1 x2
regress lpe1 x1 x2 [aweight=1/v]

gprobit  ntcrimes pop x1 x2

Weighted least-squares probit estimates for grouped data

      Source |       SS       df       MS              Number of obs =
472531
-------------+------------------------------           F(  2,472528)
=29169.51
       Model |    10652.8642     2   5326.4321           Prob > F      =
0.0000
    Residual |     86284.8961472528  .182602716           R-squared     =
0.1099
-------------+------------------------------           Adj R-squared =
0.1099
       Total |  96937.7603472530  .205146256           Root MSE      =
.42732

----------------------------------------------------------------------------
--
    ntcrimes |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
          x1 |     .2110069   .0009378   224.99   0.000     .2091688
.212845
          x2 |     -.0964621   .0010868   -88.76
0.000    -.0985921   -.0943321
       _cons |  -1.546212   .0013383 -1155.35
0.000    -1.548835   -1.543589
----------------------------------------------------------------------------
--

. regress lpe1 x1 x2  [aweight=1/v]
(sum of wgt is   6.1780e+06)

      Source |       SS       df       MS              Number of obs =
472531
-------------+------------------------------           F(  2,472528)
=29169.51
       Model |  10652.8642     2  5326.43212           Prob > F      =
0.0000
    Residual |  86284.8962472528  .182602716           R-squared     =
0.1099
-------------+------------------------------           Adj R-squared =
0.1099
       Total |  96937.7604472530  .205146256           Root MSE      =
.42732

----------------------------------------------------------------------------
--
        lpe1 |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
          x1 |   .2110069   .0009378   224.99   0.000     .2091688
.212845
          x2 |  -.0964621   .0010868   -88.76
0.000    -.0985921   -.0943321
       _cons |  -1.546212   .0013383 -1155.35
0.000    -1.548835   -1.543589
----------------------------------------------------------------------------
--

Regards

Anthony
----- Original Message ----- 
From: "Antonio Rodrigues Andres" <[email protected]>
To: <[email protected]>
Sent: Friday, October 24, 2003 9:43 AM
Subject: st: Programming question


> Dear friends
>
>
> I run this regression using probit grouped data regression models
>
> gprobit ntcrimes pop cl income1 pyoung pforeign unempl $zvars
>
> I have tried to replicate the analysis
>
> gen lpe1=invnorm(ntcrimes/pop)
> gen v= (ntcrimes/pop)*(pop-ntcrimes/pop)/(pop*normden^2*lpe1)
>
> regress lpe1 cl income1 pyoung pforeign unempl $zvars [aweight=1/v]
>
>
> but I dont get the same results I guess the problem is concerning with
> the weights
>
> Antonio
> *
> *   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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index