<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Tukey의 JMP와 같은 유사한 테스트를 실행하면 "연결 문자 보고서"가 생성됩니다. 그러나 우리의 데이터는 비정규이고 분산이 이질적이므로 Kruskal-Wallis 테스트를 사용하여 분산을 조사한 다음 Steel-Dwass를 사용하여 모든 쌍의 처리에 대한 평균을 비교해야 했습니다. 이 분석을 수행한 후 어떻게 유사한 편지 보고서를 얻을 수 있습니까?
감사,
자크
readxl 라이브러리를 사용하여 xls 입력을 직접 읽을 수 있었습니다.
라이브러리("readxl")
입력 엑셀 파일은 이렇게 2열로 설정해야 합니다. 여기서 A,B는 열이고 1,2,3은 행입니다.
에이비
쌍별 비교 p.value
1 6-8월 0.1637
2 11월-8월 0.1093
삼 11월-7월 0.9316
당신(또는 다른 누군가)이 작은 입력 파일의 완전한 예, 코드 및 위 프로세스를 수행하기 위한 출력을 게시할 수 있습니까? Excel 또는 텍스트 입력 파일에서 사후 쌍별 비교를 통해 비모수 분석 후 컴팩트 문자가 표시됩니다.
사후 쌍별 비교를 통해 비모수적 분석을 수행한 후 간결한 문자 표시를 생성하는 방법을 찾았기 때문에 이 게시물을 업데이트할 것이라고 생각했습니다.
참고: 이를 위해서는 오픈 소스와 쉽게 사용할 수 있는 통계 프로그램 R이 필요합니다(저는 더 사용자 친화적인 버전인 RStudio를 사용했습니다).
JMP에서 비모수 분석을 수행한 후 쌍별 p-값이 있는 결과 테이블을 Excel 시트로 내보냅니다. 그런 다음 하나의 셀에 있도록 비교 필드의 형식을 지정해야 하며, 비교할 변수를 구분하는 단일 '-'를 사용합니다.
그런 다음 R에서 이 스크립트를 사용하여 함수를 만듭니다. https://rdrr.io/github/GegznaV/spMisc/src/R/eval_glue.R ::
#' [!] Format, parse and evaluate expression in a string
#'
#' A wrapper function to format and parse a string and evaluate it
#' as an expression. \code{eval_(X)} is a wrapper for
#' \code{eval(parse(text = glue::glue(X)))}.
#'
#' @details
#' It's a good practice to write backticks (`) arround variable names
#' to prevent from errors in situations, where variables have uncommon
#' names. See examples.
#'
#' @param ... Strings to be formatted and evaluated as an expression.
#' @param .open [\code{character(1)}: ‘\{’] \cr
#' The opening delimiter. Doubling the full delimiter escapes it.
#' @param .close [\code{character(1)}: ‘\}’] \cr
#' The closing delimiter. Doubling the full delimiter escapes it.
#' @inheritParams glue::glue
#' @inheritParams base::eval
#'
#' @export
#' @seealso Format and interpolate a string (\code{\link[glue]{glue}}).\cr
#' Evaluate an (unevaluated) expression (\code{\link[base]{eval}}).\cr
#' Parse expressions (\code{\link[base]{parse}}).
#' @examples
#' library("spMisc")
#'
#' AA <- "nn"
#'
#' glue::glue("{AA} <- 3")
#'
#' eval_glue("{AA} <- 3")
#'
#' AA
#'
#' nn
#'
#' # It's a good practice to write backticks (`) arround variable names
#' # to prevent from errors in situations, where variables have uncommon
#' # names:
#'
#' BB <- "A B"
#'
#' eval_glue("`{BB}` <- 8")
#'
#' `A B`
#'
eval_glue <- function(..., envir = parent.frame(),
.sep = "", .open = "{", .close = "}") {
x2 <- glue::glue(..., .envir = envir, .open = .open, .close = .close)
eval(parse(text = x2), envir = envir)
}
그런 다음이 스크립트에서 다른 기능을 만드십시오. https://github.com/GegznaV/biostat/blob/master/R/make_cld_df.R ::
#' **[!!]** Make a data frame with cld
#'
#' Compute a compact letter display (cld) of statistically significant
#' differences in pairwise comparisons and output he results as a dataframe.
#'
#' @note
#' This function is based on code in function [rcompanion::cldList()]
#' from package \pkg{rcompanion} by Salvatore Mangiafico.
#'
#' @param swap_compared_names (logical) \cr If `TRUE`, group names are swapped
#' from, e.g., "2-1" or "second-first" to "1-2" or "first-second". This leads to
#' different order of cld letters and different order of compared groups (if
#' without swapping the result is incorrect order of groups.)
#'
#' @inheritParams rcompanion::cldList
#' @inheritParams multcompView::multcompLetters
#'
#' @export
#' @keywords internal
# @param comparison_order (character) Character vector with desired order of groups.
make_cld_df <- function(
formula = NULL,
data = NULL,
comparison = NULL,
p.value = NULL,
threshold = 0.05,
print.comp = FALSE,
remove.space = TRUE,
remove.equal = TRUE,
# remove.zero = TRUE,
swap.colon = TRUE,
swap.vs = FALSE,
reversed = FALSE,
swap_compared_names = FALSE,
# comparison_order = NULL,
...) {
if (!is.null(formula)) {
# # **[!!!]** Formula interface needs review.
# p.value = eval(parse(text = paste0("data", "$", all.vars(formula[[2]])[1])))
# comparison = eval(parse(text = paste0("data", "$", all.vars(formula[[3]])[1])))
p.value <- eval_glue("data${all.vars(formula[[2]])[1]}")
comparison <- eval_glue("data${all.vars(formula[[3]])[1]}")
}
significant_difference <- p.value < threshold
# if (sum(significant_difference) == 0) {
# stop("No significant differences.", call. = FALSE)
# }
if (remove.space == TRUE) {
comparison <- gsub(" ", "", comparison)
}
if (remove.equal == TRUE) {
comparison <- gsub("=", "", comparison)
}
# if (remove.zero == TRUE) {
# comparison = gsub("0", "", comparison)
# }
if (swap.colon == TRUE) {
comparison <- gsub(":", "-", comparison)
}
if (swap.vs == TRUE) {
comparison <- gsub("vs", "-", comparison)
}
if (swap_compared_names == TRUE) {
part_1 <- stringr::str_extract(comparison, ".*(?=-)")
part_2 <- stringr::str_extract(comparison, "(?<=-).*")
comparison <- paste0(part_2, "-", part_1)
}
comparison
names(significant_difference) <- comparison
if (print.comp == TRUE) {
Y <- data.frame(Comparisons = names(significant_difference))
cat("\n\n")
print(Y)
cat("\n\n")
}
MCL <- multcompView::multcompLetters(significant_difference, reversed = reversed)
regular_cld <- as.character(MCL$Letters)
spaced_cld <- as.character(MCL$monospacedLetters)
if (is.null(MCL$monospacedLetters)) {
spaced_cld <- regular_cld
} else {
spaced_cld <- spaced_cld
}
res <- data.frame(
group = names(MCL$Letters),
cld = as.character(MCL$Letters),
spaced_cld = gsub(" ", "_", spaced_cld)
)
structure(res, class = c("cld_object", class(res)))
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Helper function
# cld_update <- function(res) {
# res$MonoLetter <- gsub(" ", "_", res$MonoLetter)
# names(res) <- c("Group", "cld", "spaced_cld")
# structure(res, class = c("cld_object", class(res)))
# }
그런 다음 새로 만든 make_cld_df 함수를 다음과 같은 형식으로 데이터에 적용할 수 있습니다.
x<-make_cld_df(p.value~쌍별 비교, 데이터=데이터.
그런 다음 전화 x
개선 요청이 JMP 위시 목록에 있는지 확인하고 그렇지 않은 경우 목록에 추가합니다.
4년이 지난 지금도 여전히 이 기능이 있었으면 하는 바람입니다.
프로그램에 내장된 방법이 없는 것으로 보이며 코딩에 익숙하지 않습니다(따라서 SAS 대신 JMP 사용). SAS에는 이에 대한 더 많은 옵션이 있다고 생각하지만 사용 편의성 때문에 JMP로 전환했습니다. 데이터에 따라 변환으로 분산을 수정할 수 있거나 그렇지 않은 경우 Welch ANOVA에 의존할 수 있는 경우 단순히 ANOVA를 실행하고 Tukey 또는 이와 유사한 것을 사용하는 것이 좋을 수 있습니다.
정규성 가정이 항상 충족되어야 하는 것은 아닙니다.
AJ의 생태학 실험 나무 밑에. 2006. 캠브리지 대학 출판부( 페이지 192-193)
나는 또한 이것을 하는 방법을 찾고 있었는데, 당신이 어떻게든 그것을 스크립팅할 수 있다고 확신하지만 필요한 스크립팅 능력이 없습니다.
이 작업을 수행하는 방법을 찾을 수 있었습니까? 나는 현재 강철 dwas도해야하지만 연결 문자를 얻는 방법을 모릅니다. 어떤 도움이라도 좋을 것입니다. 고맙습니다!