I would like to run Amelia function in Amelia package in a small dataset in order to handle some missing values. Here is the code :
am_hier <- amelia(karas_hier, ts = "type_questionnaire",
cs = "id_unique",
noms = "cat_prof_max",
ords = c("q19_karasek_n", "q20_karasek_n", "q21_karasek_n", "q22_karasek_n"),
polytime = 2,
intercs = TRUE,
p2s = 2)
But I have this error:
Amelia Error Code: 38
The following variable(s) are characters:
2
You may have wanted to set this as a ID variable to remove it
from the imputation model or as an ordinal or nominal
variable to be imputed. Please set it as either and
try again
The problem is that I don't have a variable named "2". I don't know how to fix this error.
- What this error means? 2) How to correct this error?
Thank you a lot!
Update
Here is a reproducible example
structure(list(id_unique = c("A70_136_B_F", "A70_136_B_F", "A70_136_B_F",
"A70_136_B_F", "A70_137_M_N", "A70_137_M_N", "A70_137_M_N", "A70_137_M_N",
"A70_138_D_S", "A70_138_D_S", "A70_138_D_S", "A70_138_D_S", "A70_216_R_M",
"A70_216_R_M", "A70_216_R_M", "A70_216_R_M", "A70_217_K_B", "A70_217_K_B",
"A70_217_K_B", "A70_217_K_B", "A70_218_L_A", "A70_218_L_A", "A70_218_L_A",
"A70_284_S_H", "A70_284_S_H", "A70_284_S_H", "A70_317_J_A", "A70_317_J_A",
"A70_317_J_A", "A70_317_J_A", "A70_318_R_P", "A70_318_R_P", "A70_318_R_P",
"A70_318_R_P", "A70_319_D_N", "A70_319_D_N", "A70_319_D_N", "A70_319_D_N",
"A70_321_P_J", "A70_321_P_J", "A70_321_P_J", "A70_321_P_J", "A70_322_K_M",
"A70_322_K_M", "A70_322_K_M", "A70_322_K_M", "A70_323_M_S", "A70_323_M_S",
"A70_323_M_S", "A70_323_M_S"), type_questionnaire = c("t0", "t1",
"t2", "t3", "t0", "t1", "t2", "t3", "t0", "t1", "t2", "t3", "t0",
"t1", "t2", "t3", "t0", "t1", "t2", "t3", "t0", "t2", "t3", "t0",
"t1", "t2", "t0", "t1", "t2", "t3", "t0", "t1", "t2", "t3", "t0",
"t1", "t2", "t3", "t0", "t1", "t2", "t3", "t0", "t1", "t2", "t3",
"t0", "t1", "t2", "t3"), cat_prof_max = c("Infirmier", "Infirmier",
"Infirmier", "Infirmier", "Infirmier", "Infirmier", "Infirmier",
"Infirmier", "Aide-soignant", "Aide-soignant", "Aide-soignant",
"Aide-soignant", "Aide-soignant", "Aide-soignant", "Aide-soignant",
"Aide-soignant", "Aide-soignant", "Aide-soignant", "Aide-soignant",
"Aide-soignant", "Infirmier", "Infirmier", "Infirmier", "Infirmier",
"Infirmier", "Infirmier", "Aide-soignant", "Aide-soignant", "Aide-soignant",
"Aide-soignant", "Aide-soignant", "Aide-soignant", "Aide-soignant",
"Aide-soignant", "Infirmier", "Infirmier", "Infirmier", "Infirmier",
"Infirmier", "Infirmier", "Infirmier", "Infirmier", "Infirmier",
"Infirmier", "Infirmier", "Infirmier", "Infirmier", "Infirmier",
"Infirmier", "Infirmier"), q19_karasek_n = c("D'accord", "D'accord",
"D'accord", "Pas d'accord", "D'accord", "Pas d'accord", "Pas d'accord",
"Pas d'accord", "D'accord", "D'accord", "D'accord", "D'accord",
"Pas du tout d'accord", "Pas du tout d'accord", "Pas du tout d'accord",
"Pas d'accord", "Tout à fait d'accord", "D'accord", "D'accord",
"Tout à fait d'accord", "D'accord", "Tout à fait d'accord", "Tout à fait d'accord",
"Pas d'accord", "D'accord", "Pas du tout d'accord", "Tout à fait d'accord",
"Tout à fait d'accord", "D'accord", "D'accord", "D'accord", "D'accord",
"Pas d'accord", "D'accord", "D'accord", "D'accord", "D'accord",
"D'accord", "Pas d'accord", "D'accord", "Pas du tout d'accord",
"Pas d'accord", "Pas d'accord", "Pas d'accord", "Pas d'accord",
"Pas du tout d'accord", "Pas d'accord", "Pas d'accord", "Pas d'accord",
"Pas d'accord"), q20_karasek_n = c("D'accord", "D'accord", "D'accord",
"D'accord", "Pas d'accord", "Pas d'accord", "Pas d'accord", "D'accord",
"D'accord", "Pas d'accord", "D'accord", "D'accord", "Pas du tout d'accord",
"Pas d'accord", "Pas du tout d'accord", "Pas d'accord", "Tout à fait d'accord",
"D'accord", "D'accord", "Tout à fait d'accord", "D'accord", "Tout à fait d'accord",
"Tout à fait d'accord", "Pas d'accord", "Pas d'accord", "Pas d'accord",
"Tout à fait d'accord", "Tout à fait d'accord", "D'accord", "D'accord",
"D'accord", "D'accord", "D'accord", "D'accord", "Tout à fait d'accord",
"Tout à fait d'accord", "D'accord", "D'accord", "Pas d'accord",
"D'accord", "D'accord", "D'accord", "Pas d'accord", "Pas d'accord",
"Pas d'accord", "Pas du tout d'accord", "Pas d'accord", "Pas d'accord",
"Pas d'accord", "D'accord"), q21_karasek_n = c("D'accord", "D'accord",
"Pas d'accord", "D'accord", "D'accord", "Pas d'accord", "Pas d'accord",
"D'accord", "D'accord", "D'accord", "D'accord", "Tout à fait d'accord",
"Pas du tout d'accord", "D'accord", "Pas d'accord", "D'accord",
"Tout à fait d'accord", "D'accord", "D'accord", "Tout à fait d'accord",
"D'accord", "D'accord", "D'accord", "Pas d'accord", "D'accord",
"Pas d'accord", "Tout à fait d'accord", "D'accord", "D'accord",
"D'accord", "D'accord", "D'accord", "D'accord", "Tout à fait d'accord",
"D'accord", "D'accord", "D'accord", "D'accord", "D'accord", "D'accord",
"Pas d'accord", "D'accord", "Pas d'accord", "Pas du tout d'accord",
"Pas d'accord", "Pas du tout d'accord", "Pas d'accord", "Pas d'accord",
"D'accord", "Pas d'accord"), q22_karasek_n = c("D'accord", "Pas d'accord",
"Pas d'accord", "Pas d'accord", "Pas du tout d'accord", "Pas d'accord",
"Pas d'accord", "Pas d'accord", "Pas d'accord", "Pas d'accord",
"D'accord", "Pas du tout d'accord", "Pas du tout d'accord", "Pas d'accord",
"D'accord", "D'accord", "D'accord", "D'accord", "D'accord", "Tout à fait d'accord",
NA, "D'accord", "D'accord", "Pas du tout d'accord", "Pas du tout d'accord",
"Pas d'accord", "D'accord", "Tout à fait d'accord", "D'accord",
"D'accord", "D'accord", "D'accord", "D'accord", "D'accord", "D'accord",
NA, "D'accord", "D'accord", "Pas d'accord", "Pas d'accord", "Pas d'accord",
"Tout à fait d'accord", "Pas d'accord", "D'accord", "Pas d'accord",
"Pas d'accord", "Pas d'accord", "Pas d'accord", "Pas d'accord",
"Pas d'accord")), row.names = c(NA, 50L), class = "data.frame")