Learn R Programming

pheno (version 1.0)

pheno.lad.fit: Fits a robust two-way linear model

Description

Fits a robust two-way linear model. The model assumes both factors (f1 and f2) to be fixed. Errors are assumed to be i.i.d. No general mean and sum of f2 is constrained to be zero.

Usage

pheno.lad.fit(D)

Arguments

D
Data frame with three columns (x, f1, f2) or a matrix where rows are ranks of factor f1 levels and columns are ranks of factor f2 levels and missing values are set to 0.

Value

  • p1Estimated parameters of factor f1, in phenology this is precisely the combined time series.
  • p2Estimated parameters of factor f2, in phenology these are precisely the station effects.
  • residResiduals
  • ierrFor length(x) > 1000 this is the return error code of rq.fit.sfn()
  • DThe input as ordered data frame, ordered first by f2 then by f1

Details

The function minimizes the least absolute deviations (LAD or L1 norm) of the residuals of a two-way linear model. This function is basically a wrapper for the rq.fit() or rq.fit.sfn() functions of the quantreg and nprq package, respectively, adapted for the estimation of combined phenological time series. Depending on the size of the problem (length(x)<=1000) either="" the="" rq.fit() function using the Barrodale-Roberts algorithm is used or (length(x)>1000) the corresponding dense matrix implementation with rq.fit.sfn() using the Interior-Point method. In phenological applications, x should be the julian day of observation of a certain phase, factor f1 should be the observation year and factor f2 should be a station-id. Note that the input data frame is sorted before fitting, such that subsequent analyses using the input data should be done using the sorted output data frame.

References

Rousseeuw PJ, Leroy AM (1987) 'Robust estimation and outlier detection'. Wiley. Schaber J, Badeck F-W (2002) 'Evaluation of methods for the combination of phenological time series and outlier detection'. Tree Physiology 22:973-982

See Also

rq.fit rq.fit.sfn

Examples

Run this code
data(DWD)
	R <- pheno.lad.fit(DWD)							# robust parameter estimation
	plot(levels(factor(R$D[[2]])),R$p1,type="l")	# plot combined time series
	R$D[R$resid >= 30,]								# observation whose residuals
   													# are > 30 days (outliers)

Run the code above in your browser using DataLab