[R] Customized R Regression Output?

Greg Snow 538280 at gmail.com
Wed May 30 18:43:59 CEST 2012


Are the x variables all the same?  if so, you can give lm a matrix as
the y variable and it will compute all the different regressions for
each column in the y matrix.  The summary function will then return a
list with the summary information for each of the regressions.

If the x variables are not identical between regressions then you
could stack all your data sets in a data frame and use the lmList
function from the nlme package to do all the regressions in one step
and get a list of returns.

In either case you can then use the sapply function to extract the
information you want from each summary and it will combine them into a
matrix for you (or use the plyr package for a little more control).

On Sun, May 27, 2012 at 6:20 AM, Chris87 <c.satzky at gmail.com> wrote:
> Hello R-Experts,
>
> I am facing the problem that I have to estimate several parameters for a lot
> of different dependent variables.
>
> One single regression looks something like this:
>
> y = beta0 + beta1 * x1 + beta2 * x2 + beta3 * x1 * x2 + beta4 * x4 + beta5 *
> lag(x4,-1)
>
> where y is the dependent variable and xi are the independent ones. Important
> to me are the different estimates of betai and their respective p-values
> only.  Now I have aprx. 50 different data sets of y and x1 to x4. So for
> each data set I need the respective estimators and their p-values. Do I
> really have to type in each single regression for each data set and copy the
> output into a table manually?
>
> Isn't it possible to get an efficient output like the following?
>
> beta0(data set 1) | P-Value(beta0, data set 1) | beta1(data set 1) |
> P-Value(beta1, data set 1)| .... | P-Value(beta5, data set n)
>
>
> Or at least getting a vector with all the estimates of beta0 for each data
> set, another vector with all estimates of beta1 for each data set, and a
> matrix with P-values for each betai of each data set?
>
> The file containing the observations for xi and y for each set of data can
> be adjusted to any kind of format.
>
> Thank you very much in advance.
>
> With kind regards
> Christian
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Customized-R-Regression-Output-tp4631497.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list