Hi missing data discussion group,
I am trying to impute the missing data for coxph model using "smcfcs" R package. But I am having this error ”Error in rmultinom(1, size = 1, prob = prob) : NA in probability vector“.
Does anyone know why I got this problem and how to solve it?
My data and code are given below.
```
> str(df_check)
Classes ‘data.table’ and 'data.frame': 2196 obs. of 15 variables:
$ fu_time : num 254 239 208 944 1266 ...
$ event : num 1 1 0 0 1 1 1 0 1 0 ...
$ o3 : num 25.2 25.4 25.7 26 28.4 ...
$ year : Factor w/ 9 levels "2015","2016",..: 1 1 1 2 2 2 2 2 2 2 ...
$ age : num 72 61.5 64.7 35.8 73.2 ...
$ sexborn : Factor w/ 2 levels "1","2": 1 2 1 2 2 2 2 2 2 2 ...
$ race_cat : Factor w/ 2 levels "White","Non_white": 1 1 1 2 1 2 1 2 1 2 ...
$ bmi : num 27.1 20.9 28.5 NA 25.3 ...
$ cardiacout: num NA 4.73 4.36 NA 3.13 2.1 4.33 2.7 5.1 5.3 ...
$ ra : num 7 NA 9 15 18 16 19 13 NA 9 ...
$ edu_cat : Factor w/ 4 levels "highsch_below",..: 1 3 1 2 1 NA 2 1 1 3 ...
$ smk : Factor w/ 3 levels "non_smk","past_smk",..: 2 2 1 3 2 1 1 1 2 1 ...
$ ins : Factor w/ 4 levels "pub","priv","priv_pub",..: 3 2 NA 1 1 NA 1 3 3 2 ...
$ med : Factor w/ 4 levels "0","1","2","3": 1 2 1 2 2 4 3 4 2 2 ...
$ ph_cat : Factor w/ 6 levels "IPAH","DPAH",..: 1 3 5 5 3 1 1 3 1 5 ...
- attr(*, ".internal.selfref")=<externalptr>
> df_surv_imp <- smcfcs(df_check, smtype = "coxph",
+ smformula = "Surv(fu_time, event) ~ o3 + year + age + sexborn + race_cat + bmi + cardiacout + ra + edu_cat + smk + ins + med + ph_cat",
+ method = c("", "", "", "", "", "logreg", "", "norm", "norm", "norm",
+ "mlogit", "mlogit", "mlogit", "", ""),
+ m = 5,
+ numit = 10)
[1] "Outcome variable(s): fu_time,event"
[1] "Passive variables: "
[1] "Partially obs. variables: sexborn,bmi,cardiacout,ra,edu_cat,smk,ins"
[1] "Fully obs. substantive model variables: o3,year,age,race_cat,med,ph_cat"
[1] "Imputation 1"
[1] "Imputing: sexborn using bmi,cardiacout,ra,edu_cat,smk,ins,o3,year,age,race_cat,med,ph_cat plus outcome"
[1] "Imputing: bmi using sexborn,cardiacout,ra,edu_cat,smk,ins,o3,year,age,race_cat,med,ph_cat plus outcome"
[1] "Imputing: cardiacout using sexborn,bmi,ra,edu_cat,smk,ins,o3,year,age,race_cat,med,ph_cat plus outcome"
[1] "Imputing: ra using sexborn,bmi,cardiacout,edu_cat,smk,ins,o3,year,age,race_cat,med,ph_cat plus outcome"
[1] "Imputing: edu_cat using sexborn,bmi,cardiacout,ra,smk,ins,o3,year,age,race_cat,med,ph_cat plus outcome"
[1] "Imputing: smk using sexborn,bmi,cardiacout,ra,edu_cat,ins,o3,year,age,race_cat,med,ph_cat plus outcome"
[1] "Imputing: ins using sexborn,bmi,cardiacout,ra,edu_cat,smk,o3,year,age,race_cat,med,ph_cat plus outcome"
[1] "Imputation 2"
Error in rmultinom(1, size = 1, prob = prob) : NA in probability vector
```
Thank you so much!
Best regards,
Riccy