17/03, 2022
Plant | Type | Treatment | conc | uptake |
---|---|---|---|---|
Qn1 | Quebec | nonchilled | 95 | 16.0 |
Qn1 | Quebec | nonchilled | 175 | 30.4 |
Qn1 | Quebec | nonchilled | 250 | 34.8 |
Qn1 | Quebec | nonchilled | 350 | 37.2 |
Qn1 | Quebec | nonchilled | 500 | 35.3 |
Qn1 | Quebec | nonchilled | 675 | 39.2 |
Qn1 | Quebec | nonchilled | 1000 | 39.7 |
Qn2 | Quebec | nonchilled | 95 | 13.6 |
Qn2 | Quebec | nonchilled | 175 | 27.3 |
Qn2 | Quebec | nonchilled | 250 | 37.1 |
Qn2 | Quebec | nonchilled | 350 | 41.8 |
Qn2 | Quebec | nonchilled | 500 | 40.6 |
Qn2 | Quebec | nonchilled | 675 | 41.4 |
Qn2 | Quebec | nonchilled | 1000 | 44.3 |
Qn3 | Quebec | nonchilled | 95 | 16.2 |
Qn3 | Quebec | nonchilled | 175 | 32.4 |
Qn3 | Quebec | nonchilled | 250 | 40.3 |
Qn3 | Quebec | nonchilled | 350 | 42.1 |
Qn3 | Quebec | nonchilled | 500 | 42.9 |
Qn3 | Quebec | nonchilled | 675 | 43.9 |
Qn3 | Quebec | nonchilled | 1000 | 45.5 |
Qc1 | Quebec | chilled | 95 | 14.2 |
Qc1 | Quebec | chilled | 175 | 24.1 |
Qc1 | Quebec | chilled | 250 | 30.3 |
Qc1 | Quebec | chilled | 350 | 34.6 |
Qc1 | Quebec | chilled | 500 | 32.5 |
Qc1 | Quebec | chilled | 675 | 35.4 |
Qc1 | Quebec | chilled | 1000 | 38.7 |
Qc2 | Quebec | chilled | 95 | 9.3 |
Qc2 | Quebec | chilled | 175 | 27.3 |
Qc2 | Quebec | chilled | 250 | 35.0 |
Qc2 | Quebec | chilled | 350 | 38.8 |
Qc2 | Quebec | chilled | 500 | 38.6 |
Qc2 | Quebec | chilled | 675 | 37.5 |
Qc2 | Quebec | chilled | 1000 | 42.4 |
Qc3 | Quebec | chilled | 95 | 15.1 |
Qc3 | Quebec | chilled | 175 | 21.0 |
Qc3 | Quebec | chilled | 250 | 38.1 |
Qc3 | Quebec | chilled | 350 | 34.0 |
Qc3 | Quebec | chilled | 500 | 38.9 |
Qc3 | Quebec | chilled | 675 | 39.6 |
Qc3 | Quebec | chilled | 1000 | 41.4 |
Mn1 | Mississippi | nonchilled | 95 | 10.6 |
Mn1 | Mississippi | nonchilled | 175 | 19.2 |
Mn1 | Mississippi | nonchilled | 250 | 26.2 |
Mn1 | Mississippi | nonchilled | 350 | 30.0 |
Mn1 | Mississippi | nonchilled | 500 | 30.9 |
Mn1 | Mississippi | nonchilled | 675 | 32.4 |
Mn1 | Mississippi | nonchilled | 1000 | 35.5 |
Mn2 | Mississippi | nonchilled | 95 | 12.0 |
Mn2 | Mississippi | nonchilled | 175 | 22.0 |
Mn2 | Mississippi | nonchilled | 250 | 30.6 |
Mn2 | Mississippi | nonchilled | 350 | 31.8 |
Mn2 | Mississippi | nonchilled | 500 | 32.4 |
Mn2 | Mississippi | nonchilled | 675 | 31.1 |
Mn2 | Mississippi | nonchilled | 1000 | 31.5 |
Mn3 | Mississippi | nonchilled | 95 | 11.3 |
Mn3 | Mississippi | nonchilled | 175 | 19.4 |
Mn3 | Mississippi | nonchilled | 250 | 25.8 |
Mn3 | Mississippi | nonchilled | 350 | 27.9 |
Mn3 | Mississippi | nonchilled | 500 | 28.5 |
Mn3 | Mississippi | nonchilled | 675 | 28.1 |
Mn3 | Mississippi | nonchilled | 1000 | 27.8 |
Mc1 | Mississippi | chilled | 95 | 10.5 |
Mc1 | Mississippi | chilled | 175 | 14.9 |
Mc1 | Mississippi | chilled | 250 | 18.1 |
Mc1 | Mississippi | chilled | 350 | 18.9 |
Mc1 | Mississippi | chilled | 500 | 19.5 |
Mc1 | Mississippi | chilled | 675 | 22.2 |
Mc1 | Mississippi | chilled | 1000 | 21.9 |
Mc2 | Mississippi | chilled | 95 | 7.7 |
Mc2 | Mississippi | chilled | 175 | 11.4 |
Mc2 | Mississippi | chilled | 250 | 12.3 |
Mc2 | Mississippi | chilled | 350 | 13.0 |
Mc2 | Mississippi | chilled | 500 | 12.5 |
Mc2 | Mississippi | chilled | 675 | 13.7 |
Mc2 | Mississippi | chilled | 1000 | 14.4 |
Mc3 | Mississippi | chilled | 95 | 10.6 |
Mc3 | Mississippi | chilled | 175 | 18.0 |
Mc3 | Mississippi | chilled | 250 | 17.9 |
Mc3 | Mississippi | chilled | 350 | 17.9 |
Mc3 | Mississippi | chilled | 500 | 17.9 |
Mc3 | Mississippi | chilled | 675 | 18.9 |
Mc3 | Mississippi | chilled | 1000 | 19.9 |
some_function(Y ~ X1 + X2 + ... + Xn, data = data.frame)
~
: Explained byModelos | Funcion |
---|---|
t-test | t.test() |
ANOVA | aov() |
Linear model | lm() |
Generalized linear model | glm() |
Generalized aditive model | gam() |
non-linear model | nls() |
Mixed effect models | lmer() |
Boosted regression trees | gbm() |
Fit1 <- lm(uptake ~ Type, data = CO2)
library(broom) glance(Fit1)
r.squared | adj.r.squared | sigma | statistic | p.value | df | logLik | AIC | BIC | deviance | df.residual | nobs |
---|---|---|---|---|---|---|---|---|---|---|---|
0.35 | 0.34 | 8.79 | 43.52 | 0 | 1 | -300.8 | 607.6 | 614.89 | 6341.44 | 82 | 84 |
tidy(Fit1)
term | estimate | std.error | statistic | p.value |
---|---|---|---|---|
(Intercept) | 33.54286 | 1.356945 | 24.719384 | 0 |
TypeMississippi | -12.65952 | 1.919011 | -6.596901 | 0 |
augment(Fit1)
uptake | Type | .fitted | .resid | .hat | .sigma | .cooksd | .std.resid |
---|---|---|---|---|---|---|---|
16.0 | Quebec | 33.54286 | -17.5428571 | 0.0238095 | 8.625388 | 0.0497139 | -2.0190449 |
30.4 | Quebec | 33.54286 | -3.1428571 | 0.0238095 | 8.841068 | 0.0015956 | -0.3617181 |
34.8 | Quebec | 33.54286 | 1.2571429 | 0.0238095 | 8.847000 | 0.0002553 | 0.1446873 |
37.2 | Quebec | 33.54286 | 3.6571429 | 0.0238095 | 8.838566 | 0.0021605 | 0.4209084 |
35.3 | Quebec | 33.54286 | 1.7571429 | 0.0238095 | 8.845923 | 0.0004988 | 0.2022333 |
39.2 | Quebec | 33.54286 | 5.6571429 | 0.0238095 | 8.825228 | 0.0051698 | 0.6510927 |
39.7 | Quebec | 33.54286 | 6.1571429 | 0.0238095 | 8.820995 | 0.0061240 | 0.7086387 |
13.6 | Quebec | 33.54286 | -19.9428571 | 0.0238095 | 8.559179 | 0.0642469 | -2.2952661 |
27.3 | Quebec | 33.54286 | -6.2428571 | 0.0238095 | 8.820233 | 0.0062957 | -0.7185038 |
37.1 | Quebec | 33.54286 | 3.5571429 | 0.0238095 | 8.839082 | 0.0020440 | 0.4093992 |
41.8 | Quebec | 33.54286 | 8.2571429 | 0.0238095 | 8.799269 | 0.0110138 | 0.9503322 |
40.6 | Quebec | 33.54286 | 7.0571429 | 0.0238095 | 8.812465 | 0.0080452 | 0.8122217 |
41.4 | Quebec | 33.54286 | 7.8571429 | 0.0238095 | 8.803900 | 0.0099726 | 0.9042954 |
44.3 | Quebec | 33.54286 | 10.7571429 | 0.0238095 | 8.765042 | 0.0186927 | 1.2380626 |
16.2 | Quebec | 33.54286 | -17.3428571 | 0.0238095 | 8.630502 | 0.0485869 | -1.9960265 |
32.4 | Quebec | 33.54286 | -1.1428571 | 0.0238095 | 8.847196 | 0.0002110 | -0.1315339 |
40.3 | Quebec | 33.54286 | 6.7571429 | 0.0238095 | 8.815439 | 0.0073757 | 0.7776940 |
42.1 | Quebec | 33.54286 | 8.5571429 | 0.0238095 | 8.795643 | 0.0118286 | 0.9848599 |
42.9 | Quebec | 33.54286 | 9.3571429 | 0.0238095 | 8.785334 | 0.0141437 | 1.0769336 |
43.9 | Quebec | 33.54286 | 10.3571429 | 0.0238095 | 8.771133 | 0.0173284 | 1.1920257 |
45.5 | Quebec | 33.54286 | 11.9571429 | 0.0238095 | 8.745356 | 0.0230958 | 1.3761731 |
14.2 | Quebec | 33.54286 | -19.3428571 | 0.0238095 | 8.576576 | 0.0604392 | -2.2262108 |
24.1 | Quebec | 33.54286 | -9.4428571 | 0.0238095 | 8.784174 | 0.0144040 | -1.0867986 |
30.3 | Quebec | 33.54286 | -3.2428571 | 0.0238095 | 8.840611 | 0.0016988 | -0.3732274 |
34.6 | Quebec | 33.54286 | 1.0571429 | 0.0238095 | 8.847331 | 0.0001805 | 0.1216688 |
32.5 | Quebec | 33.54286 | -1.0428571 | 0.0238095 | 8.847352 | 0.0001757 | -0.1200247 |
35.4 | Quebec | 33.54286 | 1.8571429 | 0.0238095 | 8.845664 | 0.0005571 | 0.2137425 |
38.7 | Quebec | 33.54286 | 5.1571429 | 0.0238095 | 8.829102 | 0.0042963 | 0.5935466 |
9.3 | Quebec | 33.54286 | -24.2428571 | 0.0238095 | 8.417641 | 0.0949391 | -2.7901623 |
27.3 | Quebec | 33.54286 | -6.2428571 | 0.0238095 | 8.820233 | 0.0062957 | -0.7185038 |
35.0 | Quebec | 33.54286 | 1.4571429 | 0.0238095 | 8.846612 | 0.0003430 | 0.1677057 |
38.8 | Quebec | 33.54286 | 5.2571429 | 0.0238095 | 8.828356 | 0.0044645 | 0.6050558 |
38.6 | Quebec | 33.54286 | 5.0571429 | 0.0238095 | 8.829833 | 0.0041313 | 0.5820374 |
37.5 | Quebec | 33.54286 | 3.9571429 | 0.0238095 | 8.836932 | 0.0025295 | 0.4554360 |
42.4 | Quebec | 33.54286 | 8.8571429 | 0.0238095 | 8.791887 | 0.0126726 | 1.0193875 |
15.1 | Quebec | 33.54286 | -18.4428571 | 0.0238095 | 8.601612 | 0.0549457 | -2.1226279 |
21.0 | Quebec | 33.54286 | -12.5428571 | 0.0238095 | 8.734974 | 0.0254138 | -1.4435842 |
38.1 | Quebec | 33.54286 | 4.5571429 | 0.0238095 | 8.833275 | 0.0033548 | 0.5244913 |
34.0 | Quebec | 33.54286 | 0.4571429 | 0.0238095 | 8.847980 | 0.0000338 | 0.0526135 |
38.9 | Quebec | 33.54286 | 5.3571429 | 0.0238095 | 8.827596 | 0.0046360 | 0.6165650 |
39.6 | Quebec | 33.54286 | 6.0571429 | 0.0238095 | 8.821870 | 0.0059267 | 0.6971295 |
41.4 | Quebec | 33.54286 | 7.8571429 | 0.0238095 | 8.803900 | 0.0099726 | 0.9042954 |
10.6 | Mississippi | 20.88333 | -10.2833333 | 0.0238095 | 8.772231 | 0.0170823 | -1.1835308 |
19.2 | Mississippi | 20.88333 | -1.6833333 | 0.0238095 | 8.846104 | 0.0004577 | -0.1937384 |
26.2 | Mississippi | 20.88333 | 5.3166667 | 0.0238095 | 8.827905 | 0.0045662 | 0.6119065 |
30.0 | Mississippi | 20.88333 | 9.1166667 | 0.0238095 | 8.788531 | 0.0134261 | 1.0492567 |
30.9 | Mississippi | 20.88333 | 10.0166667 | 0.0238095 | 8.776132 | 0.0162078 | 1.1528396 |
32.4 | Mississippi | 20.88333 | 11.5166667 | 0.0238095 | 8.752828 | 0.0214255 | 1.3254778 |
35.5 | Mississippi | 20.88333 | 14.6166667 | 0.0238095 | 8.694104 | 0.0345123 | 1.6822634 |
12.0 | Mississippi | 20.88333 | -8.8833333 | 0.0238095 | 8.791552 | 0.0127476 | -1.0224018 |
22.0 | Mississippi | 20.88333 | 1.1166667 | 0.0238095 | 8.847238 | 0.0002014 | 0.1285196 |
30.6 | Mississippi | 20.88333 | 9.7166667 | 0.0238095 | 8.780397 | 0.0152515 | 1.1183119 |
31.8 | Mississippi | 20.88333 | 10.9166667 | 0.0238095 | 8.762547 | 0.0192512 | 1.2564225 |
32.4 | Mississippi | 20.88333 | 11.5166667 | 0.0238095 | 8.752828 | 0.0214255 | 1.3254778 |
31.1 | Mississippi | 20.88333 | 10.2166667 | 0.0238095 | 8.773216 | 0.0168615 | 1.1758580 |
31.5 | Mississippi | 20.88333 | 10.6166667 | 0.0238095 | 8.767208 | 0.0182076 | 1.2218949 |
11.3 | Mississippi | 20.88333 | -9.5833333 | 0.0238095 | 8.782250 | 0.0148358 | -1.1029663 |
19.4 | Mississippi | 20.88333 | -1.4833333 | 0.0238095 | 8.846557 | 0.0003554 | -0.1707200 |
25.8 | Mississippi | 20.88333 | 4.9166667 | 0.0238095 | 8.830837 | 0.0039050 | 0.5658697 |
27.9 | Mississippi | 20.88333 | 7.0166667 | 0.0238095 | 8.812874 | 0.0079531 | 0.8075632 |
28.5 | Mississippi | 20.88333 | 7.6166667 | 0.0238095 | 8.806572 | 0.0093715 | 0.8766185 |
28.1 | Mississippi | 20.88333 | 7.2166667 | 0.0238095 | 8.810831 | 0.0084130 | 0.8305816 |
27.8 | Mississippi | 20.88333 | 6.9166667 | 0.0238095 | 8.813874 | 0.0077281 | 0.7960540 |
10.5 | Mississippi | 20.88333 | -10.3833333 | 0.0238095 | 8.770741 | 0.0174161 | -1.1950400 |
14.9 | Mississippi | 20.88333 | -5.9833333 | 0.0238095 | 8.822508 | 0.0057831 | -0.6886346 |
18.1 | Mississippi | 20.88333 | -2.7833333 | 0.0238095 | 8.842591 | 0.0012514 | -0.3203398 |
18.9 | Mississippi | 20.88333 | -1.9833333 | 0.0238095 | 8.845318 | 0.0006354 | -0.2282661 |
19.5 | Mississippi | 20.88333 | -1.3833333 | 0.0238095 | 8.846762 | 0.0003091 | -0.1592108 |
22.2 | Mississippi | 20.88333 | 1.3166667 | 0.0238095 | 8.846891 | 0.0002800 | 0.1515380 |
21.9 | Mississippi | 20.88333 | 1.0166667 | 0.0238095 | 8.847391 | 0.0001670 | 0.1170103 |
7.7 | Mississippi | 20.88333 | -13.1833333 | 0.0238095 | 8.723037 | 0.0280755 | -1.5172980 |
11.4 | Mississippi | 20.88333 | -9.4833333 | 0.0238095 | 8.783623 | 0.0145278 | -1.0914571 |
12.3 | Mississippi | 20.88333 | -8.5833333 | 0.0238095 | 8.795321 | 0.0119012 | -0.9878742 |
13.0 | Mississippi | 20.88333 | -7.8833333 | 0.0238095 | 8.803604 | 0.0100392 | -0.9073097 |
12.5 | Mississippi | 20.88333 | -8.3833333 | 0.0238095 | 8.797760 | 0.0113530 | -0.9648558 |
13.7 | Mississippi | 20.88333 | -7.1833333 | 0.0238095 | 8.811176 | 0.0083355 | -0.8267452 |
14.4 | Mississippi | 20.88333 | -6.4833333 | 0.0238095 | 8.818039 | 0.0067901 | -0.7461807 |
10.6 | Mississippi | 20.88333 | -10.2833333 | 0.0238095 | 8.772231 | 0.0170823 | -1.1835308 |
18.0 | Mississippi | 20.88333 | -2.8833333 | 0.0238095 | 8.842186 | 0.0013430 | -0.3318490 |
17.9 | Mississippi | 20.88333 | -2.9833333 | 0.0238095 | 8.841767 | 0.0014377 | -0.3433582 |
17.9 | Mississippi | 20.88333 | -2.9833333 | 0.0238095 | 8.841767 | 0.0014377 | -0.3433582 |
17.9 | Mississippi | 20.88333 | -2.9833333 | 0.0238095 | 8.841767 | 0.0014377 | -0.3433582 |
18.9 | Mississippi | 20.88333 | -1.9833333 | 0.0238095 | 8.845318 | 0.0006354 | -0.2282661 |
19.9 | Mississippi | 20.88333 | -0.9833333 | 0.0238095 | 8.847439 | 0.0001562 | -0.1131739 |
\[AIC = 2 K - 2 \ln{(\hat{L})}\]
Fit1 <- lm(uptake ~ Type, data = CO2) Fit2 <- lm(uptake ~ Treatment, data = CO2) Fit3 <- lm(uptake ~ conc, data = CO2) Fit4 <- lm(uptake ~ Type + Treatment + conc, data = CO2) Fit5 <- lm(uptake ~ Type + conc + I(log(conc)), data = CO2) Fit6 <- lm(uptake ~ Type:Treatment + conc + I(log(conc)), data = CO2)
\[ \operatorname{\widehat{uptake}} = 33.54 - 12.66(\operatorname{Type}_{\operatorname{Mississippi}}) \]
\[ \operatorname{\widehat{uptake}} = 30.64 - 6.86(\operatorname{Treatment}_{\operatorname{chilled}}) \]
\[ \operatorname{\widehat{uptake}} = 19.5 + 0.02(\operatorname{conc}) \]
\[ \begin{aligned} \operatorname{\widehat{uptake}} &= 29.26 - 12.66(\operatorname{Type}_{\operatorname{Mississippi}})\ - \\ &\quad 6.86(\operatorname{Treatment}_{\operatorname{chilled}}) + 0.02(\operatorname{conc}) \end{aligned} \]
\[ \operatorname{\widehat{uptake}} = -59.04 - 12.66(\operatorname{Type}_{\operatorname{Mississippi}}) - 0.03(\operatorname{conc}) + 17.79(\operatorname{\log(conc)}) \]
\[ \begin{aligned} \operatorname{\widehat{uptake}} &= -76.77 - 0.03(\operatorname{conc}) + 17.79(\operatorname{\log(conc)})\ + \\ &\quad 19.52() + 10.14() + 15.94()\ + \\ &\quad NA() \end{aligned} \]
Model1 <- glance(Fit1) %>% dplyr::select(r.squared, AIC) %>% mutate(Model = "Fit1") Model2 <- glance(Fit2) %>% dplyr::select(r.squared, AIC) %>% mutate(Model = "Fit2") Model3 <- glance(Fit3) %>% dplyr::select(r.squared, AIC) %>% mutate(Model = "Fit3") Model4 <- glance(Fit4) %>% dplyr::select(r.squared, AIC) %>% mutate(Model = "Fit4") Model5 <- glance(Fit5) %>% dplyr::select(r.squared, AIC) %>% mutate(Model = "Fit5") Model6 <- glance(Fit6) %>% dplyr::select(r.squared, AIC) %>% mutate(Model = "Fit6") Models <- bind_rows(Model1, Model2, Model3, Model4, Model5, Model6) %>% arrange(AIC) %>% mutate(DeltaAIC = AIC - min(AIC))
r.squared | AIC | Model | DeltaAIC |
---|---|---|---|
0.8738773 | 477.4415 | Fit6 | 0.00000 |
0.7488287 | 531.3074 | Fit5 | 53.86593 |
0.6839043 | 550.6198 | Fit4 | 73.17834 |
0.3467130 | 607.6014 | Fit1 | 130.15996 |
0.2353971 | 620.8180 | Fit3 | 143.37653 |
0.1017943 | 634.3456 | Fit2 | 156.90410 |
library(lme4) Fit7 <- lmer(uptake ~ Type:Treatment + conc + I(log(conc)) + (1 | Plant), CO2)
loglik | aic | df.residual | r2.conditional | r2.marginal | icc | rmse |
---|---|---|---|---|---|---|
-230.7054 | 477.4108 | 76 | 0.8867725 | 0.8604275 | 0.1887554 | 3.419775 |
y ~ I(abs(YEAR - 1)) + I((YEAR - 1)^2) + YEAR:InitialHabitat + YEAR:Treatment