Dear Stanners:

I am urgently working on an asset (stock) price model known as Log-Periodic Power Law (LPPL, LPPLS or JLS) model, but I am encountering the following exception warnings at the beginning of the sampling:

The current Metropolis proposal is about to be rejected because of the following issue:

Exception: lognormal_lpdf: Location/Scale parameter is inf, but must be finite!

If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine, but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

I am not sure whether this warning is a serious issue since it only occurs at the beginning of sampling. However, the Markov chains donâ€™t converge and the effective sample size is extremely low. I donâ€™t know what causes this issue. Could anyone kindly help me identify where goes wrong in my model specification?

Many thanks!

Alan

**The LPPL model is formulated as:**

\mathrm{ln}p_t = A + B(t_c - t)^m + C(t_c - t)^m \cos(\omega \mathrm{ln}(t_c - t) - \phi) + \varepsilon_t

- \mathrm{ln}p_t: log price at time t before t_c
- t_c > \max(t): critical time (i.e., time of transition to a new regime or bubble termination)
- A > 0: expected log price at the critical time t_c
- B < 0: amplitude of the power law acceleration
- -1<C<1: amplitude of the log-periodic oscillations
- 0 < m < 1: degree of the power law growth of prices
- \omega: frequency of oscillations during a bubble
- 0 < \phi < 2\pi: time scale of the oscillations, a phase parameter
- \varepsilon_t is the noise to the log price at time t

**The Stan model is:**

```
data{
int<lower=0> N; // number of observations (trading days)
vector[N] t; // time index
vector<lower=0>[N] p; // price
}
parameters{
real<lower=0.001> A;
real<upper=-0.001> B;
real<lower=-0.999, upper=0.999> C;
real<lower=max(t)+1> tc;
real<lower=0.001, upper=0.999> m;
real<lower=0.001> omega;
real<lower=0, upper=2*pi()> phi;
real<lower=0> sigma; // standard deviation of noise of log price
}
model{
// priors
A ~ uniform(0.001, 50);
B ~ uniform(-50, -0.001);
C ~ uniform(-0.999, 0.999);
tc ~ uniform(0, 200);
m ~ uniform(0.001, 0.999);
omega ~ uniform(0, 20);
phi ~ uniform(0, 2*pi());
sigma ~ normal(0, 50);
// likelihood
for (n in 1: N){
p[n] ~ lognormal(A + B*(tc-t[n])^m + C*(tc-t[n])^m*cos(omega*log(tc-t[n])-phi), sigma);
}
}
```

**Here is the data file of the S&P 500 index price:** SP500.csv (20.2 KB)

My Pystan code:

```
import pandas as pd
# Data for Stan model
data = pd.read_csv('SP500.csv')
data_stan = {'N': len(data),
't': data['time_idx'],
'p': data['price']
}
# Compile the Stan model (model_code is the Stan model)
model = pystan.StanModel(model_code=model_code)
# Fit the Stan model
fit = model.sampling(data=data_stan,
chains=3,
iter=4000,
warmup=2000,
seed=123,
n_jobs= 6,
control={'adapt_delta': 0.95, 'max_treedepth': 15}
)
```