posdef.approx            package:monomvn            R Documentation

_F_i_n_d _t_h_e _N_e_a_r_e_s_t _P_o_s_i_t_i_v_e _D_e_f_i_n_i_t_e _M_a_t_r_i_x

_D_e_s_c_r_i_p_t_i_o_n:

     Check if the matrix is positive definite via attempted Cholesky
     decomposition and inversion.  If not, then the 'sechol' function
     is used to obtain the nearest approximate Cholesky decomposition
     from which to recover an approximate covariance matrix which is
     positive definite. If that doesn't do the trick, then
     '.Machine$double.eps' is added to the diagonal (as a last-ditch
     effort) until a positive definite matrix can be returned

_U_s_a_g_e:

     posdef.approx(S, name = "S", quiet=FALSE)

_A_r_g_u_m_e_n_t_s:

       S: square 'matrix' which is supposed to be positive definite 

    name: optional name of the matrix - used for printing errors and
          warnings

   quiet: whether or not to print a 'warning' when a non-positive
          definite matrix is found 

_V_a_l_u_e:

     Returns a 'matrix' which is positive definite: either the original
     matrix, or a nearby positive definite approximation

_A_u_t_h_o_r(_s):

     Robert B. Gramacy bobby@statslab.cam.ac.uk

_R_e_f_e_r_e_n_c_e_s:

     Micah Altman, Jeff Gill and Michael McDonald (2003). _Numerical
     Issues in Statistical Computing for the Social Scientist._ John
     Wiley and Sons, New York.
      <URL: http://www.hmdc.harvard.edu/micah_altman/numal/>

     <URL: http://www.statslab.cam.ac.uk/~bobby/monomvn.html>

_S_e_e _A_l_s_o:

     'sechol' in the 'accuracy' package

_E_x_a_m_p_l_e_s:

     ## most likely generates a matrix which is close to positive definite
     ## but not quite
     s <- matrix(rnorm(100), ncol=5)
     S <- (t(s) %*% s) + matrix(rnorm(25, sd=10), ncol=5)
     S

     ## a correction, quiet=TRUE so there is no warning printed
     posdef.approx(S, quiet=TRUE)

