<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Tukey의 JMP와 같은 유사한 테스트를 실행하면 "연결 문자 보고서"가 생성됩니다. 그러나 우리의 데이터는 비정규적이고 분산이 이질적이므로 Kruskal-Wallis 테스트를 사용하여 분산을 조사한 다음 Steel-Dwass를 사용하여 모든 처리 쌍의 평균을 비교해야 했습니다. 이 분석을 수행한 후 유사한 편지 보고서를 어떻게 얻을 수 있습니까?
감사해요,
잭
readxl 라이브러리를 사용하여 xls 입력을 직접 읽을 수 있었습니다.
라이브러리("readxl")
입력 Excel 파일은 두 개의 열로 구성되어야 합니다. 여기서 A, B는 열이고 1,2,3은 행입니다.
A B
쌍별 비교 p.값
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~pairwisecomparison, data=data.
그럼 x한테 전화해
개선 요청이 JMP 위시리스트에 있는지 확인하고, 없으면 목록에 추가하겠습니다.
4년이 지난 지금도 여전히 이 기능이 있었으면 좋겠습니다.
프로그램에 내장된 방법이 없는 것 같고 저는 코딩에 능숙하지 않습니다(따라서 SAS 대신 JMP를 사용함). SAS에는 이에 대한 더 많은 옵션이 있다고 생각하지만 사용 편의성 때문에 JMP로 전환했습니다. 데이터에 따라 간단히 ANOVA를 실행하고 변환으로 분산을 수정할 수 있는 경우 Tukey 또는 이와 유사한 것을 사용하거나 그렇지 않은 경우 Welch ANOVA에 의존하는 것이 좋을 수 있습니다.
정규성 가정이 항상 충족될 필요는 없다는 것이 밝혀졌습니다.
AJ의 생태학 실험 나무 밑에. 2006. 케임브리지 대학 출판부( 페이지 192-193)
나는 또한 이 작업을 수행할 수 있는 방법을 찾고 있었습니다. 어떻게든 스크립트를 작성할 수는 있지만 필요한 스크립트 기능이 없다고 확신합니다.
이 작업을 수행할 수 있는 방법을 찾을 수 있었나요? 나는 현재 강철 dwass도 일부 수행해야 하지만 연결 문자를 얻는 방법을 모릅니다. 어떤 도움이라도 좋을 것입니다. 감사합니다!