aovFbyrow              package:hddplot              R Documentation

_c_a_l_c_u_l_a_t_e _a_o_v _F-_s_t_a_t_i_s_t_i_c _f_o_r _e_a_c_h _r_o_w _o_f _a _m_a_t_r_i_x

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

     Returns on aov F-statistic for each row of 'x'

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

     aovFbyrow(x = Golub, cl = golub.info$cancer)

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

       x: features by observations matrix

      cl: fact that classifies the values in each row

_D_e_t_a_i_l_s:

     This uses the functions 'qr()' and 'qr.qty()' for the main part of
     the calculation, for handling the calculations efficently

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

     one F-statistic for each row of 'x'

_N_o_t_e:

_A_u_t_h_o_r(_s):

     John Maindonald

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

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

     See also 'orderFeatures'

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

     mat <- matrix(rnorm(1000), ncol=20)
     cl <- factor(rep(1:3, c(7,9,4)))
     Fstats <- aovFbyrow(x = mat, cl = cl)

     ## The function is currently defined as
     aovFbyrow <- 
     function(x=matrix(rnorm(1000), ncol=20), 
              cl=factor(rep(1:3, c(7,9,4)))){
         y <- t(x)
         qr.obj <- qr(model.matrix(~cl))
         qty.obj <- qr.qty(qr.obj,y)
         tab <- table(factor(cl))
         dfb <- length(tab)-1
         dfw <- sum(tab)-dfb-1
         ms.between <- apply(qty.obj[2:(dfb+1), , drop=FALSE]^2, 2, sum)/dfb
         ms.within <- apply(qty.obj[-(1:(dfb+1)), , drop=FALSE]^2, 2, sum)/dfw
         Fstat <- ms.between/ms.within
       }

