A laboratory is interested in testing a new child friendly pesticide on Blatta orientalis (oriental cockroaches). Scientists apply the new pesticide to 81 randomly selected Blatta orientalis oothecae (eggs). The results from the experiment are stored in the data frame ROACHEGGS
in the variable eggs
. A zero in the variable eggs
indicates that nothing hatched from the egg while a 1 indicates the birth of a cockroach.
ROACHEGGS
A data frame with 81 observations on the following variable:
eggs
(numeric vector where a 0 indicates nothing hatched while a 1 indicates the birth of a cockroach.)
Ugarte, M. D., Militino, A. F., and Arnholt, A. T. 2015. Probability and Statistics with R, Second Edition. Chapman & Hall / CRC.
p <- seq(0.1, 0.9, 0.001)
negloglike <- function(p){
-(sum(ROACHEGGS$eggs)*log(p) + sum(1-ROACHEGGS$eggs)*log(1-p))
}
nlm(negloglike, .2)
#> Warning: NaNs produced
#> Warning: NA/Inf replaced by maximum positive value
#> $minimum
#> [1] 41.61724
#>
#> $estimate
#> [1] 0.209876
#>
#> $gradient
#> [1] 1.421085e-08
#>
#> $code
#> [1] 1
#>
#> $iterations
#> [1] 4
#>
rm(p, negloglike)