Hello all,
I am new to r programmeand need help. I want to do
multiple linear regression analysis. say, I have two matrix 'x' and
'y'. I
want, 'x' as my response variable and 'y' as predictor.
Each time one column of 'x' will be the response, say x[,1], then next
x[,2]
and so on. And also I need to store the coefficients in a matrix form.
Please help me.
> x
[,1] [,2] [,3] [,4]
[1,] -1 0 0 0
[2,] 0 -1 0 0
[3,] 0 0 -1 0
[4,] 0 0 0 -1
> y
[,1] [,2] [,3] [,4]
[1,] 0.6748156 0.266461216 -0.6883143 2.1332456
[2,] 0.5668101 0.295578807 0.1743760 0.4730689
[3,] -2.9465207 -2.313246341 -0.6060058 0.6236515
[4,] -1.5882276 0.002852312 -1.3152300 0.9082773>
Thanks in advance
Angila A.
[[alternative HTML version deleted]]
That can be accomplished with 8 keystrokes. A hint is to do the 4 keystrokes: ?lm Patrick Burns patrick at burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Angila Albaros wrote:> Hello all, > I am new to r programmeand need help. I want to do > multiple linear regression analysis. say, I have two matrix 'x' and 'y'. I > want, 'x' as my response variable and 'y' as predictor. > Each time one column of 'x' will be the response, say x[,1], then next x[,2] > and so on. And also I need to store the coefficients in a matrix form. > Please help me. > > > > > >> x >> > [,1] [,2] [,3] [,4] > [1,] -1 0 0 0 > [2,] 0 -1 0 0 > [3,] 0 0 -1 0 > [4,] 0 0 0 -1 > > > > >> y >> > [,1] [,2] [,3] [,4] > [1,] 0.6748156 0.266461216 -0.6883143 2.1332456 > [2,] 0.5668101 0.295578807 0.1743760 0.4730689 > [3,] -2.9465207 -2.313246341 -0.6060058 0.6236515 > [4,] -1.5882276 0.002852312 -1.3152300 0.9082773 > > > Thanks in advance > Angila A. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > >
On 7/15/08, Angila Albaros <angilaros@gmail.com> wrote:> > Dear Sir, > Thanks for your reply but my data is very huge 100 x 550 ( > for x ) and 100 x 1010 ( for y). So, I think that time , I need to take one > column of x ($x1)and do multiple regreesion with y data set.i.e x1 will be > my response and y data set is predictor, then $x2 with whole y data set and > so on. Can I use some loop ? if yes how? Just for an example, I have put > this example. > > > Thanks and regards > > Angila A. > > > On 7/15/08, Patrick Burns <pburns@pburns.seanet.com> wrote: >> >> That can be accomplished with 8 keystrokes. >> A hint is to do the 4 keystrokes: >> ?lm >> >> >> Patrick Burns >> patrick@burns-stat.com >> +44 (0)20 8525 0696 >> http://www.burns-stat.com >> (home of S Poetry and "A Guide for the Unwilling S User") >> >> Angila Albaros wrote: >> >>> Hello all, >>> I am new to r programmeand need help. I want to do >>> multiple linear regression analysis. say, I have two matrix 'x' and 'y'. >>> I >>> want, 'x' as my response variable and 'y' as predictor. >>> Each time one column of 'x' will be the response, say x[,1], then next >>> x[,2] >>> and so on. And also I need to store the coefficients in a matrix form. >>> Please help me. >>> >>> >>> >>> >>> >>> >>>> x >>>> >>>> >>> [,1] [,2] [,3] [,4] >>> [1,] -1 0 0 0 >>> [2,] 0 -1 0 0 >>> [3,] 0 0 -1 0 >>> [4,] 0 0 0 -1 >>> >>> >>> >>> >>> >>>> y >>>> >>>> >>> [,1] [,2] [,3] [,4] >>> [1,] 0.6748156 0.266461216 -0.6883143 2.1332456 >>> [2,] 0.5668101 0.295578807 0.1743760 0.4730689 >>> [3,] -2.9465207 -2.313246341 -0.6060058 0.6236515 >>> [4,] -1.5882276 0.002852312 -1.3152300 0.9082773 >>> >>> Thanks in advance >>> Angila A. >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> >>> and provide commented, minimal, self-contained, reproducible code. >>> >>> >>> >>> >> >[[alternative HTML version deleted]]