Objective function: transpose of ETA
marianklose opened this issue · 1 comments
Short question: For the calculation of the objective function we define:
U_eta <- eta %*% solve_omega %*% eta
.
The formula from https://pubmed.ncbi.nlm.nih.gov/22563254/ however is proposing to take the transpose of eta one time. So we would end up with:
U_eta <- t(eta) %*% solve_omega %*% eta
Or am I missing something? I've found it in the definition of the objective function.
# Objective function for the Empirical Bayes Estimates
# doi: 10.4196/kjpp.2012.16.2.97
objective_function <- function(y_obs=NULL,f=NULL,g=NULL,
eta=NULL,solve_omega=NULL){
# 1) When the prediction f is zero, g can be zero (depending on the residual
# error model).
# 2) log(0) is NaN, the limit of log(x) when x approaches zero is -Inf,
# 3) log(1) is zero, and 1^2 is 1
g[which(g == 0)] <- 1
U_y <- sum(((y_obs - f)/g)^2 + log(g^2))
#the transpose of a diagonal matrix is itself
U_eta <- eta %*% solve_omega %*% eta
if (TRUE %in% is.na(f)){
# if rxode2 fails to solve the model, the proposed ETA is not optimal, assign
# a large value to OFV to divert the algorithm from this area
OFV <- 10^10
} else {
OFV <- U_y + U_eta
}
return(OFV)
}
Thank you!
Short question: For the calculation of the objective function we define:
U_eta <- eta %*% solve_omega %*% eta
.The formula from https://pubmed.ncbi.nlm.nih.gov/22563254/ however is proposing to take the transpose of eta one time. So we would end up with:
U_eta <- t(eta) %*% solve_omega %*% eta
That's correct. However here t(eta)
and eta
are equivalent. That is the meaning of the following comment :
#the transpose of a diagonal matrix is itself
U_eta <- eta %*% solve_omega %*% eta
As eta
is a diagonal matrix (it is unidimensional), its transpose is itself.
Hope this is helpful