[R] the function doesn´t work

jethi kartija at hotmail.com
Mon Sep 27 00:16:39 CEST 2010


thnx again. now i understand my big problem. ok so now a want to watch the
probabilities p, which are do this for example
p[1,1]=cor(x1,y1)/(cor(x1,y1)+..+cor(xm,ym)).


so 
N = 10
n = 100
m = 2
k = n/m
l = matrix(0,nrow=m,ncol=N)
p=matrix(0,nrow=m,ncol=N)

for(i in 1:N){
  x=rnorm(n,0,0.5)
  y=rnorm(n,0,0.8)
  for(j in 1:m){
    l[j,i] = cor(
       (x[(((j-1)*k)+1):(((j-1)*k)+k)]),
       (y[(((j-1)*k)+1):(((j-1)*k)+k)]))
   

  }
} 
for(i in 1:N){
for (j in 1:m){
p[j,i]=l[j,i]^2/sum(l[,i]^2)
}
}



i didn´t write the matrix in the first loop with "l", because if i do that,
he takes at first only the first value. and then the first and the second
value of l. so its wrong. because of it i take a new two loops which make
exactly what i want.

regards
jethi

-- 
View this message in context: http://r.789695.n4.nabble.com/the-function-doesn-t-work-tp2714105p2714755.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list