# Stereotypical Logit Example

This example demonstrates the use of a stereotypical multinomial logit model. It models grade (ABC) achievement rates in a Economics course in relationship to cumulative grade point average (GPA), literacy test score (TUCE), and optional participation in a special economics course (PSI). The first step to setting up all Discrete Choice models is to declare and initialize the dcControl structure:
```//Step one: Declare dc control structure
struct dcControl dcCt;

//Initialize dc control structure
dcCt = dcControlCreate();
```
Next, load and setup the model data using the dcSet procedures:
```//Load data

//Step two: Describe data names
//Name of dependent variable
dcSetYVar(&dcCt,y[.,1]);
dcsetYLabel(&dcCt,"ABC");

//Y Category Labels
dcSetYCategoryLabels(&dcCt,"A,B,C");

//Name of independent variable
dcSetXVars(&dcCt,y[.,2:4]);
dcsetXLabels(&dcCt,"GPA, TUCE, PSI");```
Following data setup, declare the dcOut structure:
```//Step three: Declare dcOut struct
struct dcout dcout1;
```
Finally, call the stereoLogit procedure:
```//Step four: Call stereo logit procedure
dcout1 = binaryLogit(dcCt);
call printDCOut(dcOut1);
```
The example prints the model and data description to screen:
```Stereo Logistic Results
2015-05-21 07:09:28

Number of Observations:   32
Degrees of Freedom:       26

1 - A
2 - B
3 - C

Distribution Among Outcome Categories For ABC

Dependent Variable       Proportion
A                         0.3438
B                         0.4063
C                         0.2500

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
```
All coefficients, odds ratios, and marginal effects are printed:
```COEFFICIENTS

Coefficient Estimates
---------------------------------------------------------------------------

Variables      Coefficient               se            tstat             pval
Constant: A           11.3**             4.93              2.3           0.0213
Constant: C             16**             6.28             2.55           0.0107
GPA          -4.38**              2.1            -2.09            0.037
TUCE          -0.0693            0.177           -0.391            0.695
PSI           -2.54*             1.31            -1.94           0.0525
Distance: B          0.655**            0.259             2.53           0.0114
---------------------------------------------------------------------------
Estimate se in parentheses.
*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         0.012486       0.00020319          0.76723
TUCE          0.93308          0.65965           1.3198
PSI         0.078949        0.0060662           1.0275
Distance: B           1.9242           1.1586           3.1956
----------------------------------------------------------------------------

MARGINAL EFFECTS
Partial probability with respect to mean x
Marginal Effects for X Variables in A category
---------------------------------------------------------------------------

Variables       Coefficient     se              tstat           pval
GPA             -0.644**        ( 0.255)        -2.53            0.0171
TUCE            -0.0102         ( 0.0265)       -0.384           0.704
PSI             -0.373*         ( 0.214)        -1.75            0.0914
---------------------------------------------------------------------------
Estimate se in parentheses.
*p-val<0.1 **p-val<0.05 ***p-val<0.001

Marginal Effects for X Variables in B category
---------------------------------------------------------------------------

Variables       Coefficient     se              tstat           pval
GPA             -2.79*          ( 1.54)         -1.82            0.0796
TUCE            -0.0441         ( 0.119)        -0.37            0.714
PSI             -1.62           ( 1.21)         -1.34            0.191
---------------------------------------------------------------------------
Estimate se in parentheses.
*p-val<0.1 **p-val<0.05 ***p-val<0.001

Marginal Effects for X Variables in C category
---------------------------------------------------------------------------

Variables       Coefficient     se              tstat           pval
GPA             -1.38*          ( 0.767)        -1.8             0.0817
TUCE            -0.0219         ( 0.0606)       -0.36            0.721
PSI             -0.801          ( 0.671)        -1.19            0.242
---------------------------------------------------------------------------
Estimate se in parentheses.
*p-val<0.1 **p-val<0.05 ***p-val<0.001
```
In addition a number of summary statistics for model diagnostics are printed:
```********************SUMMARY STATISTICS********************

MEASURES OF FIT:

-2 Ln(Lu):                                    52.3305
-2 Ln(Lr): All coeffs equal zero              70.3112
-2 Ln(Lr): J-1 intercepts                     69.0937
LR Chi-Square (coeffs equal zero):            17.9806
d.f.                                      6.0000
p-value =                                 0.0000
LR Chi-Square (J-1 intercepts):               16.7631
d.f.                                      4.0000
p-value =                                 0.0021
Count R2, Percent Correctly Predicted:        20.0000
Ben-Akiva and Lerman's Adjusted R-square:      0.1558
Cragg and Uhler's pseudo R-square:             0.0898
Akaike Information Criterion:                  2.0103
Bayesian Information Criterion1:               0.2748
Hannan-Quinn Information Criterion:            2.1014

OBSERVED AND PREDICTED OUTCOMES

|           Predicted
Observed |       A        B        C    Total
----------------------------------------------------------
A |       8        3        0       11
B |       2        9        2       13
C |       1        4        3        8

----------------------------------------------------------
Total |      11       16        5       32
```

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.