Help with rpart--how to figure out dropped participants
Hey y'all. I'm not much of a biostats wiz, never took to R very naturally, and I'm also sort of digging this project out of the closet, so I hope you will forgive me for describing my problem in a general sense.
But a while back I was able to muster up enough competency in R to perform a recursive partitioning analysis with a decent size dataset, using the 'rpart' package. However, after I completed the analysis, I realized that two of my subjects were dropped from the computation (likely due to rules within the function on missing data). Now, my problem: I could never, for the life of me, figure out which subjects were dropped from analysis.
This is relevant because I need to change my demographics tables to reflect my population MINUS THOSE TWO MYSTERY PARTICIPANTS. My hope for an easy solution at the time was to figure out what function I needed to just spit out who was dropped from the original dataset, and then I could just create a separate dataset subtracted those two participants and therefore had an accurate table 1 for the computation that was performed.
Does anyone have any insight as to functions that I might use to figure out who was dropped? This is a problem that has plagued my subconscious for like two years at this point. Apologies again for not having more specifics on the functions I used previously to try to rectify this, much of this is on an old computer that I am pulling out of storage.
Posted Aug 6, 2022, 12:59 AM UTC
The documentation for ?rpart says:
This is implemented in the
na.rpartfunction.The implementation of na.rpart is:
So try finding rows for which part of the response is missing, or all the predictors are missing. If that doesn't work, manually construct x and yvar and try running it though the relevant part of the above.
Another alternative is re-running rpart with x = TRUE and model = TRUE. The output object should then have the model frame and the input that you can compare.