no subject (file transmission)

Mai Zhou mai@ms.uky.edu
Mon, 9 Nov 1998 10:59:48 -0500 (EST)


RNG in R and Splus 3.4

Prof. Ripley asked the details of the example. 
We were doing parametric bootstrap, so it is similar to simulation.
Anyway here is the details.

We start with a sample of 19 positive numbers. We know the sample
is from truncated exp(0.3)...only the truncation point, theta, is unknown.

In other words, the sample can be generated from something like

x1 <- rexp(100, rate=0.3)
x2 <- x1[x1<theta]     # the theta are big enough so that length(x2)>19
x3 <- x2[1:19]

And the true theta was 4, hidden from the students.
The estimate of theta from that particular sample was 3.87058501, 
the max of the sample.

Next we wanted to estimate the bias of the max, using bootstrap.
We did this:   

y1<-rexp(4000, rate=0.3)
y2<- y1[y1<3.87058501]
length(y2)  # to make sure y2 is longer than 1900 or whatever..so we are not
            # recycling 
y3<-y2[1:1900]               

# now y3 contains 100 bootstrap samples of 19 each

y4 <- matrix(y3, ncol=19, byrow=T) # actually some of students did
                                   # y4 <- t( matrix(y3, ncol=100) ) 
maxboot <- apply(y4, 1, max)
biasboot <- mean(maxboot) - 3.87058501

We did this for more than 100 runs, depend how much memory you have on your
machine, you can try put a few zeros to the above code. but you get the idea. 
The final result, biasboot, is very different when using R or Splus 3.4
Roughly 2 times (biasboot from R) = (biasboot from Splus 3.4) 
In this particula case the bias was 3.87058501-4. R seem to be better
than Splus which give a biasboot that is too small (or too big in abs value)
But more analysis using simulation reveals otherwise.

We then tried the simulation and that was reported earlier....

We use Rjune on the Win95 and Win NT machine. 

Mai Z
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._