BookmarkSubscribeRSS Feed

User-friendly SAS application: mixed model analysis, prediction and model assumptions check

Started ‎09-07-2021 by
Modified ‎09-07-2021 by
Views 4,804

I developed a user-friendly SAS macro application to perform all possible mixed model selection of fixed effects including quadratic and cross products within a user-specified subset range in the presence of random and repeated measures effects using SAS PROC MIXED (Fernandez, 2007). Options are also included in this macro to select the best covariance structure associated with the user-specified fully saturated repeated measures model; to graphically explore and to detect statistical significance of user specified linear, quadratic, interaction terms for fixed effects; and to diagnose multicollinearity, via the VIF statistic for each continuous predictor, involved in each model selection step. Two model selection criteria, AICC (corrected Akaike Information Criterion) and MDL (minimal description length) are used in all possible model selection and summaries of the best model selection are compared graphically. In this SAS community posting, I will describe the final step in ALLMIXED: Complete analysis of selected model, prediction and checking for model assumptions.

ALL POSSIBLE MODEL SELECTION STEPS

The recommended selection steps for performing the model selection in MIXED model is illustrated in Figure1. Although the recommended sequence of the steps is identified in the figure 1, it is not a requirement to follow the same sequence. Users are free to choose to run any model selection steps in any order they desire. However, before running these model selection steps the data format must be suitable for running the SAS PROC Mixed procedure. The following types of PC data formats can be used with the ALLMIXED macro: SAS temporary and permanent data files, Microsoft excel, COMMA or TAB delimited text file.

SAS 9.4 Modules required to run this macro:

  • SAS/STAT: PROC MIXED, PROC CORR, PROC REG, PROC GLMSELECT
  • SAS/GRAPH: PROC GCHART, PROC GPLOT, PROC G3D
  • Base SAS ODS (RTF, HTML, PDF)
  • SAS/ACCESS: PC FILES – PROC IMPORT and PROC EXPORTgcjfernandez_gmail_com_0-1630991367420.png

     

     

    Improved ALLMIXED SAS macro application

    The original SAS macro application, I developed (Fernandez, 2007) is not compatible in SAS enterprise guide (SAS EG) or in SAS studio. Therefore, I am presenting an improved version of the ALLMIXED macro in this post. By using this improved ALLMIXED macro application, SAS users can effectively perform complete mixed model analysis in SAS studio or in SAS EG. First download and unzip the ALLMIXED.zip file specified in this post and save the contents to a custom folder such as C:\temp\allmixed. The extracted ALLMIXED zip file should include, compiled ALLMIXED macro catalog, five macro call files corresponding to six ALLMIXED model selection steps, and sample demo data used in the demo. In this article, I will present the steps needed to perform Step6 (final) in all possible mixed model selection: Complete Mixed model analysis, prediction and checking for model assumptions. Please follow the steps outlined in the previous post to perform,  Step1 User-friendly SAS macro application - Prescreening (https://communities.sas.com/t5/SAS-Communities-Library/User-friendly-SAS-application-for-performing-...), Step2: User-friendly SAS macro application -Initial covariance selection (https://communities.sas.com/t5/SAS-Communities-Library/User-friendly-SAS-macro-application-for-perfo... ), Step3: User-friendly SAS macro application - All possible fixed effect selection (https://communities.sas.com/t5/SAS-Communities-Library/User-friendly-SAS-macro-application-Allmixed-... ), Step4:User-friendly SAS application for performing all possible mixed model selection - Interaction Detection (https://communities.sas.com/t5/SAS-Communities-Library/User-friendly-SAS-application-for-all-possibl...)

     

    Sample macro-call input for performing stp6: (final) in all possible mixed model selection: Complete mixed model analysis, prediction and checking for model assumptions

gcjfernandez_gmail_com_2-1630991543118.png

 

ALLMIXED SAS macro help – Step 6 Complete Mixed Model analysis, prediction and checking for model assumptions

 

  1. Input the Excel file name or SAS data set name?

Descriptions and Explanation: Include the data type name (XLS, TAB, TXT, SAS, TMP) and name of the data set on which you would like to perform pre-screening.

Options / Examples:

  •  xls_SIMDATA1: Data type is EXCEL, and the file name is SIMDATA1. Make sure to include the separator character '_'.

SAS_SIMDATA1: Data type is permanent SAS (SD7SAS) and the SAS permanent data name is SIMDATA1

 TMP_SIMDATA1: Data type is temporary SAS data and file name is SIMDATA1.

  1. Input required Response variable or variables

Descriptions and Explanation: Input the continuous response (dependent) variable name (or names). The name should match the variable names in the data. You can include multiple responses

Options / Examples:

  • Y Y1 Y2
  1. Input optional CLASS terms

Descriptions and Explanation: Input the names of the categorical variables that will be included in the CLASS statement in PROC Mixed.

Options / Examples:

Class= TRT time sub

 

  1. Input ith analysis (a counter) to attach to the saved output file name

Descriptions and Explanation: Input any numeric and categorical character to track the number of the analysis that you are running using this data. For example, if you input 1A, the output file created in this step would be called SIMDATA11A.ext.

Options / Examples:

Z = -1

Z = 1A

6.. Optional PROC MIXED model option

Descriptions and Explanation: Input the DDFM and any other mixed model options.

Options / Examples:

  •  Modelopt = DDFM=KR Analysis without influential statistics
  • Modelopt = DDFM=SAT INFLUENCE (iter=5 effect=sub) (Analysis with influential statistics)

 

  1. Input must have fixed effects minus the term of interest

Descriptions and Explanation: Input all selected fixed effect model terms.

Options / Examples:

  • must = trt | time x5 x15 x5*x5 x5*X15

 

  1. Proc Mixed Repeated measure Statement

Descriptions and Explanation: Input the REPEATED statement and leave the covariance type blank.

Options / Examples:

  • repeated time /sub=sub type= ar(1)
  1. Input the subject variable name

Descriptions and Explanation: In case of repeated measures data, input the subject variable name. This forces the pre-screening to do initial selection at the subject level.

Options / Examples:

  •  Id, subject, or blank

Sub = Sub

  1. Display or save the Graphs/output? choose one

Descriptions and Explanation: Option for viewing and saving all output files in a folder specified in input number 17.

WORD: Output and all SAS graphics are saved together in the user-specified folder as a single RTF format.

WEB: Output and graphics are saved in the user-specified folder as a single HTML file.

PDF: Output and graphics are saved in the user-specified folder and as a single PDF file.

TXT: Output is saved as a TXT file in all SAS versions. No output is displayed in the OUTPUT window. All graphic files are saved as PNG format in the user-specified folder.

  1. Folder containing the PC data files

Descriptions and Explanation: Input the full path of the folder containing the source data file.

Options / Examples:

  • 😧\allmixed\sasdata\ - folder name SASDATA on drive D

Make sure that you include the backslash (\) at the end of the folder name.

 OUTPUT= c:\temp\allmixed\

 

  1. Optional PROC MIXED LSMEANS Statement in the final model

Descriptions and Explanation: Input the PROC MIXED LSMEANS statement.

Options / Examples:

  • lsmeans = LSMEAN TRT | TIME /diff cl adjust=Tukey

 

  1. Folder to save the output/graphics?

Descriptions and Explanation: To save the SAS graphics, data, and output files, input the output folder name. If the 14 field is left blank, the output files are saved in the default folder.

Options / Examples:

Dir2= C:\temp\allmixed\

 

 

After selecting the final repeated measures mixed model dimensions, complete mixed model analysis (Figure 3-6), checking for normality of studentized conditional residuals (Figure 7-8), and performing) LSMEAN estimation and all pairwise comparison including with alphabet notations (Figure 9) are obtained in one step  by running this Allmixed macro.

 

ALLMIXED macro results: Final step: Model comparison, prediction and checking for model assumptions

gcjfernandez_gmail_com_3-1630991653400.pnggcjfernandez_gmail_com_4-1630991906932.pnggcjfernandez_gmail_com_5-1630991972748.pnggcjfernandez_gmail_com_6-1630992046531.pnggcjfernandez_gmail_com_7-1630992092636.png

 

gcjfernandez_gmail_com_8-1630992217230.pnggcjfernandez_gmail_com_9-1630992311325.pnggcjfernandez_gmail_com_10-1630992409403.png

 

Reference

Fernandez, G. (2007) Model Selection in PROC MIXED - A User-friendly SAS® Macro Application SAS Global Forum proceedings 191-2007

https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/191-2007.pdf

 

Version history
Last update:
‎09-07-2021 01:29 AM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags