Skip to content

sapply and loop

2 messages · Zhen Pang, Brian Ripley

#
I tried to use Rprof(). As an example, I consider the following code (from 
Venables & Ripley, 1999).

     library(MASS); library(boot); library(nls)
     data(stormer)
     storm.fm <- nls(Time ~ b*Viscosity/(Wt - c), stormer,
                     start = c(b=29.401, c=2.2183))
     st <- cbind(stormer, fit=fitted(storm.fm))
     storm.bf <- function(rs, i) {
         st$Time <-  st$fit + rs[i]
         tmp <- nls(Time ~ (b * Viscosity)/(Wt - c), st,
                    start = coef(storm.fm))
         tmp$m$getAllPars()
     }
     rs <- scale(resid(storm.fm), scale = FALSE) # remove the mean
     Rprof("boot.out")
     storm.boot <- boot(rs, storm.bf, R = 4999) # pretty slow
     Rprof(NULL)

summaryRprof()
Error in summaryRprof() : no events were recorded

I am using R1.8.1 in windows. Why can't I get the results?

Zhen
#
On Tue, 19 Oct 2004, Zhen Pang wrote:

            
I believe you parroted that from `Writing R Extensions', but failed to 
give proper credit!
At this point your unacknowledged copying went adrift.
Because you didn't do your homework, and didn't even follow your source.  
The 'file' arguments of Rprof and summaryProf have to agree: see their 
help pages (as the posting guide asks).