--- title: "Problem 8.6c" author: "Prof. Eric A. Suess" format: html: self-contained: true --- ## Problem 8.6c ```{r} library(fitdistrplus) ``` The data Simulate $n$ Bernoulli random values with $p = 0.45$. For the function *fitdist()* to work, we need to have more than one data value. So one Binomial value is $n$ Bernoulli values. ```{r} n <- 1200 size <- 1 prob <- 0.45 x <- rbinom(n, size = size, prob = prob) head(x) ``` plot the data ```{r} plotdist(x, discrete = TRUE, demp = TRUE) ``` fit the data to a binomial distribution to the sample of $n$ Bernoulli values. ```{r} fit.binom <- fitdist(data = x, dist = "binom", method = "mle", fix.arg = list(size = size), start = list(prob=0.1)) summary(fit.binom) ``` ```{r} plot(fit.binom) ``` compare ```{r} denscomp(list(fit.binom), legendtext = c("binomial")) ``` plot the log-likelihood ```{r} llplot(fit.binom) ```