[R] the function doesn´t work
Mario Valle
mvalle at cscs.ch
Sun Sep 26 09:45:55 CEST 2010
It is not a problem of not knowing R.
It is a problem of reasoning. if you use m1 and not assign to it a value
beforehand it is difficult your function works.
And this will happen in any language, not only R.
Maybe explaining what you are trying to do helps. To do this try to add
comments (starting with #) to your code.
Reading error messages is always useful too.
Best
mario
On 26-Sep-10 09:28, jethi wrote:
> hi, sorry but i can´t remove the problem.but i change the programm a little
> bit. i didn´t work with r programm before, so its really hard for me to find
> my problems. :)
>
>
> N=5
> n=100
>
>
> p_0=c(1/5,1-1/5)
>
> power = function(k1) {
> set.seed(1000)
> H=matrix(0,nrow=N,ncol=1)
>
> for(i in 1:N) {
>
> x<- matrix(rnorm(n, 0, 0.5), ncol =m1)
> y<- matrix(rnorm(n, 0, 0.8), ncol = m1)
> l<- diag(cor(x, y))
>
>
>
> q_1 = qnorm(0.05, 0, 0.05)
> q_2 = qnorm(1 - 0.05, 0, 0.05)
> p<- (l^2)/sum(l^2)
>
> H[i]<- sum(p_0*log(p_0)) - sum(p * log(p))
>
> }
> 1- mean(q_1<= H& H<= q_2)
>
> }
> m1=seq(0,n/2,len=10)
> k1=1/m1
> output<- power(k1)
> f=outer(k1,Vectorize(power))
--
Ing. Mario Valle
Data Analysis and Visualization Group | http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
More information about the R-help
mailing list