[Limdep Nlogit List] interactions in binary logit models

A.M.Zanni at lboro.ac.uk A.M.Zanni at lboro.ac.uk
Tue Jun 29 03:39:41 EST 2010


Dear Prof Greene,

thanks for replying to my previous query, the problem was 
indeed the one  you highlighted.

I have another question on the same subject (interactions 
in binary  logit models). I will use the code you provided 
in your Economic Letters  2010 paper for my question:



Sample   ; All $
Create   ; int = female*age$
Probit   ; lhs = doctor
          ; Rhs = 
female,age,int,one,educ,hhninc,hhkids,married $
Matrix   ; bz = b(4:8) ; bzz = bz'zbar $
Calc     ; df = b(1) ; da = b(2) ;di = b(3) $
Create   ; ME_Malei = phi(     da*age            + bzz)
          ; ME_FEMi  = phi(df + da*age + di * age + bzz) $
Calc     ; Ran (123479) $
Draw     ; N=2733 $
Plot     ; lhs = age ; rhs = ME_Malei,ME_FEMi ; fill ; 
Grid
          ; Title=Partial Effects for Men and Women with 
Interaction
          ; Vaxis=Partial Effects$
  

I am trying to work out how to modify the code above to 
consider a logit  rather than a probit model and I am 
struggling a little. Would  replacing 'phi' with 'lgp' be 
enough?

Also, how would I calculate the estimated probabilities, 
interaction  effects and standard deviation for this case 
when a dummy is interacted  with a continuous variable in 
a logit.

I tried the following

samp;all$
--> create ; sdindex=sqr(qfr(all,varb))
    ; tindex = all_b/sdindex $

with no success.

Thanks and best regards

Alberto 



On Fri, 18 Jun 2010 17:43:11 -0400 (EDT)
 William Greene  <wgreene at stern.nyu.edu> wrote:
> M. Zanni. It looks like the  PROBIT command has only 25 
>variables in 
> it, so b(3:26)  has a bad subscript.  Since BZ then does 
>not exsit, 
>  nothing after that will work.  
> /B. Greene
> 
> 
>  
> ----- Original Message -----
>From: "A M Zanni"  <A.M.Zanni at lboro.ac.uk>
> To: "Limdep and Nlogit Mailing  List" 
><limdep at limdep.itls.usyd.edu.au>
> Sent:  Thursday, June 17, 2010 3:04:51 PM GMT -05:00 
>US/Canada Eastern
>  Subject: [Limdep Nlogit List] interactions in binary 
>logit  models
> Dear Prof Greene and Limdep  Users
>    I  am  analysing a binary logit model with y=yes/no 
> responses to a  program and a number of dependent
> variables including price  level and respondents 
> socio-economic  characteristics. I would  like to 
>interact
> the variable describing price levels  (continuous) with 
> some of these  characteristics (generally  categorical) 
>in
> order to see how the response vary in  accordance with 
> price.
>  
> I was about to ask how  to replicate the STATA command 
> INTEFF (Ai and Norton, 2003) in  Limdep, but then last 
>week 
> came across Prof Greene's  recent paper "Testing 
> Hypotheses about  interaction terms in  nonlinear models" 
> 2010. Economic Letters 107,  291-296.
>   
>  I have been trying to use the Limdep codes provided 
>with  
> the paper. I came across a couple of problems
> both in  the set-up and interpretation. Hope you may 
>help.
>  
>   I started with the following - interaction between 
> variable  price (continuous) and blwabv (dummy):
> 
> 
> 
>  
> 
> Sample   ; All $
> Namelist ; z=one,male,  age1829, age3044, age4560, 
>TOTHSLD, 
>  CARYESN,  FLYNOFL,rent, emp,
> educ, ret,  
> taxpct,  totco2, lower, higher, 
> CHGMONEY,CHGCLIMA,CHGOTHER,COSTB,TIMEB, 
>  EASYHOME,EASYTRAN 
> $
> Probit   ; Lhs = reduce ; Rhs =  blwabv, price, z$
> Calc     ; df = b(1) ; da = b(2)  $
>  Matrix   ; bz = b(3:26) ; zbar = Mean(z) ; bzz = bz'zbar 
>$
>  Create   ; ME_Blw = phi(     da*price + bzz)
>          ; ME_Abv   = phi(df + da*price + bzz) $
> Calc     ; Ran (123479) $
>  Draw     ; N=100 $
> Plot     ; lhs = price ; rhs = ME_Blw,ME_Abv ;  fill ; 
>Grid
>          ; Title=Partial Effects for a  Model with No 
> Interaction Term
>          ; Yaxis=Partial  Effects$
> 
> 
> 
> 
> 
> And I  obtain the following:
> 
> 
> 
> 
> 
>  Calc     ; df = b(1) ; da =  b(2)  $
> --> Matrix   ; bz =  b(3:26) ; zbar = Mean(z) ; bzz = 
> bz'zbar $
>   Error    400: MNAME(first:last  ).  Matrix size 
>exceeded 
> by  this  address.
>   Error    32: Model command.  Start vals.  unreadable or 
> wrong # given.
>   Error   583: Model  command.  Start vals. unreadable or 
> wrong # given.
>  --> Create   ; ME_Blw = phi(     da*price + bzz)
>     ;  ME_Abv  = phi(df + da*price + bzz) $
>   Error   768: Have been  unable to break down the 
>command 
> segment.
>    Error   623: Check for error in DA*PRICE+BZZ
>   Error   623: Look  for: Unknown names, pairs of 
> operators, e.g., */
>    Error    61: Compilation error in CREATE. See previous 
>  diagnostic.
> --> Calc     ; Ran (123479) $
> -->  Draw     ; N=50 $
> --> Plot     ; lhs = price ; rhs =  ME_Blw,ME_Abv ; fill 
>; 
> Grid
>     ; Title=Partial  Effects for a Model with No 
> Interaction Term
>     ;  Yaxis=Partial Effects$
>   Error    71: Variable list contains a  name not in the 
> expected table.
>   Error   539: Variable  list: The unidentifiable string 
>is 
> ME_BLW
>    Error    83: RHS/RH1  variable in list  not in the 
> variable  names  table.
> 
> 
> 
>  
> 
> 
>  
>  
> I also tried the following from the paper limdep 
>  command 
> file
>  
> 
> 
> 
> 
>  
> 
> 
> ? Model with interaction  effects. Just  examine partial 
> effect ? graphically.
> Sample   ; All $
>  Create   ; int = blwabv*price$
> Probit   ; lhs = reduce
>           ; Rhs = blwabv,price, int, one, male, age1829, 
>  age3044,  age4560, TOTHSLD, CARYESN, FLYNOFL,rent, emp, 
> educ,  ret, taxpct,
> totco2, lower, higher, 
>  CHGMONEY,CHGCLIMA,CHGOTHER,COSTB,TIMEB, 
> EASYHOME,EASYTRAN 
>  $
> 
> 
> Matrix   ; bz = b(4:26) ; bzz = bz'zbar $
>  Calc     ; df = b(1) ; da = b(2) ;di = b(3) $
> Create   ;  ME_blwi = phi(    da*price + bzz)
>          ; ME_abvi  = phi(df +  da*price + di * price + 
> bzz) $
> Calc     ; Ran (123479)  $
> Draw     ; N=100 $
> Plot     ; lhs = price ; rhs =  ME_blwi,ME_abvi ; fill ; 
> Grid
>          ; Title=Partial  Effects for Blw and Abv with 
> Interaction
>          ;  Yaxis=Partial Effects $
> 
> ? Plot results from both models  in the same figure
> Plot ; lhs = price ; rhs = ME_blwi,ME_abvi ;  fill
> ;grid
> ;title=Fitted Probabilities for Models with  Interaction 
> Terms
> ;Yaxis=Fitted Probabilities (Other  Vars. At Means)$
> 
> 
> 
> And I obtained more  of less the  same (below):
> 
> 
> 
> 
> 
>  
> 
> Matrix   ; bz = b(4:26) ; bzz =  bz'zbar $
>    Error   442: Matrix: The expression contains an 
>unknown 
>  name.
>   Error   569: Error is in BZ'ZBAR
>   Error   583:  Problem with matrix. See previous 
> diagnostic.
> -->  Calc     ; df = b(1) ; da = b(2) ;di = b(3) $
> --> Create   ;  ME_blwi = phi(    da*price + bzz)
>     ; ME_abvi  = phi(df +  da*price + di * price + bzz) $
>   Error   768: Have been unable  to break down the 
>command 
> segment.
>   Error    623: Check for error in DA*PRICE+BZZ
>   Error   623: Look for:  Unknown names, pairs of 
> operators, e.g., */
>   Error     61: Compilation error in CREATE. See previous 
> diagnostic.
>  --> Calc     ; Ran (123479) $
> --> Draw     ; N=150 $
>  --> Plot     ; lhs = price ; rhs = ME_blwi,ME_abvi ; 
>fill 
>  ; Grid
>     ; Title=Partial Effects for Blw and Abv with 
>  Interaction
>     ; Yaxis=Partial Effects $
>   Error     71: Variable list contains a name not in the 
> expected table.
>    Error   539: Variable list: The unidentifiable string 
>is 
>  ME_BLWI
>   Error    83: RHS/RH1  variable in list  not in the 
>  variable names  table.
> --> Plot ; lhs = price ; rhs =  ME_blwi,ME_abvi ; fill
>     ;grid
>     ;title=Fitted  Probabilities for Models with 
> Interaction Terms
>      ;Yaxis=Fitted Probabilities (Other Vars. At Means)$
>   Error     71: Variable list contains a name not in the 
> expected table.
>    Error   539: Variable list: The unidentifiable string 
>is 
>  ME_BLWI
>   Error    83: RHS/RH1  variable in list  not in the 
>  variable names  table.
> 
> 
> 
> I am not sure  what is wrong in  the code above. Also I 
> would like to use a  logit rather than a probit.  In what 
> way would the code above  be different?
> 
> 
> 
> 
> 
>


More information about the Limdep mailing list