1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;NOTE: ODS statements in the SAS Studio environment may disable some output features.7172 /* 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 secondsuser cpu time 0.00 secondssystem cpu time 0.00 secondsmemory 244.40kOS Memory 29860.00kTimestamp 02/05/2020 04:53:34 PMStep Count 151 Switch Count 0Page Faults 0Page Reclaims 25Page Swaps 0Voluntary Context Switches 0Involuntary Context Switches 0Block Input Operations 0Block Output Operations 32177NOTE: 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)=44583NOTE: 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:13NOTE: The data set WORK.MATHEX has 579 observations and 34 variables.NOTE: DATA statement used (Total process time):real time 0.00 secondsuser cpu time 0.01 secondssystem cpu time 0.00 secondsmemory 897.18kOS Memory 30376.00kTimestamp 02/05/2020 04:53:34 PMStep Count 152 Switch Count 2Page Faults 0Page Reclaims 111Page Swaps 0Voluntary Context Switches 18Involuntary Context Switches 0Block Input Operations 0Block Output Operations 520178 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 */182NOTE: There were 579 observations read from the data set WORK.MATHEX.NOTE: PROCEDURE FREQ used (Total process time):real time 0.05 secondsuser cpu time 0.05 secondssystem cpu time 0.00 secondsmemory 3420.28kOS Memory 31408.00kTimestamp 02/05/2020 04:53:34 PMStep Count 153 Switch Count 5Page Faults 0Page Reclaims 405Page Swaps 0Voluntary Context Switches 26Involuntary Context Switches 0Block Input Operations 0Block Output Operations 536183 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;191192 /*193 Question: The estimated odds of passing the course are ___ times as great for a194 student in the elite course, compared to a student in the mainstream course.195196 Question: With 95% confidence, the chances of a student passing the catch-up197 course are between ___% and ___% as great as the chances of passing the198 mainstream course.199200 Note the deliberately vague but useful word "chances."201202 A few details about the output :203204 The higher the minus 2 Log Likelihood, the lower the (estimated) maximum205 probability of observing these responses. It is a meaure of lack of206 model fit. The Akaike information criterion and Schwarz's Bayesian207 criterion both impose a further penalty for number of explanatory208 variables. Small is good.209210 "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 */217NOTE: 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 secondsuser cpu time 0.09 secondssystem cpu time 0.00 secondsmemory 2577.34kOS Memory 32952.00kTimestamp 02/05/2020 04:53:35 PMStep Count 154 Switch Count 1Page Faults 0Page Reclaims 325Page Swaps 0Voluntary Context Switches 8Involuntary Context Switches 0Block Input Operations 0Block Output Operations 56218 proc iml;NOTE: IML Ready219 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;225226NOTE: Exiting IML.NOTE: PROCEDURE IML used (Total process time):real time 0.01 secondsuser cpu time 0.01 secondssystem cpu time 0.01 secondsmemory 499.96kOS Memory 31908.00kTimestamp 02/05/2020 04:53:35 PMStep Count 155 Switch Count 1Page Faults 0Page Reclaims 173Page Swaps 0Voluntary Context Switches 7Involuntary Context Switches 0Block Input Operations 0Block Output Operations 24227 proc logistic;228 title2 'Use the class and contrast statements';229 class course2 / param=ref; /* This param option makes the ALPHABETICALLY230 last category (Mainstream) the reference231 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;236237 /* Contrast is a little tricky in proc logistic compared to proc glm.238 It lets you specify a set of linear combinations of regression239 coefficients to test against zero. It is essential to know exactly240 what the dummy variable coding scheme is. This can still be more241 convenient than defining your own dummy variables in the data step. */242NOTE: 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 secondsuser cpu time 0.10 secondssystem cpu time 0.00 secondsmemory 2385.53kOS Memory 33208.00kTimestamp 02/05/2020 04:53:35 PMStep Count 156 Switch Count 1Page Faults 0Page Reclaims 224Page Swaps 0Voluntary Context Switches 9Involuntary Context Switches 0Block Input Operations 0Block Output Operations 56243 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 secondsuser cpu time 0.10 secondssystem cpu time 0.00 secondsmemory 2435.90kOS Memory 33208.00kTimestamp 02/05/2020 04:53:35 PMStep Count 157 Switch Count 1Page Faults 0Page Reclaims 209Page Swaps 0Voluntary Context Switches 10Involuntary Context Switches 0Block Input Operations 0Block Output Operations 80250251 /* Estimate a probability of passing without typing in the252 * estimated regression coefficients: Use the Output Delivery253 * System (ODS). All the tables in a SAS results file have names.254 * You can find out what they are with a web search on255 * "proc logistic ods table names" , which will take you to the256 * 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 */259260 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: ModelInfoLabel: Model InformationTemplate: Stat.Logistic.ModelInfoPath: Logistic.ModelInfo-------------Output Added:-------------Name: NObsLabel: Observations SummaryTemplate: Stat.Logistic.NObsPath: Logistic.NObs-------------Output Added:-------------Name: ResponseProfileLabel: Response ProfileTemplate: Stat.Logistic.ResponseProfilePath: Logistic.ResponseProfile-------------NOTE: PROC LOGISTIC is modeling the probability that passed='Yes'.Output Added:-------------Name: ConvergenceStatusLabel: Convergence StatusTemplate: Stat.Logistic.MConvergenceStatusPath: Logistic.ConvergenceStatus-------------NOTE: Convergence criterion (GCONV=1E-8) satisfied.Output Added:-------------Name: FitStatisticsLabel: Fit StatisticsTemplate: Stat.Logistic.FitStatisticsPath: Logistic.FitStatistics-------------Output Added:-------------Name: GlobalTestsLabel: Global TestsTemplate: Stat.Logistic.GlobalTestsPath: Logistic.GlobalTests-------------Output Added:-------------Name: ParameterEstimatesLabel: Parameter EstimatesTemplate: Stat.Logistic.ParameterEstimatesPath: Logistic.ParameterEstimates-------------Output Added:-------------Name: OddsRatiosLabel: Odds RatiosTemplate: Stat.Logistic.OddsRatiosPath: Logistic.OddsRatios-------------Output Added:-------------Name: AssociationLabel: Association StatisticsTemplate: Stat.Logistic.AssociationPath: 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 secondsuser cpu time 0.08 secondssystem cpu time 0.00 secondsmemory 2353.96kOS Memory 33208.00kTimestamp 02/05/2020 04:53:35 PMStep Count 158 Switch Count 1Page Faults 0Page Reclaims 201Page Swaps 0Voluntary Context Switches 9Involuntary Context Switches 9Block Input Operations 0Block Output Operations 56264 ! /* Need run with ods trace */265 ods trace off;266267 ods output ParameterEstimates = estimout;268 /* The ParameterEstimates table will be written to a SAS data269 set called estimout. */270 proc logistic data=mathex;271 title2 'Save parameter estimates using ods';272 model passed (event='Yes') = c1 c3 totscore;273NOTE: 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 secondsuser cpu time 0.08 secondssystem cpu time 0.00 secondsmemory 2688.43kOS Memory 33468.00kTimestamp 02/05/2020 04:53:35 PMStep Count 159 Switch Count 3Page Faults 0Page Reclaims 296Page Swaps 0Voluntary Context Switches 25Involuntary Context Switches 1Block Input Operations 0Block Output Operations 328274 proc print data=estimout;275NOTE: There were 4 observations read from the data set WORK.ESTIMOUT.NOTE: PROCEDURE PRINT used (Total process time):real time 0.01 secondsuser cpu time 0.02 secondssystem cpu time 0.00 secondsmemory 670.34kOS Memory 32424.00kTimestamp 02/05/2020 04:53:35 PMStep Count 160 Switch Count 0Page Faults 0Page Reclaims 62Page Swaps 0Voluntary Context Switches 0Involuntary Context Switches 0Block Input Operations 0Block Output Operations 8276 proc iml;NOTE: IML Ready277 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;290291 quit;NOTE: Exiting IML.NOTE: PROCEDURE IML used (Total process time):real time 0.02 secondsuser cpu time 0.02 secondssystem cpu time 0.00 secondsmemory 782.56kOS Memory 32424.00kTimestamp 02/05/2020 04:53:35 PMStep Count 161 Switch Count 1Page Faults 0Page Reclaims 168Page Swaps 0Voluntary Context Switches 8Involuntary Context Switches 0Block Input Operations 0Block Output Operations 16292293294 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;305