1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: ODS statements in the SAS Studio environment may disable some output features.
71
72 /* mathlogreg1.sas */
73 %include '/home/brunner0/441s20/readmath2b.sas';
NOTE: Format YNFMT is already on the library WORK.FORMATS.
NOTE: Format YNFMT has been output.
NOTE: Format CRSFMT is already on the library WORK.FORMATS.
NOTE: Format CRSFMT has been output.
NOTE: Format NFMT is already on the library WORK.FORMATS.
NOTE: Format NFMT has been output.
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 244.40k
OS Memory 29860.00k
Timestamp 02/05/2020 04:53:34 PM
Step Count 151 Switch Count 0
Page Faults 0
Page Reclaims 25
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 32
177
NOTE: The infile '/home/brunner0/441s20/exploremath.data.txt' is:
Filename=/home/brunner0/441s20/exploremath.data.txt,
Owner Name=brunner0,Group Name=oda,
Access Permission=-rw-r--r--,
Last Modified=26Jan2020:18:49:34,
File Size (bytes)=44583
NOTE: 579 records were read from the infile '/home/brunner0/441s20/exploremath.data.txt'.
The minimum record length was 75.
The maximum record length was 75.
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
99 at 96:24 99 at 135:13
NOTE: The data set WORK.MATHEX has 579 observations and 34 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 897.18k
OS Memory 30376.00k
Timestamp 02/05/2020 04:53:34 PM
Step Count 152 Switch Count 2
Page Faults 0
Page Reclaims 111
Page Swaps 0
Voluntary Context Switches 18
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 520
178 proc freq;
179 title2 'Course by passed with proc freq';
180 tables course2 * passed / nocol nopercent chisq;
181 /* Note 'No resp' is missing for course2 */
182
NOTE: There were 579 observations read from the data set WORK.MATHEX.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.05 seconds
user cpu time 0.05 seconds
system cpu time 0.00 seconds
memory 3420.28k
OS Memory 31408.00k
Timestamp 02/05/2020 04:53:34 PM
Step Count 153 Switch Count 5
Page Faults 0
Page Reclaims 405
Page Swaps 0
Voluntary Context Switches 26
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 536
183 proc logistic;
184 title2 'Course by passed with dummy vars: Compare LR Chisq = 34.4171';
185 model passed (event='Yes') = c1 c3; /* Omit c2 so Mainstream is reference category */
186 /* Wald chi-squared tests */
187 course: test c1=c3=0;
188 Course1_vs_2: test c1=0;
189 Course1_vs_3: test c1=c3;
190 Course2_vs_3: test c3=0;
191
192 /*
193 Question: The estimated odds of passing the course are ___ times as great for a
194 student in the elite course, compared to a student in the mainstream course.
195
196 Question: With 95% confidence, the chances of a student passing the catch-up
197 course are between ___% and ___% as great as the chances of passing the
198 mainstream course.
199
200 Note the deliberately vague but useful word "chances."
201
202 A few details about the output :
203
204 The higher the minus 2 Log Likelihood, the lower the (estimated) maximum
205 probability of observing these responses. It is a meaure of lack of
206 model fit. The Akaike information criterion and Schwarz's Bayesian
207 criterion both impose a further penalty for number of explanatory
208 variables. Small is good.
209
210 "Association of Predicted Probabilities and Observed Responses":
211 * Every case has Y=0 or Y=1.
212 * Every case has a p-hat.
213 * Pick a case with Y=0, and another case with Y=1. That's a pair.
214 * If the case with Y=0 has a lower p-hat than the case with Y=1,
215 the pair is concordant.
216 */
217
NOTE: PROC LOGISTIC is modeling the probability that passed='Yes'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 579 observations read from the data set WORK.MATHEX.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.08 seconds
user cpu time 0.09 seconds
system cpu time 0.00 seconds
memory 2577.34k
OS Memory 32952.00k
Timestamp 02/05/2020 04:53:35 PM
Step Count 154 Switch Count 1
Page Faults 0
Page Reclaims 325
Page Swaps 0
Voluntary Context Switches 8
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 56
218 proc iml;
NOTE: IML Ready
219 title2 'Estimate prob. of passing for for course=3: Compare 31/39 = 0.7949';
220 b0 = 0.4077;
220 ! b1 = -1.4838;
220 ! b2 = 0.9468;
221 c1 = 0;
221 ! c3=1;
222 lcombo = b0 + b1*c1 + b2*c3;
223 probpass = exp(lcombo) / (1+exp(lcombo));
224 print "Estimated probability of passing course 3 (Elite) is " probpass;
225
226
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.01 seconds
memory 499.96k
OS Memory 31908.00k
Timestamp 02/05/2020 04:53:35 PM
Step Count 155 Switch Count 1
Page Faults 0
Page Reclaims 173
Page Swaps 0
Voluntary Context Switches 7
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 24
227 proc logistic;
228 title2 'Use the class and contrast statements';
229 class course2 / param=ref; /* This param option makes the ALPHABETICALLY
230 last category (Mainstream) the reference
231 category. Default is effect coding. */
232 model passed (event='Yes') = course2;
233 contrast 'Catch-up vs Mainstream' course2 1 0;
234 contrast 'Elite vs Mainstream' course2 0 1;
235 contrast 'Catch-up vs Elite' course2 1 -1;
236
237 /* Contrast is a little tricky in proc logistic compared to proc glm.
238 It lets you specify a set of linear combinations of regression
239 coefficients to test against zero. It is essential to know exactly
240 what the dummy variable coding scheme is. This can still be more
241 convenient than defining your own dummy variables in the data step. */
242
NOTE: PROC LOGISTIC is modeling the probability that passed='Yes'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 579 observations read from the data set WORK.MATHEX.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.09 seconds
user cpu time 0.10 seconds
system cpu time 0.00 seconds
memory 2385.53k
OS Memory 33208.00k
Timestamp 02/05/2020 04:53:35 PM
Step Count 156 Switch Count 1
Page Faults 0
Page Reclaims 224
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 56
243 proc logistic;
244 title2 'Course controlling for score on diagnostic test';
245 class course2 / param=ref;
246 model passed (event='Yes') = course2 totscore;
247 contrast 'Course controlling for totscore' course2 1 0,
248 course2 0 1;
249 run;
NOTE: PROC LOGISTIC is modeling the probability that passed='Yes'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 579 observations read from the data set WORK.MATHEX.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.10 seconds
user cpu time 0.10 seconds
system cpu time 0.00 seconds
memory 2435.90k
OS Memory 33208.00k
Timestamp 02/05/2020 04:53:35 PM
Step Count 157 Switch Count 1
Page Faults 0
Page Reclaims 209
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 80
250
251 /* Estimate a probability of passing without typing in the
252 * estimated regression coefficients: Use the Output Delivery
253 * System (ODS). All the tables in a SAS results file have names.
254 * You can find out what they are with a web search on
255 * "proc logistic ods table names" , which will take you to the
256 * manual. Easier is to do a preliminary run with ods trace on,
257 * which writes the table names on the log file as they are produced.
258 */
259
260 ods trace on;
261 proc logistic data=mathex;
262 title2 'What are the ods table names?';
263 model passed (event='Yes') = c1 c3 totscore;
264 run;
Output Added:
-------------
Name: ModelInfo
Label: Model Information
Template: Stat.Logistic.ModelInfo
Path: Logistic.ModelInfo
-------------
Output Added:
-------------
Name: NObs
Label: Observations Summary
Template: Stat.Logistic.NObs
Path: Logistic.NObs
-------------
Output Added:
-------------
Name: ResponseProfile
Label: Response Profile
Template: Stat.Logistic.ResponseProfile
Path: Logistic.ResponseProfile
-------------
NOTE: PROC LOGISTIC is modeling the probability that passed='Yes'.
Output Added:
-------------
Name: ConvergenceStatus
Label: Convergence Status
Template: Stat.Logistic.MConvergenceStatus
Path: Logistic.ConvergenceStatus
-------------
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
Output Added:
-------------
Name: FitStatistics
Label: Fit Statistics
Template: Stat.Logistic.FitStatistics
Path: Logistic.FitStatistics
-------------
Output Added:
-------------
Name: GlobalTests
Label: Global Tests
Template: Stat.Logistic.GlobalTests
Path: Logistic.GlobalTests
-------------
Output Added:
-------------
Name: ParameterEstimates
Label: Parameter Estimates
Template: Stat.Logistic.ParameterEstimates
Path: Logistic.ParameterEstimates
-------------
Output Added:
-------------
Name: OddsRatios
Label: Odds Ratios
Template: Stat.Logistic.OddsRatios
Path: Logistic.OddsRatios
-------------
Output Added:
-------------
Name: Association
Label: Association Statistics
Template: Stat.Logistic.Association
Path: Logistic.Association
-------------
NOTE: There were 579 observations read from the data set WORK.MATHEX.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.07 seconds
user cpu time 0.08 seconds
system cpu time 0.00 seconds
memory 2353.96k
OS Memory 33208.00k
Timestamp 02/05/2020 04:53:35 PM
Step Count 158 Switch Count 1
Page Faults 0
Page Reclaims 201
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 9
Block Input Operations 0
Block Output Operations 56
264 ! /* Need run with ods trace */
265 ods trace off;
266
267 ods output ParameterEstimates = estimout;
268 /* The ParameterEstimates table will be written to a SAS data
269 set called estimout. */
270 proc logistic data=mathex;
271 title2 'Save parameter estimates using ods';
272 model passed (event='Yes') = c1 c3 totscore;
273
NOTE: PROC LOGISTIC is modeling the probability that passed='Yes'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: The data set WORK.ESTIMOUT has 4 observations and 7 variables.
NOTE: There were 579 observations read from the data set WORK.MATHEX.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.07 seconds
user cpu time 0.08 seconds
system cpu time 0.00 seconds
memory 2688.43k
OS Memory 33468.00k
Timestamp 02/05/2020 04:53:35 PM
Step Count 159 Switch Count 3
Page Faults 0
Page Reclaims 296
Page Swaps 0
Voluntary Context Switches 25
Involuntary Context Switches 1
Block Input Operations 0
Block Output Operations 328
274 proc print data=estimout;
275
NOTE: There were 4 observations read from the data set WORK.ESTIMOUT.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
user cpu time 0.02 seconds
system cpu time 0.00 seconds
memory 670.34k
OS Memory 32424.00k
Timestamp 02/05/2020 04:53:35 PM
Step Count 160 Switch Count 0
Page Faults 0
Page Reclaims 62
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
276 proc iml;
NOTE: IML Ready
277 title2 'Estimated Probabilty of Passing';
278 use estimout;
279 read all var {Estimate} into b;
280 print "Estimated regression coefficients";
281 print b;
282 /* Student in the catch-up class who got 10 right out of 20 */
283 x1 = {1, 1, 0, 10};
283 ! /* Rows are separated by commas */
284 pihat1 = exp(x1`*b)/(1+exp(x1`*b));
285 print "Student in the catch-up class who got 10 right out of 20" pihat1;
286 /* Student in the elite class who got all 20 right */
287 x2 = {1, 0, 1, 20};
287 ! /* Rows are separated by commas */
288 Pihat2 = exp(x2`*b)/(1+exp(x2`*b));
289 print "Student in the elite class who got 20 right out of 20" pihat2;
290
291 quit;
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
real time 0.02 seconds
user cpu time 0.02 seconds
system cpu time 0.00 seconds
memory 782.56k
OS Memory 32424.00k
Timestamp 02/05/2020 04:53:35 PM
Step Count 161 Switch Count 1
Page Faults 0
Page Reclaims 168
Page Swaps 0
Voluntary Context Switches 8
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16
292
293
294 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
305