Last data update: 2014.03.03

R: Tau-Regression using the Fast-tau-Algorithm
FastTauR Documentation

Tau-Regression using the Fast-tau-Algorithm

Description

Performs tau-Regression using the Fast-tau-Algorithm.

Usage

FastTau(x, y, taucontrol = list(N = 500, kk = 2, tt = 5, rr = 2, approximate = 0),
 beta_gamma)

Arguments

x

numeric (n,p)-matrix: Designmatrix.

y

numeric vector: n observations.

taucontrol

list of four integer and one logical value: Control parameters (see Details).

beta_gamma

numeric vector: Specifies one parameter candidate of length p (see Details).

Details

The Fast-tau-Algorithm to efficiently perform tau-Regression was published by Salibian-Barrera, Willems and Zamar (2008). It bases on starting with a set of N parameter candidates, locally optimizing them using kk iterations, then optimizing the tt best candidates to convergence and finally choosing the best parameter candidate. Since calculation of the objective value is computationally expensive, it is possible to approximate it with rr iteration steps when choosing approximate=TRUE. For more details see Salibian-Barrera, Willems and Zamar (2008).

The R-function FastTau used in RobPer is a slightly changed version of the R-code published in Salibian-Barrera, Willems and Zamar (2008). It was changed in order to work more efficiently, especially when fitting step functions, and to specify one parameter candidate in advance. For details see Thieler, Fried and Rathjens (2016).

Value

beta

numeric vector: Fitted parameter vector.

scale

numeric: Value of the objective function

Author(s)

Matias Salibian-Barrera and Gert Willems, modified by Anita M. Thieler

References

Salibian-Barrera, M., Willems, G. and Zamar, R. (2008): The Fast-tau Estimator for Regression. Journal of Computational and Graphical Statistics, 17 (3), 659-682

Thieler, A. M., Fried, R. and Rathjens, J. (2016): RobPer: An R Package to Calculate Periodograms for Light Curves Based on Robust Regression. Journal of Statistical Software, 69 (9), 1-36, <doi:10.18637/jss.v069.i09>

See Also

Applied in RobPer.

Examples

set.seed(22)
# Generate a disturbed light curve
lightcurve <- tsgen(ttype="unif",ytype="sine" , pf=7, redpart=0.1, interval=TRUE,
    npoints=100, ncycles=10, ps=7, SNR=4, alpha=0)
tt <- lightcurve[,1]
y  <- lightcurve[,2]
s  <- rep(1,100)  # unweighted regression

plot(tt, y, type="l", main="Fitting a sine to a disturbed lightcurve")

# Fit the true model (a sine of period 7)... designmatrix:
X <- Xgen(tt, n=100, s, pp=7, design="sine")
# Robust tau-fit:
beta_FastTau <- FastTau(X, y)$beta
# Robust S-fit:
beta_FastS <- FastS(X, y)$beta
# Least squares fit:
beta_lm <- lm(y~0+X)$coeff

# Plot:
sin7_fun <- function(t, beta) beta[1]+ beta[2]*sin(t*2*pi/7)+ beta[3]*cos(t*2*pi/7)
sin_FastTau <- function(t) sin7_fun(t, beta_FastTau)
sin_FastS <- function(t) sin7_fun(t, beta_FastS)
sin_lm <- function(t) sin7_fun(t, beta_lm)
curve(sin_FastTau, col="green", add=TRUE)
curve(sin_FastS, col="blue", add=TRUE, lty=2)
curve(sin_lm, col="red", add=TRUE)

legend("topleft", fill=c("black", "red", "green", "blue"),
    legend=c("Light Curve (disturbed)", "Least Squares Fit", "FastTau Fit", "FastS Fit"))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RobPer)
Loading required package: robustbase
Loading required package: quantreg
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

Loading required package: splines
Loading required package: BB
Loading required package: rgenoud
##  rgenoud (Version 5.7-12.4, Build Date: 2015-07-19)
##  See http://sekhon.berkeley.edu/rgenoud for additional documentation.
##  Please cite software as:
##   Walter Mebane, Jr. and Jasjeet S. Sekhon. 2011.
##   ``Genetic Optimization Using Derivatives: The rgenoud package for R.''
##   Journal of Statistical Software, 42(11): 1-26. 
##

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RobPer/FastTau.Rd_%03d_medium.png", width=480, height=480)
> ### Name: FastTau
> ### Title: Tau-Regression using the Fast-tau-Algorithm
> ### Aliases: FastTau
> 
> ### ** Examples
> 
> set.seed(22)
> # Generate a disturbed light curve
> lightcurve <- tsgen(ttype="unif",ytype="sine" , pf=7, redpart=0.1, interval=TRUE,
+     npoints=100, ncycles=10, ps=7, SNR=4, alpha=0)
> tt <- lightcurve[,1]
> y  <- lightcurve[,2]
> s  <- rep(1,100)  # unweighted regression
> 
> plot(tt, y, type="l", main="Fitting a sine to a disturbed lightcurve")
> 
> # Fit the true model (a sine of period 7)... designmatrix:
> X <- Xgen(tt, n=100, s, pp=7, design="sine")
> # Robust tau-fit:
> beta_FastTau <- FastTau(X, y)$beta
> # Robust S-fit:
> beta_FastS <- FastS(X, y)$beta
> # Least squares fit:
> beta_lm <- lm(y~0+X)$coeff
> 
> # Plot:
> sin7_fun <- function(t, beta) beta[1]+ beta[2]*sin(t*2*pi/7)+ beta[3]*cos(t*2*pi/7)
> sin_FastTau <- function(t) sin7_fun(t, beta_FastTau)
> sin_FastS <- function(t) sin7_fun(t, beta_FastS)
> sin_lm <- function(t) sin7_fun(t, beta_lm)
> curve(sin_FastTau, col="green", add=TRUE)
> curve(sin_FastS, col="blue", add=TRUE, lty=2)
> curve(sin_lm, col="red", add=TRUE)
> 
> legend("topleft", fill=c("black", "red", "green", "blue"),
+     legend=c("Light Curve (disturbed)", "Least Squares Fit", "FastTau Fit", "FastS Fit"))
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>