Po visits the Panda Village. He captures 10 pandas and marks their butts with paint.
A week later he returns to the village and captures 15 pandas. Five of these 15 pandas have paint on their butts, indicating that they are recaptured pandas.
Can you guess/estimate the total numbers of pandas in the Panda Village?
Poll:
\(N=20\) 🐼
\(N=30\) 🐼
\(N=40\) 🐼
Based on maximum likelihoodk, what N would you pick if you recapture 4, 5 or 6 pandas?
hyperLik <- function(N,M,n,m){dhyper(m,M,N-M,n)}
possibleN <- 20:40
likelihoods <- hyperLik(possibleN, 10, 15, 5)
plot(possibleN,likelihoods,
type="l",
ylab="Likelihood",
xlab="N",
main = "Likelihood of N")
For more information aobut Mark and recapture, you may read Wikipedia: Mark and recapture.
Go though LabAssignment3.pdf
LabAssignment3.pdf
Download and open LabAssignment3.Rmd
LabAssignment3.Rmd in RStudio and run codes inside. Things should be exactly same as LabAssignment3.pdf
.
Download, open LabAssignment3_otg.Rmd
LabAssignment3_jp.Rmd and save as a new Rmd file for your own Lab Assignment submission. Knit this Rmd file to see if you can make a html, pdf or words. If you couldn’t, just use RStudio Cloud or the Binder RStudio set by Po.
Run/add/edit/delete the codes in your own copy of LabAssignment3_jp.Rmd
and add/edit/delete some writings. Knit to see how the .pdf looks like. Tidy up the codes and writings. Knit and submit!
Read the R Documentation of the functions you learn today. Enter the following codes, one by one, and read the corresponding documentation/help in the Help tab.
?dhyper
?plot
?which.max
?read.table
?c
?head
?mean
?sd
?summary
?hist
?table
?mosaicplot
?boxplot
?aggregate
How Po knows all those built-in functions in R?
Way 1: Google it
Way 2: Read R Help/Documentation
There is no secret ingredient. – Mr. Ping 🍜
Interactive R course lessons swirl https://swirlstats.com/students.html
Install swirl with the following commands.
# If you haven't installed the swirl package yet
install.packages("swirl")
library(swirl)
install_course_github("swirldev", "R_Programming_E")
After swirl is installed (you only need to do it once), you can start/resume the R tutorial with the commands:
library(swirl)
swirl()
Schedule some time to go though all the lessons by yourself! Almost all of the R codes you need to know are here in those lessons.
If you prefer more static readings (Po did read them to learn R!):
If you like RStudio’s data science things,