madmad              package:wavethresh              R Documentation

_C_o_m_p_u_t_e _s_q_u_a_r_e _o_f _m_e_d_i_a_n _a_b_s_o_l_u_t_e _d_e_v_i_a_t_i_o_n (_m_a_d) _f_u_n_c_t_i_o_n.

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

     This function simply returns the square of the median absolute
     deviation (mad) function in S-Plus. This is required for supply to
     the 'threshold' series of functions which require estimates of
     spread on the variance scale (not the standard deviation scale).

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

     madmad(x)

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

       x: The vector for which you wish to compute the square of mad
          on.

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

     The square of the median absolute deviation of the coefficients
     supplied by 'x'.

_R_E_L_E_A_S_E:

     Version 3.4.1 Copyright Guy Nason 1994

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

     'threshold'

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

     #
     #
     # Generate some normal data with mean 0 and sd of 8
     # and we'll also contaminate it with an outlier of 1000000
     # This is akin to signal wavelet coefficients mixing with the noise.
     #
     #ContamNormalData <- c(1000000, rnorm(1000, mean=0, sd=8))
     #
     # What is the variance of the data?
     #
     #var(ContamNormalData)
     # [1] 999000792
     #
     # Wow, a seriously unrobust answer!
     #
     # How about the median absolute deviation?
     #
     #mad(ContamNormalData)
     # [1] 8.14832
     # 
     # A much better answer!
     #
     # Now let's use madmad to get the answer on the variance scale 
     #
     #madmad(ContamNormalData)
     # [1] 66.39512
     #
     # The true variance was 64, so the 66.39512 was a much better answer
     # than that returned by the call to the variance function.

