## ansariTest - moodTest - varTest -
xmpBasics("Start: Ansari/Mood/Var Test > ")
# Differences in scale / variances:
data(nyseres)
x = nyseres[4001:5000, 1]
y = nyseres[6001:7000, 1]
p = c(
ansariTest(x, y)$p.value,
moodTest(x, y)$p.value,
varTest(x, y)$p.value)
test = c("ansari", "mood", "var")
data.frame(test, p)
## ansariTest - moodTest - varTest -
xmpBasics("Next: Ansari/Mood/Var Test > ")
# Differences in scale / variances:
x = rnorm(1000)
y = rnorm(1000)
p = c(
ansariTest(x, y)$p.value,
moodTest(x, y)$p.value,
varTest(x, y)$p.value)
test = c("ansari", "mood", "var")
data.frame(test, p)
## gofnorm -
xmpBasics("Next: Goodness-of-Fit Test for Normality > ")
x = nyseres[1:1000, 1]
# Standardize the data:
x = (x-mean(x))/sqrt(var(x))
# Test:
r = gofnorm(x, doprint = TRUE)
## ksTest -
# unique: remove ties:
xmpBasics("Next: Kolmogorov-Smirnov Goodness-of-Fit Test > ")
nyseres = unique(nyseres[, 1])
ksTest(nyseres, "pnorm")
# Do x and y come from the same distribution?
x = nyseres[1:(length(nyseres)/2)]
y = nyseres[(length(nyseres)/2+1):length(nyseres)]
ksTest(x, y)
# Does x come from an alpha stable distribution?
alpha = scalinglawPlot(nyseres, doplot = FALSE)$exponent
ksTest(x = nyseres, y = "psymstb", alpha, alternative = "gr")
## runsTest -
xmpBasics("Next: Runs Test > ")
runsTest(nyseres)
runsTest(rnorm(length(nyseres)))
Run the code above in your browser using DataLab