diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2019-11-04 17:21:04 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2019-11-04 17:29:48 +0100 |
commit | 31fd7412f46c9715962763d435cb0060ea420752 (patch) | |
tree | 771183a2c729131e7364f0a41dae967f73dc150e | |
parent | 0220b25f01a4451fa44a7b2f30f5849c4d822a9c (diff) |
Include fixed parameters in model names in lrtest
-rw-r--r-- | NEWS.md | 4 | ||||
-rw-r--r-- | R/confint.mkinfit.R | 8 | ||||
-rw-r--r-- | R/lrtest.mkinfit.R | 18 | ||||
-rw-r--r-- | docs/news/index.html | 5 | ||||
-rw-r--r-- | docs/reference/confint.mkinfit.html | 20 | ||||
-rw-r--r-- | docs/reference/lrtest.mkinfit.html | 30 | ||||
-rw-r--r-- | man/confint.mkinfit.Rd | 8 | ||||
-rw-r--r-- | man/lrtest.mkinfit.Rd | 8 |
8 files changed, 68 insertions, 33 deletions
@@ -1,6 +1,8 @@ # mkin 0.9.49.8 (unreleased) -- 'confint.mkinfit': Make the quadratic approximation the default, as the likelihood profiling takes too much time for any with more than three parameters +- 'lrtest.mkinfit': Improve naming of the compared fits in the case of fixed parameters + +- 'confint.mkinfit': Make the quadratic approximation the default, as the likelihood profiling takes a lot of time, especially if the fit has more than three parameters # mkin 0.9.49.7 (2019-11-01) diff --git a/R/confint.mkinfit.R b/R/confint.mkinfit.R index 84183808..78dda95d 100644 --- a/R/confint.mkinfit.R +++ b/R/confint.mkinfit.R @@ -4,10 +4,10 @@ #' the curvature of the likelihood function at the maximum likelihood parameter #' estimates. #' The alternative method 'profile' is based on the profile likelihood for each -#' parameter. The method uses two nested optimisations and can take a very long -#' time, even if parallelized by specifying 'cores' on unixoid platforms. The -#' speed of the method could likely be improved by using the method of Venzon -#' and Moolgavkar (1988). +#' parameter. The 'profile' method uses two nested optimisations and can take a +#' very long time, even if parallelized by specifying 'cores' on unixoid +#' platforms. The speed of the method could likely be improved by using the +#' method of Venzon and Moolgavkar (1988). #' #' @param object An \code{\link{mkinfit}} object #' @param parm A vector of names of the parameters which are to be given diff --git a/R/lrtest.mkinfit.R b/R/lrtest.mkinfit.R index 60b6c46a..a5689830 100644 --- a/R/lrtest.mkinfit.R +++ b/R/lrtest.mkinfit.R @@ -30,17 +30,27 @@ lmtest::lrtest #' dfop_fit <- mkinfit("DFOP", test_data, quiet = TRUE) #' lrtest(dfop_fit, sfo_fit) #' lrtest(sfo_fit, dfop_fit) -#' +#' #' # The following two examples are commented out as they fail during #' # generation of the static help pages by pkgdown -#' # lrtest(dfop_fit, error_model = "tc") -#' # lrtest(dfop_fit, fixed_parms = c(k2 = 0)) +#' #lrtest(dfop_fit, error_model = "tc") +#' #lrtest(dfop_fit, fixed_parms = c(k2 = 0)) +#' +#' # However, this equivalent syntax 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))) #' } #' @export lrtest.mkinfit <- function(object, object_2 = NULL, ...) { name_function <- function(x) { - paste(x$mkinmod$name, "with error model", x$err_mod) + object_name <- paste(x$mkinmod$name, "with error model", x$err_mod) + if (length(x$bparms.fixed) > 0) { + object_name <- paste(object_name, + "and fixed parameter(s)", + paste(names(x$bparms.fixed), collapse = ", ")) + } + return(object_name) } if (is.null(object_2)) { diff --git a/docs/news/index.html b/docs/news/index.html index baddfc96..5aef06f9 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -134,12 +134,13 @@ <a href="#mkin-0-9-49-8-unreleased" class="anchor"></a>mkin 0.9.49.8 (unreleased)<small> Unreleased </small> </h1> <ul> -<li>‘confint.mkinfit’: Make the quadratic approximation the default, as the likelihood profiling takes too much time for any with more than three parameters</li> +<li><p>‘lrtest.mkinfit’: Improve naming of the compared fits in the case of fixed parameters</p></li> +<li><p>‘confint.mkinfit’: Make the quadratic approximation the default, as the likelihood profiling takes a lot of time, especially if the fit has more than three parameters</p></li> </ul> </div> <div id="mkin-0-9-49-7-2019-11-01" class="section level1"> <h1 class="page-header"> -<a href="#mkin-0-9-49-7-2019-11-01" class="anchor"></a>mkin 0.9.49.7 (2019-11-01)<small> Unreleased </small> +<a href="#mkin-0-9-49-7-2019-11-01" class="anchor"></a>mkin 0.9.49.7 (2019-11-01)<small> 2019-11-02 </small> </h1> <ul> <li><p>Fix a bug introduced in 0.9.49.6 that occurred if the direct optimisation yielded a higher likelihood than the three-step optimisation in the d_3 algorithm, which caused the fitted parameters of the three-step optimisation to be returned instead of the parameters of the direct optimisation</p></li> diff --git a/docs/reference/confint.mkinfit.html b/docs/reference/confint.mkinfit.html index 13662adf..ea69c3bb 100644 --- a/docs/reference/confint.mkinfit.html +++ b/docs/reference/confint.mkinfit.html @@ -40,10 +40,10 @@ the curvature of the likelihood function at the maximum likelihood parameter estimates. The alternative method 'profile' is based on the profile likelihood for each -parameter. The method uses two nested optimisations and can take a very long -time, even if parallelized by specifying 'cores' on unixoid platforms. The -speed of the method could likely be improved by using the method of Venzon -and Moolgavkar (1988)." /> +parameter. The 'profile' method uses two nested optimisations and can take a +very long time, even if parallelized by specifying 'cores' on unixoid +platforms. The speed of the method could likely be improved by using the +method of Venzon and Moolgavkar (1988)." /> <meta name="twitter:card" content="summary" /> @@ -144,10 +144,10 @@ and Moolgavkar (1988)." /> the curvature of the likelihood function at the maximum likelihood parameter estimates. The alternative method 'profile' is based on the profile likelihood for each -parameter. The method uses two nested optimisations and can take a very long -time, even if parallelized by specifying 'cores' on unixoid platforms. The -speed of the method could likely be improved by using the method of Venzon -and Moolgavkar (1988).</p> +parameter. The 'profile' method uses two nested optimisations and can take a +very long time, even if parallelized by specifying 'cores' on unixoid +platforms. The speed of the method could likely be improved by using the +method of Venzon and Moolgavkar (1988).</p> </div> <pre class="usage"><span class='co'># S3 method for mkinfit</span> @@ -254,13 +254,13 @@ On Windows machines, cores > 1 is currently not supported.</p></td> <span class='kw'>use_of_ff</span> <span class='kw'>=</span> <span class='st'>"max"</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='no'>f_d_1</span> <span class='kw'><-</span> <span class='fu'><a href='mkinfit.html'>mkinfit</a></span>(<span class='no'>SFO_SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/subset.html'>subset</a></span>(<span class='no'>FOCUS_2006_D</span>, <span class='no'>value</span> <span class='kw'>!=</span> <span class='fl'>0</span>), <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='fu'><a href='https://rdrr.io/r/base/system.time.html'>system.time</a></span>(<span class='no'>ci_profile</span> <span class='kw'><-</span> <span class='fu'><a href='https://rdrr.io/r/stats/confint.html'>confint</a></span>(<span class='no'>f_d_1</span>, <span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"profile"</span>, <span class='kw'>cores</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>))</div><div class='output co'>#> User System verstrichen -#> 51.341 0.000 51.370 </div><div class='input'><span class='co'># Using more cores does not save much time here, as parent_0 takes up most of the time</span> +#> 51.058 0.000 51.088 </div><div class='input'><span class='co'># Using more cores does not save much time here, as parent_0 takes up most of the time</span> <span class='co'># If we additionally exclude parent_0 (the confidence of which is often of</span> <span class='co'># minor interest), we get a nice performance improvement from about 50</span> <span class='co'># seconds to about 12 seconds if we use at least four cores</span> <span class='fu'><a href='https://rdrr.io/r/base/system.time.html'>system.time</a></span>(<span class='no'>ci_profile_no_parent_0</span> <span class='kw'><-</span> <span class='fu'><a href='https://rdrr.io/r/stats/confint.html'>confint</a></span>(<span class='no'>f_d_1</span>, <span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"profile"</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"k_parent_sink"</span>, <span class='st'>"k_parent_m1"</span>, <span class='st'>"k_m1_sink"</span>, <span class='st'>"sigma"</span>), <span class='kw'>cores</span> <span class='kw'>=</span> <span class='no'>n_cores</span>))</div><div class='output co'>#> <span class='message'>Profiling the likelihood</span></div><div class='output co'>#> User System verstrichen -#> 0.001 0.007 11.432 </div><div class='input'><span class='no'>ci_profile</span></div><div class='output co'>#> 2.5% 97.5% +#> 0.005 0.004 11.349 </div><div class='input'><span class='no'>ci_profile</span></div><div class='output co'>#> 2.5% 97.5% #> parent_0 96.456003650 1.027703e+02 #> k_parent_sink 0.040762501 5.549764e-02 #> k_parent_m1 0.046786482 5.500879e-02 diff --git a/docs/reference/lrtest.mkinfit.html b/docs/reference/lrtest.mkinfit.html index fae471fc..1d82eb74 100644 --- a/docs/reference/lrtest.mkinfit.html +++ b/docs/reference/lrtest.mkinfit.html @@ -73,7 +73,7 @@ and can be expressed by fixing the parameters of the other." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.8</span> </span> </div> @@ -196,11 +196,29 @@ lower number of fitted parameters (null hypothesis).</p> #> 2 3 -63.954 -2 43.002 4.594e-10 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</div><div class='input'> -# The following two examples are commented out as they fail during -# generation of the static help pages by pkgdown -# lrtest(dfop_fit, error_model = "tc") -# lrtest(dfop_fit, fixed_parms = c(k2 = 0)) -# } +<span class='co'># The following two examples are commented out as they fail during</span> +<span class='co'># generation of the static help pages by pkgdown</span> +<span class='co'>#lrtest(dfop_fit, error_model = "tc")</span> +<span class='co'>#lrtest(dfop_fit, fixed_parms = c(k2 = 0))</span> + +<span class='co'># However, this equivalent syntax works for static help pages</span> +<span class='fu'><a href='https://rdrr.io/pkg/lmtest/man/lrtest.html'>lrtest</a></span>(<span class='no'>dfop_fit</span>, <span class='fu'><a href='https://rdrr.io/r/stats/update.html'>update</a></span>(<span class='no'>dfop_fit</span>, <span class='kw'>error_model</span> <span class='kw'>=</span> <span class='st'>"tc"</span>))</div><div class='output co'>#> Likelihood ratio test +#> +#> Model 1: DFOP with error model tc +#> Model 2: DFOP with error model const +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 6 -34.587 +#> 2 5 -42.453 -1 15.731 7.302e-05 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/lmtest/man/lrtest.html'>lrtest</a></span>(<span class='no'>dfop_fit</span>, <span class='fu'><a href='https://rdrr.io/r/stats/update.html'>update</a></span>(<span class='no'>dfop_fit</span>, <span class='kw'>fixed_parms</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k2</span> <span class='kw'>=</span> <span class='fl'>0</span>)))</div><div class='output co'>#> Likelihood ratio test +#> +#> Model 1: DFOP with error model const +#> Model 2: DFOP with error model const and fixed parameter(s) k2 +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 5 -42.453 +#> 2 4 -57.340 -1 29.776 4.851e-08 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</div><div class='input'># } </div></pre> </div> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> diff --git a/man/confint.mkinfit.Rd b/man/confint.mkinfit.Rd index 60e82517..f2521ccd 100644 --- a/man/confint.mkinfit.Rd +++ b/man/confint.mkinfit.Rd @@ -52,10 +52,10 @@ The default method 'quadratic' is based on the quadratic approximation of the curvature of the likelihood function at the maximum likelihood parameter estimates. The alternative method 'profile' is based on the profile likelihood for each -parameter. The method uses two nested optimisations and can take a very long -time, even if parallelized by specifying 'cores' on unixoid platforms. The -speed of the method could likely be improved by using the method of Venzon -and Moolgavkar (1988). +parameter. The 'profile' method uses two nested optimisations and can take a +very long time, even if parallelized by specifying 'cores' on unixoid +platforms. The speed of the method could likely be improved by using the +method of Venzon and Moolgavkar (1988). } \examples{ f <- mkinfit("SFO", FOCUS_2006_C, quiet = TRUE) diff --git a/man/lrtest.mkinfit.Rd b/man/lrtest.mkinfit.Rd index c07d9868..bc8ab4dc 100644 --- a/man/lrtest.mkinfit.Rd +++ b/man/lrtest.mkinfit.Rd @@ -40,7 +40,11 @@ lrtest(sfo_fit, dfop_fit) # The following two examples are commented out as they fail during # generation of the static help pages by pkgdown -# lrtest(dfop_fit, error_model = "tc") -# lrtest(dfop_fit, fixed_parms = c(k2 = 0)) +#lrtest(dfop_fit, error_model = "tc") +#lrtest(dfop_fit, fixed_parms = c(k2 = 0)) + +# However, this equivalent syntax 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))) } } |