*----------------- Data on Physical Fitness -----------------* | These measurements were made on men involved in a physical | | fitness course at N.C. State University. | | Only selected variables of | | Oxygen (oxygen intake, ml per kg body weight per minute), | | Runtime (time to run 1.5 miles in minutes), and | | RunPulse (heart rate while running) are used. | | Certain values were changed to missing for the analysis. | *------------------------------------------------------------*; /***************************means*********************************/ data Fitness1; input Oxygen RunTime RunPulse @@; datalines; 44.609 11.37 178 45.313 10.07 185 54.297 8.65 156 59.571 . . 49.874 9.22 . 44.811 11.63 176 . 11.95 176 . 10.85 . 39.442 13.08 174 60.055 8.63 170 50.541 . . 37.388 14.03 186 44.754 11.12 176 47.273 . . 51.855 10.33 166 49.156 8.95 180 40.836 10.95 168 46.672 10.00 . 46.774 10.25 . 50.388 10.08 168 39.407 12.63 174 46.080 11.17 156 45.441 9.63 164 . 8.92 . 45.118 11.08 . 39.203 12.88 168 45.790 10.47 186 50.545 9.93 148 48.673 9.40 186 47.920 11.50 170 47.467 10.50 170 ; proc mi data=Fitness1 seed=3237851 nimpute=20 /*noprint*/ out=outmi; var Oxygen RunTime RunPulse; run; proc univariate data=outmi noprint; var Oxygen RunTime RunPulse; output out=outuni mean=Oxygen RunTime RunPulse stderr=SOxygen SRunTime SRunPulse; by _Imputation_; run; proc print data=outuni (obs=10); title 'UNIVARIATE Means and Standard Errors (First 10 Imputations)'; run; proc mianalyze data=outuni edf=30; modeleffects Oxygen RunTime RunPulse; stderr SOxygen SRunTime SRunPulse; run; /**********************************Regression*****************************************/ proc reg data=outmi outest=outreg covout /*noprint*/; model Oxygen= RunTime RunPulse; by _Imputation_; run; proc print data=outreg(obs=8); var _Imputation_ _Type_ _Name_ Intercept RunTime RunPulse; title 'REG Model Coefficients and Covariance Matrices' ' (First Two Imputations)'; run; proc mianalyze data=outreg edf=28; modeleffects Intercept RunTime RunPulse; run; /*************************Generalized Linear Model*****************************/ ods select none; proc genmod data=outmi; model Oxygen= RunTime RunPulse/covb; by _Imputation_; ods output ParameterEstimates=gmparms ParmInfo=gmpinfo CovB=gmcovb; run; ods select all; proc print data=gmparms (obs=8); var _Imputation_ Parameter Estimate StdErr; title 'GENMOD Model Coefficients (First Two Imputations)'; run; proc print data=gmpinfo (obs=6); title 'GENMOD Parameter Information (First Two Imputations)'; run; proc print data=gmcovb (obs=8); var _Imputation_ RowName Prm1 Prm2 Prm3; title 'GENMOD Covariance Matrices (First Two Imputations)'; run; proc mianalyze parms=gmparms covb=gmcovb parminfo=gmpinfo; modeleffects Intercept RunTime RunPulse; run; /*************************************Percentages and Frequency***********************************************/ data incomedat; title 'Income Data'; input Gender $ Education $ Income $; datalines; M GH 1 F . . F LH 0 M LH 0 F . 1 M LH 0 M GH 1 M GH 1 F LH 0 F LH . M LH 0 M GH 1 M GH 1 F GH . F LH 0 M LH 0 F LH 1 M LH 0 M GH 1 M GH 1 F LH . F LH . M LH 0 M . 1 M GH . F GH 1 F LH 0 M LH 0 F LH 1 M LH 0 M GH 1 M GH 1 F LH 0 F LH . M LH 0 M GH 1 M GH 1 F GH 1 F LH 0 M LH 0 F LH 1 M LH 0 M GH 1 M GH 1 F LH . F LH . M LH 0 M GH 1 M GH 1 F GH . F LH 0 M LH 0 F LH 1 M LH 0 M GH 1 M GH 0 F LH 0 F LH . M LH 0 M GH 1 M GH . F GH 0 F LH 0 M LH 0 F LH 1 M LH 0 M GH 1 M GH 1 F LH . F LH . M LH 0 M GH 0 ; proc mi data=incomedat seed=1305417 out=incomedat2; class Gender Education Income; fcs logistic( Income= Gender Education); fcs logistic( Education= Gender Income); var Gender Education Income; run; proc sort data=incomedat2; by _imputation_; run; /*Run SURVEYFREQ by _IMPUTATION_ assuming the MI step is already done*/ proc surveyfreq data=incomedat2; by _imputation_; tables Education*income/wtfreq; ods output crosstabs=ctab; ods trace on; run; proc print; run; /*Sort the data by the TABLES variable which is called RESPONSE here*/ proc sort; by Education income _imputation_; run; /*Run MIANALYZE with STDERR option for percentages*/ proc mianalyze data=ctab; by Education income;*this would be the TABLES variable; modeleffects percent; stderr stdErr; title 'Results of for Proportions'; run; /*Run MIANALYZE with STDERR option for Frequencies*/ proc mianalyze data=ctab; by Education income;*this would be the TABLES variable; modeleffects WgtFreq; stderr StdDev; title 'Results of for Frequencies'; run; /************************************************************************************************/ /********************************Logistic regression Model*************************************/ *-----------------------------Fish2 Data-----------------------------* | The data set contains two species of the fish (Parkki and Perch) | | and two measurements: Length and Width. | | Some values have been set to missing, and the resulting data set | | has a monotone missing pattern in the variables | | Length, Width, and Species. | *--------------------------------------------------------------------*; data Fish2; title 'Fish Measurement Data'; input Species $ Length Width @@; datalines; Parkki 16.5 2.3265 Parkki 17.4 2.3142 . 19.8 . Parkki 21.3 2.9181 Parkki 22.4 3.2928 . 23.2 3.2944 Parkki 23.2 3.4104 Parkki 24.1 3.1571 . 25.8 3.6636 Parkki 28.0 4.1440 Parkki 29.0 4.2340 Perch 8.8 1.4080 . 14.7 1.9992 Perch 16.0 2.4320 Perch 17.2 2.6316 Perch 18.5 2.9415 Perch 19.2 3.3216 . 19.4 . Perch 20.2 3.0502 Perch 20.8 3.0368 Perch 21.0 2.7720 Perch 22.5 3.5550 Perch 22.5 3.3075 . 22.5 . Perch 22.8 3.5340 . 23.5 . Perch 23.5 3.5250 Perch 23.5 3.5250 Perch 23.5 3.5250 Perch 23.5 3.9950 . 24.0 . Perch 24.0 3.6240 Perch 24.2 3.6300 Perch 24.5 3.6260 Perch 25.0 3.7250 . 25.5 3.7230 Perch 25.5 3.8250 Perch 26.2 4.1658 Perch 26.5 3.6835 . 27.0 4.2390 Perch 28.0 4.1440 Perch 28.7 5.1373 . 28.9 4.3350 . 28.9 . . 28.9 4.5662 Perch 29.4 4.2042 Perch 30.1 4.6354 Perch 31.6 4.7716 Perch 34.0 6.0180 . 36.5 6.3875 . 37.3 7.7957 . 39.0 . . 38.3 . Perch 39.4 6.2646 Perch 39.3 6.3666 Perch 41.4 7.4934 Perch 41.4 6.0030 Perch 41.3 7.3514 . 42.3 . Perch 42.5 7.2250 Perch 42.4 7.4624 Perch 42.5 6.6300 Perch 44.6 6.8684 Perch 45.2 7.2772 Perch 45.5 7.4165 Perch 46.0 8.1420 Perch 46.6 7.5958 ; proc mi data=Fish2 seed=1305417 out=outfish2; class Species; monotone logistic( Species= Length Width); var Length Width Species; run; ods select none; proc logistic data=outfish2; class Species; model Species= Length Width / covb; by _Imputation_; ods output ParameterEstimates=lgsparms; run; ods select all; proc print data=lgsparms (obs=6); title 'LOGISTIC Model Coefficients (First Two Imputations)'; run; proc mianalyze parms=lgsparms; modeleffects Intercept Length Width; run; /************************************Nominal Logistic Model****************************************/ *-----------------------------Fish3 Data-----------------------------* | The data set contains three species of the fish | | (Parkki, Perch, and Roach) and two measurements: Length and Width. | | Some values have been set to missing, and the resulting data set | | has an arbitrary missing pattern in the variables | | Length, Width, and Species. | *--------------------------------------------------------------------*; data Fish3; title 'Fish Measurement Data'; input Species $ Length Width @@; datalines; Roach 16.2 2.2680 Roach 20.3 2.8217 Roach 21.2 . Roach . 3.1746 Roach 22.2 3.5742 Roach 22.8 3.3516 Roach 23.1 3.3957 . 23.7 . Roach 24.7 3.7544 Roach 24.3 3.5478 Roach 25.3 . Roach 25.0 3.3250 Roach 25.0 3.8000 Roach 27.2 3.8352 Roach 26.7 3.6312 Roach 26.8 4.1272 Roach 27.9 3.9060 Roach 29.2 4.4968 Roach 30.6 4.7736 Roach 35.0 5.3550 Parkki 16.5 2.3265 Parkki 17.4 . Parkki 19.8 2.6730 Parkki 21.3 2.9181 Parkki 22.4 3.2928 Parkki 23.2 3.2944 Parkki 23.2 3.4104 Parkki 24.1 3.1571 . . 3.6636 Parkki 28.0 4.1440 Parkki 29.0 4.2340 Perch 8.8 1.4080 . 14.7 1.9992 Perch 16.0 2.4320 Perch 17.2 2.6316 Perch 18.5 2.9415 Perch 19.2 3.3216 . 19.4 3.1234 Perch 20.2 . Perch 20.8 3.0368 Perch 21.0 2.7720 Perch 22.5 3.5550 Perch 22.5 3.3075 Perch 22.5 3.6675 Perch . 3.5340 Perch 23.5 3.4075 Perch 23.5 3.5250 Perch 23.5 3.5250 . 23.5 3.5250 Perch 23.5 3.9950 Perch 24.0 3.6240 Perch 24.0 3.6240 Perch 24.2 3.6300 Perch 24.5 3.6260 Perch 25.0 3.7250 Perch . 3.7230 Perch 25.5 3.8250 Perch . 4.1658 Perch 26.5 3.6835 . 27.0 4.2390 Perch . 4.1440 Perch 28.7 5.1373 . 28.9 4.3350 Perch 28.9 4.3350 Perch 28.9 4.5662 Perch 29.4 4.2042 Perch 30.1 4.6354 Perch 31.6 4.7716 Perch 34.0 6.0180 Perch 36.5 6.3875 Perch 37.3 7.7957 Perch 39.0 . Perch 38.3 6.7408 Perch . 6.2646 . 39.3 . Perch 41.4 7.4934 Perch 41.4 6.0030 Perch 41.3 7.3514 Perch 42.3 7.1064 Perch 42.5 7.2250 Perch 42.4 7.4624 Perch 42.5 6.6300 Perch 44.6 6.8684 Perch 45.2 7.2772 Perch 45.5 7.4165 Perch 46.0 8.1420 . 46.6 7.5958 ; proc means n nmiss min P25 P50 P75 max mean std maxdec=2 data=Fish3; var Length Width; run; proc mi data=Fish3 seed=30535 nimpute=20 minimum=8.80 1.41 . maximum=46.60 8.14 . out=outfish3; class Species; fcs reg(Length=Width Species); fcs reg(Width=Length Species); fcs logistic ( Species= Length Width / link=glogit); var Length Width Species; run; proc means n nmiss min P25 P50 P75 max mean std maxdec=2 data=outfish3; var Length Width; run; proc freq data=fish3; tables Species /missing list; run; proc freq data=outfish3; tables Species /missing list; run; ods select none; proc logistic data=outfish3; class Species; model Species= Length Width / link=glogit covb; by _Imputation_; ods output ParameterEstimates=lgsparms CovB=lgscovb; run; ods select all; proc print data=lgsparms (obs=12); title 'LOGISTIC Model Coefficients (First Two Imputations)'; run; proc print data=lgscovb (obs=12); title 'LOGISTIC Model Covariance Matrices (First Two Imputations)'; run; proc mianalyze parms(link=glogit)=lgsparms covb(effectvar=stacking)=lgscovb mult; modeleffects Intercept Length Width; run; /*******************************Mixed effect model*************************************/ ods select none; proc mixed data=outmi; model Oxygen= RunTime RunPulse RunTime*RunPulse/solution covb; by _Imputation_; ods output SolutionF=mixparms CovB=mixcovb; run; ods select all; proc print data=mixparms (obs=8); var _Imputation_ Effect Estimate StdErr; title 'MIXED Model Coefficients (First Two Imputations)'; run; proc print data=mixcovb (obs=8); var _Imputation_ Row Effect Col1 Col2 Col3 Col4; title 'Covariance Matrices (First Two Imputations)'; run; proc mianalyze parms=mixparms edf=27; modeleffects Intercept RunTime RunPulse RunTime*RunPulse; run; proc mianalyze parms=mixparms edf=27 covb(effectvar=rowcol)=mixcovb; modeleffects Intercept RunTime RunPulse RunTime*RunPulse; run; ods select none; proc mixed data=outfish2; class Species; model Length= Species Width/ solution; by _Imputation_; ods output SolutionF=mxparms; run; ods select all; proc print data=mxparms (obs=8); var _Imputation_ Effect Species Estimate StdErr; title 'MIXED Model Coefficients (First Two Imputations)'; run; proc mianalyze parms(classvar=full)=mxparms; class Species; modeleffects Intercept Species Width; run;