Re: [R] Matrix oriented computing

2005-08-26 Thread Gabor Grothendieck
On 8/26/05, Marc Schwartz (via MN) <[EMAIL PROTECTED]> wrote: > On Fri, 2005-08-26 at 15:25 +0200, Peter Dalgaard wrote: > > Marc Schwartz <[EMAIL PROTECTED]> writes: > > > > > x <- c(0.005, 0.010, 0.025, 0.05, 0.1, 0.5, 0.9, > > >0.95, 0.975, 0.99, 0.995) > > > > > > df <- c(1:100) > > > >

Re: [R] Matrix oriented computing

2005-08-26 Thread Marc Schwartz (via MN)
Prof. Ripley, Excellent point. Neither sapply() nor outer() are the "elephant in the room" in this situation. On Fri, 2005-08-26 at 16:55 +0100, Prof Brian Ripley wrote: > Try profiling. Doing this many times to get an overview, e.g. for sapply > with df=1:1000: > > % self%

Re: [R] Matrix oriented computing

2005-08-26 Thread John Fox
140x23604 http://socserv.mcmaster.ca/jfox > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Marc > Schwartz (via MN) > Sent: Friday, August 26, 2005 10:26 AM > To: Peter Dalgaard > Cc: r-help@stat.math.et

Re: [R] Matrix oriented computing

2005-08-26 Thread Prof Brian Ripley
Try profiling. Doing this many times to get an overview, e.g. for sapply with df=1:1000: % self% total self secondstotalsecondsname 98.26 6.78 98.26 6.78 "FUN" 0.58 0.04 0.58 0.04 "unlist" 0.29 0.02

Re: [R] Matrix oriented computing

2005-08-26 Thread Marc Schwartz (via MN)
On Fri, 2005-08-26 at 15:25 +0200, Peter Dalgaard wrote: > Marc Schwartz <[EMAIL PROTECTED]> writes: > > > x <- c(0.005, 0.010, 0.025, 0.05, 0.1, 0.5, 0.9, > >0.95, 0.975, 0.99, 0.995) > > > > df <- c(1:100) > > > > mat <- sapply(x, qchisq, df) > > > > > dim(mat) > > [1] 100 11 > > >

Re: [R] Matrix oriented computing

2005-08-26 Thread Peter Dalgaard
Marc Schwartz <[EMAIL PROTECTED]> writes: > x <- c(0.005, 0.010, 0.025, 0.05, 0.1, 0.5, 0.9, >0.95, 0.975, 0.99, 0.995) > > df <- c(1:100) > > mat <- sapply(x, qchisq, df) > > > dim(mat) > [1] 100 11 > > > str(mat) > num [1:100, 1:11] 3.93e-05 1.00e-02 7.17e-02 2.07e-01 4.12e-01 ...

Re: [R] Matrix oriented computing

2005-08-26 Thread Patrick Burns
I believe that the following is what you want: x <- c(0.005, 0.010, 0.025, 0.05, 0.1, 0.5, 0.9, 0.95, 0.975, 0.99, 0.995) dof <- 1:100 ans <- outer(x, dof, qchisq) dimnames(ans) <- list(x, dof) Note that 'df' is not a very auspicious name for an object since it is the name of a function. Patri

Re: [R] Matrix oriented computing

2005-08-26 Thread Marc Schwartz
On Fri, 2005-08-26 at 14:44 +0200, Sigbert Klinke wrote: > Hi, > > I want to compute the quantiles of Chi^2 distributions with different > degrees of freedom like > > x<-cbind(0.005, 0.010, 0.025, 0.05, 0.1, 0.5, 0.9, 0.95, 0.975, 0.99, 0.995) > df<-rbind(1:100) > m<-qchisq(x,df) > > and hoped

Re: [R] Matrix oriented computing

2005-08-26 Thread Achim Zeileis
On Fri, 26 Aug 2005 14:44:10 +0200 Sigbert Klinke wrote: > Hi, > > I want to compute the quantiles of Chi^2 distributions with different > degrees of freedom like > > x<-cbind(0.005, 0.010, 0.025, 0.05, 0.1, 0.5, 0.9, 0.95, 0.975, 0.99, > 0.995) df<-rbind(1:100) > m<-qchisq(x,df) > > and hoped

[R] Matrix oriented computing

2005-08-26 Thread Sigbert Klinke
Hi, I want to compute the quantiles of Chi^2 distributions with different degrees of freedom like x<-cbind(0.005, 0.010, 0.025, 0.05, 0.1, 0.5, 0.9, 0.95, 0.975, 0.99, 0.995) df<-rbind(1:100) m<-qchisq(x,df) and hoped to get back a length(df) times length(x) matrix with the quantiles. Since