# Standard error of predictions?

**URL:** <https://discourse.julialang.org/t/standard-error-of-predictions/55398>\
**Category:** Statistics\
**Created:** [February 16, 2021, 2:50pm UTC](https://discourse.julialang.org/t/standard-error-of-predictions/55398 "2021-02-16T14:50:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [February 16, 2021, 2:50pm UTC](https://discourse.julialang.org/t/standard-error-of-predictions/55398/1 "2021-02-16T14:50:41Z")

</div>

seems like `StatsBase.predict()` gives only the point estimate (the mean) of prediction. How could I get more information like confidence interval or standard error **of the prediction** (not the coefficients)? thanks.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 16, 2021, 3:23pm UTC](https://discourse.julialang.org/t/standard-error-of-predictions/55398/2 "2021-02-16T15:23:29Z")

</div>

Depends on the model I suppose? For a `LinearModel` it’s:

```julia
  predict(mm::LinearModel, newx::AbstractMatrix;
          interval::Union{Symbol,Nothing} = nothing, level::Real = 0.95)

  If interval is nothing (the default), return a vector with the predicted values for model mm and new data newx. Otherwise, return a    
  3-column matrix with the prediction and the lower and upper confidence bounds for a given level (0.95 equates alpha = 0.05). Valid     
  values of interval are :confidence delimiting the uncertainty of the predicted relationship, and :prediction delimiting estimated      
  bounds for new data points.

```

---

<div class="post-metadata">

**Author:** ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Post date:** [February 16, 2021, 4:32pm UTC](https://discourse.julialang.org/t/standard-error-of-predictions/55398/3 "2021-02-16T16:32:23Z")

</div>

A few things:  
Suppose the true model is y = E[y|X] + \varepsilon

1. Confidence intervals (CI) give a range for the conditional expectation E[y|X]  
Prediction intervals (PI) give a range for y  
PIs tend to be wider than CIs b/c they also take the true error term into account
2. There are many different ways of estimating PIs, some have different properties, others work better under different assumptions.  
My favorite recent paper on this is: [Predictive inference with the jackknife+](https://arxiv.org/abs/1905.02928)
