Success/failure error estimation in R

Viewed 1050

I have success/failure data (trees that survived/died over a certain period) and would like to estimate an error from a binomial distribution to be associated to each of my observations (7 sites). So far I have been using glm to do so:

s <- c(1,20,0,40,2,1,0) # success
f <- c(2,0,20,4,50,0,1) # failure

#for each observation I would calculate this error: 

error <- vector ()  
z_scores <- vector ()  
p_value <- vector ()  

  for (i in 1:7) {
    models <- glm (cbind (s[i], f[i]) ~ 1, family = 'binomial')
    error [i] <- summary (models)$coefficients[2]
    z_scores [i] <- summary (models)$coefficients[3]
    p_value [i] <- summary (models)$coefficients[4]
  }

Would this be the best approach?

How is the probability of the binomial distribution estimated here?

Note that regardless the number of success and failure my error is extremely high when either s or f are =0

1 Answers
Related