t -tests
one-way ANOVAs
Mutiple categorical predictors
within groups and between groups
compare SSbetween and SSwithin using our F statistic
anova(m)
summary(aov(m))
the highest-level interactions
> m <- lm(breaks ~ wool+tension+wool:tension, contrasts=list(wool="contr.helmert", tension="contr.helmert"), data=warpbreaks)
> anova(m)
Analysis of Variance Table
Response: breaks
Df Sum Sq Mean Sq F value Pr(>F)
wool 1 450.7 450.67 3.7653 0.0582130 .
tension 2 2034.3 1017.13 8.4980 0.0006926 ***
wool:tension 2 1002.8 501.39 4.1891 0.0210442 *
Residuals 48 5745.1 119.69
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
with(warpbreaks, interaction.plot(wool, tension, breaks))
with is a generic function that evaluates expr in a local environment constructed from data.
interaction.plot()
the durationsOnt data set from the languageR package
> head(CO2)
Grouped Data: uptake ~ conc | Plant
<environment: R_EmptyEnv>
Plant Type Treatment conc uptake
1 Qn1 Quebec nonchilled 95 16.0
2 Qn1 Quebec nonchilled 175 30.4
3 Qn1 Quebec nonchilled 250 34.8
4 Qn1 Quebec nonchilled 350 37.2
5 Qn1 Quebec nonchilled 500 35.3
6 Qn1 Quebec nonchilled 675 39.2
> with(CO2, interaction.plot(Treatment, Type, uptake))
library(languageR)
englishy <- english[english$AgeSubject=="young",]
被験者「young」だけの抽出。
plot(RTlexdec ~ WrittenFrequency, englishy)
「young」の被験者データについて、反応時間と頻度の対応関係をプロット。
右下がりの傾向=>頻度の高い単語は反応が速い。
> m <- lm(RTlexdec ~ WrittenFrequency, englishy)
>
> m
Call:
lm(formula = RTlexdec ~ WrittenFrequency, data = englishy)
Coefficients:
(Intercept) WrittenFrequency
6.62556 -0.03711
> summary(m)
Call:
lm(formula = RTlexdec ~ WrittenFrequency, data = englishy)
Residuals:
Min 1Q Median 3Q Max
-0.34664 -0.05523 -0.00546 0.05167 0.34877
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.6255559 0.0049432 1340.34 <2e-16 ***
WrittenFrequency -0.0371069 0.0009242 -40.15 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.08142 on 2282 degrees of freedom
Multiple R-squared: 0.414, Adjusted R-squared: 0.4137
F-statistic: 1612 on 1 and 2282 DF, p-value: < 2.2e-16
more than one continuous predictor
n <- lm(RTlexdec ~ WrittenFrequency + FrequencyInitialDiphoneSyllable, englishy)
> n <- lm(RTlexdec ~ WrittenFrequency + FrequencyInitialDiphoneSyllable, englishy)
>
> n
Call:
lm(formula = RTlexdec ~ WrittenFrequency + FrequencyInitialDiphoneSyllable,
data = englishy)
Coefficients:
(Intercept) WrittenFrequency
6.614295 -0.037193
FrequencyInitialDiphoneSyllable
0.001084
> summary(n)
Call:
lm(formula = RTlexdec ~ WrittenFrequency + FrequencyInitialDiphoneSyllable,
data = englishy)
Residuals:
Min 1Q Median 3Q Max
-0.34483 -0.05525 -0.00584 0.05185 0.34635
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.614295 0.012171 543.435 <2e-16 ***
WrittenFrequency -0.037193 0.000928 -40.077 <2e-16 ***
FrequencyInitialDiphoneSyllable 0.001084 0.001070 1.012 0.311
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.08141 on 2281 degrees of freedom
Multiple R-squared: 0.4143, Adjusted R-squared: 0.4137
F-statistic: 806.6 on 2 and 2281 DF, p-value: < 2.2e-16
Regression diagnostics
plot(n)
> q <- lm(RTlexdec ~ WrittenFrequency + I(WrittenFrequency^2), englishy)
>
> plot(q)
one-way ANOVAs
Mutiple categorical predictors
within groups and between groups
compare SSbetween and SSwithin using our F statistic
anova(m)
summary(aov(m))
the highest-level interactions
> m <- lm(breaks ~ wool+tension+wool:tension, contrasts=list(wool="contr.helmert", tension="contr.helmert"), data=warpbreaks)
> anova(m)
Analysis of Variance Table
Response: breaks
Df Sum Sq Mean Sq F value Pr(>F)
wool 1 450.7 450.67 3.7653 0.0582130 .
tension 2 2034.3 1017.13 8.4980 0.0006926 ***
wool:tension 2 1002.8 501.39 4.1891 0.0210442 *
Residuals 48 5745.1 119.69
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
with(warpbreaks, interaction.plot(wool, tension, breaks))
with is a generic function that evaluates expr in a local environment constructed from data.
interaction.plot()
the durationsOnt data set from the languageR package
> head(CO2)
Grouped Data: uptake ~ conc | Plant
<environment: R_EmptyEnv>
Plant Type Treatment conc uptake
1 Qn1 Quebec nonchilled 95 16.0
2 Qn1 Quebec nonchilled 175 30.4
3 Qn1 Quebec nonchilled 250 34.8
4 Qn1 Quebec nonchilled 350 37.2
5 Qn1 Quebec nonchilled 500 35.3
6 Qn1 Quebec nonchilled 675 39.2
> with(CO2, interaction.plot(Treatment, Type, uptake))
library(languageR)
englishy <- english[english$AgeSubject=="young",]
被験者「young」だけの抽出。
plot(RTlexdec ~ WrittenFrequency, englishy)
「young」の被験者データについて、反応時間と頻度の対応関係をプロット。
右下がりの傾向=>頻度の高い単語は反応が速い。
> m <- lm(RTlexdec ~ WrittenFrequency, englishy)
>
> m
Call:
lm(formula = RTlexdec ~ WrittenFrequency, data = englishy)
Coefficients:
(Intercept) WrittenFrequency
6.62556 -0.03711
> summary(m)
Call:
lm(formula = RTlexdec ~ WrittenFrequency, data = englishy)
Residuals:
Min 1Q Median 3Q Max
-0.34664 -0.05523 -0.00546 0.05167 0.34877
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.6255559 0.0049432 1340.34 <2e-16 ***
WrittenFrequency -0.0371069 0.0009242 -40.15 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.08142 on 2282 degrees of freedom
Multiple R-squared: 0.414, Adjusted R-squared: 0.4137
F-statistic: 1612 on 1 and 2282 DF, p-value: < 2.2e-16
more than one continuous predictor
n <- lm(RTlexdec ~ WrittenFrequency + FrequencyInitialDiphoneSyllable, englishy)
> n <- lm(RTlexdec ~ WrittenFrequency + FrequencyInitialDiphoneSyllable, englishy)
>
> n
Call:
lm(formula = RTlexdec ~ WrittenFrequency + FrequencyInitialDiphoneSyllable,
data = englishy)
Coefficients:
(Intercept) WrittenFrequency
6.614295 -0.037193
FrequencyInitialDiphoneSyllable
0.001084
> summary(n)
Call:
lm(formula = RTlexdec ~ WrittenFrequency + FrequencyInitialDiphoneSyllable,
data = englishy)
Residuals:
Min 1Q Median 3Q Max
-0.34483 -0.05525 -0.00584 0.05185 0.34635
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.614295 0.012171 543.435 <2e-16 ***
WrittenFrequency -0.037193 0.000928 -40.077 <2e-16 ***
FrequencyInitialDiphoneSyllable 0.001084 0.001070 1.012 0.311
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.08141 on 2281 degrees of freedom
Multiple R-squared: 0.4143, Adjusted R-squared: 0.4137
F-statistic: 806.6 on 2 and 2281 DF, p-value: < 2.2e-16
Regression diagnostics
plot(n)
> q <- lm(RTlexdec ~ WrittenFrequency + I(WrittenFrequency^2), englishy)
>
> plot(q)