[R] invalid arguments RUNIF

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Tue Jun 17 15:10:19 CEST 2008


Erik Iverson wrote:
> Just a general comment, I have not looked at your code.  You may want
> to look at the Debugging R portion of the Introduction to R manual on
> CRAN.  There is also a graphical debugger from the 'debug' package on
> CRAN. Either one of these will become immensely helpful in situations
> like this.
>
Also, in this particular case, the offending call is in your own code,
so how about print()ing the arguments to runif() before running it?

> Yasin Hajizadeh wrote:
>>   Hi all
>>   I would be grateful you can help me with my problem.
>>   I try to run an optimization code . in one line I have runif in
>> order to sample the PDF. I get this error while i run it.      Error
>> in runif(1, f$d[[n.of.u.vars + n.of.o.vars + j]][[2]][1],
>> f$d[[n.of.u.vars +  :   invalid arguments
>>
I.e, insert

print(f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][1:2])

at the beginning of the for loop below

>>     for (j in 1:n.of.x.vars) {
>>       X <- c(X, runif(1,f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][1],
>>         f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][2]))
>>     }
>>     X <- t(X)
(You likely don't really want to grow X on every call to runif(), but
that is a different matter)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list