Path: news.mathworks.com!not-for-mail
From: "Tom Lane" <tlane@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Important Regression Questions
Date: Thu, 5 Nov 2009 10:10:17 -0500
Organization: The MathWorks, Inc
Lines: 33
Message-ID: <hcupsp$otp$1@fred.mathworks.com>
References: <hcscmu$8u9$1@fred.mathworks.com> <hcsika$kc3$1@fred.mathworks.com> <hcudvl$8i$1@fred.mathworks.com>
Reply-To: "Tom Lane" <tlane@mathworks.com>
NNTP-Posting-Host: lanet.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1257433817 25529 172.31.57.151 (5 Nov 2009 15:10:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Nov 2009 15:10:17 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
Xref: news.mathworks.com comp.soft-sys.matlab:582755


> I have checked for regstats and have seen that it calculates the values 
> based on the model. But one can not make it to calculate the values for a 
> cubic or 5th degree polynomial fitting.
>
> Could someone please confirm?

The polyfit function would be easier for this:

>> load census
>> x = (cdate-mean(cdate))/100;
>> p = polyfit(x,pop,5)
p =
    6.3901    4.7543   -3.8481   60.9626  120.8211   62.2285

But it is possible to use regstats for this by specifying the model as a 
vector of powers of the x variable:

>> regstats(pop,x,(0:5)','beta')
ans =
    source: 'regstats'
      beta: [6x1 double]
>> ans.beta
ans =
   62.2285
  120.8211
   60.9626
   -3.8481
    4.7543
    6.3901

-- Tom