Open leostimpfle opened 1 week ago
predict
still does not work with newdata
and fixed effects (see #467). Something doesn't quite work in the fixef
method inherited from feols
. I'll investigate further.
Attention: Patch coverage is 0%
with 6 lines
in your changes missing coverage. Please review.
Files with missing lines | Patch % | Lines |
---|---|---|
pyfixest/estimation/fepois_.py | 0.00% | 6 Missing :warning: |
Flag | Coverage Δ | |
---|---|---|
core-tests | 77.79% <0.00%> (+0.10%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Files with missing lines | Coverage Δ | |
---|---|---|
pyfixest/estimation/fepois_.py | 86.79% <0.00%> (-0.42%) |
:arrow_down: |
If I change to the following
def predict(
self,
newdata: Optional[DataFrameType] = None,
atol: float = 1e-6,
btol: float = 1e-6,
type: PredictionType = "link",
) -> np.ndarray:
#if newdata is not None and self._has_fixef:
# raise NotImplementedError()
y_hat = super().predict(newdata=newdata, type=type, atol=atol, btol=btol)
if type == "response":
y_hat = np.exp(y_hat)
return y_hat
predict works with newdata
and fixed effects for type = "response"
:
%load_ext autoreload
%autoreload 2
import pyfixest as pf
data = pf.get_data(model = "Fepois")
fit = pf.fepois("Y ~ X1 | f1", data = data)
fit.predict(newdata = data.dropna(), type = "response")[0:5]
# array([2.7803393 , 2.81678101, 3.20245421, 3.3940836 , 3.38641651])
fit.predict(type = "response")[0:5]
# array([2.78032513, 2.81699512, 3.20381613, 3.39393412, 3.38457835])
Closes #468