How to obtain the pvalues of the coefficients in GLM.jl?


I have fitted a model

using DataFrames
df = DataFrame(
  x = 2*y + 1 + rand(100),
  y = rand(100)
using GLM
mdl = lm(@formula(y~x), df)

now I can see the pvalues of the coefficients. How do I obtain the pvalues and set them to a variable?

The output from above

Formula: y ~ 1 + x

             Estimate Std.Error t value Pr(>|t|)
(Intercept)   1.46518 0.0514909 28.4552   <1e-48
x             2.08846 0.0889749 23.4724   <1e-41


You can extract the pvalues with

julia> coeftable(mdl).cols[4]
2-element Array{StatsBase.PValue,1}:

We should probably come up with a better way.


It works. However, How can i extract the p-value of a particular variable, say :ENERGY from the model, say model…?


Well, I understand that if you the following command


you will have limited option to use those as they are in StatsBase.
If you try this (may not be very efficient), it works better

a = coeftable(model).cols[4]
pVals = [ a[i].v for i in 1:length(a) ]

Hope it helps