Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

right

One-sided right smooth for a Locfit model.


Description

The right() function is used in a locfit model formula to specify a one-sided smooth: when fitting at a point x, only data points with x_i ≤ x should be used. This can be useful in estimating points of discontinuity, and in cross-validation for forecasting a time series. right(x) is equivalent to lp(x,style="right").

When using this function, it will usually be necessary to specify an evaluation structure, since the fit is not smooth and locfit's interpolation methods are unreliable. Also, it is usually best to use deg=0 or deg=1, otherwise the fits may be too variable. If nearest neighbor bandwidth specification is used, it does not recognize right().

Usage

right(x,...)

Arguments

x

numeric variable.

...

Other arguments to lp().

See Also

Examples

# compute left and right smooths
data(penny)
xev <- (1945:1988)+0.5
fitl <- locfit(thickness~left(year,h=10,deg=1), ev=xev, data=penny)
fitr <- locfit(thickness~right(year, h=10, deg=1), ev=xev, data=penny)
# plot the squared difference, to show the change points.
plot( xev, (predict(fitr, where="ev") - predict(fitl, where="ev"))^2 )

locfit

Local Regression, Likelihood and Density Estimation

v1.5-9.4
GPL (>= 2)
Authors
Catherine Loader [aut], Jiayang Sun [ctb], Lucent Technologies [cph], Andy Liaw [cre]
Initial release
2020-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.