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:
linear regression p-values

Subject: linear regression p-values

From: Joao Lencart

Date: 30 Sep, 2004 16:37:37

Message: 1 of 4

Hi,
Is there a way of getting p-values from a linear single variable
regression model in matlab?
I've tried to use regress from the statistical toolbox but it only gives
out p-values if more than 1 independent variable is used in the model
(say y= a*X1+ b*X2+C).

Any suggestions?

Thanks,

JL.

Subject: linear regression p-values

From: Tom Lane

Date: 30 Sep, 2004 11:55:51

Message: 2 of 4

> I've tried to use regress from the statistical toolbox but it only gives
> out p-values if more than 1 independent variable is used in the model
> (say y= a*X1+ b*X2+C).

Joao, when I try this I get a p-value regardless of the number of
predictors. This p-value is for an F test against the alternative of no
effect of any predictors.

> Any suggestions?

Another idea is to use the regstats function. Here I get the 'tstat' output
which includes estimates, standard errors, t statistics, and p values for
all coefficients.

>> load hald
>> str = regstats(heat,ingredients,'linear',{'tstat'});
>> str.tstat
ans =
    beta: [5x1 double]
      se: [5x1 double]
       t: [5x1 double]
    pval: [5x1 double]
     dfe: 8

-- Tom

Subject: linear regression p-values

From: Joao Lencart

Date: 30 Sep, 2004 17:35:00

Message: 3 of 4

Tom,

When using regstats I get a:

??? Error using ==> regstats
Invalid statistic name 'tstat'.

Can this be a toolbox version problem? I'm using version 4.0.

Thanks,
JL


Tom Lane wrote:
>>I've tried to use regress from the statistical toolbox but it only gives
>>out p-values if more than 1 independent variable is used in the model
>>(say y= a*X1+ b*X2+C).
>
>
> Joao, when I try this I get a p-value regardless of the number of
> predictors. This p-value is for an F test against the alternative of no
> effect of any predictors.
>
>
>>Any suggestions?
>
>
> Another idea is to use the regstats function. Here I get the 'tstat' output
> which includes estimates, standard errors, t statistics, and p values for
> all coefficients.
>
>
>>>load hald
>>>str = regstats(heat,ingredients,'linear',{'tstat'});
>>>str.tstat
>>
> ans =
> beta: [5x1 double]
> se: [5x1 double]
> t: [5x1 double]
> pval: [5x1 double]
> dfe: 8
>
> -- Tom
>
>

Subject: linear regression p-values

From: Tom Lane

Date: 30 Sep, 2004 12:51:19

Message: 4 of 4

> When using regstats I get a:
>
> ??? Error using ==> regstats
> Invalid statistic name 'tstat'.
>
> Can this be a toolbox version problem? I'm using version 4.0.

Yes, that's right. This feature is not in earlier versions of the toolbox.

If you can't upgrade, another alternative is to use the glmfit function. I
believe this is available in the release you have. Compared with regress,
glmfit has a broader range of statistical results. And although glmfit fits
"generalized linear models," the ordinary linear model is the default. See
if this works:

load hald
[b,def,st] = glmfit(ingredients,heat)

-- Tom

Tags for this Thread

No tags are associated with 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