Hi
I want to do linear regression
X_vec=a*Y_vec + b
.
.
.
where X_vec(1....100) and Y_vec (1..100) are vectors (say of size
100). So I have an overdetermined system where each vector value gives
me one equation and I want to determine 'a' and 'b' after regression.
I am bit novice any help?
"fas" <faisalmufti@gmail.com> wrote in message
news:13a0ad36-75d8-4ca0-b585-727d3a8ce1a9@w8g2000prd.googlegroups.com...
> Hi
> I want to do linear regression
> X_vec=a*Y_vec + b
> .
> .
> .
>
> where X_vec(1....100) and Y_vec (1..100) are vectors (say of size
> 100). So I have an overdetermined system where each vector value gives
> me one equation and I want to determine 'a' and 'b' after regression.
> I am bit novice any help?
Look at the Interactive Fitting and Programmatic Fitting sections of the
Data Analysis documentation:
fas <faisalmufti@gmail.com> wrote in message <13a0ad36-75d8-4ca0-b585-
727d3a8ce1a9@w8g2000prd.googlegroups.com>...
> Hi
> I want to do linear regression
> X_vec=a*Y_vec + b
> .
> .
> .
>
> where X_vec(1....100) and Y_vec (1..100) are vectors (say of size
> 100). So I have an overdetermined system where each vector value gives
> me one equation and I want to determine 'a' and 'b' after regression.
> I am bit novice any help?
On May 16, 11:31 pm, "John D'Errico" <woodch...@rochester.rr.com>
wrote:
> fas <faisalmu...@gmail.com> wrote in message <13a0ad36-75d8-4ca0-b585-
>
> 727d3a8ce...@w8g2000prd.googlegroups.com>...
>
> > Hi
> > I want to do linear regression
> > X_vec=a*Y_vec + b
> > .
> > .
> > .
>
> > where X_vec(1....100) and Y_vec (1..100) are vectors (say of size
> > 100). So I have an overdetermined system where each vector value gives
> > me one equation and I want to determine 'a' and 'b' after regression.
> > I am bit novice any help?
>
> polyfit
>
> John
My data is 100x100, 2D which I have converted to X(:) as same for Y,
but it seems its not the right approach to run 1D polyfit on it. Any
idea what to do now
fas <faisalmufti@gmail.com> wrote in message <4c336df8-f903-4db2-
bb4a-7a8cf785ec45@j33g2000pri.googlegroups.com>...
> On May 16, 11:31 pm, "John D'Errico" <woodch...@rochester.rr.com>
> wrote:
> > fas <faisalmu...@gmail.com> wrote in message <13a0ad36-75d8-
4ca0-b585-
> >
> > 727d3a8ce...@w8g2000prd.googlegroups.com>...
> >
> > > Hi
> > > I want to do linear regression
> > > X_vec=a*Y_vec + b
> > > .
> > > .
> > > .
> >
> > > where X_vec(1....100) and Y_vec (1..100) are vectors (say of size
> > > 100). So I have an overdetermined system where each vector value
gives
> > > me one equation and I want to determine 'a' and 'b' after regression.
> > > I am bit novice any help?
> >
> > polyfit
> >
> > John
>
> My data is 100x100, 2D which I have converted to X(:) as same for Y,
> but it seems its not the right approach to run 1D polyfit on it. Any
> idea what to do now
You need to think about what you want to
do, or at least explain yourself more clearly.
You will find that learning to explain yourself
clearly will often bring you directly to the
answer that you need.
You have an array X and an array Y. Originally
you said that X and Y were vectors of length
100. Now you are telling us that they are
arrays of size 100x100. It cannot be both.
On May 17, 9:51 pm, "John D'Errico" <woodch...@rochester.rr.com>
wrote:
> fas <faisalmu...@gmail.com> wrote in message <4c336df8-f903-4db2-
>
> bb4a-7a8cf785e...@j33g2000pri.googlegroups.com>...
>
>
>
> > On May 16, 11:31 pm, "John D'Errico" <woodch...@rochester.rr.com>
> > wrote:
> > > fas <faisalmu...@gmail.com> wrote in message <13a0ad36-75d8-
> 4ca0-b585-
>
> > > 727d3a8ce...@w8g2000prd.googlegroups.com>...
>
> > > > Hi
> > > > I want to do linear regression
> > > > X_vec=a*Y_vec + b
> > > > .
> > > > .
> > > > .
>
> > > > where X_vec(1....100) and Y_vec (1..100) are vectors (say of size
> > > > 100). So I have an overdetermined system where each vector value
> gives
> > > > me one equation and I want to determine 'a' and 'b' after regression.
> > > > I am bit novice any help?
>
> > > polyfit
>
> > > John
>
> > My data is 100x100, 2D which I have converted to X(:) as same for Y,
> > but it seems its not the right approach to run 1D polyfit on it. Any
> > idea what to do now
>
> You need to think about what you want to
> do, or at least explain yourself more clearly.
> You will find that learning to explain yourself
> clearly will often bring you directly to the
> answer that you need.
>
> You have an array X and an array Y. Originally
> you said that X and Y were vectors of length
> 100. Now you are telling us that they are
> arrays of size 100x100. It cannot be both.
>
> Try a little harder. Explain your problem.
>
> John
Ok, X and Y were for an example case are of size 100. In actual X and
Y are both of 2D of size (100x100 again example case). I converted
them to vectorized form as 10000x1. So I have 10000 equations each for
one point and now I want to fit polyfit. But the problem is that as
they are converted from 2D matrix. If I plot in 1D they do not appear
right and hence I believe polyfit may not work. The other option I can
think of is to sort it after converting it into vectorized form, so
that then can come in some order (for of some curve). Will it be ok to
apply polyfit on it. Will the coefficient that I find will have same
meaning or if the regression is done on the same 2D function (some
how)
Thanks,
On May 17, 8:35=A0pm, fas <faisalmu...@gmail.com> wrote:
> On May 17, 9:51 pm, "John D'Errico" <woodch...@rochester.rr.com>
> wrote:
>
>
>
>
>
> > fas <faisalmu...@gmail.com> wrote in message <4c336df8-f903-4db2-
>
> > bb4a-7a8cf785e...@j33g2000pri.googlegroups.com>...
>
> > > On May 16, 11:31 pm, "John D'Errico" <woodch...@rochester.rr.com>
> > > wrote:
> > > > fas <faisalmu...@gmail.com> wrote in message <13a0ad36-75d8-
> > 4ca0-b585-
>
> > > > 727d3a8ce...@w8g2000prd.googlegroups.com>...
>
> > > > > Hi
> > > > > I want to do linear regression
> > > > > X_vec=3Da*Y_vec + b
> > > > > .
> > > > > .
> > > > > .
>
> > > > > where X_vec(1....100) and Y_vec (1..100) are vectors (say of size
> > > > > 100). So I have an overdetermined system where each vector value
> > gives
> > > > > me one equation and I want to determine 'a' and 'b' after regressi=
on.
> > > > > I am bit novice any help?
>
> > > > polyfit
>
> > > > John
>
> > > My data is 100x100, 2D which I have converted to X(:) as same for Y,
> > > but it seems its not the right approach to run 1D polyfit on it. Any
> > > idea what to do now
>
> > You need to think about what you want to
> > do, or at least explain yourself more clearly.
> > You will find that learning to explain yourself
> > clearly will often bring you directly to the
> > answer that you need.
>
> > You have an array X and an array Y. Originally
> > you said that X and Y were vectors of length
> > 100. Now you are telling us that they are
> > arrays of size 100x100. It cannot be both.
>
> > Try a little harder. Explain your problem.
>
> > John
>
> Ok, X and Y were for an example case are of size 100. In actual X and
> Y are both of 2D of size (100x100 =A0again example case). I converted
> them to vectorized form as 10000x1. So I have 10000 equations each for
> one point and now I want to fit polyfit. But the problem is that as
> they are converted from 2D matrix. If I plot in 1D they do not appear
> right and hence I believe polyfit may not work. The other option I can
> think of is to sort it after converting it into vectorized form, so
> that then can come in some order (for of some curve). Will it be ok to
> apply polyfit on it. Will the coefficient that I find will have same
> meaning or if the regression is done on the same 2D function (some
> how)
> Thanks,-
On May 18, 7:39 pm, Greg Heath <he...@alumni.brown.edu> wrote:
> On May 17, 8:35 pm, fas <faisalmu...@gmail.com> wrote:
>
>
>
> > On May 17, 9:51 pm, "John D'Errico" <woodch...@rochester.rr.com>
> > wrote:
>
> > > fas <faisalmu...@gmail.com> wrote in message <4c336df8-f903-4db2-
>
> > > bb4a-7a8cf785e...@j33g2000pri.googlegroups.com>...
>
> > > > On May 16, 11:31 pm, "John D'Errico" <woodch...@rochester.rr.com>
> > > > wrote:
> > > > > fas <faisalmu...@gmail.com> wrote in message <13a0ad36-75d8-
> > > 4ca0-b585-
>
> > > > > 727d3a8ce...@w8g2000prd.googlegroups.com>...
>
> > > > > > Hi
> > > > > > I want to do linear regression
> > > > > > X_vec=a*Y_vec + b
> > > > > > .
> > > > > > .
> > > > > > .
>
> > > > > > where X_vec(1....100) and Y_vec (1..100) are vectors (say of size
> > > > > > 100). So I have an overdetermined system where each vector value
> > > gives
> > > > > > me one equation and I want to determine 'a' and 'b' after regression.
> > > > > > I am bit novice any help?
>
> > > > > polyfit
>
> > > > > John
>
> > > > My data is 100x100, 2D which I have converted to X(:) as same for Y,
> > > > but it seems its not the right approach to run 1D polyfit on it. Any
> > > > idea what to do now
>
> > > You need to think about what you want to
> > > do, or at least explain yourself more clearly.
> > > You will find that learning to explain yourself
> > > clearly will often bring you directly to the
> > > answer that you need.
>
> > > You have an array X and an array Y. Originally
> > > you said that X and Y were vectors of length
> > > 100. Now you are telling us that they are
> > > arrays of size 100x100. It cannot be both.
>
> > > Try a little harder. Explain your problem.
>
> > > John
>
> > Ok, X and Y were for an example case are of size 100. In actual X and
> > Y are both of 2D of size (100x100 again example case). I converted
> > them to vectorized form as 10000x1. So I have 10000 equations each for
> > one point and now I want to fit polyfit. But the problem is that as
> > they are converted from 2D matrix. If I plot in 1D they do not appear
> > right and hence I believe polyfit may not work. The other option I can
> > think of is to sort it after converting it into vectorized form, so
> > that then can come in some order (for of some curve). Will it be ok to
> > apply polyfit on it. Will the coefficient that I find will have same
> > meaning or if the regression is done on the same 2D function (some
> > how)
> > Thanks,-
>
> Why is it more difficult than solving
>
> Y = W*[ones(100);X]
>
> for W?
>
> Hope this helps.
>
> Greg
Sorry I could not get you completely. ?
I would like to know that if we convert a nxm (matrix ) function to 1D
and then sort it and then polyfit . Can we use the result. As in a 3D
format( nxm) matrix I cannot use polyfit :(
fas <faisalmufti@gmail.com> wrote in message <f4a869df-f422-47d9-
bda7-1daafa173bb1@z16g2000prn.googlegroups.com>...
> > Why is it more difficult than solving
> >
> > Y = W*[ones(100);X]
> >
> > for W?
> >
> > Hope this helps.
> >
> > Greg
>
> Sorry I could not get you completely. ?
>
> I would like to know that if we convert a nxm (matrix ) function to 1D
> and then sort it and then polyfit . Can we use the result. As in a 3D
> format( nxm) matrix I cannot use polyfit :(
fas <faisalmufti@gmail.com> wrote in message <2e7d4e65-1ce4-4bf3-
8ab3-81f0bae4638c@c19g2000prf.googlegroups.com>...
> Ok, X and Y were for an example case are of size 100. In actual X and
> Y are both of 2D of size (100x100 again example case). I converted
> them to vectorized form as 10000x1. So I have 10000 equations each for
> one point and now I want to fit polyfit. But the problem is that as
> they are converted from 2D matrix. If I plot in 1D they do not appear
> right and hence I believe polyfit may not work. The other option I can
> think of is to sort it after converting it into vectorized form, so
> that then can come in some order (for of some curve). Will it be ok to
> apply polyfit on it. Will the coefficient that I find will have same
> meaning or if the regression is done on the same 2D function (some
> how)
> Thanks,
What does not "appear" right?
If your model is as stated, then this is correct.
I think that you are asking to do a 2-d regression,
in both the x and y directinos, but for some reason
do not realize that is what you want to do. Or, you
just don't want to admit it.
On May 18, 9:29 pm, "John D'Errico" <woodch...@rochester.rr.com>
wrote:
> fas <faisalmu...@gmail.com> wrote in message <2e7d4e65-1ce4-4bf3-
>
> 8ab3-81f0bae46...@c19g2000prf.googlegroups.com>...
>
> > Ok, X and Y were for an example case are of size 100. In actual X and
> > Y are both of 2D of size (100x100 again example case). I converted
> > them to vectorized form as 10000x1. So I have 10000 equations each for
> > one point and now I want to fit polyfit. But the problem is that as
> > they are converted from 2D matrix. If I plot in 1D they do not appear
> > right and hence I believe polyfit may not work. The other option I can
> > think of is to sort it after converting it into vectorized form, so
> > that then can come in some order (for of some curve). Will it be ok to
> > apply polyfit on it. Will the coefficient that I find will have same
> > meaning or if the regression is done on the same 2D function (some
> > how)
> > Thanks,
>
> What does not "appear" right?
>
> If your model is as stated, then this is correct.
>
> I think that you are asking to do a 2-d regression,
> in both the x and y directinos, but for some reason
> do not realize that is what you want to do. Or, you
> just don't want to admit it.
>
> John
I admit that I wan to to do 2D regression. So if I want to to do that
then doing a vectorization and sorting and then regression may not be
right (Is it?). So in that case how to to 2D regression ?
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.
Public Submission Policy
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 Disclaimer prior to use.