I am trying to use pool_performance to do calibration plot and also AUC for ROC for model performance in R.
I don't get impvar parameter in the function though the description says that Name of the variable that distinguishes the imputed datasets.
What does it mean? could you give me any example?
Here is the example from help("pool_performance"). It gives
"Impnr"as the
impvarargument. As you note, the
argument` section for the function specifies it as
A character vector. Name of the variable that distinguishes the imputed datasets.
And that is a variable within the data
argument. Using the example that is lbpmilr
, which has as its variables
> colnames(lbpmilr)
[1] "Impnr" "ID" "Chronic" "Gender"
[5] "Carrying" "Pain" "Tampascale" "Function"
[9] "Radiation" "Age" "Smoking" "Satisfaction"
[13] "JobControl" "JobDemands" "SocialSupport" "Duration"
[17] "BMI"
and the first is given as the impvar
argument, which is typeof
integer
and contains unique values in the range 1:10. help("ibpmilr") describes the data set as 10 imputed data set and so it appears that
Impnr` is an identifier relating each observation (row) to one of the imputed data sets identified by the integers 1:10.
library(psfmi)
perf <- pool_performance(
data = lbpmilr, nimp = 5, impvar = "Impnr",
formula = Chronic ~ Gender + Pain + Tampascale +
Smoking + Function + Radiation + Age + factor(Carrying),
cal.plot = TRUE, plot.method = "mean",
groups_cal = 10, model_type = "binomial"
)
perf$ROC_pooled
#> 95% Low C-statistic 95% Up
#> C-statistic (logit) 0.8005 0.8714 0.9197
perf$R2_pooled
#> [1] 0.5060599
Created on 2023-06-28 with reprex v2.0.2
Thank you for the answer! So what I have to do now is
- add one column with Impnr for each imputed data set
(for imputed_1 all impnr is 1, for imputed_2 all impnr is 2...etc) - put impnr in the parameter of impvar
- do pool_performance
Is it correct?
Then I was wondering how I can do that in r...
That's it. Might be easier just to add s column to each of the imputed datasets before combining them.
This topic was automatically closed 21 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.