Outputting Regression results into a data frame in R

Viewed 3118

I was wondering if there is any command that can output the results of a lm model into a data frame in R like outest in SAS. Any ideas? I am running multiple models and I want the result to look like below -

Model  |  alpha   | Beta | Rsquared | F |  df |
model0 |  8.4     | ...  | ....     | ..|  .. |
model1 |  ...     | ...  | ....     | ..|  .. |
model2 |  ...     | ...  | ....     | ..|  .. |

The data i have is 'ds' which is -

X1 | X2 | Y1 |
.. | .. | .. |
.. | .. | .. |
.. | .. | .. |
.. | .. | .. |

And my code is a simple lm code -

model0 <- lm(Y1 ~ X1, ds)
model1 <- lm(Y1 ~ 1, ds)
model2 <- lm(Y1 ~ X1 + X2, ds)
2 Answers
Related