R: This function fits a GLD regression linear model and conducts...
GLD.lm.full
R Documentation
This function fits a GLD regression linear model and conducts simulations to
display the statistical properties of estimated coefficients
Description
The function is an extension of GLD.lm and defaults to
1000 simulation runs, coefficients and statistical properties of coefficients
can be plotted as part of the output.
A symbolic expression of the model to be fitted, similar to the formula
argument in lm, see formula for more information
data
Dataset containing variables of the model
param
Can be "rs", "fmkl" or "fkml"
maxit
Maximum number of iterations for numerical optimisation
fun
If param="fmkl" or "fkml", this can be one of fun.RMFMKL.ml.m,
fun.RMFMKL.ml, for maximum
likelihood estimation (*.ml.m is a faster implementation of *.ml) and
fun.RMFMKL.lm for L moment matching.
If param="rs", this can be one of fun.RPRS.ml.m,
fun.RPRS.ml, for maximum
likelihood estimation (*.ml.m is a faster implementation of *.ml) and
fun.RPRS.lm for L moment matching.
method
Defaults to "Nelder-Mead" algorithm, can also be "SANN" but this is a lot slower
and may not as good
range
The is the quantile range to plot the QQ plot, defaults to 0.01 and 0.99 to
avoid potential problems with extreme values of GLD which might be -Inf or Inf.
n.simu
Number of times to repeat the simulation runs, defaults to 1000.
summary.plot
Whether to plot the coefficients graphically, defaults to TRUE.
init
Choose a different set of initial values to start the optimisation process. This
can either be full set of parameters including GLD parameter estimates, or it
can just be the coefficient estimates of the regression model.
Details
This function usually takes some time to run, as it involves refitting the
GLD regression model many times, the progress of the simulation is outputted
to the R screen, so users can guage the progress of the computation.
Value
[[1]]
Output of GLD.lm
[[2]]
A matrix showing the bias adjustment, coefficents of the model,
parameters of GLD and whether the result converged at each run
[[3]]
Adjusted simulation result so that the empirical mean of
coefficients is the same as the estimated parameters obtained in
GLD.lm
Author(s)
Steve Su
References
Su (2014) "Flexible Parametric Quantile Regression Model" Statistics &
Computing
See Also
GLD.lm, GLD.quantreg,
summaryGraphics.gld.lm
Examples
## Dummy example
## Create dataset
set.seed(10)
x<-rnorm(200,3,2)
y<-3*x+rnorm(200)
dat<-data.frame(y,x)
## 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)
## Not run:
## Extract the Engel dataset
library(quantreg)
data(engel)
## Fit a full GLD regression
engel.fit.full<-GLD.lm.full(foodexp~income,data=engel,param="fmkl",
fun=fun.RMFMKL.ml.m)
## Extract the mammals dataset
library(MASS)
## Fit a full GLD regression
mammals.fit.full<-GLD.lm.full(log(brain)~log(body),data=mammals,param="fmkl",
fun=fun.RMFMKL.ml.m)
## Using quantile regression coefficients as starting values
library(quantreg)
mammals.fit1.full<-GLD.lm.full(log(brain)~log(body),data=mammals,param="fmkl",
fun=fun.RMFMKL.ml.m, init=rq(log(brain)~log(body),data=mammals)$coeff)
## Using the result of mammals.fit.full as initial values
mammals.fit2.full<-GLD.lm.full(log(brain)~log(body),data=mammals,param="fmkl",
fun=fun.RMFMKL.ml.m, init=mammals.fit1.full[[1]][[3]])
## 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/GLD.lm.full.Rd_%03d_medium.png", width=480, height=480)
> ### Name: GLD.lm.full
> ### Title: This function fits a GLD regression linear model and conducts
> ### simulations to display the statistical properties of estimated
> ### coefficients
> ### Aliases: GLD.lm.full
> ### 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 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="Rplots967.pdf")
>
> ## Not run:
> ##D ## Extract the Engel dataset
> ##D
> ##D library(quantreg)
> ##D data(engel)
> ##D
> ##D ## Fit a full GLD regression
> ##D
> ##D engel.fit.full<-GLD.lm.full(foodexp~income,data=engel,param="fmkl",
> ##D fun=fun.RMFMKL.ml.m)
> ##D
> ##D ## Extract the mammals dataset
> ##D library(MASS)
> ##D
> ##D ## Fit a full GLD regression
> ##D
> ##D mammals.fit.full<-GLD.lm.full(log(brain)~log(body),data=mammals,param="fmkl",
> ##D fun=fun.RMFMKL.ml.m)
> ##D
> ##D ## Using quantile regression coefficients as starting values
> ##D library(quantreg)
> ##D
> ##D mammals.fit1.full<-GLD.lm.full(log(brain)~log(body),data=mammals,param="fmkl",
> ##D fun=fun.RMFMKL.ml.m, init=rq(log(brain)~log(body),data=mammals)$coeff)
> ##D
> ##D ## Using the result of mammals.fit.full as initial values
> ##D
> ##D mammals.fit2.full<-GLD.lm.full(log(brain)~log(body),data=mammals,param="fmkl",
> ##D fun=fun.RMFMKL.ml.m, init=mammals.fit1.full[[1]][[3]])
> ## End(Not run)
>
>
>
>
>
> dev.off()
png
2
>