tea_data <-make_tea_data(n_total =60)mod <-lm(rating ~ condition, data = tea_data)summary(mod)
Call:
lm(formula = rating ~ condition, data = tea_data)
Residuals:
Min 1Q Median 3Q Max
-2.6 -0.6 0.4 0.5 2.5
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.5000 0.2206 20.396 <2e-16 ***
conditiontea first -0.9000 0.3120 -2.884 0.0055 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.208 on 58 degrees of freedom
Multiple R-squared: 0.1255, Adjusted R-squared: 0.1104
F-statistic: 8.32 on 1 and 58 DF, p-value: 0.005495
7.2 Generalized linear models
tea_data$liked_tea <-ifelse(tea_data$rating >=5, 1, 0)modglm <-glm(liked_tea ~ condition, data = tea_data, family ="binomial")summary(modglm)
Call:
glm(formula = liked_tea ~ condition, family = "binomial", data = tea_data)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 8.287e-16 3.651e-01 0.000 1.0000
conditiontea first -1.190e+00 5.654e-01 -2.104 0.0354 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 78.859 on 59 degrees of freedom
Residual deviance: 74.185 on 58 degrees of freedom
AIC: 78.185
Number of Fisher Scoring iterations: 4
7.3 Linear mixed effects models
library(lme4)
Loading required package: Matrix
Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':
expand, pack, unpack
tea_data <- tea_data |>mutate(id =rep(1:30, times =2))mod_mix <-lmer(rating ~ condition + (1| id), data = tea_data)
boundary (singular) fit: see help('isSingular')
summary(mod_mix)
Linear mixed model fit by REML ['lmerMod']
Formula: rating ~ condition + (1 | id)
Data: tea_data
REML criterion at convergence: 193.4
Scaled residuals:
Min 1Q Median 3Q Max
-2.1515 -0.4965 0.3310 0.4138 2.0688
Random effects:
Groups Name Variance Std.Dev.
id (Intercept) 0.00 0.000
Residual 1.46 1.208
Number of obs: 60, groups: id, 30
Fixed effects:
Estimate Std. Error t value
(Intercept) 4.5000 0.2206 20.396
conditiontea first -0.9000 0.3120 -2.884
Correlation of Fixed Effects:
(Intr)
condtntfrst -0.707
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')