%macro glogit (data=_last_, response=, vars=, groupvar=); /********************************************************************* Version 1.0, 5-20-1999 MACRO GLOGIT does maximum likelihood estimation of logistic regression models for two or more groups when the residual variance is allowed to differ across groups. For details on the models, see Paul D. Allison (1999) "Comparing Logit and Probit Coefficients Across Groups." Forthcoming in Sociological Methods and Research. There are four parameters: DATA is the name of the data set to be analyzed. Default is the most recently created data set. RESPONSE is the dependent variable with values of 1 and 0. VARS is a list of independent variables in the regression model (max 20). GROUPVAR is a list of dichotomous (1,0) variables that define the groups. The number of variables in the list should be one less than the number of groups. Ordinarily, variables in this list should also appear in the VARS list. The maximum number of groups is 6. Example of usage: %glogit(data=promotion, response=prom, vars=dur dur2 female undgrd arts prest, groupvar=female) The output from NLIN does not report any variable names. B0 is the estimate of the intercept. B1, B2,... are estimates of the coefficients of the variables in the VAR list, in the order in which they appear in the list. DEL1, DEL2,... are coefficients of the group dummies in the equation for the residual standard deviation. Author: Paul D. Allison, University of Pennsylania allison@ssc.upenn.edu http://www.ssc.upenn.edu/~allison/ *********************************************************************/ %do i=1 %to 20; %let var&i=%scan(&vars,&i); %if &&var&i= %then %goto out; %end; %out: %let i=%eval(&i-1); %do j=1 %to 6; %let vv&j=%scan(&groupvar,&j); %if &&vv&j= %then %goto out2; %end; %out2: %let j=%eval(&j-1); proc nlin nohalve sigsq=1 data=&data; parms b0=0 %do m=1 %to &i; b&m=0 %end; %do n=1 %to &j; del&n=0 %end;; pred=b0 %do m=1 %to &i; +b&m*&&var&m %end;; int=1 %do n=1 %to &j; +del&n*&&vv&n %end;; u=pred*int; w=exp(u); _weight_=(1+w)**2/w; _loss_=(-&response*u+log(1+exp(u)))/_weight_; model &response=w/(1+w); run; %mend glogit;