Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Silver75
Frequent Visitor

Survival Analysis with PowerBI and R

Hi
I'm trying to realizing a Kaplan Mayer Survival non parametric model in PowerBI Desktop using script R, with filter in a drill-down
I have a flat file/table in PowerBI with main information for drill down, this is my script

 

library(survival)
time=dataset$tenure
event=dataset$censor
kmsurvival=survfit(Surv(time, event)~1, conf.type="none")
plot(kmsurvival, xlab="tenure", ylab="Survival Probability", col.lab="red", pch="1", lwd="3", col="blue", bg="yellow", xscale=1, xlim=c(1,24))


where
tenure is numeric
censor is numeric (1=died, 0=live)

The probability result seems to be overstimated


Can anyone please help me how to solve this? is my script  wrong?

thank you

 

4 REPLIES 4
LijunChen
Helper II
Helper II

Does any of you has any good advice on this important problem? 

v-huizhn-msft
Employee
Employee

Hi @Silver75,

Your script is right as I tested. I run the sample script and get expected result.

I create a sample table.

2.PNG

Then click R visual highlighted in red line in the following screenshot. Select the Test[tenure] andTest[censor] as value levels.

1.PNG

 

Type the R script and run, you will get the desired result which is same with the picture in Rsudio.

11.PNG

If there is any error message when you run the scipt? Could you please share more details for further analysis.

Best Regards,
Angelia

Hi @v-huizhn-msft

thank you, any error during the script, the survival probability is overstimated respect other software, in particular KM cut some time intervals.

 

In add, If I insert in the dataset other variable (eg sex, civil status, etc..) the Drill – Down on survival graph doesn’t work

Hi @Silver75,

Do you mind share your .pbix file for further analysis?

Best Regards,
Angelia

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.