I have a data with answers which is a subset of population. I need to make an adjustment to make this data correspond to the real data we got about total population. Moreover in our data several answers can correspond to the same exploitation.
I have tried do attribute to each answer an initial weight (for realise that, I attributed every answer to exploitations and corresponding to the obtained total number of exploitation I managed to count the weight (column weight)).
Data preview: https://i.stack.imgur.com/8tpc4.png
Then I tried to applicate calibration with icarus:
I calculates target margins. For that I took external (given to me) data about status and number of sales in all population. I counted a sum of all status and divided each category on this total number to get a margin. The same I made for number of sales.
The external data about total population was:
Status:
- EEA 2151
- BBF 244
- RDR 34
- SRF 11246
- TRT 1618
- KLL 342
- RDT 306
Number of sales:
- 0 -> 12840 sales
- from 100000 to 199999 -> 53 sales
- from 50 to 99999 -> 192 sales
library(icarus)
mar1 <- c("Status",7,0.1348,0.0153,0.0021,0.7048,0.1014,0.0214,0.0192) #status
mar2 <- c("nb_sales",3,0.9813,0.0041,0.0147,0,0,0,0) #total number of sales
marges <- rbind(mar1, mar2)
wCalesLogit <- calibration(data=weighted_data, marginMatrix=marges, colWeights="weight", method="logit", bounds=c(0.4,2.1), description=TRUE)
At the end I tried fonction but every time it fails. Can anybody helps me to understand what’s wrong or give some propositions how to solve it, please
I’am beginner in R and don’t really know how this fonction goes
Error I got after calibration:
Error in calibration(data = weighted_data, marginMatrix = marges, colWeights = "weight", : No convergence in 2500 iterations.
Наталия Каипова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.