Correlation and Simple Regression - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Correlation and Simple Regression

Description:

var height weight age; Proc Corr is used for finding the sample correlation coefficient between 2 ... var height weight; Sometimes a single point can really ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 17
Provided by: mickey9
Category:

less

Transcript and Presenter's Notes

Title: Correlation and Simple Regression


1
Chapter 5
  • Correlation and Simple Regression

2
Proc Corr
  • proc corr datasample1
  • var height weight age
  • Proc Corr is used for finding the sample
    correlation coefficient between 2 numerical
    variables.
  • It will find the sample correlation coeff between
    all pairs listed in the var statement.
  • It will also provide p-values for testing the
    claim that the population corr. coefficient is 0.

3
Spearman vs. Pearson
  • proc corr datasample1 pearson spearman
  • var height weight
  • Sometimes a single point can really affect
    Pearsons correlation coefficient.
  • Spearman decided to rank the heights and then
    rank the weights and then run Pearsons
    correlation coefficient on these ranks. This way
    the magnitude of the point doesnt influence the
    result.

4
Proc Reg
  • proc reg datasample1
  • model weight height
  • plot predicted. height P weightheight
    /overlay
  • Proc Reg is used for carrying out least squares
    regression.
  • We are basically fitting a straight line to the
    data in this case.
  • To see how good the fit is, we can plot the
    predicted values as well as the observed against
    height on the same graph.

5
Plotting residuals
  • proc reg datasample1
  • model weight height
  • plot residualpredicted. o
  • plot predicted.height P
  • u95m.heightU l95m.heightL / overlay
  • We may want to plot the residuals versus
    predicted values to check assumptions.
  • We can also obtain confidence limits for the mean
    response.

6
Hypothesis Testing in Regression
  • proc reg datasample1
  • model weight height
  • test1 test b14
  • test2 test b10
  • test3 test b1
  • the last 2 tests are equivalent
  • b1 and b2 are simply labels. you can make these
    whatever
  • you want

7
Noprint Option
  • If you dont want any output printed,
  • proc reg datasample1 noprint
  • model weight height

8
More Options
  • We can obtain predicted values, confidence
  • limits and set the significance of the confidence
  • interals.
  • proc reg datasample1
  • model weight height / p cli alpha0.1

9
Missing Values
  • A period is used for missing values.
  • data new
  • input x y
  • datalines
  • 1 2
  • 3 .
  • 4 7
  • 8 10
  • proc reg
  • model y x / p
  • run
  • SAS will predict the value of y at x3.

10
Non-linear Least Squares
  • Instead of fitting a straight line, we may think
    the data
  • follows a much different overall model such as

11
  • The number of bacteria
  • present at time t (in
  • minutes) is given
  • by

12
(No Transcript)
13
  • We are interested in finding an estimate for
  • k based on the data. In SAS, the procedure to
  • use is proc nlin. We will need to supply it
    with
  • the partial derivative with respect to k. That
    is,

14
  • data nlin01
  • input t N
  • datalines
  • 1.0 109
  • 6.2 107
  • 11.4 153
  • 16.6 199
  • 21.8 261
  • 27.1 303
  • 32.3 382
  • 37.5 448
  • 42.7 549
  • 47.9 663
  • 53.1 813
  • 58.3 1022
  • 63.5 1261
  • 68.7 1570
  • 73.9 1906
  • 79.2 2371
  • 84.4 2906
  • 89.6 3596
  • 94.8 4430
  • 100.0 5456

15
  • proc nlin
  • parms k1
  • model N 100exp(kt)
  • der.k 100texp(kt)
  • run

16
  • If we think that µ is between 15 and 25 and we
  • dont want SAS searching outside that range,
  • we may add the line
  • bounds 0 lt k lt 1.5
  • We could also get faster convergence if we
  • supply SAS with the second partial derivatives.
Write a Comment
User Comments (0)
About PowerShow.com