I need R code that will run this simulation.
X=c(55.0, 38.4, 25.2, 79.3, 60.0, 53.9, 49.1, 50.9, 70.2, 73.7, 73.5, 69.6, 47.2, 77.9, -3.4,
65.5, 58.8, 33.1, 22.5, 79.5, 49.6, 60.0, 43.5, 14.5, 40.7)
Hi,
Please find the R code for the 90% confidence interval for σ2 based on the simulation:
X <- c(55.0, 38.4, 25.2, 79.3, 60.0, 53.9, 49.1, 50.9, 70.2, 73.7, 73.5, 69.6, 47.2, 77.9, -3.4,65.5, 58.8, 33.1, 22.5, 79.5, 49.6, 60.0, 43.5, 14.5, 40.7)
var.interval <- function(data, conf.level =
0.90) {
df = length(data) - 1
chilower = qchisq((1 - conf.level)/2, df)
chiupper = qchisq((1 - conf.level)/2, df, lower.tail = FALSE)
v = var(data)
c(df * v/chiupper, df * v/chilower)
}
var.interval(X)
Get Answers For Free
Most questions answered within 1 hours.