?density
x <- rchisq(100, 5)
hist(x, prob=TRUE)
curve( dchisq(x, df=5), col='green', add=TRUE)
curve( dchisq(x, df=10), col='red', add=TRUE )
x <- rchisq(100, 5)
hist(x, prob=TRUE)
curve( dchisq(x, df=1), col='green', add=TRUE)
curve( dchisq(x, df=10), col='red', add=TRUE )
lines( seq(0.00001, 20, length = 1000), dchisq(seq(0.00001, 20, length = 1000), df = 1), lty = 1)
plot( seq(0.00001, 20, length = 1000), dchisq(seq(0.00001, 20, length = 1000), df = 1), lty = 1)
plot(lines( seq(0.00001, 20, length = 1000), dchisq(seq(0.00001, 20, length = 1000), df = 1), lty = 1))
hist(x, prob=TRUE, ylim 0 c(0, 100))
hist(x, prob=TRUE, ylim = c(0, 100))
plot(lines( seq(0.00001, 20, length = 1000), dchisq(seq(0.00001, 20, length = 1000), df = 1), lty = 1))
hist(x, prob=TRUE, ylim = c(0, 100))
plot( seq(0.00001, 20, length = 1000), dchisq(seq(0.00001, 20, length = 1000), df = 1), lty = 1)
hist(x, prob=TRUE, ylim = c(0, 100))
lines( seq(0.00001, 20, length = 1000), dchisq(seq(0.00001, 20, length = 1000), df = 1), lty = 1)
hist(x, prob=TRUE, ylim = c(0, 1))
lines( seq(0.00001, 20, length = 1000), dchisq(seq(0.00001, 20, length = 1000), df = 1), lty = 1)
load("Z:/cmmgrp/Silke/Bootstrap_SJ_HB_ALB/reproducible_files/reproducible_files/teststat_LR_test.R")
load("Z:/cmmgrp/Silke/Bootstrap_SJ_HB_ALB/reproducible_files/R_Objects/teststat_LR_test_H0.Rda")
teststat_LR_test_H0
plot(density(teststat.LR.test.H0[,1], from = 0), type = "l", xlim = c(0, 8), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(0.00001, 20, length = 1000), dchisq(seq(0.00001, 20, length = 1000), df = 1), lty = 1)
lines( seq(0.000001, 20, length = 1000), dchisq(seq(0.000001, 20, length = 1000), df = 1), lty = 1)
dchisq(seq(0.000001, 20, length = 1000)[1]
dchisq(seq(0.000001, 20, length = 1000), df = 1)[1]
plot(density(teststat.LR.test.H0[,1], from = 0), type = "l", xlim = c(0, 8), ylim = c(1, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, width = 0.0001), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, width = 0.1), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, width = 0.01), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, width = 0.05), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, width = 0.001), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.05), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.5), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.01), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.02), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
3
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.03), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.04), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(0.000001, 20, length = 1000), dchisq(seq(0.000001, 20, length = 1000), df = 1), lty = 1)
lines(density(teststat.LR.test.H0[,2], from = 0), lty = 2)
lines(density(teststat.LR.test.H0[,2], from = 0, bw = 0.04), lty = 2)
lines(density(teststat.LR.test.H0[,2], from = 0, bw = 0.03), lty = 2)
lines(density(teststat.LR.test.H0[,2], from = 0, bw = 0.02), lty = 2)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.04), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(0.000001, 20, length = 1000), dchisq(seq(0.000001, 20, length = 1000), df = 1), lty = 1)
lines(density(teststat.LR.test.H0[,2], from = 0, bw = 0.02), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.04), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 1000), dchisq(seq(0.000001, 20, length = 1000), df = 1, col = "red"), lty = 1)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.04), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 1000), dchisq(seq(0.000001, 20, length = 1000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, bw = 0.02), lty = 2)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.04), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, bw = 0.02), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.02), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, bw = 0.02), lty = 2)
plot(density(teststat.LR.test.H0[,1], from = 0, bw = 0.04), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, bw = 0.04), lty = 2)
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.5), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.5), lty = 2)
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.1), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.1), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.5), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.4), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 1), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 1), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 1.9), lty = 2)
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.1), lty = 2)
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", lty = c(1,2), legend = c("T     ", "T*"))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1,2, 1), legend = c("T     ", "T*", expression(gamma)))
legend("topright", col = c("black", "black", "red"), lty = c(1,2, 1), legend = c("T     ", "T*", expression(chi)))
legend("topright", col = c("black", "black", "red"), lty = c(1,2, 1), legend = c("T     ", "T*", expression(chi^2)))
legend("topright", col = c("black", "black", "red"), lty = c(1,2, 1), legend = c("T     ", "T*", paste(expression(chi^2), "-distribution", sep = ""))
legend("topright", col = c("black", "black", "red"), lty = c(1,2, 1), legend = c("T     ", "T*", paste(expression(chi^2), "-distribution", sep = "")))
paste(expression(chi^2), "-distribution", sep = "")
legend("topright", col = c("black", "black", "red"), lty = c(1,2, 1), legend = c("T     ", "T*", expression(paste(chi^2, "-distribution"), sep = "")))
legend("topright", col = c("black", "black", "red"), lty = c(1,2, 1), legend = c("T     ", "T*", expression(paste(chi^2, "-distribution", sep = ""))))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1,2, 1), legend = c("T     ", "T*", expression(paste(chi^2, "-distribution", sep = ""))))
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                    ", "T*", expression(paste(chi^2, "-distribution", sep = ""))))
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                                        ", "T*", expression(paste(chi^2, "-distribution", sep = ""))))
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                                ", "T*", expression(paste(chi^2, "(1)-distribution", sep = ""))))
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                                ", "T*", expression(paste(chi^2(1), "(1)", sep = ""))))
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                                ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T       ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T            ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                 ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
# create Figure 2: plot density of T and T* (save e.g. as pdf of size 6x5)
graphics.off()
pdf(height = 6, width = 4, file = "testatistic_LRtest.pdf")
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                 ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
graphics.off()
# create Figure 2: plot density of T and T* (save e.g. as pdf of size 6x5)
graphics.off()
pdf(height = 4, width = 6, file = "testatistic_LRtest.pdf")
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                 ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
graphics.off()
# create Figure 2: plot density of T and T* (save e.g. as pdf of size 6x5)
graphics.off()
pdf(height = 4, width = 5, file = "testatistic_LRtest.pdf")
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                 ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
graphics.off()
# create Figure 2: plot density of T and T* (save e.g. as pdf of size 6x5)
graphics.off()
pdf(height = 6, width = 4, file = "testatistic_LRtest.pdf")
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                 ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
graphics.off()
# create Figure 2: plot density of T and T* (save e.g. as pdf of size 6x5)
graphics.off()
pdf(height = 4, width = 4.5, file = "testatistic_LRtest.pdf")
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T                 ", "T*", expression(paste(chi^2, "(1)", sep = ""))))
graphics.off()
# create Figure 2: plot density of T and T* (save e.g. as pdf of size 6x5)
graphics.off()
pdf(height = 4, width = 4.5, file = "testatistic_LRtest.pdf")
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red")
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("T", "T*", expression(paste(chi^2, "(1)", sep = ""))))
graphics.off()
getwd()
load("R_Objects/teststat_z_test_H0.Rda")
graphics.off()
pdf(height = 4, width = 4.5, file = "testatistic_Ztest.pdf")
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red")
lines(density(teststat.z.test.H0[,2]), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"))
graphics.off()
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red", lwd = 0.6)
lines(density(teststat.z.test.H0[,2]), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"))
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red", lwd = 0.1)
lines(density(teststat.z.test.H0[,2]), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"))
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red", lwd = 1)
lines(density(teststat.z.test.H0[,2]), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"))
?lines
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red", lwd = 3)
lines(density(teststat.z.test.H0[,2]), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"))
graphics.off()
pdf(height = 4, width = 4.5, file = "testatistic_Ztest.pdf")
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red", lwd = 0.5)
lines(density(teststat.z.test.H0[,2]), lty = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"))
graphics.off()
graphics.off()
pdf(height = 4, width = 4.5, file = "testatistic_Ztest.pdf")
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2, lwd = 1.5)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red", lwd = 0.5)
lines(density(teststat.z.test.H0[,2]), lty = 2, lwd = 1.5)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"))
graphics.off()
graphics.off()
pdf(height = 4, width = 4.5, file = "testatistic_Ztest.pdf")
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2, lwd = 2)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red", lwd = 0.5)
lines(density(teststat.z.test.H0[,2]), lty = 2, lwd = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"), lwd = c(2, 2, 0.5))
graphics.off()
graphics.off()
pdf(height = 4, width = 4.5, file = "testatistic_Ztest.pdf")
plot(density(teststat.z.test.H0[,1]), type = "l", xlim = c(-6, 6), xlab = "Test statistic", main = "Empirical density functions for Z-test", cex.lab = 1.1, cex.main = 1.2, lwd = 2)
lines( seq(-6, 6, length = 100000), dnorm(seq(-6, 6, length = 100000)), lty = 1, col = "red", lwd = 0.8)
lines(density(teststat.z.test.H0[,2]), lty = 2, lwd = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), legend = c("Z", "Z*", "N(0, 1)"), lwd = c(2, 2, 1))
graphics.off()
# create Figure 2: plot density of T and T* (save e.g. as pdf of size 6x5)
graphics.off()
pdf(height = 4, width = 4.5, file = "testatistic_LRtest.pdf")
plot(density(teststat.LR.test.H0[,1], from = 0, adjust = 0.9), type = "l", xlim = c(0, 8), ylim = c(0, 1.3), xlab = "Test statistic", main = "Empirical density functions for LR-test", cex.lab = 1.1, cex.main = 1.2, lwd = 2)
lines(seq(0.000001, 20, length = 100000), dchisq(seq(0.000001, 20, length = 100000), df = 1), lty = 1, col = "red", lwd = 0.8)
lines(density(teststat.LR.test.H0[,2], from = 0, adjust = 0.9), lty = 2, lwd = 2)
legend("topright", col = c("black", "black", "red"), lty = c(1, 2, 1), lwd = c(2, 2, 1), legend = c("T", "T*", expression(paste(chi^2, "(1)", sep = ""))))
graphics.off()
