I managed to remove the first row of the matrix from what I learned from digging around this website, but apparently there's an easier way to do it. This is what I currently have:
> prestige.income <- lm(prestige ~ log2(income), data=Prestige)
> prestige.edu <- lm(prestige ~ education, data=Prestige)
> prestige.women <- lm(prestige ~ women, data=Prestige)
> prestige.all <- lm(prestige ~ education + income + women, data=Prestige)
> comparison <- cbind(INCOME=coef(prestige.income), EDUCATION=coef(prestige.edu),
WOMEN=coef(prestige.women), ALL=coef(prestige.mod))
> comparison
INCOME EDUCATION WOMEN ALL
(Intercept) -139.85572 -10.731982 48.69299929 -110.96582409
education 14.94173 5.360878 -0.06417284 3.73050783
log2(income) -139.85572 -10.731982 48.69299929 9.31466643
women 14.94173 5.360878 -0.06417284 0.04689514
> remove <- rownames(comparison)[1]
> remove
[1] "(Intercept)"
> comp.noint <- comparison[!rownames(comparison) %in% remove, ]
> comp.noint
INCOME EDUCATION WOMEN ALL
education 14.94173 5.360878 -0.06417284 3.73050783
log2(income) -139.85572 -10.731982 48.69299929 9.31466643
women 14.94173 5.360878 -0.06417284 0.04689514
This is supposedly the easier way/way I was supposed to do it, but I don't understand why it works:
> comparison[-1,-5]
INCOME EDUCATION WOMEN ALL
education 14.94173 5.360878 -0.06417284 3.73050783
log2(income) -139.85572 -10.731982 48.69299929 9.31466643
women 14.94173 5.360878 -0.06417284 0.04689514
I was told the -1 gets rid of the first row, but it doesn't actually do that..
> comparison[-1]
[1] 14.94173191 -139.85572422 14.94173191 -10.73198197 5.36087773
[6] -10.73198197 5.36087773 48.69299929 -0.06417284 48.69299929
[11] -0.06417284 -110.96582409 3.73050783 9.31466643 0.04689514
And I was given no explanation for why the -5 does anything. I know this is probably a really basic question, but my teacher couldn't explain to me why this works and I can't find anything on Google or in the textbooks. Any help would be great. Thanks!