We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From a user
I think that there should be a n factor in front of the term log(2*pi), due to the product of n gaussian densities.
I noticed this problem when trying to write my own likelihood function a() instead of a numeric constant a.
function (predicted, observed, sd, a) { if (any(is.na(observed))) stop("AR1 likelihood cannot work with NAs included, split up the likelihood") if (sd <= 0) return(-Inf) if (abs(a) >= 1) return(-Inf) n = length(observed) res = predicted - observed ll = 0.5 * (-log(2 * pi) - n * log(sd^2) + log(1 - a^2) - (1 - a^2)/sd^2 * res[1]^2 - 1/sd^2 * sum((res[2:n] - a * res[1:(n - 1)])^2)) return(ll) } <environment: namespace:BayesianTools>
The text was updated successfully, but these errors were encountered:
You're right, there was an n missing, it should have been
ll = 0.5 * ( - n * log(2*pi) - n * log(sd^2) + log( 1- a^2 ) - (1- a^2) / sd^2 * res[1]^2 - 1 / sd^2 * sum( (res[2:n] - a * res[1:(n-1)])^2)
The issue was fixed with commit 9bb16f9 to the master branch
Thanks for reporting this!
Sorry, something went wrong.
No branches or pull requests
From a user
I think that there should be a n factor in front of the term log(2*pi), due to the product of n gaussian densities.
I noticed this problem when trying to write my own likelihood function a() instead of a numeric constant a.
function (predicted, observed, sd, a)
{
if (any(is.na(observed)))
stop("AR1 likelihood cannot work with NAs included, split up the likelihood")
if (sd <= 0)
return(-Inf)
if (abs(a) >= 1)
return(-Inf)
n = length(observed)
res = predicted - observed
ll = 0.5 * (-log(2 * pi) - n * log(sd^2) + log(1 - a^2) -
(1 - a^2)/sd^2 * res[1]^2 - 1/sd^2 * sum((res[2:n] -
a * res[1:(n - 1)])^2))
return(ll)
}
<environment: namespace:BayesianTools>
The text was updated successfully, but these errors were encountered: