From 6064a205d42220062506b11d6334b4f8e3217041 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 12 Nov 2019 15:16:28 +0100 Subject: lrtest method for mmkin columns with two fits --- R/lrtest.mkinfit.R | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'R/lrtest.mkinfit.R') diff --git a/R/lrtest.mkinfit.R b/R/lrtest.mkinfit.R index a5689830..380cf3a5 100644 --- a/R/lrtest.mkinfit.R +++ b/R/lrtest.mkinfit.R @@ -18,6 +18,8 @@ lmtest::lrtest #' parameters (alternative hypothesis) is listed first, then the model with the #' lower number of fitted parameters (null hypothesis). #' +#' The method for mmkin objects only works for column objects with two members. +#' #' @importFrom stats logLik update #' @param object An \code{\link{mkinfit}} object #' @param object_2 Optionally, another mkinfit object fitted to the same data. @@ -68,3 +70,10 @@ lrtest.mkinfit <- function(object, object_2 = NULL, ...) { lmtest::lrtest.default(object_2, object, name = name_function) } } + +#' @rdname lrtest.mkinfit +#' @export +lrtest.mmkin <- function(object, ...) { + if (nrow(object) != 2 | ncol(object) > 1) stop("Only works for a column containing two mkinfit objects") + lrtest(object[[1, 1]], object[[2, 1]]) +} -- cgit v1.2.1