# Meaning of \`GLM.lm\` results (\`t\` and \`Pr(\>|t|)\`)

**URL:** <https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042>\
**Category:** Statistics\
**Tags:** regression, hypothesis-tests, linear-regression\
**Created:** [September 30, 2022, 2:49pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042 "2022-09-30T14:49:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Post date:** [September 30, 2022, 2:49pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/1 "2022-09-30T14:49:57Z")

</div>

Hi all!

This is a very noobish question, I was uncertain if I should put it in “New to Julia” section, so sorry about it.

Anyway, when I fit a linear model using the `GLM` package, like this:

```julia
using DataFrames
using CSV
using GLM

df = DataFrame(CSV.File("raw_planar_data.csv"));

fm = @formula(z ~ x + y)
@time(model = lm(fm, df))

```

Julia prints this pretty table:

```julia
julia> @time(model = lm(fm, df))
  0.048781 seconds (28.79 k allocations: 2.329 MiB, 40.01% gc time, 99.00% compilation time: 100% of which was recompilation)
StatsModels.TableRegressionModel{LinearModel{GLM.LmResp{Vector{Float64}}, GLM.DensePredChol{Float64, LinearAlgebra.CholeskyPivoted{Float64, Matrix{Float64}, Vector{Int64}}}}, Matrix{Float64}}

z ~ 1 + x + y

Coefficients:
──────────────────────────────────────────────────────────────────────────
                 Coef. Std. Error t Pr(>|t|) Lower 95% Upper 95%
──────────────────────────────────────────────────────────────────────────
(Intercept) 0.0413819 0.36563 0.11 0.9099 -0.675407 0.758171
x 1.99483 0.00960031 207.79 <1e-99 1.97601 2.01365
y 0.994769 0.00950755 104.63 <1e-99 0.97613 1.01341
──────────────────────────────────────────────────────────────────────────

```

For what I understood, Julia performs a t-test for each parameter \beta\_i, checking

\begin{align} \mathbb{H}\_0 &: \beta\_i = 0 \\ \mathbb{H}\_1 &: \beta\_i \neq 0 \end{align}

Now, **please tell me if I got it right** :

- `t` is the _value of the t-statistic_ for each test
- `Pr(>|t|)` is the _p-value_ for each test
- `Lower 95%` and `Upper 95%` are the _confidence interval, with significance level \alpha = 0.05_, for each parameter

**Is this all correct, or did I interpreted something wrongly?**

Thanks!

P.S., side question (if you like): how is the standard error calculated in a linear regression test?

---

<div class="post-metadata">

**Author:** ![rmsmsgood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rmsmsgood/32/20544_2.png) [@rmsmsgood](https://discourse.julialang.org/u/rmsmsgood)\
**Post date:** [September 30, 2022, 3:02pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/2 "2022-09-30T15:02:31Z")

</div>

You all right. Anyway, `@time` doesn’t require `()`, that is, you can use that like below:

```julia
@time model = lm(fm, df)

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [September 30, 2022, 3:06pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/3 "2022-09-30T15:06:46Z")

</div>

> [@bertulli](#):
>
> P.S., side question (if you like): how is the standard error calculated in a linear regression test?

This sounds suspiciously like a homework problem. There are plenty of resources online to learn about how standard errors are calculated.

---

<div class="post-metadata">

**Author:** ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Post date:** [September 30, 2022, 3:25pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/4 "2022-09-30T15:25:41Z")

</div>

It isn’t, but I see why it looked like so, sorry. The more complete question should have been: “what is the statistic used to assess the mean of a coefficient in a LM, from which I can then calculate the standard error?”. I have taken a Stats course at university but it didn’t cover linear regression. Anyway, I have probably [found the answer](https://stats.stackexchange.com/questions/344006/understanding-t-test-for-linear-regression), and it’s already too advanced for my curiosity-motivated study, so I think I’ll just trust the software library and use the results.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [September 30, 2022, 3:54pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/5 "2022-09-30T15:54:11Z")

</div>

As a resource, Stock and Watsons introduction to econometrics has a very good description of OLS

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [September 30, 2022, 5:58pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/6 "2022-09-30T17:58:53Z")

</div>

> [@bertulli](#):
>
> Anyway, I have probably [found the answer](https://stats.stackexchange.com/questions/344006/understanding-t-test-for-linear-regression), and it’s already too advanced for my curiosity-motivated study, so I think I’ll just trust the software library and use the results.

If you move quickly away from Frequentist stats and towards Bayesian stats then the answer is always very simple: everything is derived from the posterior distribution.

The frequentist tests for regression stuff can mostly be seen as approximations to Bayes under some improper prior distribution.

I just always do Bayes, but sometimes do GLM type stuff and interpret as convenient quick approximation of Bayes.

---

<div class="post-metadata">

**Author:** ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Post date:** [October 1, 2022, 2:54pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/7 "2022-10-01T14:54:35Z")

</div>

To @pdeffebach : thanks, but my question was about the test performed: are you suggesting that because that is part of the OLS standard process?

To @dlakelan : I still didn’t grasp the difference between frequentist and Bayesian statistics. Is it important to conduct a multiple linear regression? Or can I “just trust Julia” (and let’s say, accept the parameter when `Pr(>|t|)` \< 0.05 as usual)?

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [October 1, 2022, 4:05pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/8 "2022-10-01T16:05:06Z")

</div>

> [@bertulli](#):
>
> Or can I “just trust Julia” (and let’s say, accept the parameter when `Pr(>|t|)` \< 0.05 as usual)?

This accept and reject stuff is definitely what’s wrong with much of Frequentist stats. For example, if you have Pr(\>|t|) = 0.07 will you “accept that the slope really is zero?” That is a very poor way to do things. The proper interpretation is rather that you have insufficient information to ensure exactly what sign the slope should be. In the real world almost nothing is exactly 0. And simply because you have a small sample size is no reason to conclude strongly that a parameter is actually 0. Similarly if in one dataset p\<0.05 and another p\>0.05 it is very wrong to say in condition one the parameter is not zero but rather equal approximately to the estimated value, and in condition two the parameter is exactly 0 and therefore the estimate of the difference of the effects is such and such…

It is worth it to avoid falling into the many many logical fallacies that are committed by the nonspecialist using the usual rituals of Null Hypothesis Significance Testing.

If you have not already had too much standard stats education you are in a good position to avoid making these mistakes 😅perhaps look into Kruszke’s “Doing Bayesian Data Analysis” or some other similar very intro book. Mainly to build up a proper intuition for valid inferences rather than many fallacies.

See also [Scientists rise up against statistical significance](https://www.nature.com/articles/d41586-019-00857-9)

---

<div class="post-metadata">

**Author:** ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Post date:** [October 1, 2022, 4:22pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/9 "2022-10-01T16:22:54Z")

</div>

Thanks for the suggestion! 👍 Yes I know that “not rejecting the null hypothesis” **doesn’t mean** “the null hypothesis **is true** ”, but you’re right, knowing myself I would have got distracted and assumed it 🥴

My question (a bit too pragmatical, I admit), was “is this statistic sufficiently solid to trust the usual significance level (0.05) in a normal regression problem?”. Whose answer, I get now, is “it depends”.

One minor thing: wdym here?

> [@dlakelan](#):
>
> If you have not already had too much standard stats education you are in a good position to avoid making these mistakes

Because I would have said, “since I got only basic stats educations, I am _especially_ prone to error”

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [October 1, 2022, 4:30pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042/10 "2022-10-01T16:30:52Z")

</div>

> [@bertulli](#):
>
> wdym here?

I mean, it will be easier for you to unlearn the wrong thinking you were taught in 1 semester than the wrong thinking you have developed over several years of a stats masters etc.
