Tuesday, March 17, 2009

Smoothing on R

One of you asked how to produce a "3RSSH, twice" smooth on R.  It seems that my R notes on the web could be clarified.  Here I illustrate a simple function to do the smooth that we want.

Here is a new function that you can use called smooth.3RSSH.twice.

SMOOTH=han(smooth(attend,kind="3RSS")) # 3RSSH smooth
ROUGH=data-SMOOTH                      # computes the rough
SMOOTH+han(smooth(ROUGH,kind="3RSS"))  # twicing operation

This program does three things:

1.  First, one computes a 3RSSH smooth using the smooth command in R and the han function from the LearnEDA package.

2.  Then one computes the rough (the residuals) from this smooth.

3.  Then one smooths the rough (using the same 3RSSH smooth) and adds this "smoothed rough" to the first smooth to get a "twiced smooth".

Here is an illustration of how it works for the Braves attendance data from the notes.
(I am assuming the above function has been read into R.)



Mind Writer! said...

Nice way to smooth. I've been trying to work on Spatial Analysis using Variogram and I found R quite tough to understand and use for such use. Can you suggest any nice and easy way to Kriging?

Mind Writer! said...

Moreover, I've been interested to work on Bayesian Kriging but understanding R seems quite tough.