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.3 From f6385b071cee2c261da28bf98fd1599da1a30ddb Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 13 Nov 2019 11:05:39 +0100 Subject: Likelihood ratio test for mmkin columns with two fits --- NAMESPACE | 1 + R/lrtest.mkinfit.R | 5 ++--- docs/reference/index.html | 2 +- docs/reference/lrtest.mkinfit.html | 8 ++++++-- man/lrtest.mkinfit.Rd | 6 +++++- 5 files changed, 15 insertions(+), 7 deletions(-) (limited to 'R/lrtest.mkinfit.R') diff --git a/NAMESPACE b/NAMESPACE index f428a612..e561621b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,6 +7,7 @@ S3method(confint,mkinfit) S3method(loftest,mkinfit) S3method(logLik,mkinfit) S3method(lrtest,mkinfit) +S3method(lrtest,mmkin) S3method(mkinpredict,mkinfit) S3method(mkinpredict,mkinmod) S3method(nobs,mkinfit) diff --git a/R/lrtest.mkinfit.R b/R/lrtest.mkinfit.R index 380cf3a5..0054ea88 100644 --- a/R/lrtest.mkinfit.R +++ b/R/lrtest.mkinfit.R @@ -18,10 +18,9 @@ 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 An \code{\link{mkinfit}} object, or an \code{\link{mmkin}} column +#' object containing two fits to the same data. #' @param object_2 Optionally, another mkinfit object fitted to the same data. #' @param \dots Argument to \code{\link{mkinfit}}, passed to #' \code{\link{update.mkinfit}} for creating the alternative fitted object. diff --git a/docs/reference/index.html b/docs/reference/index.html index 0947ff94..4398469b 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -209,7 +209,7 @@ more datasets

-

lrtest(<mkinfit>)

+

lrtest(<mkinfit>) lrtest(<mmkin>)

Likelihood ratio test for mkinfit models

diff --git a/docs/reference/lrtest.mkinfit.html b/docs/reference/lrtest.mkinfit.html index 1d82eb74..70157db9 100644 --- a/docs/reference/lrtest.mkinfit.html +++ b/docs/reference/lrtest.mkinfit.html @@ -145,14 +145,18 @@ and can be expressed by fixing the parameters of the other.

# S3 method for mkinfit
-lrtest(object, object_2 = NULL, ...)
+lrtest(object, object_2 = NULL, ...) + +# S3 method for mmkin +lrtest(object, ...)

Arguments

- + diff --git a/man/lrtest.mkinfit.Rd b/man/lrtest.mkinfit.Rd index bc8ab4dc..84d7bc99 100644 --- a/man/lrtest.mkinfit.Rd +++ b/man/lrtest.mkinfit.Rd @@ -2,12 +2,16 @@ % Please edit documentation in R/lrtest.mkinfit.R \name{lrtest.mkinfit} \alias{lrtest.mkinfit} +\alias{lrtest.mmkin} \title{Likelihood ratio test for mkinfit models} \usage{ \method{lrtest}{mkinfit}(object, object_2 = NULL, ...) + +\method{lrtest}{mmkin}(object, ...) } \arguments{ -\item{object}{An \code{\link{mkinfit}} object} +\item{object}{An \code{\link{mkinfit}} object, or an \code{\link{mmkin}} column +object containing two fits to the same data.} \item{object_2}{Optionally, another mkinfit object fitted to the same data.} -- cgit v1.2.3 From 68eed166cbe10a5ee79f5b1139261dea98234b22 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 18 Mar 2020 16:16:18 +0100 Subject: Clarify comment in example code --- R/lrtest.mkinfit.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'R/lrtest.mkinfit.R') diff --git a/R/lrtest.mkinfit.R b/R/lrtest.mkinfit.R index 0054ea88..c3f4d38e 100644 --- a/R/lrtest.mkinfit.R +++ b/R/lrtest.mkinfit.R @@ -37,7 +37,7 @@ lmtest::lrtest #' #lrtest(dfop_fit, error_model = "tc") #' #lrtest(dfop_fit, fixed_parms = c(k2 = 0)) #' -#' # However, this equivalent syntax works for static help pages +#' # However, this equivalent syntax also works for static help pages #' lrtest(dfop_fit, update(dfop_fit, error_model = "tc")) #' lrtest(dfop_fit, update(dfop_fit, fixed_parms = c(k2 = 0))) #' } -- cgit v1.2.3
object

An mkinfit object

An mkinfit object, or an mmkin column +object containing two fits to the same data.

object_2