[S] A simulation study in Splus4

Lin, Shang (slin@nki.rfmh.org)
Tue, 12 May 1998 14:23:57 -0400


Hi, Splus users,

I am writing a program in Splus4 to do a simulation study involving
bootstrap
confidence interval of cost-effectiveness ratio statistics. I have
incorporated
some of the suggestions I learned from reading Splus4 programmer's guide
chapters 18-20 in the program below.

#Simulation study of bootstrap confidence interval
#of cost-effectiveness ratio statistics
nr<-1000
nb<-100
probs<-c(25,50,950,975)/1000
s<-c(12500000,-750,4125000,900,-750,.5,825,0.18,
4125000,825,15125000,-660,900,0.18,-660,.72)
out1<-matrix(0,nr,12)
out2<-matrix(0,nr,12)
out3<-matrix(0,nr,12)
for (i in 1:nr)
{
y<-t(t(chol(matrix(s,4,4)))%*%matrix(rnorm(200,0,1),4,50)+
c(30000,50,40000,60))
temp<-bootstrap(y,mean(y[,1]-y[,3])/mean(y[,2]-y[,4]),B=nb,trace=F)
out1[i,]<-c(unlist(temp$observed),unlist(temp$est),
limits.emp(temp,probs),limits.bca(temp,probs))

y<-rbind(y[,1:2],y[,3:4])
dimnames(y)<-list(NULL,c("cost","effect"))
temp<-bootstrap(data.frame(y,grp=rep(c(1,2),c(50,50))),
(mean(cost[grp==1]) - mean(cost[grp==2]))/
(mean(effect[grp==1])-mean(effect[grp==2])),group=grp,B=nb,trace=F)
out2[i,]<-c(unlist(temp$observed),unlist(temp$est),
limits.emp(temp,probs),limits.bca(temp,probs))

temp<-bootstrap(data.frame(y,grp=rep(c(1,2),c(50,50))),
mean(cost[grp==1])/mean(effect[grp==1]) -
mean(cost[grp==2])/mean(effect[grp==2]),group=grp,B=nb,trace=F)
out3[i,]<-c(unlist(temp$observed),unlist(temp$est),
limits.emp(temp,probs),limits.bca(temp,probs))
}
apply(out1,2,mean)
sqrt(apply(out1,2,var)/nr)
apply(out2,2,mean)
sqrt(apply(out2,2,var)/nr)
apply(out3,2,mean)
sqrt(apply(out3,2,var)/nr)

Currently, I am comparing three bootstrap statistics but may add a few
more later on. With 1000 iterations and 100 bootstrap resamples in each
bootstrap call, the program tooks over 7 hours to complete using a
Nec powermate p133 with 80mb ram running under window 95. I may
also increase # of iterations and # of bootstrap resamples if possible. I
would like to know if my problem is written as effecient as possible. In
particular, I would like to know whether it is more efficient to split up
the
program into different parts with each doing only one bootstrap statistic.
I would also like to know if there is better way to extract results from ith

bootstrap call and save them in the ith row of matrix out[i,]. I would
greatly
appreciate any suggestions of improvement. Thank you for your help.

Shang Lin

Statistical Sciences and Epidemiology Div
Nathan Kline Institute
Orangeburg, NY 10962
slin@nki.rfmh.org
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news