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

Error when printing estimated proportions with no domains #59

Open
michaelwalshe opened this issue Aug 13, 2024 · 0 comments
Open

Error when printing estimated proportions with no domains #59

michaelwalshe opened this issue Aug 13, 2024 · 0 comments

Comments

@michaelwalshe
Copy link

Hi,

I've encountered the following error when printing a proportion estimator:

from samplics import TaylorEstimator
from samplics.datasets import load_nhanes2
from samplics.utils.types import PopParam

nhanes2 = load_nhanes2()["data"]

prop_est = TaylorEstimator(PopParam.prop)

prop_est.estimate(
    y=nhanes2["highlead"],
    psu=nhanes2["psuid"],
    stratum=nhanes2["stratid"],
    remove_nan=True,
)

print(prop_est)

Gives the following:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File c:\\Users\\Michael.Walshe.AMADEUS\\source\\katalyze-data\\CAMIS\\testing.py:1
----> 1 print(prop_est)

File c:\\Users\\Michael.Walshe.AMADEUS\\source\\katalyze-data\\CAMIS\\renv\\python\\virtualenvs\\renv-python-3.11\\Lib\\site-packages\\samplics\\estimation\\expansion.py:109, in _SurveyEstimator.__str__(self)
    107 upper_ci = list()
    108 coef_var = list()
--> 109 for domain in self.domains:
    110     domains += np.repeat(domain, len(self.point_est[domain])).tolist()
    111     levels += list(self.point_est[domain].keys())

TypeError: iteration over a 0-d array

I think this is due to the __str__ method of SurveyEstimator checking that self.domain is not None rather than self.domain.shape in ((), (0,)) which is what it looks like the checks are elsewhere.

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

1 participant