As usual, a more detailed accounting can be obtained via the callstr(lma).
The estimated values ofβiare stored inlma$coefficients. You can display
them by typing the name at the prompt.
You can also save some typing by abbreviating component names, as
long as you don’t shorten a component’s name to the point of being ambig-
uous. For example, if a list consists of the componentsxyz,xywa, andxbcde,
then the second and third components can be abbreviated toxywandxb,
respectively. So here we could type the following:
> lma$coef
(Intercept) examsquiz[, 1]
1.1205209 0.5899803
Sincelma$coefficientsis a vector, printing it is simple. But consider what
happens when you print the objectlmaitself:
> lma
Call:
lm(formula = examsquiz[, 2] ~ examsquiz[, 1])
Coefficients:
(Intercept) examsquiz[, 1]
1.121 0.590
Why did R print only these items and not the other components oflma?
The answer is that here R is using theprint()function, which is another
example of generic functions. As a generic function,print()actually hands
off the work to another function whose job is to print objects of classlm—
theprint.lm()function—and this is what that function displays.
We can get a more detailed printout of the contents oflmaby call-
ingsummary(), the generic function discussed earlier. It triggers a call to
summary.lm()behind the scenes, and we get a regression-specific summary:
> summary(lma)
Call:
lm(formula = examsquiz[, 2] ~ examsquiz[, 1])
Residuals:
Min 1Q Median 3Q Max
-3.4804 -0.1239 0.3426 0.7261 1.2225
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.1205 0.6375 1.758 0.08709.
examsquiz[, 1] 0.5900 0.2030 2.907 0.00614**
...
18 Chapter 1