I am using the mice package to obtain completed data.
I believe the problem is that I am not doing imputations for all the data, and so some of them have NAs. (some variables with missing data are used simply to predict missingness in others so I don’t want to impute those.
I can duplicate the problem with this code:
require(mice)
impute <- mice(
nhanes,
imputationMethod = c(
"", # age
"pmm", # bmi
"pmm", # hyp
"" # chl
),
seed = 101)
x11()
densityplot(impute)
Error in density.default(x = c(NA_real_, NA_real_, NA_real_, NA_real_, :
need at least 2 points to select a bandwidth automatically
How can I get the densityplots ? If I replace the "" with "pmm" for chl or just run impute <- mice(nhanes) then it will work with this example, to produce this:

but I can’t do that with my own data, so I’m looking for another way….just to get the
density plots for bmi and hyp, after running mice with my code above which does not impute values for chl
Edit:
I know I can use the methods in the answer to my earlier question using ggplot, but in this case I really need to work with densityplot
You will still have a large number of missing data in the ‘chl’-column. You could use the
pkg:micefunctioncompleteto pull together the original non-missing and the imputed values. But thedensityplot.midsfunction will do it if you reverse the roles of data and formula as (eventually) described in the Details of the help page.