Skip to content

R code Error : Hybrid Censored Weibull Distribution

2 messages · ritwik_r at isical.ac.in, Peter Dalgaard

#
Dear Sir/madam,

I'm getting a problem with a R-code which calculate Fisher Information
Matrix for Hybrid Censored Weibull Distribution. My problem is that:

when I take weibull(scale=1,shape=2) { i.e shape>1} I got my desired
result but when I take weibull(scale=1,shape=0.5) { i.e shape<1} it gives
error : Error in integrate(int2, lower = 0, upper = t) : the integral is
probably divergent. I could not found any theoretical interpretation of
it. I'm sending the code :


#########################################################################################

f3<-function(t,r){
#calculation for t1

fb1<-function(t,r){
v1<-numeric(0)
for(j in 1:r){

int1<-function(x1){
int_1<- (1/p+log(x1/lamda))^2 * j * choose(n,j) *
(pweibull(x1,shape=p,scale=lamda))^(j-1) * (1 -
pweibull(x1,shape=p,scale=lamda))^(n-j) *
dweibull(x1,shape=p,scale=lamda)
int_1
}
v1[j]<-integrate(int1,lower=0,upper=t)$value
}
sum(v1)
}

#calculation for t2

fb2<-function(t,r){
v2<-numeric(0)
for(j in 1:r){

int2<-function(x2){
int_2<- (1/p+log(x2/lamda))*(-p/lamda) * j * choose(n,j) *
(pweibull(x2,shape=p,scale=lamda))^(j-1) * (1 -
pweibull(x2,shape=p,scale=lamda))^(n-j) *
dweibull(x2,shape=p,scale=lamda)
int_2
}
v2[j]<-integrate(int2,lower=0,upper=t)$value
}
sum(v2)
}

#calculation for t3

fb3<-function(t,r){
v3<-numeric(0)
for(j in 1:r){

int3<-function(x3){
int_3<- (p/lamda)^2 * j * choose(n,j) *
(pweibull(x3,shape=p,scale=lamda))^(j-1) * (1 -
pweibull(x3,shape=p,scale=lamda))^(n-j) *
dweibull(x3,shape=p,scale=lamda)
int_3
}
v3[j]<-integrate(int3,lower=0,upper=t)$value
}
sum(v3)
}

a<-c(fb1(t,r),fb2(t,r),fb2(t,r),fb3(t,r))
A<-matrix(a,nrow=2,ncol=2,byrow="TRUE")

C<-solve(A)

func1<-function(u1){
u11<- (log(-log(1-u1)))^2
u11
}
m1<-(C[1,1]/p^4)*integrate(func1,lower=0,upper=1)$value

func2<-function(u2){
u22<- log(-log(1-u2))
u22
}
m2<- (-2)*C[1,2]*(1/(p^2 *lamda))*integrate(func2,lower=0,upper=1)$value

m3<- C[2,2]/lamda^2

m<-m1+m2+m3
m
}

output=f3(5,10)


##################################################################################################


Moreover When I consider f3,fb1,fb2,fb3 all are functions of single
variable "t" ,desired results come but in case of two variables the
problem arises. Here "t" is Real Number and "r" is Integer.

I'm suffering this problem since last three months. Please anyone help me
out.

Thanking you in advance.
Regards

Ritwik Bhattacharya


Senior Research Fellow
SQC & OR UNIT, KOLKATA
INDIAN STATISTICAL INSTITUTE

Voice : +91 9051253944

This mail is scanned by Ironport
#
On Oct 20, 2011, at 21:25 , ritwik_r at isical.ac.in wrote:

            
The code doesn't work...
Error in f(x, ...) : object 'p' not found

Furthermore, if I guess p=.5, lamda=1, n=10, the code doesn't even break:
[1] 1.155917

So what do you expect _us_ to do about it?

I strongly suspect that actually testing the code (in a clean R session) would have revealed issues causing you not to have to submit the post at all...

-pd