Getting error while running flexsurvreg function

37 Views Asked by At

Can anyone help me how to to define the below given custom distribution in flexsurvreg function.

custom_pdf=function(y,b0,b1,b2,b3,sigma,alpha){#pdf of proposed model
  z=(y-b0-b1*t2-b2*t3-b3*t4)/sigma
  ft=exp(z)
  num=alpha*ft*((exp(-ft))^alpha)*((1-exp(-ft))^(alpha-1))
  den=sigma*(((1-exp(-ft))^alpha)+((exp(-ft))^alpha))^2
  res=num/den
  return(res)
}
custom_cdf=function(y,b0,b1,b2,b3,sigma,alpha){#cdf of proposed model
  z=(y-b0-b1*t2-b2*t3-b3*t4)/sigma
  ft=exp(z)
  num=(1-exp(-ft))^alpha
  den=(1-exp(-ft))^alpha+(exp(-ft))^alpha
  res=num/den
  return(res)
}

alpha=4.62
sigma=6.2
b0=8.7
b1=-0.07
b2=1.4
b3=2.5


 flexsurvreg(Surv(data_log$log_time, data_log$SURVIVAL_STATUS)~1, data = data_log, dist = custom_pdf,inits = c(1,1,1,1,1,1))

I am getting the error "flexsurvreg(Surv(data_log$log_time, data_log$SURVIVAL_STATUS)~1, data = data_log, dist = custom_pdf,inits = c(1,1,1,1,1,1)) Error in parse.dist(dist) : "dist" should be a string for a built-in distribution, or a list for a custom distribution"while running the below code

0

There are 0 best solutions below