Well, see the help page for by() or an apply() function. But, YIKES, maybe work with a statistician who can help you with the underlying issue.
-----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Valeria Muzzolini Sent: Monday, October 14, 2013 7:47 AM To: r-help@r-project.org Subject: [R] repeat a linear regression model Hello, I'd like to repeat a linear regression model for groups of rows that are identified by an ID number. My table is like this: ID Y X1 X2 X3 X4 1 555 111 222 333 456 1 345 234 445 543 33 1 456 353 453 456 333 2 562 118 229 340 463 2 352 241 452 550 40 2 463 360 460 463 340 3 .... ... ... ... .... 3 3 I want to obtain an estimate of the linear model for each ID. ex. y = a1X1 + b1X2 + c1X3 + d1X4 where ID= 1 y = a2X1 + b2X2 + c2X3 + d2X4 where ID= 2 and so on... I'd like to obtain a table such this: ID a b c d 1 ... ... ... .. 2 .. .. .. .. 3 .. .. .. .. Can you sugget me something? Can I use a "for" script? Thank you very much! Valeria [[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 and provide commented, minimal, self-contained, reproducible code. ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.