kogalur / randomForestSRC

DOCUMENTATION:
https://www.randomforestsrc.org/
GNU General Public License v3.0
115 stars 18 forks source link

Error message when trying to obtain partial plots #372

Closed cmnelson1 closed 1 year ago

cmnelson1 commented 1 year ago

Good morning. I am no longer able to obtain partial plots in rfsrc and I am now receiving the following error when trying to obtain the partial plots of a random survival forest object:

Error in Math.factor(cens) : ‘floor’ not meaningful for factors

I am using the same code I have used many times (where I did not previously receive this error). plot.variable(RFobject, surv.type ="surv", partial = TRUE)

I have also tried using the "partial" function as displayed in your survival vignette, but am getting this error instead: Error in partial(RFobject, partial.type = "mort", partial.xvar = "newADLASTVS") : An error has occurred in prediction. Please turn trace on for further analysis.

I am currently using the newest version of the randomForestSRC package (whereas previously I was using an older version). I don't know if this is the reason. I do have factor variables in my data set (but previously I also had factor variables). I get this same error even when I request a partial plot of a single (and numeric) variable.

Please advise! Thank you!

In case this is helpful, this is the structure of my data set:

str(mtfact3_2_imp) 'data.frame': 801 obs. of 51 variables: $ month_survival: num 40 65 46 4 41 22 1 64 5 64 ... $ death : Factor w/ 2 levels "0","1": 2 1 2 2 2 2 2 1 2 1 ... $ trttrue : Factor w/ 3 levels "PN","PN+CM","TAU": 1 2 2 1 2 2 3 1 1 3 ... $ calcage : num 46.3 50.8 65.1 59.5 31.7 ... $ GRB_IDU : Factor w/ 2 levels "0","1": 1 1 1 2 1 1 1 1 1 1 ... $ CombinedHCV : Factor w/ 2 levels "0","1": 1 1 1 2 1 1 1 2 1 1 ... $ dsouth2 : Factor w/ 2 levels "0","1": 2 2 2 2 2 2 2 2 2 2 ... $ active_druguse: Factor w/ 2 levels "0","1": 2 2 2 1 1 1 1 2 1 2 ... $ insurance_cat : Factor w/ 5 levels "0","1","2","3",..: 1 3 2 1 5 5 3 3 1 3 ... $ HIVlength : num 14.1 15 15 0 16 ... $ IHONART : Factor w/ 2 levels "0","1": 1 2 2 1 1 1 2 2 1 2 ... $ IHREFCM : Factor w/ 2 levels "0","1": 2 2 1 2 2 1 1 1 2 2 ... $ IHREFH : Factor w/ 2 levels "0","1": 2 1 1 2 2 1 1 1 2 2 ... $ IHREFMH : Factor w/ 2 levels "0","1": 2 1 1 1 2 1 1 1 1 1 ... $ IHREFDR : Factor w/ 2 levels "0","1": 2 1 1 1 2 1 1 1 1 1 ... $ IHREFOHC : Factor w/ 2 levels "0","1": 2 2 1 2 2 1 2 1 2 2 ... $ IHREFOOS : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 1 1 ... $ IHMEDSUP : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 2 ... $ GARATING : num 100 60 60 70 80 78 60 70 80 100 ... $ FASMOKE : Factor w/ 2 levels "0","1": 2 2 1 1 2 1 1 2 2 2 ... $ CDCD4C : num 10 144 206 162 125 61 87 81 69 114 ... $ CDCOPIES : num 120713 312 20 68325 546417 ... $ CDHGB : num 14 13.8 9.7 12.9 12.3 10.3 9.6 10.9 7.7 10 ... $ CDHCT : num 43.5 44.9 30.1 38.7 36.6 31.1 31.7 32.7 23.9 33.5 ... $ CDWBC : num 2.2 4.1 4.8 6.1 4.5 8.6 7.7 3.2 2.7 2.6 ... $ CDPLAT : num 131 165 265 174 131 30 433 203 310 169 ... $ CDCALC : num 28.9 21.5 33.3 19.3 21 47 19.9 27.6 17.6 24 ... $ CDCREAT : num 1.07 0.98 1.02 0.75 0.95 1.06 1.83 0.89 3.37 0.87 ... $ CDTBILI : num 0.8 0.5 0.747 2.3 0.6 ... $ CDTPROT : num 7.1 7 7.9 8.7 7.3 ... $ CDALB : num 4.1 4.1 3.51 4 3.4 4 2.4 3.6 1.9 3.9 ... $ CDAST : num 79 32 57.1 71 39 ... $ CDALT : num 34 27 41.4 38 18 ... $ CDALK : num 83 75 107 66 102 ... $ CDDIAG : Factor w/ 2 levels "0","1": 2 1 1 2 2 1 2 1 2 1 ... $ CDSODIUM : num 140 139 139 137 139 ... $ CDCHLOR : num 101 104 110 104 112 ... $ CDBICARB : num 30 25.8 16 25 17 ... $ DEGENDER : num 0 0 0 0 1 1 0 1 0 1 ... $ DEETHNIC : num 0 1 0 0 0 1 0 0 0 0 ... $ race : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ... $ ADEDUCAT : num 2 3 2 2 5 2 2 2 3 5 ... $ ADMARRIE : Factor w/ 6 levels "1","2","3","4",..: 6 5 3 5 5 3 5 4 5 5 ... $ ADWORKIN : Factor w/ 10 levels "1","2","3","4",..: 6 8 8 5 8 6 8 8 3 8 ... $ ADINCPER : num 6000 44376 8200 0 16000 ... $ AD6MJAIL : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ... $ ADENG2LA : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ... $ ADLIVSLP : Factor w/ 12 levels "1","2","3","4",..: 8 9 7 1 9 2 8 9 1 9 ... $ AD06ALDR : Factor w/ 2 levels "0","1": 2 1 1 1 2 1 1 1 1 1 ... $ newADLASTVS : num 1 3 1 4.75 1 4 1 1 5 1 ... $ newAD6MOHSP : num 1 2 2 2 1 1 2 1 2 1 ...

cmnelson1 commented 1 year ago

I figured out my own error---had deaths as a factor instead of integer!