# Weighted linear regression with confidence interval

**URL:** <https://discourse.julialang.org/t/weighted-linear-regression-with-confidence-interval/60610>\
**Category:** General Usage\
**Tags:** package, regression\
**Created:** [May 6, 2021, 12:41am UTC](https://discourse.julialang.org/t/weighted-linear-regression-with-confidence-interval/60610 "2021-05-06T00:41:07Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![AquaIndigo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquaindigo/32/15820_2.png) [@AquaIndigo](https://discourse.julialang.org/u/AquaIndigo)\
**Post date:** [May 6, 2021, 8:29am UTC](https://discourse.julialang.org/t/weighted-linear-regression-with-confidence-interval/60610/4 "2021-05-06T08:29:58Z")

</div>

```julia
julia> df = DataFrame(x = [1, 2, 3.], y = [1, 3, 4.])

julia> df.w = [2, 3, 4]

julia> fit1 = glm(@formula(y ~ x), df, Normal(), wts = df.w)

julia> predict(fit1, df[:, [:x]], interval=:confidence)
3×3 DataFrame
│ Row │ prediction │ lower │ upper │
│ │ Float64? │ Float64? │ Float64? │
├─────┼────────────┼──────────┼──────────┤
│ 1 │ 1.24 │ 0.923618 │ 1.55638 │
│ 2 │ 2.68 │ 2.50221 │ 2.85779 │
│ 3 │ 4.12 │ 3.87927 │ 4.36073 │

```

---

_[View the full topic](https://discourse.julialang.org/t/weighted-linear-regression-with-confidence-interval/60610)._
