A mechanical component was run continuously till it failed (test-to-failure). We have data of one such experiment.
Data Dictionary
- age --> time in mins.
life_per --> age/total time to failure
life_status --> faliure==1 and 0== non failure (note: we only have 1 record with life_status=1 i.e. the time/age when it failed)
- feature1 --> covariate/sensor reading taken the component.
Note: only the begining and ending of the data is showning the image.
From this data how do I calculate the Weibull hazard rate function for feature1 variable in R or Python?
I tried the below code.
Code (reference Weibull cumulative distribution function starting from "fitdistr" command )
fit_dist<-fitdist(base$feature1,"weibull",lower = c(0, 0), start = list(scale = 1, shape = 1))
rms_coefficients<-matrix(coef(fit_dist))
rownames(rms_coefficients)<-c("scale","shape")
rms_pdf<-dweibull(base$feature1,shape=rms_coefficients["shape",1],scale=rms_coefficients["scale",1])
rms_cdf<-1-exp(-((base$feature1/rms_coefficients["scale",1])^rms_coefficients["shape",1]))
hazard_rate_fun_feature1 <-rms_pdf/(1-rms_cdf)
- Is the hazard rate function for feature1 calculated the correct way in the code? In the code hazard function is not at all a function of time or age component. I thought hazard function should always be function of time.
- In the formula it seems that hazard function is a function of time. So I am confused on whether hazard function for feature1 should be calculated based on time or without it.