se cargan los datos
library(readxl)
p <- read_excel("C:/Users/Javi3/Downloads/p.xlsx")
str(p)
## Classes 'tbl_df', 'tbl' and 'data.frame': 57 obs. of 8 variables:
## $ repeticion : num 1 1 1 2 2 2 2 3 3 3 ...
## $ planta : num 9 10 11 9 10 11 12 9 10 11 ...
## $ tratamiento: num 1 1 1 1 1 1 1 1 1 1 ...
## $ c : num NA NA NA 40.5 48 ...
## $ f : num 0.734 0.777 0.719 NA NA ...
## $ pn : num -0.91 -1.32 -2.68 -1.43 -1.55 -1.53 NA 0.11 -1.64 -0.78 ...
## $ potencial : num NA NA NA 1.8 1.8 1.8 1.8 1.9 1.9 1.9 ...
## $ e : num 1.05 0.98 1.17 0.46 0.46 0.45 NA 0.88 0.72 0.66 ...
p$repeticion <- as.factor(p$repeticion)
p$tratamiento <- as.factor(p$tratamiento)
para verificar los supuestos es igual que antes, pero en este caso se prueban tres tratamientos no dos, el proseso es obtigosos, por eso no lo voy a realizar, crean que para e, se cumple la normalidad y la hocedasticidad, y para potencial y pn no
El modelo que he utilizado es uno lineal mixto
library(lme4)
## Loading required package: Matrix
m1l <- lmer(potencial ~ tratamiento + (1|repeticion), REML = FALSE, p)
m1p <- lmer(pn ~ tratamiento + (1|repeticion), REML = FALSE, p)
m1e <- lmer(e ~ tratamiento + (1|repeticion), REML = FALSE, p)
plot(m1l)
qqnorm(resid(m1l))
qqline(resid(m1l))
plot(m1p)
qqnorm(resid(m1p))
qqline(resid(m1p))
plot(m1e)
qqnorm(resid(m1e))
qqline(resid(m1e))
Se realiza un anova a los modelos elegidos para analizar los estadisticos si se encuentran diferencias
anova(m1l)
## Analysis of Variance Table
## Df Sum Sq Mean Sq F value
## tratamiento 2 13 6.5001 12.942
anova(m1e)
## Analysis of Variance Table
## Df Sum Sq Mean Sq F value
## tratamiento 2 0.23592 0.11796 3.5244
anova(m1p)
## Analysis of Variance Table
## Df Sum Sq Mean Sq F value
## tratamiento 2 81.254 40.627 1.8048
#para que tengan una idea del valor p de los estadisticos
library(sjPlot)
## Warning in checkMatrixPackageVersion(): Package version inconsistency detected.
## TMB was built with Matrix version 1.2.11
## Current Matrix version is 1.2.8
## Please re-install 'TMB' from source or restore original 'Matrix' package
sjt.lmer(m1l)
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
potencial | ||||
B | CI | p | ||
Fixed Parts | ||||
(Intercept) | 3.06 | 2.20 – 3.91 | <.001 | |
tratamiento (0.5) | -1.23 | -1.72 – -0.74 | <.001 | |
tratamiento (1) | -0.91 | -1.40 – -0.41 | .004 | |
Random Parts | ||||
σ2 | 0.502 | |||
τ00, repeticion | 0.638 | |||
Nrepeticion | 4 | |||
ICCrepeticion | 0.559 | |||
Observations | 48 | |||
R2 / Ω02 | .673 / .672 |
sjt.lmer(m1p)
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
pn | ||||
B | CI | p | ||
Fixed Parts | ||||
(Intercept) | -2.50 | -4.91 – -0.10 | .047 | |
tratamiento (0.5) | 1.05 | -2.35 – 4.44 | .549 | |
tratamiento (1) | 3.23 | -0.17 – 6.62 | .069 | |
Random Parts | ||||
σ2 | 22.510 | |||
τ00, repeticion | 0.000 | |||
Nrepeticion | 5 | |||
ICCrepeticion | 0.000 | |||
Observations | 45 | |||
R2 / Ω02 | .074 / .074 |
sjt.lmer(m1e)
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
e | ||||
B | CI | p | ||
Fixed Parts | ||||
(Intercept) | 0.75 | 0.50 – 1.00 | <.001 | |
tratamiento (0.5) | -0.09 | -0.22 – 0.04 | .203 | |
tratamiento (1) | -0.18 | -0.31 – -0.05 | .025 | |
Random Parts | ||||
σ2 | 0.033 | |||
τ00, repeticion | 0.070 | |||
Nrepeticion | 5 | |||
ICCrepeticion | 0.675 | |||
Observations | 45 | |||
R2 / Ω02 | .725 / .724 |
Se hacen los intervalos de confianza para ver si el cero esta entre el intervalo
library(lmerTest)
##
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
##
## lmer
## The following object is masked from 'package:stats':
##
## step
confint.merMod(m1l) #potencial
## Computing profile confidence intervals ...
## 2.5 % 97.5 %
## .sig01 0.4211558 2.0109352
## .sigma 0.5829481 0.8871307
## (Intercept) 1.9835274 4.1264739
## tratamiento0.5 -1.7320141 -0.7279859
## tratamiento1 -1.4070141 -0.4029859
confint.merMod(m1p) #pn
## Computing profile confidence intervals ...
## 2.5 % 97.5 %
## .sig01 0.0000000 2.6543999
## .sigma 3.9106076 5.9230448
## (Intercept) -4.9575110 -0.0511557
## tratamiento0.5 -2.4236504 4.5149837
## tratamiento1 -0.2436504 6.6949837
confint.merMod(m1e) #e
## Computing profile confidence intervals ...
## 2.5 % 97.5 %
## .sig01 0.1497840 0.58684042
## .sigma 0.1491531 0.23173059
## (Intercept) 0.4559989 1.05200111
## tratamiento0.5 -0.2254722 0.04280556
## tratamiento1 -0.3114722 -0.04319444
library(multcomp)
## Loading required package: mvtnorm
## Loading required package: survival
## Loading required package: TH.data
## Loading required package: MASS
##
## Attaching package: 'TH.data'
## The following object is masked from 'package:MASS':
##
## geyser
comparacion <-glht(m1l, linfct=mcp(tratamiento ="Tukey"))
comparacionp <-glht(m1p, linfct=mcp(tratamiento ="Tukey"))
comparacione <-glht(m1e, linfct=mcp(tratamiento ="Tukey"))
summary(comparacion)
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = potencial ~ tratamiento + (1 | repeticion), data = p,
## REML = FALSE)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## 0.5 - 0.01 == 0 -1.2300 0.2506 -4.909 <0.001 ***
## 1 - 0.01 == 0 -0.9050 0.2506 -3.612 <0.001 ***
## 1 - 0.5 == 0 0.3250 0.2506 1.297 0.397
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- single-step method)
summary(comparacionp)
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = pn ~ tratamiento + (1 | repeticion), data = p,
## REML = FALSE)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## 0.5 - 0.01 == 0 1.046 1.732 0.604 0.818
## 1 - 0.01 == 0 3.226 1.732 1.862 0.150
## 1 - 0.5 == 0 2.180 1.732 1.258 0.419
## (Adjusted p values reported -- single-step method)
summary(comparacione)
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: Tukey Contrasts
##
##
## Fit: lmer(formula = e ~ tratamiento + (1 | repeticion), data = p,
## REML = FALSE)
##
## Linear Hypotheses:
## Estimate Std. Error z value Pr(>|z|)
## 0.5 - 0.01 == 0 -0.09133 0.06680 -1.367 0.3583
## 1 - 0.01 == 0 -0.17733 0.06680 -2.655 0.0216 *
## 1 - 0.5 == 0 -0.08600 0.06680 -1.287 0.4023
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- single-step method)
```