Published on :
Statistical CREATION_INTERNE

Polynomial Regression Analysis on Cell Life Expectancy

This code is also available in: Deutsch Español Français
Awaiting validation
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!
1options ls=80;
2DATA 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;
9CARDS;
10150 0.6 10
11 86 1.0 10
12 49 1.4 10
13288 0.6 20
14157 1.0 20
15131 1.0 20
16184 1.0 20
17109 1.4 20
18279 0.6 30
19235 1.0 30
20224 1.4 30
21;
2 Code Block
PROC PRINT
Explanation :
Display of the created dataset.
Copied!
1PROC PRINT; RUN;
3 Code Block
PROC GLM
Explanation :
Execution of a full second-order polynomial regression model including linear, quadratic, and interaction terms.
Copied!
1 
2PROC GLM;
3model y=tx1 tx2 tx1s tx2s tx12;
4/* full model y= tx1 + tx2 + tx1^2 +tx2^2 + tx1*tx2 */
5RUN;
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!
1PROC GLM; /* the F-test for lack of fit */
2class x1 x2; /* classify x1 and x2 to be indicator variables*/
3model y=x1|x2; /* y = x1 + x2 + x1*x2 */
4RUN;
5 Code Block
PROC REG
Explanation :
Test of a first-order model using only the transformed linear variables.
Copied!
1 
2PROC REG;
3/* test for the first order model */
4model y=tx1 tx2;
5/* y= tx1 + tx2 */
6RUN;
7 
6 Code Block
PROC REG
Explanation :
Test of a first-order model using the original variables.
Copied!
1PROC REG;
2model y=x1 x2; /* y = x1 + x2 */
3RUN;
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.