Please share your Stan program and accompanying data if possible.

When including Stan code in your post it really helps if you make it as readable as possible by using Stan code chunks (```stan) with clear spacing and indentation. For example, use

```
model {
vector[N] mu = alpha + beta * x;
y ~ normal(mu, sigma);
}
```

instead of

model{

vector[N] mu = alpha+beta*x;

y~normal(mu,sigma);

}

To include mathematical notation in your post put LaTeX syntax between two `$`

symbols, e.g.,

p(\theta | y) \propto p(\theta) p(y | \theta).

I’m trying to program a simple Lincoln-Peterson mark-recapture example using the hyperG likelihood:

I have easily programmed this example using the more common binomial likelihood, but also want and need to be able to program using the HyperG. I forgot to add that this appears to compile, but when I run it sampling does not occur because ‘b’ takes a values on the order of negative 200000 despite being constrained to no less than 70.

Here are my Rstan and stan files:

//HG1.stan. Test of simple Lincoln-Peterson model using a hypergeometric likelihood

//February 13 2019

data{

int<lower = 0> a;//M

int<lower=0> N; //C

int<lower = 0, upper = min(a,N)> n;//R

}

transformed data{

int<lower = N-n> b; //N-M

}

//parameters{

// real<lower = (N-n)> b; //(C-R+M)> N;

// }

model {

// R~binomial(C, M/N);

n~hypergeometric(N,a,b); //n, N and a known; b is unkown and to be estimated

}

generated quantities{

int <lower = 0>Pop;

Pop = a+b; //total population size

}

#HG1_stan.R

#Test: Simple Lincoln-Peterson mark-recp model using a hypergeomtric likelihood

#February 13 2019

#a = 500; #number marked and released

#N =100; #number recaptured

#n = 30; #number marked among the C recaptures

stanDat <- list(a = 500, N = 100, n = 30)

#sample posterior:

HG1fit <- stan(file=“HG1.stan”, data = stanDat, init=list(list(b = 80)),iter = 100, chains = 1)

print(HG1fit)

The right-most remmed-out notations in the .stan file are the corresponding variables in the mark-recap examples in Section 15.3, pp. 2016-17 of the Stan Reference Manual.