Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
p-value for multiple linear regression

Subject: p-value for multiple linear regression

From: john Chandler

Date: 4 Sep, 2009 05:21:00

Message: 1 of 7

Hi,

I am running multiple linear regression with three dependent variables using the regress function. Matlab is spitting out only 1 p-value or strictly speaking, the F-statistic.

Is there any way to get the p-values corresponding to all of the dependent variables? I have checked the glmfit and regstats functions - they didn't give the desired values.

Thanks.

Subject: p-value for multiple linear regression

From: Peter Perkins

Date: 4 Sep, 2009 14:47:47

Message: 2 of 7

john Chandler wrote:
> Hi,
>
> I am running multiple linear regression with three dependent variables using the regress function. Matlab is spitting out only 1 p-value or strictly speaking, the F-statistic.
>
> Is there any way to get the p-values corresponding to all of the dependent variables? I have checked the glmfit and regstats functions - they didn't give the desired values.

You probably mean the p-values for the Wald statistics, i.e. the Student's t tail probability for aHat/se_aHat? Those are definitely returned by both regstats and glmfit, in the 'tstats' and stats.p outputs, respectively.

Hope this helps.

Subject: p-value for multiple linear regression

From: Tom Lane

Date: 4 Sep, 2009 14:54:19

Message: 3 of 7

> I am running multiple linear regression with three dependent variables
> using the regress function. Matlab is spitting out only 1 p-value or
> strictly speaking, the F-statistic.
>
> Is there any way to get the p-values corresponding to all of the dependent
> variables? I have checked the glmfit and regstats functions - they didn't
> give the desired values.

Do you mean three independent variables? Then I would expect glmfit to work.
See the third output, a structure with a 'p' field among others:

  load hald
  [b,dev,st] = glmfit(ingredients,heat);
  [b, st.se, st.t, st.p] %coef, std err, t stat, p-val

And I would expect regstats to work with the 'tstat' output:

  st = regstats(heat,ingredients,'linear','tstat')
  [st.tstat.beta, st.tstat.se, st.tstat.t, st.tstat.pval]

If these aren't what you need, please elaborate. You should know that a t
test for a single coefficient is equivalent to (has the same p-value as) an
F test for that coefficient.

-- Tom

Subject: p-value for multiple linear regression

From: john Chandler

Date: 5 Sep, 2009 00:54:02

Message: 4 of 7

"Tom Lane" <tlane@mathworks.com> wrote in message <h7r9mr$a6k$1@fred.mathworks.com>...
> > I am running multiple linear regression with three dependent variables
> > using the regress function. Matlab is spitting out only 1 p-value or
> > strictly speaking, the F-statistic.
> >
> > Is there any way to get the p-values corresponding to all of the dependent
> > variables? I have checked the glmfit and regstats functions - they didn't
> > give the desired values.
>
> Do you mean three independent variables? Then I would expect glmfit to work.
> See the third output, a structure with a 'p' field among others:
>
> load hald
> [b,dev,st] = glmfit(ingredients,heat);
> [b, st.se, st.t, st.p] %coef, std err, t stat, p-val
>
> And I would expect regstats to work with the 'tstat' output:
>
> st = regstats(heat,ingredients,'linear','tstat')
> [st.tstat.beta, st.tstat.se, st.tstat.t, st.tstat.pval]
>
> If these aren't what you need, please elaborate. You should know that a t
> test for a single coefficient is equivalent to (has the same p-value as) an
> F test for that coefficient.
>
> -- Tom
>

This is exactly what I wanted! I was using the wrong structure with regstats, but I am not sure what I was doing wrong with glmfit.

How did you know that the pvalues are under tstat? I didn't find any reference in the documentation for regstats. I am curious because there may be other stats 'hidden' under the other elements.

Thank you for your help! I am trying to do all of my statistics in Matlab and it has been okay so far.

John.

Subject: p-value for multiple linear regression

From: Tom Lane

Date: 8 Sep, 2009 21:57:10

Message: 5 of 7

> This is exactly what I wanted! I was using the wrong structure with
> regstats, but I am not sure what I was doing wrong with glmfit.
>
> How did you know that the pvalues are under tstat? I didn't find any
> reference in the documentation for regstats. I am curious because there
> may be other stats 'hidden' under the other elements.

John, that's probably because I work here (at The MathWorks). I just
remembered that the tstat thing was a structure with stuff related to t
statistics, including p-values as well as the values of the statistics
themselves.

I can see what you mean about the reference page for regstats not being
clear. I'll try to make sure that's improved. Thanks for pointing it out.

-- Tom

Subject: p-value for multiple linear regression

From: Nils Tobias

Date: 23 Jul, 2010 18:15:07

Message: 6 of 7

"Tom Lane" <tlane@mathworks.com> wrote in message
> I can see what you mean about the reference page for regstats not being
> clear. I'll try to make sure that's improved. Thanks for pointing it out.
>
> -- Tom
>

As I was looking for the same thing today I still couldn't find a good explanation on the regstats help page (http://www.mathworks.com/access/helpdesk/help/toolbox/stats/regstats.html).

However it wasn't too difficult to figure out what's behind that, but I think it wouldn't harm to add some more text to this function:

the structure tstat contains:
beta: estimated coefficients of the regression (simply repeated)
se: standard error for each coefficient
t: the actual t-values for each coefficient (testing if a coefficient is different from 0)
pval: p-values for each t-value (2 * probability for a t-distribution that a value is greater or equal to the calculated t-value)
dfe: degrees of freedom (datapoints - number of coefficients)

-NT

Subject: p-value for multiple linear regression

From: Nils Tobias

Date: 23 Jul, 2010 18:15:07

Message: 7 of 7

"Tom Lane" <tlane@mathworks.com> wrote in message
> I can see what you mean about the reference page for regstats not being
> clear. I'll try to make sure that's improved. Thanks for pointing it out.
>
> -- Tom
>

As I was looking for the same thing today I still couldn't find a good explanation on the regstats help page (http://www.mathworks.com/access/helpdesk/help/toolbox/stats/regstats.html).

However it wasn't too difficult to figure out what's behind that, but I think it wouldn't harm to add some more text to this function:

the structure tstat contains:
beta: estimated coefficients of the regression (simply repeated)
se: standard error for each coefficient
t: the actual t-values for each coefficient (testing if a coefficient is different from 0)
pval: p-values for each t-value (2 * probability for a t-distribution that a value is greater or equal to the calculated t-value)
dfe: degrees of freedom (datapoints - number of coefficients)

-NT

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us