Thread Subject: Linear fit forcing zerointercept: How to compute confidence interval

Subject: Linear fit forcing zerointercept: How to compute confidence interval

From: Rafael

Date: 12 Nov, 2009 22:04:02

Message: 1 of 3

Hi,

I was using polyfit to fit a line in my data. The nice thing about doing that is that I can actually get the 95% confidence interval as well when I use the polyconf function.

[p,S] = polyfit(x,y,1);
[Y,DELTA] = polyconf(p,x,S);

Now, I need to fit a line but force the intercept to be zero. My understanding is that polyfit cannot be used, and I heard in some of the posts that a simple equation like X\Y will give me the slope. polyconf needs the S variable calculated in polyfit to generate the confidence interval DELTA. Is there any way I can generate this same variable for the new linear fit X\Y or perhaps another way to compute confidence intervals in this case?

Thank you,

Subject: Linear fit forcing zerointercept: How to compute confidence

From: jrenfree

Date: 12 Nov, 2009 23:06:08

Message: 2 of 3

On Nov 12, 2:04 pm, "Rafael " <roso...@gmail.com> wrote:
> Hi,
>
> I was using polyfit to fit a line in my data. The nice thing about doing that is that I can actually get the 95% confidence interval as well when I use the polyconf function.
>
> [p,S] = polyfit(x,y,1);
> [Y,DELTA] = polyconf(p,x,S);
>
> Now, I need to fit a line but force the intercept to be zero. My understanding is that polyfit cannot be used, and I heard in some of the posts that a simple equation like X\Y will give me the slope. polyconf needs the S variable calculated in polyfit to generate the confidence interval DELTA. Is there any way I can generate this same variable for the new linear fit X\Y or perhaps another way to compute confidence intervals in this case?
>
> Thank you,

http://www.mathworks.com/support/solutions/en/data/1-12BBUC/index.html?product=OP&solution=1-12BBUC

Subject: Linear fit forcing zerointercept: How to compute confidence

From: Rafael

Date: 13 Nov, 2009 00:07:01

Message: 3 of 3

Hi,

Thanks for your reply, but I don't think this will actually solve my problem. As I said, I can compute the slope Y = aX by doing "slope = X\Y". That only works when forcing intercept to be (0,0) (my case). Perhaps for intercept different fro (0,0), the link seems to be very helpful. What I would like to do is how to compute the confidence interval that I used to do with polyfit/polyconf functions when I did not have the constraint of zero intercept.

From help polyfit:
...
[p,S] = polyfit(x,y,n)
...
structure S for use with polyval to obtain error estimates or predictions. Structure S contains fields R, df, and normr, for the triangular factor from a QR decomposition of the Vandermonde matrix of X, the degrees of freedom, and the norm of the residuals, respectively...

[y,delta] = polyval(p,x,S)

Thank you,




jrenfree <jrenfree@gmail.com> wrote in message <fd920462-481c-4e9e-9c7a-201a5a209cf7@u36g2000prn.googlegroups.com>...
> On Nov 12, 2:04?pm, "Rafael " <roso...@gmail.com> wrote:
> > Hi,
> >
> > I was using polyfit to fit a line in my data. The nice thing about doing that is that I can actually get the 95% confidence interval as well when I use the polyconf function.
> >
> > [p,S] = polyfit(x,y,1);
> > [Y,DELTA] = polyconf(p,x,S);
> >
> > Now, I need to fit a line but force the intercept to be zero. My understanding is that polyfit cannot be used, and I heard in some of the posts that a simple equation like X\Y will give me the slope. polyconf needs the S variable calculated in polyfit to generate the confidence interval DELTA. Is there any way I can generate this same variable for the new linear fit X\Y or perhaps another way to compute confidence intervals in this case?
> >
> > Thank you,
>
> http://www.mathworks.com/support/solutions/en/data/1-12BBUC/index.html?product=OP&solution=1-12BBUC

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com