Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounds not working #10

Open
TimBock opened this issue May 27, 2019 · 2 comments
Open

Bounds not working #10

TimBock opened this issue May 27, 2019 · 2 comments

Comments

@TimBock
Copy link

TimBock commented May 27, 2019

When I run the following, I get minimum and maximum weight values that are outside the bounds. Sorry if I've misunderstood the documentation...

library(icarus)
mar1 <- c("categ",3,80,90,60)
mar2 <- c("sexe",2,140,90,0)
mar3 <- c("service",2,100,130,0)
mar4 <- c("salaire", 0, 470000,0,0)
margins <- rbind(mar1, mar2, mar3, mar4)
wCal <- calibration(data = data_ex2,
marginMatrix = margins,
colWeights="poids",
method = "logit",
bounds = c(3, 38),
description=FALSE)
range(wCal)

@haroine
Copy link
Collaborator

haroine commented May 28, 2019

Hi! Thanks for the reproducible example!

The bounds are actually on the g-weights (i.e. reweighting factor = w/d), which in this case refers to the vector wCal / data_ex2$poids

The problem as defined here does not actually have a solution, since margin on categ for example implies a constraint on total population of 230, but the min bound of 3 on the reweighting factor would mean an estimated pop total with calibrated weights of at least 3*230 = 690. What you observe here is thus a numerical aberration (icarus finds a numerical solution within the pre-set 1e-6 tolerance).

If what you want is the range of the final weight wCal between 3 and 38, since all initial weights are equal to 10 you can thus use:

bounds = c(0.3, 380)

which gives:

> range(wCal)
[1]  3.96063 39.08558

Hope it helps :)

@TimBock
Copy link
Author

TimBock commented May 31, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants