Note how the addition increases the estimate for males because the dataset did not contain a sufficient number of young males which the number of females seems sufficient because females mature older in this species.
+
plot_maturity(survey_ghl, length = "age", length.unit = "years",
xlab = "Age", length.bin.width = 1,
force.zero.group.length = 0,
@@ -228,117 +222,133 @@ Simple plot using log-transformation and linear models by default.
-
+
plot_lw(survey_ghl, length = "length", weight = "weight")
#> $plot
-#>
-#> $text
-#> [1] "Logarithm transformed linear length-weight model. Not splitted by sex: \n a = 0 +/- 0 - 0 (95% CIs). \n b = 3.221 +/- 3.22 - 3.22 (95% CIs). \n Number of included specimens = 67457 \n Total number of measured = 618779 \n Excluded (data missing): \n Length = 0; weight = 551322"
-#>
-#> $params
-#> # A tibble: 2 × 7
-#> term estimate std.error statistic p.value conf.low conf.high
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 a 0.00000382 0.00491 -2540. 0 0.00000379 0.00000386
-#> 2 b 3.22 0.00128 2519. 0 3.22 3.22
+#>
+#> $text
+#> [1] "Logarithm transformed linear length-weight model. Not splitted by sex: \n a = 3.8236e-06 +/- 3.7869e-06 - 3.8606e-06 (95% CIs). \n b = 3.221 +/- 3.22 - 3.22 (95% CIs). \n Length in cm and weight in kg \n Number of included specimens = 67457 \n Total number of measured = 618779 \n Excluded (data missing): \n Length = 0; weight = 551322; outlier = 0"
+#>
+#> $params
+#> # A tibble: 2 × 14
+#> term estimate std.error statistic p.value conf.low conf.high r.squared
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 a 0.00000382 0.00491 -2540. 0 0.00000379 0.00000386 0.989
+#> 2 b 3.22 0.00128 2519. 0 3.22 3.22 0.989
+#> # ℹ 6 more variables: AIC <dbl>, nobs <int>, length <chr>, length.unit <chr>,
+#> # weight <chr>, weight.unit <chr>
The dashed lines represent 95% confidence intervals.
Non-linear least square models
Use non-linear least squares instead:
-
+
plot_lw(survey_ghl, use.nls = TRUE)
#> $plot
-#>
-#> $text
-#> [1] "Nonlinear least squares length-weight model. Not splitted by sex: \n a = 0 +/- 0 - 0 (95% CIs). \n b = 3.419 +/- 3.42 - 3.42 (95% CIs). \n Number of included specimens = 67457 \n Total number of measured = 618779 \n Excluded (data missing): \n Length = 0; weight = 551322"
-#>
-#> $params
-#> # A tibble: 2 × 7
-#> term estimate std.error statistic p.value conf.low conf.high
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 a 0.00000173 0.0000000156 110. 0 0.00000170 0.00000176
-#> 2 b 3.42 0.00215 1590. 0 3.42 3.42
+#>
+#> $text
+#> [1] "Nonlinear least squares length-weight model. Not splitted by sex: \n a = 1.7268e-06 +/- 1.6962e-06 - 1.758e-06 (95% CIs). \n b = 3.419 +/- 3.42 - 3.42 (95% CIs). \n Length in cm and weight in kg \n Number of included specimens = 67457 \n Total number of measured = 618779 \n Excluded (data missing): \n Length = 0; weight = 551322; outlier = 0"
+#>
+#> $params
+#> # A tibble: 2 × 13
+#> term estimate std.error statistic p.value conf.low conf.high AIC nobs
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
+#> 1 a 0.00000173 1.56e-8 110. 0 1.70e-6 1.76e-6 -27925. 67457
+#> 2 b 3.42 2.15e-3 1590. 0 3.42e+0 3.42e+0 -27925. 67457
+#> # ℹ 4 more variables: length <chr>, length.unit <chr>, weight <chr>,
+#> # weight.unit <chr>
Split by sex
The decimal point of a and b estimates depends on the length and weight units. FishBase uses centimeters and grams. The function can correct for the units when asked (but length.unit
and weight.unit
parameters have to be defined correctly).
-
+
plot_lw(survey_ghl, split.by.sex = TRUE, correct.units = TRUE)
#> $plot
-#>
-#> $text
-#> [1] "Logarithm transformed linear length-weight model for females and males, respectively: \n a = 0.0035 +/- 0.003 - 0.004 (95% CIs) and 0.0051 +/- 0.005 - 0.005 (95% CIs). \n b = 3.247 +/- 3.24 - 3.25 (95% CIs) and 3.143 +/- 3.14 - 3.15 (95% CIs). \n Number of included specimens = 34889 and 30354 \n Total number of measured = 618779 \n Excluded (data missing): \n Length = 0; weight = 456891; sex = 96645"
-#>
-#> $params
-#> # A tibble: 4 × 8
-#> sex term estimate std.error statistic p.value conf.low conf.high
-#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 F a 0.00350 0.00765 -739. 0 0.00344 0.00355
-#> 2 F b 3.25 0.00195 1666. 0 3.24 3.25
-#> 3 M a 0.00507 0.0101 -525. 0 0.00497 0.00517
-#> 4 M b 3.14 0.00265 1188. 0 3.14 3.15
+#>
+#> $text
+#> [1] "Logarithm transformed linear length-weight model for females and males, respectively: \n a = 0.0035 +/- 0.00344 - 0.00355 (95% CIs) and 0.00507 +/- 0.00497 - 0.00517 (95% CIs). \n b = 3.247 +/- 3.24 - 3.25 (95% CIs) and 3.143 +/- 3.14 - 3.15 (95% CIs). \n Length in cm and weight in g \n Number of included specimens = 34889 and 30354 \n Total number of measured = 618779 \n Excluded (data missing): \n Length = 0; weight = 456891; sex = 96645; outlier = 0"
+#>
+#> $params
+#> # A tibble: 4 × 15
+#> # Groups: sex [2]
+#> sex term estimate std.error statistic p.value conf.low conf.high r.squared
+#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 F a 0.00350 0.00765 -739. 0 0.00344 0.00355 0.988
+#> 2 F b 3.25 0.00195 1666. 0 3.24 3.25 0.988
+#> 3 M a 0.00507 0.0101 -525. 0 0.00497 0.00517 0.979
+#> 4 M b 3.14 0.00265 1188. 0 3.14 3.15 0.979
+#> # ℹ 6 more variables: AIC <dbl>, nobs <int>, length <chr>, length.unit <chr>,
+#> # weight <chr>, weight.unit <chr>
You can also transform the parameters according to the formulas given in the FishBase.
-
+
plot_lw(survey_ghl %>% dplyr::mutate(weight = weight*1000), weight.unit = "g")$params
-#> # A tibble: 2 × 7
-#> term estimate std.error statistic p.value conf.low conf.high
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 a 0.00382 0.00491 -1133. 0 0.00379 0.00386
-#> 2 b 3.22 0.00128 2519. 0 3.22 3.22
+#> # A tibble: 2 × 14
+#> term estimate std.error statistic p.value conf.low conf.high r.squared
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 a 0.00382 0.00491 -1133. 0 0.00379 0.00386 0.989
+#> 2 b 3.22 0.00128 2519. 0 3.22 3.22 0.989
+#> # ℹ 6 more variables: AIC <dbl>, nobs <int>, length <chr>, length.unit <chr>,
+#> # weight <chr>, weight.unit <chr>
Log-log axes to see differences
-
+
plot_lw(survey_ghl, split.by.sex = TRUE, log.axes = TRUE)$plot
+
+
Outlier removal
+
+
+plot_lw(survey_ghl, outlier.percentile = 99.5, annotate.coefficients = TRUE)$plot
+
+
Catch curves to estimate instantaneous total mortality (Z)
Catch curves were added to the version 0.2.3 and may not be available in the CRAN version. A FishR tutorial written by Ogle (2013) contains a nice explanation of catch curves. At the time of writing ggFishPlots calculates only the simple log-linearised regression.
-
+
-
-#>
-#> $text
-#> [1] "Instantenous total mortality (Z) estimated using a catch curve and\nage range .\n\nZ = 0.19 (0.123-0.257 95% CIs)\nN at age 0 = 1448 (449-4674 95% CIs)\nLongevity = 38.3 years (23.8 - 68.8 95% CIs)\n\n"
-#>
-#> $params
-#> # A tibble: 2 × 8
-#> sex term estimate std.error statistic p.value conf.low conf.high
-#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 both (Intercept) 7.28 0.573 12.7 2.25e-13 6.11 8.45
-#> 2 both age -0.190 0.0328 -5.79 2.85e- 6 -0.257 -0.123
+
+#>
+#> $text
+#> [1] "Instantenous total mortality (Z) estimated using a catch curve and\nage range .\n\nZ = 0.19 (0.123-0.257 95% CIs)\nN at age 0 = 1448 (449-4674 95% CIs)\nLongevity = 38.3 years (23.8 - 68.8 95% CIs)\n\n"
+#>
+#> $params
+#> # A tibble: 2 × 8
+#> sex term estimate std.error statistic p.value conf.low conf.high
+#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 both (Intercept) 7.28 0.573 12.7 2.25e-13 6.11 8.45
+#> 2 both age -0.190 0.0328 -5.79 2.85e- 6 -0.257 -0.123
The ages to be included to the Z estimation can be adjusted using the age.range
argument.
-
+
-
+
In the plot above, -b is Z (i.e. Z = 0.356) and exp(a) (i.e. 68391) is the number of 0 age fish assuming constant mortality.
Split by sex
-
+
-
+
Use a named list to use separate age ranges for females and males.
-
+
tmp <- plot_catchcurve(survey_ghl,
age.range = list("F" = c(13,26), "M" = c(10,26)),
split.by.sex = TRUE)
tmp$plot
-
+
Parameter estimates for the catch curve above:
-
+
Instantenous total mortality (Z) estimated using a catch curve and
age range for females and for males.
@@ -357,22 +367,21 @@ The data used in the package are a property of the Institute of Marine Research and the Norwegian Government. They are distributed under the Creative Commons (CCBY or NLOD) licenses allowing free use as long as the source (IMR) is cited. We ask any user to refer to the package if plots or estimates are used in reports or scientific articles. For up-to-date citation information, please use:
-
+
citation("ggFishPlots")
-#>
#> To cite package 'ggFishPlots' in publications use:
#>
-#> Vihtakari M (2023). _ggFishPlots: Visualise and Calculate Life
+#> Vihtakari M (2024). _ggFishPlots: Visualise and Calculate Life
#> History Parameters for Fisheries Science using 'ggplot2'_. R package
-#> version 0.2.4, <https://deepwaterimr.github.io/ggFishPlots/>.
+#> version 0.2.7, <https://deepwaterimr.github.io/ggFishPlots/>.
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> title = {ggFishPlots: Visualise and Calculate Life History Parameters for Fisheries Science using 'ggplot2'},
#> author = {Mikko Vihtakari},
-#> year = {2023},
-#> note = {R package version 0.2.4},
+#> year = {2024},
+#> note = {R package version 0.2.7},
#> url = {https://deepwaterimr.github.io/ggFishPlots/},
#> }
@@ -417,6 +426,7 @@ Developers
Dev status
@@ -427,13 +437,11 @@
Dev status
diff --git a/docs/pkgdown.js b/docs/pkgdown.js
index 5fccd9c..9bd6621 100644
--- a/docs/pkgdown.js
+++ b/docs/pkgdown.js
@@ -30,10 +30,10 @@
/* Clipboard --------------------------*/
function changeTooltipMessage(element, msg) {
- var tooltipOriginalTitle=element.getAttribute('data-original-title');
- element.setAttribute('data-original-title', msg);
+ var tooltipOriginalTitle=element.getAttribute('data-bs-original-title');
+ element.setAttribute('data-bs-original-title', msg);
$(element).tooltip('show');
- element.setAttribute('data-original-title', tooltipOriginalTitle);
+ element.setAttribute('data-bs-original-title', tooltipOriginalTitle);
}
if(ClipboardJS.isSupported()) {
@@ -60,7 +60,7 @@
e.clearSelection();
});
- clipboard.on('error', function() {
+ clipboard.on('error', function(e) {
changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy');
});
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 8c384ac..eb728e6 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -1,6 +1,6 @@
-pandoc: 2.19.2
-pkgdown: 2.0.7
+pandoc: '3.2'
+pkgdown: 2.0.9
pkgdown_sha: ~
articles: {}
-last_built: 2023-03-23T16:54Z
+last_built: 2024-06-26T09:45Z
diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png
index 849f4cb..cffc43b 100644
Binary files a/docs/reference/Rplot001.png and b/docs/reference/Rplot001.png differ
diff --git a/docs/reference/Rplot002.png b/docs/reference/Rplot002.png
index 140d84d..6a3ba11 100644
Binary files a/docs/reference/Rplot002.png and b/docs/reference/Rplot002.png differ
diff --git a/docs/reference/Rplot003.png b/docs/reference/Rplot003.png
index 78285b0..be9f6de 100644
Binary files a/docs/reference/Rplot003.png and b/docs/reference/Rplot003.png differ
diff --git a/docs/reference/Rplot004.png b/docs/reference/Rplot004.png
index 609668c..2124f34 100644
Binary files a/docs/reference/Rplot004.png and b/docs/reference/Rplot004.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-10-1.png b/docs/reference/figures/README-unnamed-chunk-10-1.png
index 11738da..de1deeb 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-10-1.png and b/docs/reference/figures/README-unnamed-chunk-10-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-11-1.png b/docs/reference/figures/README-unnamed-chunk-11-1.png
index c738442..38deb1a 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-11-1.png and b/docs/reference/figures/README-unnamed-chunk-11-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-12-1.png b/docs/reference/figures/README-unnamed-chunk-12-1.png
index 6ae5b46..58eaf8c 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-12-1.png and b/docs/reference/figures/README-unnamed-chunk-12-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-15-1.png b/docs/reference/figures/README-unnamed-chunk-15-1.png
index a90eaa9..82fa412 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-15-1.png and b/docs/reference/figures/README-unnamed-chunk-15-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-17-1.png b/docs/reference/figures/README-unnamed-chunk-17-1.png
index 126dfe7..9aa86cd 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-17-1.png and b/docs/reference/figures/README-unnamed-chunk-17-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-18-1.png b/docs/reference/figures/README-unnamed-chunk-18-1.png
index 3160178..afb18dc 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-18-1.png and b/docs/reference/figures/README-unnamed-chunk-18-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-19-1.png b/docs/reference/figures/README-unnamed-chunk-19-1.png
index 272044e..3160178 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-19-1.png and b/docs/reference/figures/README-unnamed-chunk-19-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-20-1.png b/docs/reference/figures/README-unnamed-chunk-20-1.png
index d8ee5aa..272044e 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-20-1.png and b/docs/reference/figures/README-unnamed-chunk-20-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-21-1.png b/docs/reference/figures/README-unnamed-chunk-21-1.png
index 9fbf153..d8ee5aa 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-21-1.png and b/docs/reference/figures/README-unnamed-chunk-21-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-22-1.png b/docs/reference/figures/README-unnamed-chunk-22-1.png
new file mode 100644
index 0000000..9fbf153
Binary files /dev/null and b/docs/reference/figures/README-unnamed-chunk-22-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-5-1.png b/docs/reference/figures/README-unnamed-chunk-5-1.png
index e76de10..8701907 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-5-1.png and b/docs/reference/figures/README-unnamed-chunk-5-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-7-1.png b/docs/reference/figures/README-unnamed-chunk-7-1.png
index 9e24668..51a8fa8 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-7-1.png and b/docs/reference/figures/README-unnamed-chunk-7-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-8-1.png b/docs/reference/figures/README-unnamed-chunk-8-1.png
index 261a6e5..9d1f4ba 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-8-1.png and b/docs/reference/figures/README-unnamed-chunk-8-1.png differ
diff --git a/docs/reference/figures/README-unnamed-chunk-9-1.png b/docs/reference/figures/README-unnamed-chunk-9-1.png
index 6cf8468..dd2ae43 100644
Binary files a/docs/reference/figures/README-unnamed-chunk-9-1.png and b/docs/reference/figures/README-unnamed-chunk-9-1.png differ
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 3f7257f..d2731c0 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -1,16 +1,16 @@
-
Function reference • ggFishPlotsFunction reference • ggFishPlots
Skip to contents
-