Published on :
Statistics CREATION_INTERNE

Multinomial Generalized Logit Modeling with PROC BGLIMM

This code is also available in: Deutsch Español Français
Awaiting validation
The script creates a 'school' dataset containing learning preferences. It then uses the BGLIMM (Bayesian Generalized Linear Mixed Models) procedure to fit statistical models on a nominal response variable ('Style') with a multinomial distribution and a generalized logit (glogit) link function. Two models are tested: one with interaction and one without, with specific contrast estimations.
Data Analysis

Type : CREATION_INTERNE


Data is directly defined within the script via a DATA Step using DATALINES ('school' dataset).

1 Code Block
DATA STEP Data
Explanation :
Creation of the 'school' dataset. The INPUT statement uses the '@@' symbol (double trailing @) to read multiple observations per data line.
Copied!
1DATA school;
2 LENGTH Program $ 9;
3 INPUT School Program $ Style $ Count @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
4 DATALINES;
51 regular self 10 1 regular team 17 1 regular class 26
61 afternoon self 5 1 afternoon team 12 1 afternoon class 50
72 regular self 21 2 regular team 17 2 regular class 26
82 afternoon self 16 2 afternoon team 12 2 afternoon class 36
93 regular self 15 3 regular team 15 3 regular class 16
103 afternoon self 12 3 afternoon team 12 3 afternoon class 20
11;
2 Code Block
PROC BGLIMM
Explanation :
Execution of the BGLIMM procedure to fit a model including the main effects 'School', 'Program', and their interaction 'School*Program'. The 'Count' variable is used as a frequency variable.
Copied!
1PROC BGLIMM DATA=school seed=123 dic;
2 freq Count;
3 class School Program;
4 model Style(ref="class")=School Program School*Program / dist=multinomial
5 link=glogit;
6RUN;
3 Code Block
PROC BGLIMM
Explanation :
Second execution of PROC BGLIMM on a model without interaction. ESTIMATE statements are added to calculate and test specific contrasts (comparisons between schools and programs) with the 'exp' option to exponentiate results (odds ratios) and 'bycat' for estimations by response category.
Copied!
1PROC BGLIMM DATA=school seed=123 dic;
2 freq Count;
3 class School Program;
4 model Style(ref="class")= School Program / dist=multinomial
5 link=glogit;
6 estimate 'School 1 vs 3' School 1 0 -1 / exp bycat;
7 estimate 'School 2 vs 3' School 0 1 -1 / exp bycat;
8 estimate 'Afternoon vs Regular' Program 1 -1 / exp bycat;
9RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.