[R] the function doesn´t work

Mario Valle mvalle at cscs.ch
Sun Sep 26 09:22:31 CEST 2010


  The message is clear. Just resove this problem before posting a 
terribly general and so not useful "it does not work".
Best
                     mario

 > f=outer(p,m,Vectorize(power))
Error in outer(p, m, Vectorize(power)) : object 'p' not found
 > persp(p,m,power,theta=-50,phi=30,d=4,border="black")
Error in persp(p, m, power, theta = -50, phi = 30, d = 4, border = 
"black") :
   object 'p' not found


On 26-Sep-10 08:39, jethi wrote:
> hey, my function doesn´t work. can somebody help me?
> the graphic doesn´t work and also the function. thnx a lot.
>
> N=10
> n=100
>
> p_0=c(1/5,1-1/5)
>
> power = function(p,m) {
> set.seed(1000)
> H=matrix(0,nrow=N,ncol=1)
> for(i in 1:N) {
>   x<- matrix(rnorm(n, 0, 0.5), ncol = m)
>   y<- matrix(rnorm(n, 0, 0.8), ncol = m)
>   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)
> }
> m=seq(10,50,len=10)
> f=outer(p,m,Vectorize(power))
> persp(p,m,power,theta=-50,phi=30,d=4,border="black")

-- 
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