BookmarkSubscribeRSS Feed

User-friendly SAS application for all possible mixed model selection Step4: Interaction Detection

Started ‎08-31-2021 by
Modified ‎08-31-2021 by
Views 6,544

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 community posting, I will describe the prescreening step of ALLMIXED exploration and interaction detection steps.

 

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-1630437084753.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 Step4-exploration and interaction detection. Please follow the steps outlined in the previous post to perform step1- Prescreening (https://communities.sas.com/t5/SAS-Communities-Library/User-friendly-SAS-application-for-performing-...), step2: Initial covariance selection (https://communities.sas.com/t5/SAS-Communities-Library/User-friendly-SAS-macro-application-for-perfo... ), Step3 User-friendly SAS macro application Allmixed: Step3: All possible fixed effect selection ( https://communities.sas.com/t5/SAS-Communities-Library/User-friendly-SAS-macro-application-Allmixed-... ).

     

    STEP4: Exploration and Interaction detection

    Model selection success can also be influenced by model specification error when significant higher order model terms (quadratic and cross-product) omitted from the mixed model. The need for a quadratic term for an interaction between any two predictor variables could be evaluated in the 'quadratic’ or ‘interaction detection plot respectively. To detect the need for a significant quadratic term, first fit the full model including the quadratic term for the given predictor variable (Xi) and examine the Type III P-value for statistical significance and output the predicted values (YHATfull) for the full model. Then drop both the linear and the quadratic terms for this given predictor from the model and estimate the predicted values for this reduced model (YHATred). Then a graphical display between the Δyhat (YHATfull -YHATred) and Xi can reveal the nature and the strength of quadratic effects (Figure 7). Similarly, to detect the need for a significant interaction term between two predictors, first fit the full model including the cross-product term for the two predictor variables (X1 and X2) and examine the Type III P-value for statistical significance of the interaction term and output the predicted values (YHATfull) for the full model. Then drop the cross product from the model and estimate the predicted values for this reduced model (YHATred). Then a 3-D graphical display between the Δyhat (YHATfull -YHATred) and X1 and X2 can reveal the nature and the strength of interaction effects (Figure 5). Options are included in step4 to graphically explore and to detect statistical significance of user specified linear, quadratic, interaction terms for fixed effects.

    gcjfernandez_gmail_com_1-1630437287420.png

    ALLMIXED SAS macro help – Step 4 Exploration and interaction detection

     

    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. Pre-screening fixed variables using GLMSELECT

    Descriptions and Explanation: To start the variable pre-screening mode, enter yes. Pre-screening based on the LASSO method using the selection method SBC and the stop criterion NONE will be performed. This field should be left blank to run all other model selection steps.

    Options / Examples:

    • GLMSELECT=
    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

     

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

    Descriptions and Explanation: Input must have model effects minus the term of interest. If the fixed effect of interest is Trt*time then you must have model effects trt time x5 x15 x5*x5. X5*X15

    Options / Examples:

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

     

    1. 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. 13. Exploration: Interaction and Quadratic plots: Input the type of fixed effect you would like to explore

    Descriptions and Explanation: Input the fixed effect terms that you would explore.

    Options / Examples:

    • QL x QL interaction: QLQL_trt*time (Time is treated as QL.)
    • QL x QT interaction: QLQT_trt*time (Time is treated as QT.)
    • X5 Linear: LINR_X5:

     

    (Exclude the effect in question (X5) from the must-have model term specified in macro input 7.)

    • X5 Quadratic: QUAD_x5*X5

    (Exclude the effect in question (X5) from the model term specified in macro input 7.)

     

    • X5*X15 Interaction: INTR_X5*X15

    (Exclude the effect in question (X5*X15) from the model term specified in macro input 7.)

     

    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. 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\

     

     

    ALLMIXED macro results: Detecting Interaction

    gcjfernandez_gmail_com_2-1630437454654.png

     

    gcjfernandez_gmail_com_3-1630437516869.png

     

    gcjfernandez_gmail_com_4-1630437573844.pnggcjfernandez_gmail_com_5-1630437616950.pnggcjfernandez_gmail_com_6-1630437667711.png

     

    gcjfernandez_gmail_com_7-1630437750474.pnggcjfernandez_gmail_com_8-1630437796593.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:
‎08-31-2021 03:26 PM
Updated by:
Contributors

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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