f1.ld.f1: Nonparametric Tests for the F1-LD-F1 Design in nparLD: Nonparametric Analysis of Longitudinal Data in Factorial Experiments (rdrr.io) (https://rdrr.io/cran/nparLD/man/f1.ld.f1.html)

Medidas repetidas no paramétrico

ejercicio de clase diseño F1LDF1 (nparLD)

Tutorial nparLD

library("nparLD")
## Warning: package 'nparLD' was built under R version 4.2.2
## Loading required package: MASS
data("dental")
dental
##    resp boys time subject
## 1  26.0   12    8       1
## 2  21.5   13    8       2
## 3  23.0   14    8       3
## 4  25.5   15    8       4
## 5  20.0   16    8       5
## 6  24.5   17    8       6
## 7  22.0   18    8       7
## 8  24.0   19    8       8
## 9  23.0   20    8       9
## 10 27.5   21    8      10
## 11 23.0   22    8      11
## 12 21.5   23    8      12
## 13 17.0   24    8      13
## 14 22.5   25    8      14
## 15 23.0   26    8      15
## 16 22.0   27    8      16
## 17 25.0   12   10       1
## 18 22.5   13   10       2
## 19 22.5   14   10       3
## 20 27.5   15   10       4
## 21 23.5   16   10       5
## 22 25.5   17   10       6
## 23 22.0   18   10       7
## 24 21.5   19   10       8
## 25 20.5   20   10       9
## 26 28.0   21   10      10
## 27 23.0   22   10      11
## 28 23.5   23   10      12
## 29 24.5   24   10      13
## 30 25.5   25   10      14
## 31 24.5   26   10      15
## 32 21.5   27   10      16
## 33 29.0   12   12       1
## 34 23.0   13   12       2
## 35 24.0   14   12       3
## 36 26.5   15   12       4
## 37 22.5   16   12       5
## 38 27.0   17   12       6
## 39 24.5   18   12       7
## 40 24.5   19   12       8
## 41 31.0   20   12       9
## 42 31.0   21   12      10
## 43 23.5   22   12      11
## 44 24.0   23   12      12
## 45 26.0   24   12      13
## 46 25.5   25   12      14
## 47 26.0   26   12      15
## 48 23.5   27   12      16
## 49 31.0   12   14       1
## 50 26.5   13   14       2
## 51 27.5   14   14       3
## 52 27.0   15   14       4
## 53 26.0   16   14       5
## 54 28.5   17   14       6
## 55 26.5   18   14       7
## 56 25.5   19   14       8
## 57 26.0   20   14       9
## 58 31.5   21   14      10
## 59 25.0   22   14      11
## 60 28.0   23   14      12
## 61 29.5   24   14      13
## 62 26.0   25   14      14
## 63 30.0   26   14      15
## 64 25.0   27   14      16
alturas=dental
#resp=altura de planta
#time = semanal 
# Diseño LD-F1

Analisis descriptivo

boxplot(resp ~ time, data = alturas,
        lwd = 2
        , xlab = "Tiempo(semanas)",
        ylab="Altura (cm)",
        font.lab = 2,
        cex.lab = 2,
        main = "Diagrama de caja")

Ho: ER8=ER10=ER12=ER14

mod1LD <- nparLD(resp ~ time,
                 data = alturas,
                 subject = "subject",
                 description = FALSE)
##  LD F1 Model 
##  ----------------------- 
##  Check that the order of the time level is correct.
##  Time level:   8 10 12 14 
##  If the order is not correct, specify the correct order in time.order.
summary(mod1LD)
## Model: 
## LD F1 Model 
##  
## Call: 
## resp ~ time
## 
## Relative Treatment Effect (RTE):
##        RankMeans Nobs       RTE
## time8   19.06250   16 0.2900391
## time10  24.31250   16 0.3720703
## time12  37.03125   16 0.5708008
## time14  49.59375   16 0.7670898
## 
## Wald-Type Statistc (WTS):
##      Statistic df      p-value
## time  94.47718  3 2.391503e-20
## 
## ANOVA-Type Statistc (ATS):
##      Statistic       df      p-value
## time  31.48774 2.700785 1.437729e-18
plot(mod1LD)

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.2
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:MASS':
## 
##     select
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
alturas |> 
  group_by(time) |> 
  summarise(medias=mean(resp),
            desv=sd(resp)) |> 
  ggplot(aes(x=time,y=medias,group=1))+
  geom_point()+
  geom_line()

data("rat")
boxplot(resp ~ group * time, data = rat, names = FALSE,
        col = c("grey", 2, 3), lwd = 2)

axis(1, at = 2, labels = "Time 0", font = 2, cex = 2)
axis(1, at = 5, labels = "Time 1", font = 2,cex = 2)
axis(1, at = 8, labels = "Time 2", font = 2,cex = 2)
axis(1, at = 11, labels = "Time 3", font = 2,cex = 2)
axis(1, at = 14, labels = "Time 4", font = 2,cex = 2)
legend(1, 190, c("Control", "15:15:15", "Gallinaza"), lwd = c(3, 3, 3),
       col = c("grey", 2, 3), cex = 1)

levels(rat$group)=c("Control", "15:15:15", "Gallinaza")

mod2LD <- nparLD(resp ~ time * group, data = rat,
                 subject = "subject", description = FALSE)
##  F1 LD F1 Model 
##  ----------------------- 
##  Check that the order of the time and group levels are correct.
##  Time level:   0 1 2 3 4 
##  Group level:   Control Gallinaza 15:15:15 
##  If the order is not correct, specify the correct order in time.order or group.order.
plot(mod2LD)