Description Usage Arguments Details Value Author(s) References See Also Examples

This function uses the standard thin plate spline function `Tps`

and a algorithm based on
psuedo data to compute robust smoothers based on the Huber weight function. By modifying the
symmetry of the Huber function and changing the scale one can also approximate a quantile
smoother. This function is experimental in that is not clear how efficient the psuedo-data
algorithm is acheiving convergence to a solution.

1 2 |

`x` |
Locations of observations. |

`Y` |
Observations |

`...` |
Any other arguments to pass to the Tps function. |

`C` |
Scaling for huber robust weighting function. (See below.) Usually it is better to leave this at 1 and
just modify the scale |

`f.start` |
The initial value for the estimated function. If NULL then the constant function at the
median of |

`psi.scale` |
The scale value for the Huber function. When C=1, this is the point where the Huber weight function will
change from quadratic to linear. Default is to use the scale |

`alpha` |
The quantile that is estimated by the spline. Default is .5 giving a median. Equivalently this parameter controls the slope of the linear wings in the Huber function |

`Niterations` |
Maximum number of interations of the psuedo data algorithm |

`tolerance` |
Convergence criterion based on the relative change in the predicted values of the function estimate. Specifically if the criterion |

`verbose` |
If TRUE intermediate results are printed out. |

This is an experimentla function that uses the psuedo-value algorithm to compute a class of robust and quantile problems.

The Thin Plate Spline/ Kriging model through fields is: Y.k= f(x.k) = P(x.k) + Z(x.k) + e.k

with the goal of estimating the smooth function: f(x)= P(x) + Z(x)

The extension in this function is that e.k can be heavy tailed or have outliers and one would still like a robust estimate of f(x). In the quantile approximation (very small scale parameter) f(x) is an estimate of the alpha quantile of the conditional distribution of Y given x.

The algorithm is iterative and involves at each step tapering the residuals in a nonlinear way. Let psi.wght be this tapering function then given an initial estimate of f, f.hat the new data for smoothing is

` Y.psuedo<- f.hat + psi.scale* psi.wght( Y - f.hat, psi.scale=psi.scale, alpha=alpha)`

A thin plate spline is now estimated for these data and a new prediction for f is found. This new vector is
used to define new psuedo values. Convergence is achieved when the the subsequent estimates of f.hat do not
change between interations. The advantage of this algorithm is at every step a standard "least squares" thin
plate spline is fit to the psuedo data. Because only the observation vector is changing at each iteration
Some matrix decompositions need only be found once and the computations at each subsequent iteration are efficient.
At convergence there is some asymptotic theory to suggest that the psuedo data can be fit using the least
squares spline and the standard smoothing techinques are valid. For example one can consider looking at the
cross-validation function for the psuedo-data as a robust version to select a smoothing parameter. This approach
is different from the weighted least squared algorithm used in the `qsreg`

function. Also `qsreg`

is only
designed to work with 1-d cubic smoothing splines.

The "rho" function indicating the departure from a pure quadratic loss function has the definition

1 2 3 4 5 |

The derivative of this function "psi" is

1 2 3 4 5 |

Note that if C is very small and if alpha = .5 then psi will essentially be 1 for r > 0 and -1 for r < 0. The key feature here is that outside a ceratin range the residual is truncated to a constant value. This is similar to the Windsorizing operation in classical robust statistics.

Another advantage of the psuedo data algotrithm is that at convergence one can just apply all the usual generic functions from Tps to the psuedo data fit. For example, predict, surface, print, etc. Some additional components are added to the Krig/Tps object, however, for information about the iterations and original data. Note that currently these are not reported in the summaries and printing of the output object.

A `Krig`

object with additional components:

`yraw` |
Original Y values |

`conv.info` |
A vector giving the convergence criterion at each iteration. |

`conv.flag` |
If TRUE then convergence criterion was less than the tolerance value. |

`psi.scale` |
Scaling factor used for the psi.wght function. |

`value` |
Value of alpha. |

Doug Nychka

Oh, Hee-Seok, Thomas CM Lee, and Douglas W. Nychka. "Fast nonparametric quantile regression with arbitrary smoothing methods." Journal of Computational and Graphical Statistics 20.2 (2011): 510-526.

qsreg

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | ```
data(ozone2)
x<- ozone2$lon.lat
y<- ozone2$y[16,]
# Smoothing fixed at 50 df
look1<- QTps( x,y, psi.scale= 15, df= 50)
## Not run:
# Least squares spline (because scale is so large)
look2<- QTps( x,y, psi.scale= 100, df= 50)
#
y.outlier<- y
# add in a huge outlier.
y.outlier[58]<- 1e5
look.outlier1<- QTps( x,y.outlier, psi.scale= 15, df= 50)
# least squares spline.
look.outlier2<- QTps( x,y.outlier, psi.scale=100 , df= 50)
#
set.panel(2,2)
surface( look1)
title("robust spline")
surface( look2)
title("least squares spline")
surface( look.outlier1, zlim=c(0,250))
title("robust spline w/outlier")
points( rbind(x[58,]), pch="+")
surface( look.outlier2, zlim=c(0,250))
title("least squares spline w/outlier")
points( rbind(x[58,]), pch="+")
set.panel()
## End(Not run)
# some quantiles
look50 <- QTps( x,y, psi.scale=.5)
look75 <- QTps( x,y,f.start= look50$fitted.values, alpha=.75)
# a simulated example that finds some different quantiles.
## Not run:
set.seed(123)
N<- 400
x<- matrix(runif( N), ncol=1)
true.g<- x *(1-x)*2
true.g<- true.g/ mean( abs( true.g))
y<- true.g + .2*rnorm( N )
look0 <- QTps( x,y, psi.scale=10, df= 15)
look50 <- QTps( x,y, df=15)
look75 <- QTps( x,y,f.start= look50$fitted.values, df=15, alpha=.75)
## End(Not run)
## Not run:
# this example tests the quantile estimate by Monte Carlo
# by creating many replicate point to increase the sample size.
# Replicate points are used because the computations for the
# spline are dominated by the number of unique locations not the
# total number of points.
set.seed(123)
N<- 80
M<- 200
x<- matrix( sort(runif( N)), ncol=1)
x<- matrix( rep( x[,1],M), ncol=1)
true.g<- x *(1-x)*2
true.g<- true.g/ mean( abs( true.g))
errors<- .2*(rexp( N*M) -1)
y<- c(matrix(true.g, ncol=M, nrow=N) + .2 * matrix( errors, ncol=M, nrow=N))
look0 <- QTps( x,y, psi.scale=10, df= 15)
look50 <- QTps( x,y, df=15)
look75 <- QTps( x,y, df=15, alpha=.75)
bplot.xy(x,y, N=25)
xg<- seq(0,1,,200)
lines( xg, predict( look0, x=xg), col="red")
lines( xg, predict( look50, x=xg), col="blue")
lines( xg, predict( look75, x=xg), col="green")
## End(Not run)
## Not run:
# A comparison with qsreg
qsreg.fit50<- qsreg(rat.diet$t,rat.diet$con, sc=.5)
lam<- qsreg.fit50$cv.grid[,1]
df<- qsreg.fit50$cv.grid[,2]
M<- length(lam)
CV<-rep( NA, M)
M<- length( df)
fhat.old<- NULL
for ( k in M:1){
temp.obj<- QTps(rat.diet$t,rat.diet$con, f.start=fhat.old, psi.scale=.5, tolerance=1e-6,
verbose=FALSE, df= df[k])
cat(k, " ")
CV[k] <- temp.obj$Qinfo$CV.psuedo
fhat.old<- temp.obj$fitted.values
}
plot( df, CV, type="l", lwd=2)
# psuedo data estimate
points( qsreg.fit50$cv.grid[,c(5,6)], col="blue")
# alternative CV estimate via reweighted LS
points( qsreg.fit50$cv.grid[,c(2,3)], col="red")
## End(Not run)
``` |

fields documentation built on Jan. 30, 2018, 1:07 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.