# ************************************************************************* # # FILE: ncpumpexample.r # # Date Created: April 20, 2004 # Author: Mark E. Irwin # # Contents: Modification of the Pump failure example of Gaver and O'Muircheartaigh # (1987) as proposed by Gelfand and Smith (1990). Analysis by Metropolis # within Gibbs. # # p_i | lambda_i ~ Poisson(lambda_i t_i) # lambda_i | mu, sigma2 ~ logN(mu, sigma2) # mu | nu, tau ~ N(nu, tau2) # sigma2 | delta, gamma ~ IGamma(gamma, delta) # # Random Walk proposal for log(lambda_i) # Gibbs for mu and sigma2 # # Revision History # Date Name Changes/Reasons # # ************************************************************************* # # Input: # # None # # Output: # # None, but many variables are created # # ************************************************************************* # Data failures <- c(5, 1, 5, 14, 3, 19, 1, 1, 4, 22) time <- c(94.32, 15.72, 62.88, 125.76, 5.24, 31.44, 1.048, 1.048, 2.096, 10.48) rawrates <- failures / time # Prior nu <- -50 tau2 <- 100 gamma <- 1 delta <- 100 # Sampler Parameters lambdastart <- rawrates mustart <- mean(log(rawrates)) sigma2start <- var(log(rawrates)) start <- list(lambda=lambdastart, mu=mustart, sigma2=sigma2start) niter <- 101000 # rwvar <- sigma2start/9 rwvar <- 0.000001 pumpnc000001 <- ncpumpgibbs(failures, time, nu, tau2, gamma, delta, niter, rwvar, start)