friedman.test(y, ...) ## Default S3 method: friedman.test(y, groups, blocks, ...) ## S3 method for class 'formula': friedman.test(formula, data, subset, na.action, ...)
y |
a numeric vector or numeric matrix that specifies the observations.
If y is a numeric matrix, the row indices specify the block membership and the column indices specify the group or treatment for each corresponding element of y and the arguments groups and blocks are ignored. Missing values NAs are allowed, but all data for each block in which at least one element of y is a missing value (NA) is ignored. However, infinite values (Infs) are not removed because they are rankable. |
groups |
a factor object that specifies the group (treatment) for each corresponding element of y.
If groups is not a factor object, it will be coerced to one.
length(groups) must equal length(y). There must be exactly one element of y that corresponds to
each combination of the levels of groups and blocks. This argument is ignored if y is a numeric matrix. Missing values (NAs) and infinite values (Infs) are not allowed. |
blocks |
a factor object that specifies the block membership for each corresponding element of y.
If blocks is not a factor object, it will be coerced to one.
length(blocks) must equal length(y). There must be exactly one element of y that corresponds to
each combination of the levels of groups and blocks. This argument is ignored if y is a numeric matrix. Missing values (NAs) and infinite values (Infs) are not allowed. |
formula | a formula or terms that describe the model. In general, formulas follow the pattern, a ~ b | c, where a specifies the data values, b specifies the groups, and c specifies the blocks. |
data | a data frame or matrix that contains the objects named in formula. By default, this argument reads in values from parent.frame() and you do not need to call this argument explicitly. However, if parent.frame() contains a matrix, you must use the data argument. |
subset | a numeric vector that specifies a subset from the data frame (data) to use in formula. |
na.action | a character string that specifies how missing values (NAs) are handled. By default, an error is returned. |
... |
further arguments to be passed to or from methods. |
statistic | Friedman chi-square statistic along with the names attribute Friedman chi-squared. |
parameter | degrees of freedom of the asymptotic chi-square distribution associated with statistic along with the names attribute df. |
p.value | the asymptotic p-value for the test. |
method | a character string that returns the name of the method used, the value is Friedman rank sum test. |
data.name | a character string (vector of length 1) that contains the actual names of the input arguments y, groups, and blocks. If y is a numeric matrix, groups and blocks are ignored. |
treatments <- factor(rep(c("Trt1", "Trt2", "Trt3"), each=4)) people <- factor(rep(c("Subject1", "Subject2", "Subject3", "Subject4"), 3)) y <- c(0.73,0.76,0.46,0.85,0.48,0.78,0.87,0.22,0.51,0.03,0.39,0.44) friedman.test(y, treatments, people)# Now suppose the data is in the form of a matrix, rows are people and # columns are treatments. # Generate 'ymat' and the factor objects: ymat <- matrix(c(0.73,0.76,0.46,0.85,0.48,0.78,0.87,0.22,0.51, 0.03,0.39,0.44), ncol=3) bl <- factor(as.vector(row(ymat))) gr <- factor(as.vector(col(ymat))) friedman.test(ymat, gr, bl) # same answer as above