@@ -629,7 +629,7 @@ def _derivative_exog(self, params, exog=None, transform="dydx",
629
629
dummy_idx = None , count_idx = None ,
630
630
offset = None , exposure = None ):
631
631
"""
632
- This should implement the derivative of the non-linear function
632
+ Derivative of mean, expected endog with respect to the parameters
633
633
"""
634
634
if exog is None :
635
635
exog = self .exog
@@ -642,8 +642,8 @@ def _derivative_exog(self, params, exog=None, transform="dydx",
642
642
k_extra = getattr (self , 'k_extra' , 0 )
643
643
params_exog = params if k_extra == 0 else params [:- k_extra ]
644
644
645
- lin_pred = self .predict ( params , which = "linear" )
646
- margeff = self . family . link . inverse_deriv ( lin_pred )[:, None ] * params_exog
645
+ margeff = ( self .family . link . inverse_deriv ( lin_pred )[:, None ] *
646
+ params_exog )
647
647
if 'ex' in transform :
648
648
margeff *= exog
649
649
if 'ey' in transform :
@@ -2299,6 +2299,9 @@ def get_margeff(self, at='overall', method='dydx', atexog=None,
2299
2299
dummy = False , count = False ):
2300
2300
"""Get marginal effects of the fitted model.
2301
2301
2302
+ Warning: offset, exposure and weights (var_weights and freq_weights)
2303
+ are not supported by margeff.
2304
+
2302
2305
Parameters
2303
2306
----------
2304
2307
at : str, optional
@@ -2366,12 +2369,15 @@ def get_margeff(self, at='overall', method='dydx', atexog=None,
2366
2369
2367
2370
When using after Poisson, returns the expected number of events per
2368
2371
period, assuming that the model is loglinear.
2372
+
2373
+ Status : unsupported features offset, exposure and weights. Default
2374
+ handling of freq_weights for average effect "overall" might change.
2375
+
2369
2376
"""
2370
2377
if getattr (self .model , "offset" , None ) is not None :
2371
2378
raise NotImplementedError ("Margins with offset are not available." )
2372
2379
if (np .any (self .model .var_weights != 1 ) or
2373
- np .any (self .model .freq_weights != 1 )
2374
- ):
2380
+ np .any (self .model .freq_weights != 1 )):
2375
2381
warnings .warn ("weights are not taken into account by margeff" )
2376
2382
from statsmodels .discrete .discrete_margins import DiscreteMargins
2377
2383
return DiscreteMargins (self , (at , method , atexog , dummy , count ))
0 commit comments