Download presentation
Presentation is loading. Please wait.
Published byMagdalene Bryant Modified over 9 years ago
1
Kernel estimators ESSI SYRJÄLÄ
2
Introduction
3
More generally
4
Basic asymptotics
5
Kernel estimator
6
R-code: Choices of bandwidth library(faraway) data(trees) attach(trees) plot(Height ~ Girth, trees,main="bandwidth=1") # The default uses a uniform kernel but it’s quite rough so we # change it to normal kernel lines(ksmooth(Girth,Height,"normal",1),lwd=2,col = "red") plot(Height ~ Girth, trees,main="bandwidth=3") lines(ksmooth(Girth,Height,"normal",3),lwd=2,col = "red") plot(Height ~ Girth, trees,main="bandwidth=7") lines(ksmooth(Girth,Height,"normal",7),lwd=2,col = "red")
7
Kernel estimates with different bandwidths
8
R-code install.packages("sm") library(sm) #Cross-validated choice of bandwidth hm<-hcv(Girth,Height,display="lines") #hm=2.291831 #This uses Gaussian kernel sm.regression(Girth,Height,h=hm,xlab="girth",ylab="height")
9
Cross-validation criterion as a function of a smoothing parameter and kernel estimate with this value of the smoothing parameter
10
Exercise Use data ais from package alr3. Find the best value for the smoothing parameter (bandwidth) by plotting pictures with different bandwidths and then by cross-validation. Notice that you have to define start value and end value (?hcv). Then do the same thing just for females (when sex is female).
11
References Faraway, Julian J. Extending the Linear Model with R: Generalized Linear, Mixed Effects and Nonparametric Regression Models, Chapman& Hall/CRC, 2006. Wikipedia. Kernel density estimation. Edited 1.4.2015. http://en.wikipedia.org/wiki/Kernel_density_estimation Wikipedia. Big O notation. Edited 12.3.2015. http://en.wikipedia.org/wiki/Big_O_notation#Usage
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.