I am currently trying to use hot deck data imputation to impute the DBC (psychometric test), but I keep getting the error:
Error in apply(data, 1, function(x) all(is.na(x))) :
dim(X) must have a positive length
My code is below:
hot.deck(data$DBC, m = 48, method = c( "p.draw"), cutoff = 48, sdCutoff = 1, optimizeSD = FALSE, optimStep = 0.1, optimStop = 5, weightedAffinity = FALSE, impContinuous = c("HD"), IDvars = NULL)
Happy to help if you can provide some data (just make dummy data if you need to with the right properties). A reprex (FAQ: How to do a minimal reproducible example ( reprex ) for beginners) makes it much easier for us to help you.
Hi, thanks for your help.
My data set for the DBC isn't very large, it consists of 131 participants, of whom 83 have completed it. Below is what happens when I try to view it
head(DBC)
[1] DBC 0 1 24 6 3
Levels: 0 1 10 12 13 14 15 16 17 18 19 2 22 23 24 25 26 27 28 29 3 31 32 36 38 4 41 5 6 7 8 9 DBC
Does this mean my data has been coded incorrectly?
It is very hard to help you with only the information you have here. If you do a reprex then I can run it locally and see the error first hand (hence my suggestion to create one).
At the moment, I can't say I know from which library you're pulling hot.deck nor what your complete dataset looks like etc. I have a feeling your input as a single column from data being fed into the function is the problem. Please have a look at the reprex link 