Posts

March 14, 2017 Pre-Class

.table { width: 80%; margin-left:10%; margin-right:10%; } Project Goals: With this project we will simulate a famoues probability problem. This will not require knowledge of probability or statistics but only the logic to follow the steps in order to simulate this problem. This is one way to solve problems by using the computer. 1 Gambler’s Ruin: Suppose you have a bankroll of $1000 and make bets of $100 on a fair game.

March 7, 2017 In-Class Project

Jackknife for Gamma Parameters Recall our friend the method of moments estimator: gamma.est <- function(the_data) { m <- mean(the_data) v <- var(the_data) a <- m^2/v s <- v/m return(c(a=a,s=s)) } Jackknife for Gamma Parameters Function Write a function called gamma.jackknife that takes argument a_vector and returns jackknife standard error estimates on the gamma parameters. gamma.jackknife <- function(a_vector) { n1=length(a_vector) estimate_a=c(n1) estimate_s=c(n1) for(i in 1:n1) { estimate_a[i]=gamma.est(a_vector[-i])[1] estimate_s[i]=gamma.est(a_vector[-i])[2] } se_a=sqrt((var(estimate_a))((n1-1)^2)/n1) se_s=sqrt((var(estimate_s))((n1-1)^2)/n1) jackknife.

February 28, 2017 - In-Class Project

1 ckm_nodes<-read.csv("ckm_nodes.csv") 2 table(ckm_nodes$adoption_date,exclude = NULL) ## ## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ## 11 9 9 11 11 11 13 7 4 1 5 3 3 4 4 ## 16 17 Inf <NA> ## 2 1 16 121 The number pf doctors began prescribing tetracycline in each month of the study can be found in the table. 16 are never prescribed.

March 7, 2017 - Pre-Class

 mean.jackknife <- function(a_vector) {
  vec<-rep(0,length(a_vector))
  for (i in 1:length(a_vector)){
    vec[i]<-mean(a_vector[-i])
  }
  jackknife.variance<-((length(a_vector) - 1)/length(a_vector)) * sum((vec - mean(vec))^2)
  jackknife.stderr<-sqrt(jackknife.variance)
  return(jackknife.stderr)
}
some_normals <- rnorm(100,mean=7,sd=5)
mean(some_normals)
## [1] 7.35254
(formula_se_of_mean <- sd(some_normals)/sqrt(length(some_normals)))
## [1] 0.5227524
all.equal(formula_se_of_mean,mean.jackknife(some_normals))
## [1] TRUE