Polynomial Regression Using SAS



Polynomial Regression Using SAS

/*Read in the SPSS portable file using Proc Convert*/

filename file1 "d:\510\2007\data\htwt.por";

proc convert spss=file1 out=htwt;

run;

options pageno=1;

OPTIONS FORMCHAR="|----|+|---+=|-/\*";

title;

proc contents data=htwt;

run;

The CONTENTS Procedure

Data Set Name WORK.HTWT Observations 237

Member Type DATA Variables 4

Engine V9 Indexes 0

Created Monday, February 05, 2007 04:41:38 PM Observation Length 32

Last Modified Monday, February 05, 2007 04:41:38 PM Deleted Observations 0

Protection Compressed NO

Data Set Type Sorted NO

Label

Data Representation WINDOWS_32

Encoding wlatin1 Western (Windows)

Engine/Host Dependent Information

Data Set Page Size 4096

Number of Data Set Pages 3

First Data Page 1

Max Obs per Page 126

Obs in First Data Page 83

Number of Data Set Repairs 0

File Name c:\temp\_TD2040\htwt.sas7bdat

Release Created 9.0101M2

Host Created XP_PRO

Alphabetic List of Variables and Attributes

# Variable Type Len Format

2 AGE Num 8 5.2

3 HEIGHT Num 8 5.2

1 SEX Char 8 8.

4 WEIGHT Num 8 6.2

proc means data=htwt;

run;

The MEANS Procedure

Variable N Mean Std Dev Minimum Maximum

-------------------------------------------------------------------------------

AGE 237 16.4430380 1.8425767 13.9000000 25.0000000

HEIGHT 237 61.3645570 3.9454019 50.5000000 72.0000000

WEIGHT 237 101.3080169 19.4406980 50.5000000 171.5000000

-------------------------------------------------------------------------------

goptions reset=all;

goptions device=win target=winprtm;

symbol1 color=black value=dot height=.5 interpol=rq;

title "Scatter Plot with Quadratic Regression Line";

proc gplot data=htwt;

where age < 20;

plot height * age ;

run;

[pic]

/*Data Step to Create Age-Squared, Centered Age, and Centered Age-Squared*/

data htwt2;

set htwt;

agesq = age*age;

centage = age - 16.3;

centagesq = centage*centage;

run;

title "Regression Model with Original Age and Age-Squared Variables";

proc reg data=htwt2;

where age < 20;

model height = age agesq;

plot rstudent.*predicted.;

output out=regdata1 p=predict r=resid rstudent=rstudent;

run; quit;

Regression Model with Original Age and Age-Squared Variables

The REG Procedure

Model: MODEL1

Dependent Variable: HEIGHT

Number of Observations Read 230

Number of Observations Used 230

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 2 1436.79524 718.39762 84.02 |t|

Intercept 1 -31.22120 22.20249 -1.41 0.1610

AGE 1 9.83820 2.70952 3.63 0.0003

agesq 1 -0.25318 0.08199 -3.09 0.0023

[pic]

proc univariate data=regdata1;

var rstudent;

histogram;

qqplot / normal(mu=est sigma=est);

run;

[pic] [pic]

title "Regression Model with Centered Age and Age-Squared Variables";

proc reg data=htwt2;

where age < 20;

model height = centage centagesq;

run; quit;

The REG Procedure

Model: MODEL1

Dependent Variable: HEIGHT

Number of Observations Read 230

Number of Observations Used 230

Analysis of Variance

Sum of Mean

Source DF Squares Square F Value Pr > F

Model 2 1436.79524 718.39762 84.02 |t|

Intercept 1 61.87284 0.29323 211.00 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download