From 7091d3738e7e55acb20edb88772b228f6f5b6c98 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 31 Oct 2019 01:55:01 +0100 Subject: Add likelihood ratio test and other methods, fixes The likelihood ratio test method is lrtest, in addition, methods for update and residuals were added. --- docs/reference/lrtest.mkinfit.html | 231 +++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 docs/reference/lrtest.mkinfit.html (limited to 'docs/reference/lrtest.mkinfit.html') diff --git a/docs/reference/lrtest.mkinfit.html b/docs/reference/lrtest.mkinfit.html new file mode 100644 index 00000000..dd47d91d --- /dev/null +++ b/docs/reference/lrtest.mkinfit.html @@ -0,0 +1,231 @@ + + + + + + + + +Likelihood ratio test for mkinfit models — lrtest.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Compare two mkinfit models based on their likelihood. If two fitted +mkinfit objects are given as arguments, it is checked if they have been +fitted to the same data. It is the responsibility of the user to make sure +that the models are nested, i.e. one of them has less degrees of freedom +and can be expressed by fixing the parameters of the other.

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

Arguments

+ + + + + + + + + + + + + + +
object

An mkinfit object

object_2

Optionally, another mkinfit object fitted to the same data.

...

Argument to mkinfit, passed to +update.mkinfit for creating the alternative fitted object.

+ +

Details

+ +

Alternatively, an argument to mkinfit can be given which is then passed +to update.mkinfit to obtain the alternative model.

+

The comparison is then made by the lrtest.default +method from the lmtest package. The model with the higher number of fitted +parameters (alternative hypothesis) is listed first, then the model with the +lower number of fitted parameters (null hypothesis).

+ +

Examples

+
# \dontrun{ +test_data <- subset(synthetic_data_for_UBA_2014[[12]]$data, name == "parent") +sfo_fit <- mkinfit("SFO", test_data, quiet = TRUE) +dfop_fit <- mkinfit("DFOP", test_data, quiet = TRUE) +lrtest(dfop_fit, sfo_fit)
#> Likelihood ratio test +#> +#> Model 1: DFOP with error model const +#> Model 2: SFO with error model const +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 5 -42.453 +#> 2 3 -63.954 -2 43.002 4.594e-10 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lrtest(sfo_fit, dfop_fit)
#> Likelihood ratio test +#> +#> Model 1: DFOP with error model const +#> Model 2: SFO with error model const +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 5 -42.453 +#> 2 3 -63.954 -2 43.002 4.594e-10 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lrtest(dfop_fit, error_model = "tc")
#> Error in mkinfit(mkinmod = "DFOP", observed = test_data, quiet = TRUE, error_model = "tc", parms.ini = c(k1 = 0.359673923258109, k2 = 0.0219997339436148, g = 0.692423284341522), state.ini = c(parent = 103.83323992643)): Objekt 'test_data' nicht gefunden
lrtest(dfop_fit, fixed_parms = c(k2 = 0))
#> Error in mkinfit(mkinmod = "DFOP", observed = test_data, quiet = TRUE, fixed_parms = ..1, parms.ini = c(k1 = 0.359673923258109, k2 = 0.0219997339436148, g = 0.692423284341522), state.ini = c(parent = 103.83323992643)): Objekt 'test_data' nicht gefunden
# } +
+
+ +
+ + + +
+ + + + + + + + -- cgit v1.2.1