-
Notifications
You must be signed in to change notification settings - Fork 187
Open
Description
The function np.bincount(ids) returns a generic ValueError: 'list' argument must have no negative elements.
linearmodels/linearmodels/panel/model.py
Lines 97 to 102 in 9288df3
| def panel_structure_stats(ids: IntArray, name: str) -> Series: | |
| bc = np.bincount(ids) | |
| bc = bc[bc > 0] | |
| index = ["mean", "median", "max", "min", "total"] | |
| out = [bc.mean(), np.median(bc), bc.max(), bc.min(), bc.shape[0]] | |
| return Series(out, index=index, name=name) |
In my case that happened due to some NaN within the entity effect, which lead to negative values (-1) in the ids.
In my opinion, both the properties entity_ids and time_ids should return an error if the elements in the index contains some NaN (since I had a quite hard time figuring it out).
linearmodels/linearmodels/panel/data.py
Lines 365 to 389 in 9288df3
| @property | |
| def entity_ids(self) -> IntArray: | |
| """ | |
| Get array containing entity group membership information | |
| Returns | |
| ------- | |
| ndarray | |
| 2d array containing entity ids corresponding dataframe view | |
| """ | |
| index = self.index | |
| return np.asarray(index.codes[0])[:, None] | |
| @property | |
| def time_ids(self) -> IntArray: | |
| """ | |
| Get array containing time membership information | |
| Returns | |
| ------- | |
| ndarray | |
| 2d array containing time ids corresponding dataframe view | |
| """ | |
| index = self.index | |
| return np.asarray(index.codes[1])[:, None] |
If necessary, I would be happy to work on that.
Metadata
Metadata
Assignees
Labels
No labels