[Limdep Nlogit List] Error 185 using Krinsky and Robb bootstrapping method

William Greene wgreene at stern.nyu.edu
Fri Apr 8 22:03:54 AEST 2016


Nathan. WALD does not save the draws from K&R as variables or matrices.
But, you
can program this computation as shown below.  (Note, your WALD command does
not
need to operate on all 36 coefficients, as you are only using the first 8.)
 Here is a routine
that will create the draws on WTP.
/Bill Greene


? Covariance matrix for parameter estimates. 8x8 and 8x1
Matrix ; vz = varb(1:8,1:8) $
Matrix ; bz = b(1:8) $
Sample ; 1 - 1000 $
? Random draws for K&R, z is 1000x8
Create ; z1=rnn(0,1) ; z2 = rnn(0,1) ; z3 = rnn(0,1) ; z4 = rnn(0,1)
       ; z5=rnn(0,1) ; z6 = rnn(0,1) ; z7 = rnn(0,1) ; z8 = rnn(0,1) $
Name   ; z = z1,z2,z3,z4,z5,z6,z7,z8 $
? Move random draws to matrix area. mz is 1000x8
Matrix ; mz = z $
? Linear transformation of standard normal draws. C is 8x8
? wz is 1000x8 $
Matrix ; C = Chol(vz) $
Matrix ; wz = mz*C $
? Move draws back into data area
Create ; z = wz $
? Create random draws from asymptotic distribution
Create ; bw1 = bz(1) + z1 ; bw2 = bz(2) + z2
       ; bw3 = bz(3) + z3 ; bw4 = bz(4) + z4
       ; bw5 = bz(5) + z5 ; bw6 = bz(6) + z6
       ; bw7 = bz(7) + z7 ; bw8 = bz(8) + z8 $
Create ; wtp1 = -bw1/bw7
       ; wtp2 = -bw2/bw7
       ; wtp3 = -bw3/bw7
       ; wtp4 = -bw4/bw7
       ; wtp5 = -bw5/bw7
       ; wtp6 = -bw6/bw7
       ; wtp7 = -bw8/bw7 $


On Wed, Apr 6, 2016 at 10:50 PM, Nathan P. Kemper <nkemper at uark.edu> wrote:

> Professor Hensher,
>
> The example you suggested helped me a great deal. Thank you. I was able to
> generate Wald functions using K&R with 1000 draws.  The code below gives me
> the means of the variables and the z, C.I.  However, because I would like
> the take the next step of using the combinatorial test, I need to be able
> to save the distribution of the 1000 MWTPs so that I can then apply the Poe
> test in order to test treatment effects across my 5 treatments. Is there a
> way in the Wald command to save the bootstraps? I have placed the WALD
> codes I used which uses b and varb as the starting points and calculates
> the mean WTP using 1000 K&R but only reports the mean.
>
> When I use my old code which works flawlessly for some of my treatments, I
> get that pesky error:
>
> Error    185: MATRIX - GINV,SINV,CHOL  singular, not P.D. if SINV or CHOL
>
> I searched on the internet a solution to this problem, but without
> success. I believe it is related to the fact that I'm dividing coefficients
> by coefficients which is resulting in some values that cause the "not P.D."
> error and shut down the routine. I am wondering whether it is a coding or
> data issue.  Or if I can use the new Wald command to generate a
> distribution of 1,000 WTPs?
>
> Sorry for bothering again. Here is my ECLOGIT code for treatment 5 and the
> Wald functions below. Also, I placed the Wald proc output at the end.  A
> sincere thank you in advance for any further advice.
>
> sample; all$
> ECLOGIT; IF [cell=5];
>     Lhs=CHOICE;
>     Choices=PRODA, PRODB, NONE;
>     RPL;
>     Pts= 250;
>     halton;
>     FCN= bng(n),bgm(n),blo(n),bmd(n),bhi(n),blc(n);
>     Correlated;
>     PDS = 8;
>     PARAMETERS;
>     MODEL:
>     U (PRODA)=bprice*price+bng*ng+bgm*gm+blo*lo+bmd*md+bhi*hi+blc*lc/
>     U (PRODB)=bprice*price+bng*ng+bgm*gm+blo*lo+bmd*md+bhi*hi+blc*lc/
>     U (NONE)=bnone*none;
> ECM = (PRODA,PRODB)$
> matrix
>     ;v_varb = part(varb,1,36,1,36)
>     ;b_b    = part(b,1,36,1,1)
>     $
> WALD; Labels =
> a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,
>
>  a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36
>     ; Start  = b_b
>     ; Var    = v_varb
>     ; Fn1 = wtpng = a1/-a7
>     ; Fn2 = wtpgm = a2/-a7
>     ; Fn3 = wtplo = a3/-a7
>     ; Fn4 = wtpmd = a4/-a7
>     ; Fn5 = wtphi = a5/-a7
>     ; Fn6 = wtplc = a6/-a7
>     ; Fn7 = wtpno = a8/-a7
>     ; k&r ; pts=1000$
>
>
> -----------------------------------------------------------------------------
> WALD procedure. Estimates and standard errors
> for nonlinear functions and joint test of
> nonlinear restrictions.
> Wald Statistic             =    464.47987
> Prob. from Chi-squared[ 7] =       .00000
> Krinsky-Robb method used with 1000 draws
> Functions are computed at means of variables
>
> --------+--------------------------------------------------------------------
>         |                  Standard            Prob.      95% Confidence
> WaldFcns|  Coefficient       Error       z    |z|>Z*         Interval
>
> --------+--------------------------------------------------------------------
>    WTPNG|    3.14315***      .61879     5.08  .0000     1.93034   4.35595
>    WTPGM|   -1.76899***      .29734    -5.95  .0000    -2.35176  -1.18622
>    WTPLO|     .87775**       .37497     2.34  .0192      .14281   1.61268
>    WTPMD|     .35289         .33414     1.06  .2909     -.30202   1.00779
>    WTPHI|     .71558**       .28931     2.47  .0134      .14853   1.28263
>    WTPLC|    1.60495***      .24355     6.59  .0000     1.12760   2.08230
>    WTPNO|   -8.23527***      .49023   -16.80  .0000    -9.19610  -7.27445
>
> --------+--------------------------------------------------------------------
> Note: ***, **, * ==>  Significance at 1%, 5%, 10% level.
>
> -----------------------------------------------------------------------------
>
>
> Nathan Kemper
> Dept. of Agricultural Economics and Agribusiness
> University of Arkansas - Fayetteville
>
> _______________________________________________
> Limdep site list
> Limdep at limdep.itls.usyd.edu.au
> http://limdep.itls.usyd.edu.au
>



-- 
William Greene
Department of Economics
Stern School of Business, New York University
44 West 4 St., 7-90
New York, NY, 10012
URL: http://people.stern.nyu.edu/wgreene
Email: wgreene at stern.nyu.edu
Ph. +1.212.998.0876


More information about the Limdep mailing list