From: Jay-Anne Padayao on
Hi!..
I am having a hard time doing a program regarding Multiple
regression,wherein the user is prompt to input the independent
variable(x1,x2,x3,...xn)as well as the dependent variable y.

I can only do it with 2 independent variable,but I can't function it
anymore if I try having three and more independent variables.

Need your help!..
Thanks!

Regards,
Jen
From: TideMan on
On Mar 6, 10:48 am, Jay-Anne Padayao <jayanne.pada...(a)gmail.com>
wrote:
> Hi!..
> I am having a hard time doing a program regarding Multiple
> regression,wherein the user is prompt to input the independent
> variable(x1,x2,x3,...xn)as well as the dependent variable y.
>
> I can only do it with 2 independent variable,but I can't function it
> anymore if I try having three and more independent variables.
>
> Need your help!..
> Thanks!
>
> Regards,
> Jen

The general solution is:
A\y
where A is a matrix of the independent variables.
I don't understand why you have problems with more than two
independent variables. Matlab does all the work for you.
From: Jay-Anne Padayao on

> The general solution is:
> A\y
> where A is a matrix of the independent variables.
> I don't understand why you have problems with more than two
> independent variables.  Matlab does all the work for you.



Yes..but my problem goes with the fact that this program must be
applicable to any user input..
What i mean is..the user must be asked the ff:
How many independent variables do you have:
(the no. of x values to be asked below depends to the answer to this
question)
Input x1:
Input x2:
Input xn:
Input Y:
coeff=
The equation will be:

From: TideMan on
On Mar 6, 11:41 am, Jay-Anne Padayao <jayanne.pada...(a)gmail.com>
wrote:
> > The general solution is:
> > A\y
> > where A is a matrix of the independent variables.
> > I don't understand why you have problems with more than two
> > independent variables.  Matlab does all the work for you.
>
> Yes..but my problem goes with the fact that this program must be
> applicable to any user input..
> What i mean is..the user must be asked the ff:
> How many independent variables do you have:
> (the no. of x values to be asked below depends to the answer to this
> question)
> Input x1:
> Input x2:
> Input xn:
> Input Y:
> coeff=
> The equation will be:

Well don't put them in individual vectors.
That takes too much programming.
Put them straight into the matrix A.
A=zeros(nt,nvar); % preallocate
then first x goes into A(:,1), second into A(:,2), and so on.
From: Jay-Anne Padayao on

> Well don't put them in individual vectors.
> That takes too much programming.
> Put them straight into the matrix A.
> A=zeros(nt,nvar);  % preallocate
> then first x goes into A(:,1), second into A(:,2), and so on.

ok..I'll do it..I am not familiar with (nt,nvar);
what does this mean?...
and..after getting A,
will it still go to the same process?
b= A\y?