lm.fit                 package:stats                 R Documentation

_F_i_t_t_e_r _F_u_n_c_t_i_o_n_s _f_o_r _L_i_n_e_a_r _M_o_d_e_l_s

_D_e_s_c_r_i_p_t_i_o_n:

     These are the basic computing engines called by 'lm' used to fit
     linear models.  These should usually _not_ be used directly unless
     by experienced users.

_U_s_a_g_e:

     lm.fit (x, y,    offset = NULL, method = "qr", tol = 1e-7,
            singular.ok = TRUE, ...)

     lm.wfit(x, y, w, offset = NULL, method = "qr", tol = 1e-7,
             singular.ok = TRUE, ...)

_A_r_g_u_m_e_n_t_s:

       x: design matrix of dimension 'n * p'.

       y: vector of observations of length 'n', or a matrix with 'n'
          rows.

       w: vector of weights (length 'n') to be used in the fitting
          process for the 'wfit' functions.  Weighted least squares is
          used with weights 'w', i.e., 'sum(w * e^2)' is minimized.

  offset: numeric of length 'n').  This can be used to specify an _a
          priori_ known component to be included in the linear
          predictor during fitting.

  method: currently, only 'method="qr"' is supported.

     tol: tolerance for the 'qr' decomposition.  Default is 1e-7.

singular.ok: logical. If 'FALSE', a singular model is an error.

     ...: currently disregarded.

_V_a_l_u_e:

     a list with components 

coefficients: 'p' vector

residuals: 'n' vector or matrix

fitted.values: 'n' vector or matrix

 effects: (not null fits)'n' vector of orthogonal single-df effects. 
          The first 'rank' of them correspond to non-aliased
          coeffcients, and are named accordingly.

 weights: 'n' vector - _only_ for the '*wfit*' functions.

    rank: integer, giving the rank

df.residual: degrees of freedom of residuals

      qr: (not null fits) the QR decomposition, see 'qr'.

_S_e_e _A_l_s_o:

     'lm' which you should use for linear least squares regression,
     unless you know better.

_E_x_a_m_p_l_e_s:

     set.seed(129)
     n <- 7 ; p <- 2
     X <- matrix(rnorm(n * p), n,p) # no intercept!
     y <- rnorm(n)
     w <- rnorm(n)^2

     str(lmw <- lm.wfit(x=X, y=y, w=w))

     str(lm. <- lm.fit (x=X, y=y))

