This example runs the binary logit model using the GAUSS DC application. It uses a version of the education program effectiveness data originally collected by Spector and Mazzeo (1980). The dataset includes 32 observations of 6 different variables: letter grade (ABC), grade point average (GPA ), an indicator of participation in a personalized system of instruction (PSI), student test scores on an economics test (TUCE), and indicators of if the student received an A (A) or A+ (APLUS1).
Load the data
This example uses the formula string syntax to load data using loadd
. The formula string syntax syntax allows users to load, transform and analyze data in one line.
new;
cls;
library dc;
// Load data
fname = getGAUSShome() $+ "pkgs/dc/examples/aldnel.dat";
y = loadd(fname);
Set up the model parameters
The Discrete Choice Module uses a suite of dcSet
functions to set various features of the model. An instance of the dcControl
structure must be declared for storing all parameters prior to calling any dcSet
functions.
// Step one: Declare dc control structure
struct dcControl dcCt;
// Initialize dc control structure
dcCt = dcControlCreate();
// Step two: Describe data names
// Name of dependent variable
dcSetYVar(&dcCt, y[., 5]);
dcSetYLabel(&dcCt, "A");
// Name of independent variable
dcSetXVars(&dcCt, y[., 2:4]);
dcSetXLabels(&dcCt, "GPA, TUCE, PSI");
Estimate the Model
The binary logit model can be estimated using the binaryLogit
procedure. This function takes a dcControl
structure as an input and returns all output to a dcOut
structure. In addition, a complete report of results can be printed to screen using the printDCOut
procedure.
// Step three: Declare dcOut struct
struct dcout dcout1;
// Step four: Call binary logit procedure
dcout1 = binaryLogit(dcCt);
// Print Results
call printDCOut(dcOut1);
Output
The output from binaryLogit
model reads
Binary Logit Results Number of Observations: 32 Degrees of Freedom: 28 1 - Y0 2 - Y1 Distribution Among Outcome Categories For A Dependent Variable Proportion
Y0 0.6563
Y1 0.3438
Descriptive Statistics (N=32): Independent Vars. Mean Std Dev Minimum Maximum
GPA 3.1172 0.4521 2.0600 4.0000
TUCE 21.9375 3.7796 12.0000 29.0000
PSI 0.4375 0.4883 0.0000 1.0000
COEFFICIENTS Coefficient Estimates -------------------------------------------------------------------------------- Variables Coefficient se tstat pval Constant: Y0 -13** 4.93 -2.64 0.00828 GPA 2.83** 1.26 2.24 0.0252 TUCE 0.0952 0.142 0.672 0.501 PSI 2.38** 1.06 2.23 0.0255 -------------------------------------------------------------------------------- *p-val<0.1 **p-val<0.05 ***p-val<0.001
ODDS RATIO Odds Ratio ---------------------------------------------------------------------------- Variables Odds Ratio 95% Lower Bound 95% Upper Bound GPA 16.88 1.4201 200.63 TUCE 1.0998 0.83336 1.4515 PSI 10.791 1.3393 86.941 ---------------------------------------------------------------------------- MARGINAL EFFECTS
Partial probability with respect to mean x Marginal Effects for X Variables in Y1 category --------------------------------------------------------------------------- Variables Coefficient se tstat pval
GPA 0.534** ( 0.237) 2.25 0.0321
TUCE 0.018 ( 0.0262) 0.685 0.499
PSI 0.449** ( 0.197) 2.28 0.0299
--------------------------------------------------------------------------- Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
********************SUMMARY STATISTICS******************** MEASURES OF FIT: -2 Ln(Lu): 25.7793 -2 Ln(Lr): All coeffs equal zero 44.3614 -2 Ln(Lr): J-1 intercepts 41.1835 LR Chi-Square (coeffs equal zero): 18.5822 d.f. 4.0000 p-value = 0.0000 LR Chi-Square (J-1 intercepts): 15.4042 d.f. 3.0000 p-value = 0.0015 Count R2, Percent Correctly Predicted: 26.0000 Adjusted Percent Correctly Predicted: 0.4545 Madalla's pseudo R-square: 0.3821 McFadden's pseudo R-square: 0.3740 Ben-Akiva and Lerman's Adjusted R-square: 0.2283 Cragg and Uhler's pseudo R-square: 0.2358 Akaike Information Criterion: 1.0556 Bayesian Information Criterion: 1.2388 Hannan-Quinn Information Criterion: 1.1163 OBSERVED AND PREDICTED OUTCOMES | Predicted Observed | Y0 Y1 Total ------------------------------------------------- Y0 | 18 3 21 Y1 | 3 8 11 ------------------------------------------------- Total | 21 11 32