From 3621588c04cbaa393ba62c97137f6aec746d114f Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 26 Nov 2018 09:09:43 +0100 Subject: Support logLik and AIC for manual weights Static documentation rebuilt by pkgdown --- R/logLik.mkinfit.R | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'R') diff --git a/R/logLik.mkinfit.R b/R/logLik.mkinfit.R index c30cc099..d3f4232d 100644 --- a/R/logLik.mkinfit.R +++ b/R/logLik.mkinfit.R @@ -19,12 +19,21 @@ 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 - if (object$reweight.method == "obs") n_var_comp <- length(object$var_ms_unweighted) - else n_var_comp <- 2 + # 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)) -- cgit v1.2.1