Hi I am trying to find a parametric bootstrap confidence interval and when I used the boot function I get zero bias and zero st.error? What could be my mistake? Thank you and take care. Laila [[alternative HTML version deleted]]
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,theta2= 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]]
On Sat, 26 Jul 2008, laila khalfan wrote:> Hi> I am trying to find a parametric bootstrap confidence interval and when > I used the boot function I get zero bias and zero st.error? What could > be my mistake?The way you simulated the 'parametric bootstrap'.> 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.PLEASE do as we ask. We need to know what you did to have any idea of what you did wrong. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
HiI 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 MLestimates{ 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) #the function that generate the sample{ 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,theta2= 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]]
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<-36 n<-40 shape<-2 theta11<-exp(1) # (=2.718282) theta21<-exp(.5) #( =1.648721) m0<- function(Ti,Tj) #a function that generates the MLestimates { 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) #the function that generate the sample { U<-runif(n) Us<-sort(U) F1tau<- pgamma((tau/theta1),shape,1) n1<-sum(Us<- 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