[R] mardia's test

From: Jiao Yang <yj316_at_gwu.edu>
Date: Sat, 16 Jun 2007 16:50:08 -0400


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")

    }
}

R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 16 Jun 2007 - 20:54:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 16 Jun 2007 - 22:32:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.