Top Banner
Smoothing Scatterplots Using Penalized Splines 1
94

Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

Mar 15, 2018

Download

Documents

duongnhan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

Smoothing Scatterplots Using Penalized Splines

1

Page 2: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

What do we mean by smoothing? Fitting a "smooth" curve to the data in a scatterplot

2

Page 3: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

Why would we want to fit a smooth curve to the data in a scatterplot? Imagine the model

yi=f(xi)+ei (i=1,…,n) e1,…,en ~ independent, mean 0, and f is some unknown smooth function.

3

Page 4: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

If the subject matter underlying the data set tells us nothing about a parametric form for f, we may prefer to let the data suggest a curve rather than concocting some parametric function that we hope will fit the data well. The estimated curve might help us see features of the data that are obscured by variation or simply provide a nice summary of the relationship between y and x.

4

Page 5: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

d=read.delim( "http://www.public.iastate.edu/~dnett/S511/Diabetes.txt") head(d) subject age acidity y 1 1 5.2 -8.1 4.8 2 2 8.8 -16.1 4.1 3 3 10.5 -0.9 5.2 4 4 10.6 -7.8 5.5 5 5 10.4 -29.0 5.0 6 6 1.8 -19.2 3.4 #Variables are #subject: subject ID number #age: age diagnosed with diabetes #acidity: a measure of acidity called base deficit #y: natural log of serum C-peptide concentration #Original source is Sockett et al. (1987) #mentioned in Hastie and Tibshirani's book #"Generalized Additive Models".

5

Page 6: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  6

Page 7: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  7

Page 8: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  8

Page 9: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  9

Page 10: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  10

Page 11: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

Again consider the model

yi=f(xi)+ei (i=1,…,n) e1,…,en ~ independent, mean 0, and f is some unknown smooth function.

11

Page 12: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

12

Page 13: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

13

Page 14: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  14

Page 15: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

15

Page 16: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

16

Page 17: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  17

Page 18: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

18

Page 19: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  19

Page 20: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

20

Page 21: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

21

Page 22: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

22

Page 23: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

23

Page 24: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

24

Page 25: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  25

Page 26: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

26

Page 27: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

27

Page 28: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

28

Page 29: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

29

Page 30: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

30

Page 31: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

31

Page 32: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

32

Page 33: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

33

Page 34: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  34

Page 35: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  35

Page 36: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  36

Page 37: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

Some Strategies for Choosing the Smoothing Parameter

1. Cross-Validation (CV)

2. Generalized Cross-Validation (GCV)

3. Linear Mixed Effects Model Approach

There are other approaches, but we will restrict our discussion to the methods above.

37

Page 38: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

1. Cross-Validation (CV): CV is a general strategy for choosing "tuning" parameters like our smoothing parameter λ2. These are parameters whose values are not of interest except for the fact that they affect estimates of the model parameters that are of interest.

38

Page 39: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

We will talk specifically about leave-one-out cross-validation, which is a special case of cross-validation. This approach is known as PRESS (PRediction Error Sum of Squares) when it is used to select variables in multiple regression.

39

Page 40: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

40

Page 41: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

41

Page 42: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

42

Page 43: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

43

Page 44: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

44

Page 45: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

45

Page 46: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

46

Page 47: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

47

Page 48: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

48

Page 49: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

49

Page 50: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

50

Page 51: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

51

Page 52: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

52

Page 53: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

53

Page 54: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

54

Page 55: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  55

Page 56: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  56

Page 57: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

57

Page 58: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

58

Page 59: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

59

Page 60: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

60

Page 61: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

61

Page 62: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

62

Page 63: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

63

Page 64: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

64

Page 65: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

65

Page 66: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  66

dnett
Text Box
DF=10
Page 67: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  67

dnett
Text Box
DF=2
Page 68: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  68

dnett
Text Box
DF=3.59
Page 69: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

69

Page 70: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

70

Page 71: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

71

Page 72: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

72

Page 73: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

73

Page 74: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

74

Page 75: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

75

Page 76: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

76

Page 77: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

77

Page 78: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

78

Page 79: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

79

Page 80: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

The source for the information in these slides is Ruppert, D., Wand, M.P., Carroll, R.J. (2003). Semiparametric Regression. Cambridge University Press, New York.

80

Page 81: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

d=read.delim( "http://www.public.iastate.edu/~dnett/S511/Diabetes.txt") head(d) subject age acidity y 1 1 5.2 -8.1 4.8 2 2 8.8 -16.1 4.1 3 3 10.5 -0.9 5.2 4 4 10.6 -7.8 5.5 5 5 10.4 -29.0 5.0 6 6 1.8 -19.2 3.4 #Variables are #subject: subject ID number #age: age diagnosed with diabetes #acidity: a measure of acidity called base deficit #y: natural log of serum C-peptide concentration #Original source is Sockett et al. (1987) #mentioned in Hastie and Tibshirani's book #"Generalized Additive Models".

81

Page 82: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

#First install the package SemiPar. #Then issue the following commands. #Load the package SemiPar. library(SemiPar) #spm does not allow a data argument. o=spm(d$y~f(d$age,basis="trunc.poly",degree=1)) summary(o) Summary for non-linear components: df spar knots f(d$age) 3.59 5.705 8 Note this includes 1 df for the intercept.

82

Page 83: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

plot(d$age,d$y,pch=19,col=4, xlab="Age at Diagnosis", ylab="Log C-Peptide Concentration", main = expression( paste( "Linear Spline Fit with ", lambda^2,"=5.7"))) lines(o,shade=F,se=F)

83

Page 84: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  84

Page 85: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

plot(o) 85

Page 86: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

#Load the data set fossil that comes #with the SemiPar package. data(fossil) head(fossil) age strontium.ratio 1 91.78525 0.707343 2 92.39579 0.707359 3 93.97061 0.707410 4 95.57577 0.707438 5 95.60286 0.707463 6 112.33691 0.707320 dim(fossil) [1] 106 2

86

Page 87: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

#Shows relationship between strontium #ratios of ocean fossils and their age #in millions of years. The dip just less #then 115 million years ago coincides #with the mid-plate volcanic activity. #See Bralower et al. (1997). #Mid-Cretaceous strontium isotope #stratigraphy of deep-sea sections. #Geological Society of America Bulletin #109, 1421-1442. plot(fossil)

87

Page 88: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  88

Page 89: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

y=fossil$strontium.ratio x=fossil$age o=spm(y~f(x,basis="trunc.poly",degree=1)) summary(o) Summary for non-linear components: df spar knots f(x) 12.76 1.324 25 Note this includes 1 df for the intercept. plot(fossil) lines(o,se=F)

89

Page 90: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  90

Page 91: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

#Try penalized quadratic splines #rather than linear splines. o=spm(y~f(x,basis="trunc.poly",degree=2)) summary(o) Summary for non-linear components: df spar knots f(x) 10.06 2.243 25 Note this includes 1 df for the intercept. plot(fossil) lines(o,se=F)

91

Page 92: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  92

Page 93: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

 

#The next set of notes covers the lowess #(or loess) smoother. o=lowess(y~x,f=.2) plot(fossil) lines(o,lwd=2) #See also the function 'loess' which has more #capabilities then 'lowess'. #capabilities then 'lowess'.

93

Page 94: Smoothing Scatterplots Using Penalized Splinesdnett/S511/32SmoothingPenSpline.pdfSmoothing Parameter 1. Cross-Validation (CV) 2. Generalized Cross-Validation (GCV) 3. Linear Mixed

  94