File tree Expand file tree Collapse file tree 5 files changed +39
-4
lines changed
Expand file tree Collapse file tree 5 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -1883,7 +1883,7 @@ def fit(
18831883
18841884 # Adjust exog
18851885 self .exog = PanelData (self .exog .dataframe .iloc [:, retain ])
1886- x_effects = x_effects [retain ]
1886+ x_effects = x_effects [:, retain ]
18871887
18881888 params = _lstsq (x , y , rcond = None )[0 ]
18891889 nobs = self .dependent .dataframe .shape [0 ]
Original file line number Diff line number Diff line change 66import pandas as pd
77import pytest
88
9+ from linearmodels .datasets import wage_panel
910from linearmodels .iv .model import IV2SLS
1011from linearmodels .panel .data import PanelData
1112from linearmodels .panel .model import PanelOLS , PooledOLS
@@ -1531,3 +1532,26 @@ def test_entity_into():
15311532 ti = res .time_info
15321533 assert ti ["total" ] == 4
15331534 assert ti ["min" ] == 16
1535+
1536+
1537+ @pytest .mark .parametrize ("path" , ["use_lsdv" , "low_memory" ])
1538+ def test_absorbed_with_weights (path ):
1539+ data = wage_panel .load ().copy ()
1540+ year = pd .Categorical (data .year )
1541+ data = data .set_index (["nr" , "year" ])
1542+ data ["year" ] = year
1543+ # and random number between 0 and 1 for weights
1544+ data ["rand" ] = np .random .rand (data .shape [0 ])
1545+ data ["absorbe" ] = data .groupby ("nr" )["union" ].transform ("mean" )
1546+
1547+ fit_options = {}
1548+ if path :
1549+ fit_options [path ] = True
1550+
1551+ with pytest .warns (AbsorbingEffectWarning , match = "Variables have been" ):
1552+ PanelOLS .from_formula (
1553+ "lwage ~1+absorbe + married + EntityEffects" ,
1554+ data = data ,
1555+ weights = data ["rand" ],
1556+ drop_absorbed = True ,
1557+ ).fit (** fit_options )
Original file line number Diff line number Diff line change @@ -26,3 +26,13 @@ exclude = '''
2626
2727[tool .setuptools_scm ]
2828write_to = " linearmodels/_version.py"
29+
30+ [tool .pyright ]
31+ exclude = [
32+ " **/tests/**" ,
33+ ]
34+
35+ [tool .mypy ]
36+ exclude = [
37+ " tests" ,
38+ ]
Original file line number Diff line number Diff line change 11xarray >= 0.16
22mypy >= 1.3
3- black [jupyter ]== 23.3 .0
3+ black [jupyter ]== 23.7 .0
44pytest >= 7.3.0
55isort >= 5.12
66ipython
@@ -10,6 +10,7 @@ nbconvert
1010nbformat
1111nbsphinx
1212numpydoc
13+ pandas-stubs
1314pytest-xdist
1415pytest-cov
1516seaborn
Original file line number Diff line number Diff line change 1- black[jupyter]==23.3 .0
1+ black[jupyter]==23.7 .0
22coverage
33flake8
44isort
55matplotlib
6- pytest>=7.0,<7.1
6+ pytest>=7.3.0
77pytest-xdist
88pytest-cov
99seaborn
You can’t perform that action at this time.
0 commit comments