Hello,

I am fitting data using different methods e.g. Local Polynomial and Smoothing splines. The data is generated out of a true function model with added normally distributed noise.

I would like to know "how often the confidence band for all points simultaneously contain all true values". I can answer the question for one point in the following way:

e.g.

# =========================================================================================

# How many times the pointwise confidence interval at x=0.5 contains the true value at 0.5

# i.e. what is the so called "coverage rate"?

# =========================================================================================

pos = which(x==0.5)

sum(abs(estlp[pos,] - m(x[pos])) <= 1.96*selp[pos,]) # equidistant x outputs 946

# non-equidistant x outputs 938

sum(abs(estss[pos,] - m(x[pos])) <= 1.96*sess[pos,]) # equidistant x outputs 895

# non-equidistant x outputs 936

This basically tells me that out of 1000 simulation runs with different random noise, 946 times the true value i.e. m(x) for x=0.5 is contained within the 95% confidence interval. The estlp Local Polynomial performs better than Smoothing Splines under this criteria ...

Now is there any specific way to answer "how often the confidence band for all points simultaneously contain all true values" other than this below?

# =========================================================================================

# How often does the confidence band for all points simultaneously contain all true values?

# =========================================================================================

sum(abs(estlp[,] - m(x[])) <= 1.96*selp[,]) # equidistant x outputs 92560

# non-equidistant x outputs 92109

sum(abs(estss[,] - m(x[])) <= 1.96*sess[,]) # equidistant x outputs 90804

# non-equidistant x outputs 94641

Is there a dedicated function in R for this purpose i.e. to build confidence bands around a given fit ... maybe a way to plot it nicely too given that the Estimated SE are calculated.

Many thanks in advance,

Best regards,

Giovanni