scor.test {Kmisc} | R Documentation |
~~ A concise (1-5 lines) description of what the function does. ~~
scor.test(dados, scor = 1:ncol(dados))
dados |
~~Describe dados here~~ |
scor |
~~Describe scor here~~ |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
...
....
~~further notes~~
~Make other sections like Warning with section{Warning }{....} ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
##---- Should be DIRECTLY executable !! ---- ##-- ==> Define data, use random, ##-- or do help(data=index) for the standard data sets. ## The function is currently defined as function(dados, scor=1:ncol(dados)) { if (is.null(colnames(dados))) colnames(dados) <- scor names(scor) <- colnames(dados) dados <- exclui.na(dados) scor <- scor[is.element(names(scor), colnames(dados))] if (is.null(dim(dados))) return(NA) dados[is.na(dados)] <- 0 I <- 1:nrow(dados) J <- 1:ncol(dados) n.j <- apply(dados, 2, sum) ni. <- apply(dados, 1, sum) n <- sum(dados) f <- sapply(I, function(i, a, dad, si) sum(a*dad[i,]/si[i]), scor, dados, ni.) names(f) <- rownames(dados) mu <- sum(sapply(J, function(j, a, sj, n) a[j]*sj[j]/n, scor, n.j, n)) v <- sum(((scor - mu)^2)*n.j/n) Qs <- (n-1)*sum(ni.*((f-mu)^2))/(n*v) df <- nrow(dados)-1 pval <- pchisq(Qs, df, lower.tail=FALSE) res <- list(statistic=Qs, df=df, p.value=pval, estimate=f, mu=mu, var=v) class(res) <- "scor.test" return(res) }