Closed atredennick closed 9 years ago
This seems correct, although you are pushing the limits of my memory...
On 5/19/2015 8:29 AM, Andrew Tredennick wrote:
I think I had the size-based variance term wrong in the likelihood. If I am understanding everything correctly, the equation |tau_exp(tauSize_mu[n])| estimates the variance (|sigma^2|). So, since rstan takes standard deviation as the scale parameter in the normal likelihood, we need to take the square root os that equation to get |sigma|. It looks like this:
|for(n in 1:N){| |mu[n] <- a[yid[n]] + gint[gid[n]] + b1[yid[n]]_X[n] + crowdEff[n] + climEff[n];| |sigma[n] <- sqrt((fmax(tau_exp(tauSize*mu[n]), 0.0000001)));| |}| |#Likelihood (vectorized)| |Y ~ normal(mu, sigma);|
@pbadler https://github.com/pbadler, mind double-checking this? This seems right since in WinBUGS/JAGS you guys used |1/tau_exp(tauSize_mu[n])| as the precision in the likelihood (1/variance).
— Reply to this email directly or view it on GitHub https://github.com/atredennick/MicroMesoForecast/issues/18.
Peter Adler Department of Wildland Resources and the Ecology Center Utah State University http://www.cnr.usu.edu/htm/facstaff/adler-web
I think I had the size-based variance term wrong in the likelihood. If I am understanding everything correctly, the equation
tau*exp(tauSize*mu[n])
estimates the variance (sigma^2
). So, since rstan takes standard deviation as the scale parameter in the normal likelihood, we need to take the square root os that equation to getsigma
. It looks like this:for(n in 1:N){
mu[n] <- a[yid[n]] + gint[gid[n]] + b1[yid[n]]*X[n] + crowdEff[n] + climEff[n];
sigma[n] <- sqrt((fmax(tau*exp(tauSize*mu[n]), 0.0000001)));
}
#Likelihood (vectorized)
Y ~ normal(mu, sigma);
@pbadler, mind double-checking this? This seems right since in WinBUGS/JAGS you guys used
1/tau*exp(tauSize*mu[n])
as the precision in the likelihood (1/variance).