

   FFuunnccttiioonn ttoo ccoommppuuttee aannaalloogguueess ooff tthhee ttrriimmmmeedd mmeeaann ffoorr tthhee
   lliinneeaarr rreeggrreessssiioonn mmooddeell..

        trq(x, y, a1=0.1, a2,  int=TRUE, z,  method="primal", tol=1e-4)

   AArrgguummeennttss::

          x: vector or matrix of explanatory variables.  If  a
             matrix, each  column represents a variable and
             each row represents an observation (or case).
             This should not contain  column of  1s unless the
             argument intercept is FALSE.  The number of rows
             of x should equal the number of elements of  y,
             and there  should  be fewer columns than rows.
             Missing values are not  allowed.

          y: reponse vector with as many observations as the
             number of rows of x.  Missing value are not
             allowed.

         a1: the lower trimming proportion; defaults to .1 if
             missing.

         a2: the upper trimming proportion; defaults to a1 if
             missing.

        int: flag for intercept; if TRUE, an intercept term is
             included in regression model.  The default
             includes an intercept term.

          z: structure returned by the function 'rq' with tau
             <0 or >1. If missing, the function rq(x,y,int=int)
             is automatically called to generate this argument.
             If several calls to trq are anticipated for the
             same data this avoids recomputing the rq solution
             for each call.

     method: method to be used for the trimming.  If the choice
             is "primal", as is the default, a trimmed mean of
             the primal regression quantiles  is computed based
             on the sol array in the 'rq' structure.  If the
             method is "dual", a weighted least-squares fit is
             done using the dual solution in the 'rq' structure
             to construct weights.  The former method is dis-
             cussed in detail in Koenker and Potnoy(1987) the
             latter in Ruppert and Carroll(1980) and Gutenbrun-
             ner and Jureckova(1991).

        tol: Tolerance parameter for rq computions

   DDeessccrriippttiioonn::

        The function returns a regression trimmed mean and some
        associated test statistics.  The proportion a1 is
        trimmed from the lower tail and a2 from the upper tail.
        If a1+a2=1 then a result is returned for the a1 quan-
        tile.  If a1+a2<1 two methods of trimming are possible
        described below as "primal" and "dual". The function
        "trq.print" may be used to print results in the style
        of ls.print.

   VVaalluuee::

       coef: estimated coeficient vector

      resid: residuals from the fit.

        cov: the estimated covariance matrix for the coeficient
             vector.

          v: the scaling factor of the covariance matrix under
             iid error assumption: cov=v*(x'x)^(-1).

         wt: the weights used in the least squares computation,
             Returned only when method="dual".

          d: the bandwidth used to compute the sparsity func-
             tion.  Returned only when a1+a2=1.

   MMEETTHHOODD::

        details of the methods may be found in Koenker and
        Portnoy(1987) for the case of primal trimming and in
        Gutenbrunner and Jureckova(1991) for dual trimming.  On
        the estimation of the covariance matrix for individual
        quantiles, see Koenker(1987) and the discussion in Hen-
        dricks and Koenker(1991).  The estimation of the
        covariance matrix under  non-iid conditions is an open
        research problem.

   SSEEEE AALLSSOO::

        rq and qrq for further details.

   RReeffeerreenncceess::

        Bassett, G., and Koenker, R. (1982), "An Empirical
        Quantile Function for Linear Models With iid Errors,"
        Journal of the American Statistical Association,

        77, 407-415.

        Koenker, R.W. (1987), "A Comparison of Asymptotic Meth-
        ods of Testing based on L1 Estimation," in Y. Dodge
        (ed.)  Statistical Data Analysis Based on the L1 norm
        and Related Methods,

        New York:  North-Holland.

        Koenker, R. W., and Bassett, G.W (1978), "Regression
        Quantiles", Econometrica,

        46, 33-50.

        Koenker, R., and Portnoy, S. (1987), "L-Estimation for
        Linear Models", Journal of the American Statistical
        Association,

        82, 851-857.

        Ruppert, D. and Carroll, R.J. (1980), "Trimmed Least
        Squares Estimation in the Linear Model", Journal of the
        American Statistical Association, 75, 828-838.

   EExxaammpplleess::

        x <- -10:10; y <- 0.2 * x + rt(x, df=3)
        z <- rq(x,y)        #z gets the full regression quantile structure
        trq(x,y, .05, z=z)  #5% symmetric primal trimming # Error, which also occurs in S-Plus.
        trq(x,y, .01, .03, method="dual")  #1% lower and 3% upper trimmed least-
                                  #squares fit.
        trq.print(trq(x,y)) #prints trq results in the style of ls.print.

