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
       }

