So, in the R Console I run a regression and then print the coefficients with:
summary(lm1)$coefficients
The result is nice and pretty. It gets messy when I copy and paste but it looks good. The name of each regressor is listed on a separate row and then coefficients follow, each in a nice column with a column header at the top.
In a script that I run in terminal (on my macbook, btw) I use this command:
dput(summary(lm1)$coefficients)
The result (I'm only going to paste part of it) is
>structure(c(-0.0206181857293946, -0.0017031360313225, 0.000315645616785813,
>0.000599803702896499, 0.000329152314647127, -0.000359972132038397,
>0.0069812874814682, -0.000468798197004485, 0.000260098693454015,
>
>...
>
>0.0292457238789278, 8.66406612930307e-11, 0.316665800834179,
>0.0207690630122154, 0.0080390491577215, 0.0141105679984487, >7.13568902235773e-06
>), .Dim = c(41L, 4L), .Dimnames = list(c("RatiotoSPY", >"fiveDayRatioStdDev",
>"RANKfiveDayRatioStdDev", "slopeFiveDayRatioStdDev", >"RANKslopeFiveDayRatioStdDev",
>
>....
So, a few things:
- The numbers themselves that are printed by the script do not match the numbers printed by the console. Frankly, I'm not sure what the script is printing.
- Some rows have three numbers separated by commas whereas other rows have four. The console has 4: estimate, std.error, t value, Pr(>|t|). Again, the script isn't printing the same values as the console at all.
- There is no label for the rows, it seems like the row labels are all aggregated into a list at the bottom.
Is there an easy way to print out the regression coefficients and statistics nicely?