nlrq                  package:nlrq                  R Documentation

_F_u_n_c_t_i_o_n _t_o _c_o_m_p_u_t_e _n_o_n_l_i_n_e_a_r _q_u_a_n_t_i_l_e _r_e_g_r_e_s_s_i_o_n _e_s_t_i_m_a_t_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     This function implements an R version of an interior point method
     for computing the solution to quantile regression problems which
     are nonlinear in the parameters.  The algorithm is based on
     interior point ideas described in Koenker and Park (1994).

_U_s_a_g_e:

     nlrq(formula, data=parent.frame(), start, tau=0.5, control, trace=FALSE)

_A_r_g_u_m_e_n_t_s:

 formula: formula for model in nls format; accept self-starting models 

    data: an optional data frame in which to evaluate the variables in
          `formula' 

   start: a named list or named numeric vector of starting estimates 

     tau: a vector of quantiles to be estimated

 control: an optional list of control settings.  See `nlrq.control' for
          the names of the settable control values and their effect.

   trace: logical value indicating if a trace of the iteration progress
          should be printed.  Default is `FALSE'.  If `TRUE'
          intermediary results are printed at the end of each
          iteration. 

_D_e_t_a_i_l_s:

     An `nlrq' object is a type of fitted model object.  It has methods
     for the generic functions `coef' (parameters estimation at best
     solution), `formula' (model used), `deviance' (value of the
     objective function at best  solution), `print', `summary',
     `fitted' (vector of fitted variable according to the model),
     `predict' (vector of data points predicted by the model, using a
     different matrix for the independent variables) and also for the
     function `tau' (quantile used for fitting the model, as the tau
     argument of the function). Further help is also available for the
     method `residuals'.

_V_a_l_u_e:

     A list consisting of:  

       m: an `nlrqModel' object similar to an `nlsModel' in package nls

   data : the expression that was passed to `nlrq' as the data
          argument. The actual data values are present in the
          environment of the `m' component. 

_A_u_t_h_o_r(_s):

     Based on S code by Roger Koenker modified for R and to accept same
     models as nls by Philippe Grosjean.

_R_e_f_e_r_e_n_c_e_s:

     Koenker, R. and Park, B.J. (1994). An Interior Point Algorithm for
     Nonlinear Quantile Regression, Journal of Econometrics, 71(1-2):
     265-283.

_S_e_e _A_l_s_o:

     `nlrq.control' , `residuals.nlrq'

_E_x_a_m_p_l_e_s:

     # Example using model defined in the nls library
     library(nls)
     # build artificial data with multiplicative error
     Dat <- NULL; Dat$x <- rep(1:25, 20)
     set.seed(1)
     Dat$y <- SSlogis(Dat$x, 10, 12, 2)*rnorm(500, 1, 0.1)
     plot(Dat)
     # fit first a classical least-square regression
     Dat.nls <- nls(y ~ SSlogis(x, Asym, mid, scal), data=Dat); Dat.nls
     lines(1:25, predict(Dat.nls, newdata=list(x=1:25)), col=1)
     # then fit the median using nlrq
     Dat.nlrq <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data=Dat, tau=0.5, trace=T)
     lines(1:25, predict(Dat.nlrq, newdata=list(x=1:25)), col=2)
     # the 1st and 3rd quartiles regressions
     Dat.nlrq <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data=Dat, tau=0.25, trace=T)
     lines(1:25, predict(Dat.nlrq, newdata=list(x=1:25)), col=3)
     Dat.nlrq <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data=Dat, tau=0.75, trace=T)
     lines(1:25, predict(Dat.nlrq, newdata=list(x=1:25)), col=3)
     # and finally "external envelopes" holding 95
     Dat.nlrq <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data=Dat, tau=0.025, trace=T)
     lines(1:25, predict(Dat.nlrq, newdata=list(x=1:25)), col=4)
     Dat.nlrq <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data=Dat, tau=0.975, trace=T)
     lines(1:25, predict(Dat.nlrq, newdata=list(x=1:25)), col=4)
     leg <- c("least squares","median (0.5)","quartiles (0.25/0.75)",".95 band (0.025/0.975)")
     legend(1, 12.5, legend=leg, lty=1, col=1:4)

