Published on :
Statistical INTERNAL_CREATION

Isotonic contrasts with PROC MIXED

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins with a DATA STEP that generates the 'FerriteCores' dataset. This dataset simulates 'MagneticForce' measurements for four levels of 'Temp' (temperature), with five repetitions per level, the data being provided via DATALINES. Then, PROC MIXED is invoked to perform an analysis of variance on 'MagneticForce' as a function of 'Temp'. The CLASS statement specifies 'Temp' as a categorical variable. The LSMESTIMATE statement is used to define and test specific isotonic contrasts, allowing comparison of mean 'Temp' levels in an ordered manner. The '/ adjust=simulate(seed=1) cl upper' options are applied for p-value adjustment, calculation of confidence intervals, and definition of an upper bound. Finally, ODS SELECT LSMestimates is used to display only the relevant results of the least squares estimates.
Data Analysis

Type : INTERNAL_CREATION


Data is generated directly within the script via a DATA STEP and DATALINES for the 'FerriteCores' dataset. The 'MagneticForce' field is read from the DATALINES.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the 'FerriteCores' dataset. It initializes a loop to generate a 'Temp' (temperature) variable from 1 to 4, and an inner loop for 5 repetitions per 'Temp'. The 'MagneticForce' variable is read from DATALINES, simulating measurements for different temperature conditions.
Copied!
1DATA FerriteCores;
2 DO Temp = 1 to 4;
3 DO rep = 1 to 5; drop rep;
4 INPUT MagneticForce;
5 OUTPUT;
6 END;
7 END;
8 DATALINES;
910.8 9.9 10.7 10.4 9.7
1010.7 10.6 11.0 10.8 10.9
1111.9 11.2 11.0 11.1 11.3
1211.4 10.7 10.9 11.3 11.7
13;
14 
2 Code Block
PROC MIXED
Explanation :
This block uses PROC MIXED to analyze the 'FerriteCores' dataset. 'Temp' is defined as a classification variable. A model is specified with 'MagneticForce' as the response and 'Temp' as the predictor. The LSMESTIMATE statement is used to test isotonic contrasts, evaluating ordered hypotheses on the means of 'Temp' levels. Options include p-value adjustment by simulation, calculation of confidence intervals, and specification of an upper bound. ODS SELECT LSMestimates limits the output to the least squares estimates results.
Copied!
1PROC MIXED DATA=FerriteCores;
2 class Temp;
3 model MagneticForce = Temp;
4 lsmestimate Temp
5 'avg(1:1)<avg(2:4)' -3 1 1 1 divisor=3,
6 'avg(1:2)<avg(3:4)' -1 -1 1 1 divisor=2,
7 'avg(1:3)<avg(4:4)' -1 -1 -1 3 divisor=3
8 / adjust=simulate(seed=1) cl upper;
9 ods select LSMestimates;
10RUN;
11 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : S A S S A M P L E L I B R A R Y