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.

