[R] parametric bootstrap

From: laila khalfan <byblus412_at_hotmail.com>
Date: Sat, 26 Jul 2008 00:20:46 +0000

Hi
I am using the boot function in boot package. I am facing a problem in getting the values of bias and st.error in the output. r<-36n<-40shape<-2theta11<-exp(1) # (=2.718282)theta21<-exp(.5) #( =1.648721)

m0<- function(Ti,Tj)  #a function that generates the estimates{   loglik<-function(ti,tj,alpha,theta1,theta2){       -1*( log(n)-log(n1)-log(r-n1)-r*lgamma(alpha)-alpha*n1*log(theta1)-alpha*(r-n1)*log(theta2)+(alpha-1)       *sum(log(Ti))+(alpha-1)*sum(log(Tj-tau+(theta2/theta1)*tau))-(1/theta1)*sum(Ti)-       (1/theta2)*sum(Tj-tau+(theta2/theta1)*tau)+(n-r)*log(1-pgamma((max(Tj)-tau+       (theta2/theta1)*tau)/theta2,alpha,1)))   }   V<-mle2(minuslogl = loglik, start = list(alpha= 2,theta1= 11,theta2= 3), data = list(size = 20))   Est<-coef(V)}
sample1<-function(n,r,tau,shape,theta1,theta2){         U<-runif(n)          Us<-sort(U)          F1tau<- pgamma((tau/theta1),shape,1)          n1<-sum(Us<F1tau)          X1<- Us[1:n1]          X2<- theta1*qgamma(Us[1:n1],shape,1)          Ti<- X2          w=n1+1          V<- Us[w:r]             V1<-theta2*qgamma(V,shape,1)          Tj<-V1+tau-(theta2/theta1)*tau          c(Ti,Tj)          }  sample1(40,36,5,2,exp(1),exp(.5))func2<- function(data,mle){                sample1(n,length(data),tau,shape,mle[2],mle[3])          }func1<-function(data){   loglik<-function(data,alpha,theta1,theta2){       -1*( log(n)-log(n1)-log(r-n1)-r*lgamma(alpha)-alpha*n1*log(theta1)-alpha*(r-n1)*log(theta2)+(alpha-1)       *sum(log(Ti))+(alpha-1)*sum(log(Tj-tau+(theta2/theta1)*tau))-(1/theta1)*sum(Ti)-       (1/theta2)*sum(Tj-tau+(theta2/theta1)*tau)+(n-r)*log(1-pgamma((max(Tj)-tau+       (theta2/theta1)*tau)/theta2,alpha,1)))   }   V<-mle2(minuslogl = loglik, start = list(alpha= 2,theta1= 11,t!
 heta2= 3), data = list(size = 20))   Est<-coef(V) }  bootobject <- boot(data=c(Ti,Tj) , statistic= func1 , R=1000,sim="parametric", ran.gen=func2,                    mle= m0(Ti,Tj) ) 
boot.ci(bootobject, conf=.90, type= "bca") Thank you and take care. Laila

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 26 Jul 2008 - 00:23:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 26 Jul 2008 - 02:32:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive