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
16
votes
6 answers

Calculating length of 95%-CI using dplyr

Last time I asked how it was possible to calculate the average score per measurement occasion (week) for a variable (procras) that has been measured repeatedly for multiple respondents. So my (simplified) dataset in long format looks for example…
Rasul89
  • 588
  • 2
  • 5
  • 14
16
votes
3 answers

Odds ratio and confidence intervals from glmer output

I have made a model that looks at a number of variables and the effect that has on pregnancy outcome. The outcome is a grouped binary. A mob of animals will have 34 pregnant and 3 empty, the next will have 20 pregnant and 4 empty and so on. I have…
EmmaC
  • 169
  • 1
  • 1
  • 3
15
votes
2 answers

Control transparency of smoother and confidence interval

I'm refering to this SO question from 2 years ago, with ggplot : Adjust Transparency (alpha) of stat_smooth lines, not just transparency of Confidence Interval The first method suggested allows to set the alpha transparency of the confidence…
agenis
  • 8,069
  • 5
  • 53
  • 102
15
votes
5 answers

Confidence interval for exponential curve fit

I'm trying to obtain a confidence interval on an exponential fit to some x,y data (available here). Here's the MWE I have to find the best exponential fit to the data: from pylab import * from scipy.optimize import curve_fit # Read data. x, y =…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
12
votes
5 answers

Confidence Interval in Python dataframe

I am trying to calculate the mean and confidence interval(95%) of a column "Force" in a large dataset. I need the result by using the groupby function by grouping different "Classes". When I calculate the mean and put it in the new dataframe, it…
MasterShifu
  • 213
  • 1
  • 2
  • 16
12
votes
1 answer

vcovHC and confidence interval

Is it possible to have confint use the robust vcov obtained by vcovHC (from the sandwich package) after fitting a model?
Misha
  • 3,114
  • 8
  • 39
  • 60
12
votes
2 answers

A better way to build confidence bands around mean/median of an observed sample using ggplot2

So I have a three column data frame that has Trials, Ind. Variable, Observation. Something like: df1<- data.frame(Trial=rep(1:10,5), Variable=rep(1:5, each=10), Observation=rnorm(1:50)) I am trying to plot a 95% conf. Interval around the mean for…
user2217564
  • 240
  • 2
  • 9
11
votes
1 answer

Dotplot with error bars, two series, light jitter

I have a collection of data over several studies. For each study I am interested about the mean of a variable by gender, and if this significantly differs. For each study I have the mean and 95% confidence intervals for both males and females. What…
PaoloCrosetto
  • 600
  • 1
  • 7
  • 16
10
votes
5 answers

Calculating confidence intervals for a non-normal distribution

First, I should specify that my knowledge of statistics is fairly limited, so please forgive me if my question seems trivial or perhaps doesn't even make sense. I have data that doesn't appear to be normally distributed. Typically, when I plot…
Josiah
  • 654
  • 2
  • 13
  • 25
10
votes
1 answer

Python Statsmodels: Using SARIMAX with exogenous regressors to get predicted mean and confidence intervals

I'm using statsmodels.tsa.SARIMAX() to train a model with exogenous variables. Is there an equivalent of get_prediction() when a model is trained with exogenous variables so that the object returned contains the predicted mean and confidence…
10
votes
3 answers

Function parameter as argument in an R function

I am attempting to write a general function to calculate coverage probabilities for interval estimation of Binomial proportions in R. I intend to do this for a variety of confidence interval methods e.g. Wald, Clopper-Pearson, HPD intervals for…
jatotterdell
  • 109
  • 1
  • 1
  • 8
9
votes
3 answers

How to calculate confidence score of a Neural Network prediction

I am using a deep neural network model (implemented in keras)to make predictions. Something like this: def make_model(): model = Sequential() model.add(Conv2D(20,(5,5), activation = "relu")) model.add(MaxPooling2D(pool_size=(2,2))) …
9
votes
1 answer

What standard errors are returned with predict.glm(..., type = "response", se.fit = TRUE)?

I am going to fit the model on the data provided in this excellent example on how to compute the 95% confidence interval for the response, after performing a logistic regression: foo <- mtcars[,c("mpg","vs")]; names(foo) <- c("x","y") mod <- glm(y ~…
Alex
  • 15,186
  • 15
  • 73
  • 127
9
votes
2 answers

Return std and confidence intervals for out-of-sample prediction in StatsModels

I'd like to find the standard deviation and confidence intervals for an out-of-sample prediction from an OLS model. This question is similar to Confidence intervals for model prediction, but with an explicit focus on using out-of-sample data. The…
9
votes
2 answers

Gnuplot smooth confidence interval lines as opposed to error bars

I'd like a 95% confidence interval line above and below my data line - as opposed to vertical bars at each point. Is there a way that I can do this in gnuplot without plotting another line? Or do I need to plot another line and then label it…
Charon
  • 2,344
  • 6
  • 25
  • 44
1
2
3
75 76