[R] Variance

From: Dat Mai <dat.d.mai_at_gmail.com>
Date: Thu, 28 Apr 2011 17:58:24 -0400


I'm trying to find the variance of various outputs in a matrix:

for(l in 2:vl){
  for(o in 1:(l-1)){

    # Make sure the inputs are for the matrix "m"     input3=rownames(v)[o]
    input4=colnames(v)[l]

    r=t[(t$Rec1==input3 & t$Rec2==input4),output]

    if(length(r)==0){
      r=t[(t$Rec1==input4 & t$Rec2==input3),output]     }

    v[l,o]=var(q,na.rm=TRUE)
    v[o,l]=var(q,na.rm=TRUE)
    v[l,l]=var(q,na.rm=TRUE)

  }
}

Each output will yield multiple results, since each input length varies. I'm not sure if this is the right way to go about finding the variance of each pair, but this is what I've done.
The main issue I have with this now is that the results in every box in the matrix yield the same exact number, even though that most likely shouldn't happen.

The question is: "How would I find the variance of each pair of inputs?"

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 28 Apr 2011 - 22:08:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 28 Apr 2011 - 22:40:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive