Questions tagged [confidence-interval]

In statistics, a confidence interval is a measure of the precision of an estimate of an underlying parameter. In principle, if the estimate is computed several times on independent samples of data, the parameter should fall within associated confidence intervals a set proportion of the time. This proportion is known as the coverage probability, and is most commonly set to be 95%.

When estimating a vector of parameters, c(θ), based on observations of some random variables whose distribution depends on those parameters in some way, a confidence interval (for scalar θ) or confidence region (for vector c(θ)), is some set C=C(X) such that P(c(θ) ∈ C) = 1−α. To note:

  1. The confidence interval is a function of the data, X, so is itself random.
  2. The statement regarding the probability that c(θ) ∈ C should be regarded with respect to the randomness in X which controls C. Since confidence intervals are a frequentist notion, one should not think of the probability as applying to the unobserved parameter c(θ), which, to a frequentist, is not random.
  3. Often one can only compute approximate confidence intervals, which may have the nominal coverage asymptotically in the sample size.

Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

1131 questions
4
votes
1 answer

How to include confidence intervals for proportion using {gtsummary} tbl_summary?

New to posting on StackOverflow (but not reading ), so bear over with my skills. I am using the {gtsummary} package, in particular the tbl_summary function. I would like to include a 95% confidence interval of the proportions for each of the by and…
4
votes
1 answer

Confidence Interval of the predicted mean of a LMER object for large dataset

I would like to get the confidence interval (CI) for the predicted mean of a Linear Mixed Effect Model on a large dataset (~40k rows), which is itself a subset of an even larger dataset. This CI is then used for estimating the uncertainty of another…
Nino
  • 366
  • 2
  • 12
4
votes
2 answers

How to extract confidence intervals from multiple regression models?

I am extracting the regression results for two different groups as shown in this example below. In the temp data.frame i get the estimate, std.error, statistic and p-value. However, i don't get the confidence intervals. Is there a simple way to…
Jack
  • 813
  • 4
  • 17
4
votes
2 answers

Extracting Confidence Intervals data.table

What I want to do is to have columns for the upper and lower confidence interval for a proportion. Here is what I have done: > #Create some sample data > Frustration <- data.table(group = c('A','B','C'), trials = c(363,1398,139), surg =…
DavidF
  • 91
  • 5
4
votes
2 answers

Why am I getting a line shadow in a seaborn line plot?

Here is the code: fig=plt.figure(figsize=(14,8)) sns.lineplot(x='season', y='team_strikerate', hue='batting_team', data=overall_batseason) plt.legend(title = 'Teams', loc = 1, fontsize = 12) plt.xlim([2008,2022]) And here is the image Just to let…
CuriousLearner
  • 421
  • 4
  • 14
4
votes
1 answer

ggplot2: Density plot with mean / 95% confidence interval line

I know that there is a way to draw a density plot with the box plot as follows: So basically, in this plot, median & quartiles were used. However, I was not able to find out how I can express the mean & confidence intervals of each density plot. I…
KLee
  • 105
  • 1
  • 9
4
votes
1 answer

How to calculate bootstrapped confidence interval using the mean_CI_boot used in ggplot2?

I have a 2 x 2 factorial data set for which I have plotted the confidence intervals using mean_cl_boot function. I want to calculate this in R using the appropriate function. How can I do that? A sample of my data set is as: df <- data.frame( …
Rspacer
  • 2,369
  • 1
  • 14
  • 40
4
votes
1 answer

How to calculate a Confidence Interval using numpy.percentile() in Python

A homework question asked me to calculate a confidence interval for a mean. When I did it the traditional method and with numpy.percentile() -- I got different answers. I think that I may be misunderstanding how or when to use np.percentile(). My…
SherbertTheCat
  • 655
  • 2
  • 7
  • 9
4
votes
0 answers

calculate a confidence interval from the outputs of stats.linregress in python

I have a data set with two variables and I have calculated the type 1 linear regression line. I used the stats.linregress and got these results: LinregressResult(slope=0.06310526340834267, intercept=0.4327958012533457, rvalue=0.9873212197443118,…
4
votes
1 answer

why do ggplot2 95%CI and prediction 95%CI calculated manually differ?

I'd like to know why when calculating 95% confidence bands from a linear mixed effects model does ggplot2 produces narrower bands than when calculated manually, e.g. by following Ben Bolker's method here confidence intervals on predictions. That is,…
S.Bird
  • 102
  • 8
4
votes
2 answers

Pystan Posterior Uncertainty Intervals

I saw on another forum that PyStan doesn’t have the same function as RStan where they use posterior_interval(), but we can use numpy.percentile() instead. I’m currently using the pystan.StanModel.optimizing() function in PyStan to get the set of…
4
votes
1 answer

Adding confidence intervals to logarithmic regression

I am trying to add confidence intervals to a logarithmic regression curve in R. I assume there is a mathematical reason that I'm so far unable to do this, so any help would be appreciated. Here's the…
A.Benson
  • 465
  • 1
  • 6
  • 16
4
votes
2 answers

Calculate the proc lifetest 95%CI for median survival time using R survival package

I have been trying to replicate the results of proc lifetest in SAS using R (survival package and survifit function) -and especially calculate the 95%Confidence interval for the median survival time. I know that SAS is using the following formula…
Evi T
  • 61
  • 1
  • 8
4
votes
4 answers

Compute a confidence interval from sample data assuming unknown distribution

I have sample data for which I would like to compute a confidence interval, assuming a distribution that is not normal and is unknown. Basically, it looks like the distribution is Pareto. But I don't know for sure. The answers for the normal…
Brans Ds
  • 4,039
  • 35
  • 64
4
votes
3 answers

Shading confidence intervals in R - base R if possible

I am comparing two lines that were regressed using LOESS. I want to display the confidence intervals of the two lines clearly, and I am having some difficulties. I have tried using a variety of line types and colors, but the result is still to busy…
Corey
  • 405
  • 2
  • 6
  • 18