In the R code of Mardia's test, what does the line " x1 = x[x[, p] == i, -p]" mean? Thanks a lot! function (x) { p = dim(x)[2] f = p - 1 clases = length(table(x[, p])) for (i in 1:clases) { x1 = x[x[, p] == i, -p] ndat = dim(x1)[1] mo3 = mo3(x1) mard1 = ndat * mo3/6 cat("Mardia's test for class", i, "\n") cat("mard1=", mard1, "\n") p1 = 1 - pchisq(mard1, df = f * (f + 1) * (f + 2)/6) cat("pvalue for m3=", p1, "\n") mo4 = mo4(x1) mard2 = (mo4 - f * (f + 2))/sqrt(8 * f * (f + 2)/ndat) cat("mard2=", mard2, "\n") p2 = 2 * (1 - pnorm(abs(mard2))) cat("p-value for m4=", p2, "\n") if (p1 < 0.05 || p2 < 0.05) cat("There is not statistical evidence for normality in class", i, "\n") else cat("There is statistical evidence for normality", "\n") } }
On 16 June 2007 at 16:50, Jiao Yang wrote: | In the R code of Mardia's test, what does the line " x1 = x[x[, p] == i, -p]" mean? Thanks a lot! Read it from the inside out: x[, p] == i find elements of column p in x that equal i the result is an vector of true/false x[x[, p] == i, which is used here to subset those rows in x x[x[, p] == i, -p] and the -p selects all column but the p-ths Hth, Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison
Maybe Matching Threads
- Mardia's multivariate normality test
- [LLVMdev] ARM thumb-2 instruction used for non-thumb2 CPUs
- [LLVMdev] ARM thumb-2 instruction used for non-thumb2 CPUs
- bug found in predict.locfit in locfit package (PR#8057)
- bug found in predict.locfit in locfit package ( PR#8057)