aboutsummaryrefslogtreecommitdiff
path: root/R/logLik.mkinfit.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2018-11-26 09:09:43 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2018-11-26 09:12:41 +0100
commit3621588c04cbaa393ba62c97137f6aec746d114f (patch)
treeb70b6a84fa28c8e71463f661b969f575e90220e8 /R/logLik.mkinfit.R
parent82bf34f1b0db8d202abf8cd4f5b6ce8b8aecfc1a (diff)
Support logLik and AIC for manual weights
Static documentation rebuilt by pkgdown
Diffstat (limited to 'R/logLik.mkinfit.R')
-rw-r--r--R/logLik.mkinfit.R13
1 files changed, 11 insertions, 2 deletions
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))

Contact - Imprint