This example runs the Adjacent Category Logit Regression using GAUSS DC application. It uses the General Social Survey occupation outcomes data which contains 337 observations of eight variables.
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/gssocc.dat";
y = loadd(fname);
Set up the model parameters
The Discrete Choice Module uses a suite of dcSet
procedures 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: dcControl structure
// Declare dcControl struct
struct dcControl dcCt;
// Initialize dcControl struct
dcCt = dcControlCreate();
// Step Two:Describe data
// Name of dependent variable
dcSetYVar(&dcCt, y[., 1]);
dcSetYLabel(&dcCt, "occatt");
// Dependent variable categories
dcSetYCategoryLabels(&dcCt, "Menial,BC,Craft,WC,Pro");
// Reference category excluded from regression
dcSetReferenceCategory(&dcCt, 1);
// Independent variable Labels
dcSetXVars(&dcCt, y[., 2:4]);
dcSetXLabels(&dcCt, "exper,educ,white");
// Set start values
// Intercept must be L by 1
b0 = { 0 1 1 1 1};
// Coefficients
b = { 0 .1 .1 .1 .1,
0 .1 .1 .1 .1,
0 .1 .1 .1 .1};
// Set mask
mask = { 0 1 1 1 1,
0 1 1 1 1,
0 1 1 1 1};
dcCt.startValues =
pvPackmi(dcCt.startValues,
b0, "b0", mask[1, .], 1);
dcCt.startValues =
pvPackmi(dcCt.startValues,
b, "b", mask, 2);
Estimate the Model
The adjacent categories logit model can be estimated using the adjacentCategories
. 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 adjacentCategories
dcout1 = adjacentCategories(dcCt);
// Print Results
call printDCOut(dcOut1);
Output
The output from adjacentCategories
reads
Adjacent Categories Results 2018-03-08 12:04:06 Number of Observations: 337 Degrees of Freedom: 321 1 - Menial 2 - BC 3 - Craft 4 - WC 5 - Pro Distribution Among Outcome Categories For occatt Dependent Variable Proportion
Menial 0.0920
BC 0.2047
Craft 0.2493
WC 0.1217
Pro 0.3323
Descriptive Statistics (N=337): Independent Vars. Mean Std Dev Minimum Maximum
exper 20.5015 13.9179 2.0000 66.0000
educ 13.0950 2.9377 3.0000 20.0000
white 0.9169 0.2756 0.0000 1.0000
COEFFICIENTS Coefficient Estimates ----------------------------------------------------------------------------------------------- Variables Coefficient se tstat pval Constant: BC 0.741 1.52 0.488 0.626 Constant: Craft -1.83 1.19 -1.55 0.122 Constant: WC -5.15** 1.59 -3.23 0.00125 Constant: Pro -5.28** 1.68 -3.14 0.00172 exper : BC 0.00472 0.0174 0.271 0.786 exper : Craft 0.023* 0.0126 1.83 0.0674 exper : WC 0.00691 0.014 0.495 0.621 exper : Pro 0.00106 0.0144 0.0735 0.941 educ : BC -0.0994 0.102 -0.972 0.331 educ : Craft 0.193** 0.0775 2.49 0.0126 educ : WC 0.259** 0.0935 2.77 0.00555 educ : Pro 0.426*** 0.0922 4.62 3.91e-06 white : BC 1.24* 0.724 1.71 0.0878 white : Craft -0.764 0.632 -1.21 0.227 white : WC 1.1 0.819 1.34 0.179 white : Pro 0.203 0.869 0.233 0.815 ----------------------------------------------------------------------------------------------- Comparisons to Menial *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 exper : BC 1.0047 0.97105 1.0396 exper : Craft 1.0232 0.99836 1.0487 exper : WC 1.0069 0.97974 1.0349 exper : Pro 1.0011 0.97328 1.0296 educ : BC 0.90536 0.7409 1.1063 educ : Craft 1.2132 1.0422 1.4122 educ : WC 1.2961 1.079 1.5568 educ : Pro 1.5307 1.2775 1.8339 white : BC 3.4436 0.83244 14.245 white : Craft 0.46573 0.13484 1.6086 white : WC 3.0013 0.60334 14.93 white : Pro 1.225 0.22293 6.7313 ---------------------------------------------------------------------------- Comparisons to Menial MARGINAL EFFECTS
Partial probability with respect to mean x Marginal Effects for X Variables in Menial category --------------------------------------------------------------------------- Variables Coefficient se tstat pval
exper 0.00113 ( 0.000788) 1.43 0.153
educ 0.0211*** ( 0.00491) 4.29 2.33e-05
white 0.0468 ( 0.0386) 1.21 0.227
--------------------------------------------------------------------------- Comparisons to Menial Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
Marginal Effects for X Variables in BC category --------------------------------------------------------------------------- Variables Coefficient se tstat pval
exper 0.00357 ( 0.00646) 0.553 0.581
educ 0.0124 ( 0.0346) 0.357 0.721
white 0.449 ( 0.289) 1.56 0.121
--------------------------------------------------------------------------- Comparisons to Menial Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
Marginal Effects for X Variables in Craft category --------------------------------------------------------------------------- Variables Coefficient se tstat pval
exper 0.00723* ( 0.00401) 1.8 0.0722
educ 0.0793** ( 0.0347) 2.28 0.023
white -0.106 ( 0.173) -0.614 0.54
--------------------------------------------------------------------------- Comparisons to Menial Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
Marginal Effects for X Variables in WC category --------------------------------------------------------------------------- Variables Coefficient se tstat pval
exper 0.00118 ( 0.00107) 1.1 0.272
educ 0.0326** ( 0.0109) 2.99 0.00301
white 0.115* ( 0.0648) 1.77 0.0774
--------------------------------------------------------------------------- Comparisons to Menial Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
Marginal Effects for X Variables in Pro category --------------------------------------------------------------------------- Variables Coefficient se tstat pval
exper 0.00212 ( 0.00434) 0.489 0.625
educ 0.139*** ( 0.0337) 4.13 4.63e-05
white 0.127 ( 0.256) 0.497 0.619
--------------------------------------------------------------------------- Comparisons to Menial Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
********************SUMMARY STATISTICS******************** MEASURES OF FIT: -2 Ln(Lu): 853.6010 -2 Ln(Lr): All coeffs equal zero 1084.7612 -2 Ln(Lr): J-1 intercepts 1019.6881 LR Chi-Square (coeffs equal zero): 231.1602 d.f. 16.0000 p-value = 0.0000 LR Chi-Square (J-1 intercepts): 166.0872 d.f. 12.0000 p-value = 0.0000 Count R2, Percent Correctly Predicted: 147.0000 Adjusted Percent Correctly Predicted: 0.1556 Madalla's pseudo R-square: 0.3891 McFadden's pseudo R-square: 0.1629 Ben-Akiva and Lerman's Adjusted R-square: 0.1570 Cragg and Uhler's pseudo R-square: 0.0325 Akaike Information Criterion: 2.6279 Bayesian Information Criterion: 2.8093 Hannan-Quinn Information Criterion: 2.7002 OBSERVED AND PREDICTED OUTCOMES | Predicted Observed | Menial BC Craft WC Pro Total ---------------------------------------------------------------------------- Menial | 0 21 6 0 4 31 BC | 0 57 6 0 6 69 Craft | 0 60 10 0 14 84 WC | 0 24 3 0 14 41 Pro | 0 24 8 0 80 112 ---------------------------------------------------------------------------- Total | 0 186 33 0 118 337