jamalsenouci / causalimpact

Python port of CausalImpact R library
Apache License 2.0
272 stars 63 forks source link

compile_posterior_inferences() missing 1 required positional argument: 'estimation' #16

Closed boghrati closed 3 years ago

boghrati commented 5 years ago

Hi,

When I'm running the example provided in the documentation with the custom model I get the following error:

File "StatisticalMethod.py", line 160, in main_stat impact.run() File "/home/reihane/anaconda3/lib/python3.6/site-packages/causalimpact/analysis.py", line 46, in run self.params["estimation"]) File "/home/reihane/anaconda3/lib/python3.6/site-packages/causalimpact/analysis.py", line 339, in _run_with_ucm orig_std_params, estimation) TypeError: compile_posterior_inferences() missing 1 required positional argument: 'estimation'

I am using: python 3.6 numpy 1.15.3 pandas 0.23.0 statsmodels 0.9.0 nose 1.3.7 Was wondering if I'm missing something or not using the correct library versions.

Thanks, Reihane

jamalsenouci commented 5 years ago

Could you provide a reproducible example please. I would guess you could fix this by passing estimation='MLE' as an argument when initialising the causal impact object

boghrati commented 5 years ago

Thanks for the reply. I run the same example as the documentation: x1 = arma_generate_sample(ar=[0.999], ma=[0.9], nsample=100) + 100 y = 1.2 * x1 + np.random.randn(100) y[71:100] = y[71:100] + 10 post_period = [70, 100] post_period_response = y[post_period[0]:post_period[1]].copy() y[post_period[0]:post_period[1]] = np.nan ucm_model = UnobservedComponents(endog=y, exog=x1, level="llevel") impact = CausalImpact(ucm_model=ucm_model, post_period_response=post_period_response, estimation="MLE") impact.run() Same error if I add estimation = "MLE" to casualimapct function. Here's the full output: /home/reihane/anaconda3/lib/python3.6/site-packages/scipy/signal/signaltools.py:1344: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; usearr[tuple(seq)]instead ofarr[seq]. In the future this will be interpreted as an array index,arr[np.array(seq)], which will result either in an error or a different result. out = out_full[ind] RUNNING THE L-BFGS-B CODE * * * Machine precision = 2.220D-16 N = 3 M = 10 This problem is unconstrained. At X0 0 variables are exactly at the bounds At iterate 0 f= 1.30404D+00 |proj g|= 3.16241D-01 At iterate 5 f= 1.00332D+00 |proj g|= 1.03591D-02 At iterate 10 f= 1.00330D+00 |proj g|= 1.54243D-06 * * * Tit = total number of iterations Tnf = total number of function evaluations Tnint = total number of segments explored during Cauchy searches Skip = number of BFGS updates skipped
Nact = number of active bounds at final generalized Cauchy point Projg = norm of the final projected gradient F = final function value * * * N Tit Tnf Tnint Skip Nact Projg F 3 10 13 1 0 0 1.542D-06 1.003D+00
F = 1.0032969309018884
CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL Cauchy time 0.000E+00 seconds. Subspace minimization time 0.000E+00 seconds. Line search time 0.000E+00 seconds. Total User time 0.000E+00 seconds. Traceback (most recent call last): File "StatisticalMethod.py", line 158, in <module> main_stat() File "StatisticalMethod.py", line 153, in main_stat impact.run() File "/home/reihane/anaconda3/lib/python3.6/site-packages/causalimpact/analysis.py", line 46, in run self.params["estimation"])
File "/home/reihane/anaconda3/lib/python3.6/site-packages/causalimpact/analysis.py", line 339, in _run_with_ucm orig_std_params, estimation) TypeError: compile_posterior_inferences() missing 1 required positional argument: 'estimation'

nellac77 commented 4 years ago

I would be interested in how this turns out.

jamalsenouci commented 3 years ago

closed as could not reproduce with example