The script loads example data 'Power cells' from Neter (Table 8.1). It performs variable transformations (centering and scaling) to create polynomial and interaction terms. Then, it fits several regression models (full second-order model, lack of fit test, first-order models) using GLM and REG procedures to analyze the impact of charge rate and temperature on the number of cycles.
Data Analysis
Type : CREATION_INTERNE
The data is defined directly in the code via a CARDS statement in the DATA step 'brand'.
1 Code Block
DATA STEP Data
Explanation : Creation of the 'brand' table with variables y, x1, x2. Calculation of transformed (centered and scaled) variables tx1 and tx2, as well as their quadratic terms (tx1s, tx2s) and interaction (tx12).
Copied!
options ls=80;
data brand;
input y x1 x2;
tx1=(x1-1)/0.4; /* the coded variable, 1 is the mean of x and 0.4 is diff between two adjacent value */
tx2=(x2-20)/10;
tx1s=tx1**2;
tx2s=tx2**2;
tx12=tx1*tx2;
cards;
150 0.6 10
86 1.0 10
49 1.4 10
288 0.6 20
157 1.0 20
131 1.0 20
184 1.0 20
109 1.4 20
279 0.6 30
235 1.0 30
224 1.4 30
;
1
options ls=80;
2
DATA brand;
3
INPUT y x1 x2;
4
tx1=(x1-1)/0.4; /* the coded variable, 1 is the mean of x and 0.4 is diff between two adjacent value */
5
tx2=(x2-20)/10;
6
tx1s=tx1**2;
7
tx2s=tx2**2;
8
tx12=tx1*tx2;
9
CARDS;
10
1500.610
11
861.010
12
491.410
13
2880.620
14
1571.020
15
1311.020
16
1841.020
17
1091.420
18
2790.630
19
2351.030
20
2241.430
21
;
2 Code Block
PROC PRINT
Explanation : Display of the created dataset.
Copied!
proc print; run;
1
PROC PRINT; RUN;
3 Code Block
PROC GLM
Explanation : Execution of a full second-order polynomial regression model including linear, quadratic, and interaction terms.
Copied!
proc glm;
model y=tx1 tx2 tx1s tx2s tx12; /* full model y= tx1 + tx2 + tx1^2 +tx2^2 + tx1*tx2 */
run;
1
2
PROC GLM;
3
model y=tx1 tx2 tx1s tx2s tx12;
4
/* full model y= tx1 + tx2 + tx1^2 +tx2^2 + tx1*tx2 */
5
RUN;
6
4 Code Block
PROC GLM
Explanation : F-test for lack of fit. Variables x1 and x2 are treated as classification (categorical) variables to assess the overall interaction.
Copied!
proc glm; /* the F-test for lack of fit */
class x1 x2; /* classify x1 and x2 to be indicator variables*/
model y=x1|x2; /* y = x1 + x2 + x1*x2 */
run;
1
PROC GLM; /* the F-test for lack of fit */
2
class x1 x2; /* classify x1 and x2 to be indicator variables*/
3
model y=x1|x2; /* y = x1 + x2 + x1*x2 */
4
RUN;
5 Code Block
PROC REG
Explanation : Test of a first-order model using only the transformed linear variables.
Copied!
proc reg; /* test for the first order model */
model y=tx1 tx2; /* y= tx1 + tx2 */
run;
1
2
PROC REG;
3
/* test for the first order model */
4
model y=tx1 tx2;
5
/* y= tx1 + tx2 */
6
RUN;
7
6 Code Block
PROC REG
Explanation : Test of a first-order model using the original variables.
Copied!
proc reg;
model y=x1 x2; /* y = x1 + x2 */
run;
1
PROC REG;
2
model y=x1 x2; /* y = x1 + x2 */
3
RUN;
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.