You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, my code is producing the error "! Calibration failed".
Below is the code snippet that produced the error. pop_long is the target dataset with the factor variables, country, Age (group), female. all is the dataset I'm trying to rake and includes the 3 variables.
This error appears to originate from the survey package that rake_survey is wrapping around, so my first couple of thoughts would be to check whether country, Age and female have the same categories between the all dataset and in the targets, and if so, whether the cells created by those categories are of a sufficient size to conduct raking. If, say, the data does not contain any observations for a particular country, or contains only a handful of observations, the raking algorithm may not converge, in which case you might need to collapse some countries together in order to create cells with around 30 or more cases or so.
If the cells are all a sufficient size, another possibility is that the marginal distributions from the dataset are so wildly far from the targets that the algorithm cannot converge. This sort of thing might occur if there was a coding error with the raking variables.
Hello, my code is producing the error "! Calibration failed".
Below is the code snippet that produced the error.
pop_long
is the target dataset with the factor variables,country
,Age
(group),female
.all
is the dataset I'm trying to rake and includes the 3 variables.targets <- create_raking_targets(pop_long, vars = c("country", "Age", "female"), wt = "frac")
all_raking <- all %>% mutate(rk_country = dk_to_na(country), rk_Age = dk_to_na(Age), rk_female=dk_to_na(female))
all_imputed <- impute_vars(all_raking, seed = 739)
all_raked <- all %>% dplyr::mutate(weight2 = rake_survey(all_imputed, pop_margins = targets))
Here is my R version:
The text was updated successfully, but these errors were encountered: