Last data update: 2014.03.03

R: This package fits standard and quantile regression models...
GLDreg-packageR Documentation

This package fits standard and quantile regression models using RS and FMKL/FKML generalised lambda distributions via maximum likelihood estimation and L moment matching.

Description

Owing to the rich shapes of GLDs, GLD standard/quantile regression is a competitive flexible model compared to standard/quantile regression. The proposed method has some major advantages: 1) it provides a reference line which is very robust to outliers with the attractive property of zero mean residuals and 2) it gives a unified, elegant quantile regression model from the reference line with smooth regression coefficients across different quantiles. The goodness of fit of the proposed model can be assessed via QQ plots and the Kolmogorov-Smirnov test, to ensure the appropriateness of the statistical inference under consideration. Statistical distributions of coefficients of the GLD regression line are obtained using simulation, and interval estimates are obtained directly from simulated data.

Details

Package: GLDreg
Type: Package
Version: 1.0.2
Date: 2014-03-04
License: GPL (>= 3.0)

The primary fitting function for GLD regression model is GLD.lm.full. The output of GLD.lm.full can then be passed to summaryGraphics.gld.lm to display coefficients of GLD regression model graphically. Once a GLD reference model is obtained, quantile regression is obtained using GLD.quantreg.

Author(s)

Steve Su <allegro.su@gmail.com>

References

Su (2014) "Flexible Parametric Quantile Regression Model" Statistics & Computing

See Also

GLDEX

Examples


## Dummy example

## Create dataset

set.seed(10)

x<-rnorm(200,3,2)
y<-3*x+rnorm(200)

dat<-data.frame(y,x)

## Fit a FKML GLD regression

example<-GLD.lm(y~x,data=dat,fun=fun.RMFMKL.ml.m,param="fkml")

## Fit FKML GLD regression with 3 simulations

fit<-GLD.lm.full(y~x,data=dat,fun=fun.RMFMKL.ml.m,param="fkml",n.simu=3)

## Find median regression, use empirical method

med.fit<-GLD.quantreg(0.5,fit,slope="fixed",emp=TRUE)

## Not run: 

## Extract the Engel dataset 

library(quantreg)
data(engel)

## Fit GLD Regression along with simulations

engel.fit.all<-GLD.lm.full(foodexp~income,data=engel,
param="fmkl",fun=fun.RMFMKL.ml.m)

## Plot coefficient summary

summaryGraphics.gld.lm(engel.fit.all)

## Fit quantile regression from 0.1 to 0.9, with equal spacings between 
## quantiles

result<-GLD.quantreg(seq(0.1,.9,length=9),engel.fit.all,intercept="fixed")

## Plot quantile regression lines

fun.plot.q(x=engel$income,y=engel$foodexp,fit=engel.fit.all[[1]],result,
xlab="income",ylab="Food Expense")

## Sometimes the maximum likelihood estimation may fail, for example when 
## minimum/maximum support of GLD is exactly at the minimum/maximum value of the 
## dataset, if this the case, try to use the L-moment matching method.

engel.fit.all<-GLD.lm.full(foodexp~income,data=engel,
param="fmkl",fun=fun.RMFMKL.lm)


## End(Not run)

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(GLDreg)
Loading required package: GLDEX
Loading required package: cluster
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GLDreg/GLDreg-package.Rd_%03d_medium.png", width=480, height=480)
> ### Name: GLDreg-package
> ### Title: This package fits standard and quantile regression models using
> ###   RS and FMKL/FKML generalised lambda distributions via maximum
> ###   likelihood estimation and L moment matching.
> ### Aliases: GLDreg-package GLDreg
> ### Keywords: model
> 
> ### ** Examples
> 
> 
> ## Dummy example
> 
> ## Create dataset
> 
> set.seed(10)
> 
> x<-rnorm(200,3,2)
> y<-3*x+rnorm(200)
> 
> dat<-data.frame(y,x)
> 
> ## Fit a FKML GLD regression
> 
> example<-GLD.lm(y~x,data=dat,fun=fun.RMFMKL.ml.m,param="fkml")
     [,1]                                                                      
[1,] "This analysis was carried out using FKML GLD"                            
[2,] "The error distribution was estimated using Maximum Likelihood Estimation"
[3,] "The optimisation procedure used was Nelder-Mead and it has converged"    
(Intercept)           x          L1          L2          L3          L4 
 0.05895140  3.01981005 -0.01457362  1.29930852  0.22981644  0.20182903 
> 
> ## Fit FKML GLD regression with 3 simulations
> 
> fit<-GLD.lm.full(y~x,data=dat,fun=fun.RMFMKL.ml.m,param="fkml",n.simu=3)
     [,1]                                                                      
[1,] "This analysis was carried out using FKML GLD"                            
[2,] "The error distribution was estimated using Maximum Likelihood Estimation"
[3,] "The optimisation procedure used was method and it has converged"         
(Intercept)           x          L1          L2          L3          L4 
 0.05895140  3.01981005 -0.01457362  1.29930852  0.22981644  0.20182903 
[1] 1
[1] 2
[1] 3
dev.new(): using pdf(file="Rplots969.pdf")
> 
> ## Find median regression, use empirical method
> 
> med.fit<-GLD.quantreg(0.5,fit,slope="fixed",emp=TRUE)
[1] 0.5
                       0.5
(Intercept)     0.02894985
x               3.01981005
Objective Value 0.00000000
Convergence     0.00000000
> 
> ## Not run: 
> ##D 
> ##D ## Extract the Engel dataset 
> ##D 
> ##D library(quantreg)
> ##D data(engel)
> ##D 
> ##D ## Fit GLD Regression along with simulations
> ##D 
> ##D engel.fit.all<-GLD.lm.full(foodexp~income,data=engel,
> ##D param="fmkl",fun=fun.RMFMKL.ml.m)
> ##D 
> ##D ## Plot coefficient summary
> ##D 
> ##D summaryGraphics.gld.lm(engel.fit.all)
> ##D 
> ##D ## Fit quantile regression from 0.1 to 0.9, with equal spacings between 
> ##D ## quantiles
> ##D 
> ##D result<-GLD.quantreg(seq(0.1,.9,length=9),engel.fit.all,intercept="fixed")
> ##D 
> ##D ## Plot quantile regression lines
> ##D 
> ##D fun.plot.q(x=engel$income,y=engel$foodexp,fit=engel.fit.all[[1]],result,
> ##D xlab="income",ylab="Food Expense")
> ##D 
> ##D ## Sometimes the maximum likelihood estimation may fail, for example when 
> ##D ## minimum/maximum support of GLD is exactly at the minimum/maximum value of the 
> ##D ## dataset, if this the case, try to use the L-moment matching method.
> ##D 
> ##D engel.fit.all<-GLD.lm.full(foodexp~income,data=engel,
> ##D param="fmkl",fun=fun.RMFMKL.lm)
> ##D 
> ## End(Not run)
> 
> 
> 
> 
> 
> dev.off()
png 
  2 
>