# Posterior Predictive Sampling Error : Custom Distribution

I am modeling a generalized extreme value distribution with the code below. I have defined my own distribution as the gev is still not available in pymc3. The function defined is the PDF of extreme value distribution. I have taken informative priors based on the MLE estimates. Now I want to perform prior predictive checks. I tried to do so as recommended in various tutorials but it keeps on giving me key errors when I call the var_names. I have attached the trace as well. Could somebody help with the ppc? Many thanks.

``````def gev_logp(value, loca, sig, xi):
scaled = (value - loca) / sig
logp_xi_not_zero = -(tt.log(sig)
+ ((xi + 1) / xi) * tt.log1p(xi * scaled)
+ (1 + xi * scaled) ** (-1/xi))
logp_xi_zero = -tt.log(sig) + (xi+1)*(-(value - loca)/sig) - tt.exp(-(value - loca)/sig)
logp = tt.switch(tt.abs_(xi) > 1e-4, logp_xi_not_zero, logp_xi_zero)
return tt.sum(logp)

with pm.Model() as model_gev:
loca = pm.Normal('loca', mu=14.728, sigma=3)
sig= pm.Normal('sig',mu=5.386, sigma=2)
xi = pm.Normal('xi', mu=-0.076, sigma=0.01)

gev = pm.DensityDist('gev', gev_logp, observed = {'value':datin.data1, 'loca':loca, 'sig':sig, 'xi':xi})
trace = pm.sample(7000, cores=4, chains=4, tune=2500, return_inferencedata=True, idata_kwargs={"density_dist_obs": False})``````