calibrating the weibull survival model

Hi Everyone,

I am new to R.

I am validating a weibull survival model. I need to change the number of bins to 10 in plotting the graph. I am not sure which parameter in the below code I should change.

cal_model <- calibrate(model, u=5, cmethod='KM', m=50, B=20))
calibration_plot <- plot(cal_model)

Can anybody shed some lights?

If my codes are completely irrelevant can anybody provide the codes?

I am sorry I could not provide the sample data values and I am not sure which category my request for help belongs to and I chose general.

Best and thank you very much in advance.

It's hard to diagnose the problem without a reprex. See the FAQ. Especially since calibrate is not in base or stats, there's no way to know what str(cal_model) contains and what the calibrate_plot function expects by way of arguments. It doesn't have to be all the data or even your data if you can find a dataset that shows the same behavior.

The plot() function for the cal_model object is likely using the default binning for the data. To change the number of bins to 10, you can use the breaks argument in the hist() function, which is used within the plot() function.

You can modify the code to:

Copy code

calibration_plot <- plot(cal_model, breaks = seq(0, 1, by = 0.1))

This will create bins with edges at 0, 0.1, 0.2, ..., 1, which corresponds to 10 bins in total.

Alternatively, you could use the argument nclass = 10 to get the same result.

Copy code

calibration_plot <- plot(cal_model, nclass = 10)

This will change the number of bins to 10 for the histogram in the calibration plot.

1 Like

Thank you for your suggestions.

It has been helpful.

Best regards,

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.