Hello everybody. I would like to pose a question regarding a warning message after running a function of my own. The function I created for computing the p-value of the dw statistic has a command line like this: »dwf0 <- function(dw,eigen) { carfun <- function(x) { (prod(1+2*(eigen-dw)*1i*x)^(-1/2)-prod(1-2*(eigen-dw)*1i*x)^(-1/2))/(1i*x) } ; 1/2+integrate(f=carfun,lower = 0,upper = Inf, subdivisions=10000)$value/(2*pi) } , with arguments "dw" as a real and "eigen" as a vector. After I run: »dwf0(1.314416,c(3.4420282, 2.6472097, 1.8375986, 1.2928912, 0.6768543, 0.4187899, 0.1058144)) , the console replies: »[1] 0.3576019 »There were 50 or more warnings (use warnings() to see the first 50) . The first 50 warnings are similar to this (the first): »1: longer object length » is not a multiple of shorter object length in: 2 * (eigen - dw)* 0+1i * x . Altough R gives a solution (0.3576019), I wasn't able to confirm this value until now and I can't get rid of that warning message. I did a "trial and error" on subdivisions to get a mid-term between a "out of memory" and a "maximum number of subdivisions reached". I thank you for your time on reading my message. _________________________________________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Rui Cerqueira wrote:> > Hello everybody. > > I would like to pose a question regarding a warning message after running > a function of my own. The function I created for computing the p-value of > the dw statistic has a command line like this: > > ?dwf0 <- function(dw,eigen) { carfun <- function(x) { > (prod(1+2*(eigen-dw)*1i*x)^(-1/2)-prod(1-2*(eigen-dw)*1i*x)^(-1/2))/(1i*x) } > ; 1/2+integrate(f=carfun,lower = 0,upper = Inf, > subdivisions=10000)$value/(2*pi) }It might be worth making above lines a bit less confusing and extend it to some more (easier to read) lines. Then you can check at which place you are calculating with vectors of not maching lengths. Particularly check if the vectors "(eigen-dw)" and "x" in your function carfun() have got the same lengths (does it make sense?)!!!> , with arguments "dw" as a real and "eigen" as a vector. > After I run: > > ?dwf0(1.314416,c(3.4420282, 2.6472097, 1.8375986, 1.2928912, 0.6768543, > 0.4187899, 0.1058144)) > > , the console replies: > > ?[1] 0.3576019 > ?There were 50 or more warnings (use warnings() to see the first 50) > > . The first 50 warnings are similar to this (the first): > > ?1: longer object length > ? is not a multiple of shorter object length in: 2 * (eigen - dw)* > 0+1i * x > > . Altough R gives a solution (0.3576019), I wasn't able to confirm this > value until now and I can't get rid of that warning message. I did a "trial > and error" on subdivisions to get a mid-term between a "out of memory" and a > "maximum number of subdivisions reached". > I thank you for your time on reading my message.Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._