Learn R Programming

expectreg (version 0.26)

expectile.laws: Expectile regression of additive models

Description

Generalized additive models are fitted with least asymmetrically weighted squares or restricted with respect to the mean to obtain the graphs of 11 different expectiles for continuous, spatial or random effects.

Usage

expectile.laws(formula, data = NULL, smooth = c("schall", "acv", "fixed"), lambda = 0.1, expectiles = NA, parallel = FALSE)

expectile.sheets(formula, data = NULL, smooth = c("acv", "fixed"), lambda = 0.1, lambdap = 5, expectiles = NA, density = FALSE)

expectile.noncross(formula, data  = NULL, smooth = c("schall", "acv", "fixed"), lambda = 0.1, expectiles = NA)

Arguments

formula
An R formula object consisting of the response variable, '~' and the sum of all effects that should be taken into consideration. Each effect has to be given through the function base.
data
Optional data frame containing the variables used in the model, if the data is not explicitely given in the formula.
smooth
There are different smoothing algorithms that should prevent overfitting. The 'schall' algorithm iterates the smoothing penalty lambda until it converges, the asymmetric cross-validation 'acv' minimizes a score-function using
lambda
The fixed penalty can be adjusted. Also serves as starting value for the smoothing algorithms.
lambdap
A penalty for smoothing across the expectiles in the sheets function. Used if no smoothing algorithm is applied.
expectiles
In default setting, the expectiles (0.01,0.02,0.05,0.1,0.2,0.5,0.8,0.9,0.95,0.98,0.99) are calculated. You may specify your own set of expectiles in a vector. Is overridden by density.
parallel
On Unix machines with the package multicore installed the different expectiles can be calculated simultaneously, if the computer has multiple CPU cores.
density
If TRUE, 99 expectiles from 1% to 99% are fitted to allow for a density estimation afterwards.

Value

  • An object of class 'expectreg', which is basically a list consisting of:
  • lambdaThe final smoothing parameters for all expectiles and for all effects in a list. For the restricted and the bundle regression there are only the mean and the residual lambda.
  • interceptsThe intercept for each expectile.
  • coefficientsA matrix of all the coefficients, for each base element a row and for each expectile a column.
  • valuesThe fitted values for each observation and all expectiles, separately in a list for each effect in the model, sorted in order of ascending covariate values.
  • responseVector of the response variable.
  • covariatesList with the values of the covariates.
  • formulaThe formula object that was given to the function.
  • expectilesVector of fitted expectile asymmetries as given by argument expectiles.
  • effectsList of characters giving the types of covariates.
  • helperList of additional parameters like neighbourhood structure for spatial effects or 'phi' for kriging.
  • designComplete design matrix.
  • fittedFitted values $\hat{y}$.
  • plot, predict, resid, fitted, effects and further convenient methods are available for class 'expectreg'.

Details

In least asymmetrically weighted squares (LAWS) each expectile is fitted independently from the others. LAWS minimizes: $S = \sum_{i=1}^{n}{ w_i(p)(y_i - \mu_i(p))^2}$ with $w_i(p) = p 1_{(y_i > \mu_i(p))} + (1-p) 1_{(y_i < \mu_i(p))}$. The expectile sheets construct a p-spline basis for the expectiles and perform a continuous fit over all expectiles by fitting the tensor product of the expectile spline basis and the basis of the covariates. In consequence there will be most likely no crossing of expectiles but also a good fit in heteroscedastic scenarios. "schall" smoothing does not yet work for sheets. The noncross function also fits a sheet over all expectiles, but it uses quadratic programming with constraints, so crossing of expectiles will definitely not happen. So far the function is implemented for one nonlinear or spatial covariate and further parametric covariates. It works with all smoothing methods.

References

Schnabel S and Eilers P (2009) Optimal expectile smoothing Computational Statistics and Data Analysis, 53:4168-4177 Sobotka F and Kneib T (2010) Geoadditive Expectile Regression Computational Statistics and Data Analysis, doi: 10.1016/j.csda.2010.11.015. Schnabel S and Eilers P (2011) Expectile sheets for joint estimation of expectile curves (under review at Statistical Modelling)

See Also

base, expectile.boost, expectile.restricted

Examples

Run this code
ex = expectile.laws(dist ~ base(speed),data=cars,smooth="a",lambda=5)
ex = expectile.sheets(dist ~ base(speed),data=cars,smooth="f",lambda=5)
plot(ex)


data("lidar", package = "SemiPar")

explaws <- expectile.laws(logratio~base(range,"pspline"),data=lidar,smooth="acv",expectiles=c(0.05,0.25,0.5,0.75,0.95))
print(explaws)
plot(explaws)

###expectile regression using a fixed penalty
plot(expectile.laws(logratio~base(range,"pspline"),data=lidar,smooth="fixed",lambda=1,expectiles=c(0.05,0.25,0.5,0.75,0.95)))
plot(expectile.laws(logratio~base(range,"pspline"),data=lidar,smooth="fixed",lambda=0.0000001,expectiles=c(0.05,0.25,0.5,0.75,0.95)))
    #As can be seen in the plot, a too small penalty causes overfitting of the data.
plot(expectile.laws(logratio~base(range,"pspline"),data=lidar,smooth="fixed",lambda=50,expectiles=c(0.05,0.25,0.5,0.75,0.95)))
    #If the penalty parameter is chosen too large, the expectile curves are smooth but don't represent the data anymore.

Run the code above in your browser using DataLab