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)
Run the code above in your browser using DataLab