[R] running median and smoothing splines for robust surface f itting
roger koenker
rkoenker at uiuc.edu
Thu Mar 16 14:17:58 CET 2006
Andy's comment gives me an excuse to mention that rqss() in
my quantreg package does median smoothing for 1d and 2d function
and additive models involving such functions using total
variation of f' and grad f as a roughness penalties. Further
references
available from ?rqss.
Roger
url: www.econ.uiuc.edu/~roger Roger Koenker
email rkoenker at uiuc.edu Department of Economics
vox: 217-333-4558 University of Illinois
fax: 217-244-6678 Champaign, IL 61820
On Mar 16, 2006, at 6:13 AM, Liaw, Andy wrote:
> loess() should be able to do robust 2D smoothing.
>
> There's no natural ordering in 2D, so defining running medians can be
> tricky. I seem to recall Prof. Koenker talked about some robust 2D
> smoothing method at useR! 2004, but can't remember if it's
> available in some
> packages.
>
> Andy
>
> From: Vladislav Petyuk
>>
>> Hi,
>> Are there any multidimenstional versions of runmed() and
>> smooth.spline() functions? I need to fit surface into quite
>> noisy 3D data.
>>
>> Below is an example (2D) of kind of fittings I do.
>> Thank you,
>> Vlad
>>
>> #=generating complex x,y dataset with gaussian & uniform
>> noise== x <- seq(1:10000) x2 <- rep(NA,2*length(x)) y2 <-
>> rep(NA,2*length(x)) x2[seq(1,length(x2),2)] <- x
>> x2[seq(2,length(x2),2)] <- x y2[seq(1,length(x2),2)] <-
>> sin(4*pi*x/length(x)) + rnorm(length(x))
>> y2[seq(2,length(x2),2)] <- runif(length(x),min=-5,max=5)
>> #===============================================================
>>
>> #=robust & smooth fit===========================================
>> y3 <- runmed(y2,51,endrule="median") #first round of running
>> median y4 <- smooth.spline(x2,y3,df=10) #second round of
>> smoothing splines
>> #===============================================================
>>
>> #=ploting data==================================================
>> plot(x2,y2,pch=19,cex=0.1)
>> points(x2,y3,col="red",pch=19,cex=0.1) #running median
>> points(y4,col="green",pch=19,cex=0.1) #smoothing splines
>> #===============================================================
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>>
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-
> guide.html
More information about the R-help
mailing list