aboutsummaryrefslogtreecommitdiff
path: root/R/logLik.mkinfit.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/logLik.mkinfit.R')
-rw-r--r--R/logLik.mkinfit.R28
1 files changed, 4 insertions, 24 deletions
diff --git a/R/logLik.mkinfit.R b/R/logLik.mkinfit.R
index d3f4232d..d812f177 100644
--- a/R/logLik.mkinfit.R
+++ b/R/logLik.mkinfit.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 Johannes Ranke
+# Copyright (C) 2018,2019 Johannes Ranke
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -16,29 +16,9 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>
logLik.mkinfit <- function(object, ...) {
- y_ij <- object$data$observed
- yhat_ij <- object$data$predicted
- if (is.null(object$data$err)) {
- # For unweighted fits we estimate a single value for sigma from the residuals
- err <- sd(object$data$residual)
- n_var_comp <- 1 # Number of variance components estimated
- } else {
- err <- object$data$err
- # For weighted fits we check for variance models used in IRLS
- # If the variance values (err) were given and were not
- # reweighted, the number of variance components estimated is zero
- if (is.null(object$reweight.method)) {
- n_var_comp <- 0
- } else {
- n_var_comp <- switch(object$reweight.method,
- obs = length(object$var_ms_unweighted),
- tc = 2)
- }
- }
- prob_dens <- dnorm(y_ij, yhat_ij, err)
- val <- log(prod(prob_dens))
- class(val) <- "logLik"
- attr(val, "df") <- length(coef(object)) + n_var_comp
+ val <- object$logLik
+ # Number of estimated parameters
+ attr(val, "df") <- length(object$bparms.optim) + length(object$errparms)
return(val)
}
# vim: set ts=2 sw=2 expandtab:

Contact - Imprint