Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

library(tidyverse) chimp

library(tidyverse)

chimp <- read.csv("ChimpBrains.csv") summary(chimp) head(chimp)

cannibalism <- read.csv("SagebrushCrickets.csv") summary(cannibalism) head(cannibalism)

cannibalism$feedingStatus <- factor(cannibalism$feedingStatus , levels = c("starved", "fed"))

twoMedians <- tapply(cannibalism$timeToMating, cannibalism$feedingStatus, median)

diffMedian <- twoMedians[1] - twoMedians[2]

boot.diffMedian <- function(x, i){ twoMedians <- tapply(x$timeToMating[i], x$feedingStatus[i], median) diffMedian <- twoMedians[1] - twoMedians[2] }

Questions:

Now that we have the function above defined, go ahead and obtain the bootstrap replicate estimates on the data using the output bootResults and the function boot with the inputs into the boot function being cannibalism, and the function we just created, boot.diffMedian and run R=10000 for your bootstrap replicas. Comment on your Results from the observed difference in the medians

Plot the estimate of our sampling distribution using the ggplot function. Make your plot a histogram plot. Remember to put your data into a data.frame and within the data.frame apply the diffMedians=bootResults$t syntax. Label your x-axis Bootstrap replicate difference in median and label your y-axis Frequency. For aesthetics you can set your x=diffMedians and add the geom_histogram function. Color can be of any preference you choose, a binwidth=5 is fine, closed=left and set boundary=0

Calculate the bootstrap confidence interval using the function boot.ci and the inputs bootResults and type = perc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finite Mathematics and Its Applications

Authors: Larry J. Goldstein, David I. Schneider, Martha J. Siegel, Steven Hair

12th edition

ISBN: 978-0134768588, 9780134437767, 134768582, 134437764, 978-0134768632

More Books

Students also viewed these Mathematics questions