if(require("fda", quietly=TRUE)) {
# Heights of boys and girls at age 10
f.a <- growth$hgtf["10",] # girls at age 10
m.a <- growth$hgtm["10",] # boys at age 10
# Empirical cumulative distribution functions
plot(ecdf(f.a))
plot(ecdf(m.a), col='grey70', add=TRUE)
# Create a list of the data
fm.list <- list(Girls=f.a, Boys=m.a)
# \donttest{
res <- GET.distrequal(fm.list)
plot(res)
# If you want to change the labels:
plot(res, scales = "free", labels = c("Girls", "Boys"))
# If you want to change the x-label (y-label similarly):
require("ggplot2")
myxlab <- substitute(paste(italic(i), " (", j, ")", sep = ""),
list(i = "x", j = "Height in cm"))
plot(res, scales = "free") + xlab(myxlab)
# Use instead the test statistics QQ and DEN
res <- GET.distrequal(fm.list, stat = c("QQ", "DEN"))
plot(res, scales = "free")
# }
# \dontshow{
# The test with a lower number of simulations
res <- GET.distrequal(fm.list, nsim=4, alpha=0.2)
plot(res)
res <- GET.distrequal(fm.list, stat = c("QQ", "DEN"), nsim=4, alpha=0.2)
plot(res, scales = "free")
# }
# Heights of boys and girls at age 14
f.a <- growth$hgtf["14",] # girls at age 14
m.a <- growth$hgtm["14",] # boys at age 14
# Empirical cumulative distribution functions
plot(ecdf(f.a))
plot(ecdf(m.a), col='grey70', add=TRUE)
# Create a list of the data
fm.list <- list(Girls=f.a, Boys=m.a)
# \donttest{
res <- GET.distrequal(fm.list)
plot(res) + xlab(myxlab)
res <- GET.distrequal(fm.list, stat = c("QQ", "DEN"))
plot(res, scales = "free") + xlab(myxlab)
# }
# \dontshow{
# The test with a lower number of simulations
res_m <- GET.distrequal(fm.list, nsim=4, alpha=0.2)
plot(res_m)
res_c <- GET.distrequal(fm.list, stat = c("QQ", "DEN"), nsim=4, alpha=0.2)
plot(res_c, scales = "free")
# }
}
if(require("datasets", quietly=TRUE)) {
data("iris")
virginica <- subset(iris, Species == "virginica")
setosa <- subset(iris, Species == "setosa")
versicolor <- subset(iris, Species == "versicolor")
# \donttest{
res <- GET.distrequal(x = list(virginica = virginica$Sepal.Length,
setosa = setosa$Sepal.Length,
versicolor = versicolor$Sepal.Length),
stat = c("QQ", "DEN"))
plot(res, scales = "free", ncol = 3)
# }
# \dontshow{
res <- GET.distrequal(x = list(virginica = virginica$Sepal.Length,
setosa = setosa$Sepal.Length,
versicolor = versicolor$Sepal.Length),
stat = c("QQ", "DEN"), nsim=4, alpha=0.2)
plot(res, scales = "free", ncol = 3)
# }
}
Run the code above in your browser using DataLab