I am trying to fit a truncated Pareto model, but am unsure how to do that in Stan. I have data that look like this:
library(VGAM)
N = 1000
x_min = 1
x_max = 10
x = rtruncpareto(n = N, lower = x_min, upper = x_max, shape = 3)
I am able to fit these with the built-in Pareto in stan:
data {
int<lower=0> N;
vector<lower=0>[N] x;
real<lower=0> x_min;
}
parameters {
real<lower=0> alpha;
}
model {
alpha ~ lognormal(1, 1) T[0, 5];
x ~ pareto(x_min, alpha);
}
generated quantities {
vector[N] log_lik;
for (i in 1:N) {
log_lik[i] = pareto_lpdf(x[i] | x_min, alpha);
}
}
But I am unsure how to modify the model above so that it will fit the truncated Pareto (i.e., incorporate x_max). I assume it would involve writing a custom pdf in the functions{}, but that is beyond my capability with stan.
Thanks for any help!