matinv                package:Design                R Documentation

_T_o_t_a_l _a_n_d _P_a_r_t_i_a_l _M_a_t_r_i_x _I_n_v_e_r_s_i_o_n _u_s_i_n_g _G_a_u_s_s-_J_o_r_d_a_n _S_w_e_e_p _O_p_e_r_a_t_o_r

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

     This function inverts or partially inverts a matrix using pivoting
     (the sweep operator).  It is useful for sequential model-building.

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

     matinv(a, which, negate=TRUE, eps=1e-12)

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

       a: square matrix to invert or partially invert.  May have been
          inverted or partially inverted previously by matinv, in which
          case its "swept" attribute is updated.  Will un-invert if
          already inverted. 

   which: vector of column/row numbers in a to invert.  Default is all,
          for total inverse. 

  negate: So that the algorithm can keep track of which pivots have
          been swept as well as roundoff errors, it actually returns
          the negative of the inverse or partial inverse.  By default,
          these elements are negated to give the usual expected result.
           Set negate=FALSE if you will be passing the result right
          back into matinv, otherwise, negate the submatrix before
          sending back to matinv. 

     eps: singularity criterion 

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

     a square matrix, with attributes "rank" and "swept".

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

     Clarke MRB (1982).  Algorithm AS 178: The Gauss-Jordan sweep
     operator with detection of collinearity.  Appl Statist 31:166-9.

     Ridout MS, Cobb JM (1986).  Algorithm AS R78 : A remark on
     algorithm AS 178: The Gauss-Jordan sweep operator with detection
     of collinearity.  Appl Statist 38:420-2.

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

     lrm, solve

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

     a      <- diag(1:3)
     a.inv1 <- matinv(a, 1, negate=FALSE)         #Invert with respect to a[1,1]
     a.inv1
     a.inv  <- -matinv(a.inv1, 2:3, negate=FALSE) #Finish the job
     a.inv
     solve(a)

