Skip to content

Instantly share code, notes, and snippets.

@eliardocosta
Created June 25, 2021 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliardocosta/40d85834ab91808eebf72b1a4435128e to your computer and use it in GitHub Desktop.
Save eliardocosta/40d85834ab91808eebf72b1a4435128e to your computer and use it in GitHub Desktop.
#- EST0116 INFERENCIA II
#- Slides 0
# slide 97 ----------------------------------------------------------------
library(MASS)
theta <- 3
n <- 20
x <- rgamma(n, shape = theta, rate = 1); x
est <- fitdistr(x, "gamma", rate = 1); est
emv <- as.numeric(est$estimate[1]); emv # EMV
#- IC de 95% para theta
emv + c(-1, 1)*qnorm(1 - 0.05/2)*sqrt(1/(n*trigamma(emv)))
#- outra forma
emv + c(-1, 1)*qnorm(1 - 0.05/2)*est$sd
# slide 104 ---------------------------------------------------------------
#- CV verdadeiro
1/sqrt(theta)
#- IC de 95% para o CV
1/sqrt(emv) + c(-1, 1)*qnorm(1 - 0.05/2)*sqrt(1/(4*n*trigamma(emv)*emv^3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment