--- title: "Problem 46: Bowhead whale." author: "Prof. Eric A. Suess" format: html: self-contained: true --- ## Problem 46: Bowhead whale. ```{r} library(readr) whale <- read_csv("~/classes/2023-2024/Fall 2023/Stat640/website/_homework/mle/whale/whale.csv") head(whale) ``` convert the data_frame to a vector The fitdistrplus package expects a vector as input. ```{r} whale <- whale$times whale ``` ```{r} library(fitdistrplus) ``` ```{r} plotdist(whale, histo = TRUE, demp = TRUE) ``` fit gamma using MME and MLE ```{r} fit.gamma.mme <- fitdist(whale, "gamma", method = "mme") summary(fit.gamma.mme) fit.gamma.mle <- fitdist(whale, "gamma", method = "mle") summary(fit.gamma.mle) ``` plot the log-likelihood ```{r} llplot(fit.gamma.mle) llplot(fit.gamma.mle, expansion = 2) ``` compare ```{r} denscomp(list(fit.gamma.mme, fit.gamma.mle), legendtext = c("MME", "MLE")) ``` ```{r} cdfcomp(list(fit.gamma.mme, fit.gamma.mle), legendtext = c("MME", "MLE")) qqcomp(list(fit.gamma.mme, fit.gamma.mle), legendtext = c("MME", "MLE")) ``` bootstrap the MME ```{r} b1 <- bootdist(fit.gamma.mme, niter=101) print(b1) ``` ```{r} plot(b1) ``` ```{r} hist(b1$estim$shape) hist(b1$estim$rate) ``` ```{r} summary(b1) ``` bootstrap the MLE ```{r} b2 <- bootdist(fit.gamma.mle, niter=101) print(b2) ``` ```{r} hist(b2$estim$shape) hist(b2$estim$rate) ``` ```{r}) plot(b2) ``` ```{r} summary(b2) ```