I’m trying to run a Bayesian test for an excel dataframe. When it runs, I get the following warning:
ABNORMAL_TERMINATION_IN_LNSRCH
Line search cannot locate an adequate point after MAXLS
function and gradient evaluations.
Previous x, f and g restored.
Possible causes: 1 error in function or gradient evaluation;
2 rounding error dominate computation.
The test returns a value so close to zero it can be despicable. In the dataframe the average increases about 7% when comparing the pre_period with the post_period. This result from the Bayesian test doesn’t make any sense.
## Teste Bayesiano para verificar a influência da pandemia no mercado Imobiliário
from causalimpact import CausalImpact
import pandas as pd
import numpy as np
from statsmodels.tsa.arima_process import arma_generate_sample
import matplotlib.pyplot as plt
import matplotlib
df = pd.read_excel("Dados_FIPE_Isolados_2018-2023.xlsx", sheet_name="Planilha1", header=0, index_col=0, parse_dates=True);
# Verificando se o DataFrame está vazio
if df.empty:
print("Erro: DataFrame está vazio!")
else:
print("DataFrame carregado com sucesso!")
print(df.head())
# Arredondando os valores para 2 casas decimais;
df = df.round (2);
df.index = pd.to_datetime(df.index) # Garantir que o índice é datetime
df.index = df.index.round('S') # Arredondar para o segundo mais próximo
#verificando o índice
print("index verificado com sucesso!")
#verificando o df
print(df.head(10));
#Definindo o período de pré e pós-intervenção com base no número das linhas
pre_period = ['2018-01-01', '2020-03-01']
post_period = ['2020-04-01', '2023-12-01']
#Rodando o teste
ts_impact = CausalImpact(df, pre_period, post_period)
ts_impact.run()
ts_impact.summary()
ts_impact.plot()
print(ts_impact.summary())
warnings.warn(msg, FutureWarning)
Average Cumulative
Actual 6328 284803
Predicted 6328 284766
95% CI [6327, 6329] [284721, 284811]
Absolute Effect 0 36
95% CI [1, 0] [81, -8]
Relative Effect 0.0% 0.0%
95% CI [0.0%, -0.0%] [0.0%, -0.0%]
P-value 0.0%
Prob. of Causal Effect 100.0%
Average Cumulative
Actual 6328 284803
Predicted 6328 284766
95% CI [6327, 6329] [284721, 284811]
Absolute Effect 0 36
95% CI [1, 0] [81, -8]
Relative Effect 0.0% 0.0%
95% CI [0.0%, -0.0%] [0.0%, -0.0%]
P-value 0.0%
Prob. of Causal Effect 100.0%
None