Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

How would I generate matrices to represent the variants of "R" in these equations?

$
0
0

I am essentially trying to make my own code for the nonpartest() function in the npmv package. I have a dataset:

Cattle <- read.table(text=" Treatment Replicate Weight_Loss Persistent Head_Size Salebarn_Q
                             'LA 200'         1       17.90      14.10     14.25        1.0
                             'LA 200'         2       19.30      15.30      2.56        1.0
                             'LA 200'         3       19.50      16.82      5.80        1.5
                             'LA 200'         4       18.94      12.70      7.51        1.5
                               Excede         1       19.60      11.20     14.52        1.0
                               Excede         2       19.50      10.54      9.83        1.0
                               Excede         3       19.10      10.83      3.82        0.5
                               Excede         4       20.40      11.00      0.04        1.0
                              Micotil         1       17.30      14.29      1.62        1.0
                              Micotil         2       20.00      11.65      0.13        3.0
                              Micotil         3       18.10      10.89      2.41        0.0
                              Micotil         4       19.50      12.43      5.93        2.0
                               Zoetis         1       18.50      25.48     10.08        1.0
                               Zoetis         2       17.60      20.12     11.93        1.0
                               Zoetis         3       19.70      23.29      7.93        2.5
                               Zoetis         4       18.50      28.32     13.08        3.0", header=TRUE)

Which I am trying to use to generate the matrices for Ri. and R.. and Rij in the equation in the paper below so that I can calculate the test statistics G and H

I attempted to do it using

R<-matrix(rank(Cattle,ties.method = "average"),N,p)
R_bar<-matrix(rank(Cattle,ties.method = "average"),1,p)
H<-(1/(a-1))*sum(n*(R-R_bar)*t(R-R_bar))
G<-(1/(N-a)*sum(sum(R-R_bar)*(R_prime-R_bar_prime)))

But that does not work apparently.. I'm not entirely sure what they're describing in the paper in regards to the dimensions of the R matrices.. I know you should use the rank() function and then transpose them using t() for the 'prime' versions

**Images show the excerpts of the paper where the different matrices and their dimensions and how they go in the actual equations are described

enter image description here

enter image description here


Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>