Skip to content

Commit

Permalink
Merge pull request #2 from arcaldwell49/jamovi
Browse files Browse the repository at this point in the history
Jamovi
  • Loading branch information
arcaldwell49 authored May 4, 2021
2 parents c8a356a + aabe3a0 commit 2836caf
Show file tree
Hide file tree
Showing 1,339 changed files with 130,470 additions and 49 deletions.
11 changes: 11 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@
^vignettes/reanalysis_supp\.R$
^pwr_agree$
^codecov\.yml$
^.*\.jmo$
^build/js$
^build/R$
^build/R.*$
^jamovi$
^_pkgdown\.yml$
^docs$
^pkgdown$
^paper\.md$
^paper\.bib$
^paper$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.RData
.Ruserdata
inst/doc
*.jmo
^cran-comments\.md$
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: SimplyAgree
Type: Package
Title: Agreement, Consistency, and Reliability Calculations
Title: Flexible and Robust Agreement and Reliability Analyses
Version: 0.0.1
Authors@R: person("Aaron", "Caldwell", email = "[email protected]",
role = c("aut", "cre"))
Maintainer: Aaron Caldwell <[email protected]>
Description: This package calculate absolute agreement between two continuous variables (agree_test), those with replicates (agree_reps), and with nested data (agree_reps and loa_mixed). Power calculations for Bland-Altman agreement limits can be calculated with the blandPowerCurve function. In addition, test-restest reliability can also be estimated (reli_stats).
Description: Reliability and agreement analyses often have limited software support. Therefore, this package, and jamovi module, was created to make agreement and reliability analyses easier for the average researcher. The functions within this package include simple tests of agreement, agreement analysis for nested and replicate data, and provide robust analyses of reliability. In addition, this package contains a set of functions to help when planning studies looking to assess measurement agreement. For robust analyses of agreement, boostrapped limits of agreement can also be calculated.
License: GPL-3
Encoding: UTF-8
LazyData: true
Expand All @@ -22,7 +22,8 @@ Imports:
tidyr,
sjstats,
stringr,
cccrm
cccrm,
jmvcore
Suggests:
knitr,
rmarkdown,
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export(agree_reps)
export(agree_test)
export(blandPowerCurve)
export(find_n)
export(jmvagree)
export(jmvagreemulti)
export(jmvreli)
export(loa_mixed)
export(reli_stats)
import(boot)
Expand Down
18 changes: 18 additions & 0 deletions R/00jmv.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# This file is automatically generated, you probably don't want to edit this

.jmvrefs <- list(
`R`=list(
`type`="software",
`author`="R Core Team",
`year`=2018,
`title`="A Language and Envionment for Statistical Computing",
`publisher`="[Computer software]. Retrieved from https://cran.r-project.org/",
`url`="https://cran.r-project.org/"),
`SimplyAgree`=list(
`type`="software",
`author`="Caldwell, A.R.",
`year`=2021,
`title`="SimplyAgree: Flexible and Robust Agreement and Reliability Analyses",
`publisher`="[R package]. Retrieved from https://github.com/arcaldwell49/SimplyAgree",
`url`="https://github.com/arcaldwell49/SimplyAgree"))
8 changes: 6 additions & 2 deletions R/agree_nest.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
#'
#' }

#' @examples #to be added
#'
#' @examples
#' data('reps')
#' agree_nest(x = "x", y = "y", id = "id", data = reps, delta = 2)
#' @section References:
#' Zou, G. Y. (2013). Confidence interval estimation for the Bland–Altman limits of agreement with multiple observations per individual. Statistical methods in medical research, 22(6), 630-642.
#'
#' King, TS and Chinchilli, VM. (2001). A generalized concordance correlation coefficient for continuous and categorical data. Statistics in Medicine, 20, 2131:2147.
#'
#' King, TS; Chinchilli, VM; Carrasco, JL. (2007). A repeated measures concordance correlation coefficient. Statistics in Medicine, 26, 3095:3113.
#'
#' Carrasco, JL; Phillips, BR; Puig-Martinez, J; King, TS; Chinchilli, VM. (2013). Estimation of the concordance correlation coefficient for repeated measures using SAS and R. Computer Methods and Programs in Biomedicine, 109, 293-304.
#' @importFrom stats pnorm qnorm lm dchisq qchisq sd var
#' @importFrom tidyselect all_of
Expand Down
8 changes: 6 additions & 2 deletions R/agree_reps.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
#'
#' }

#' @examples #to be added
#'
#' @examples
#' #' data('reps')
#' agree_reps(x = "x", y = "y", id = "id", data = reps, delta = 2)
#' @section References:
#' Zou, G. Y. (2013). Confidence interval estimation for the Bland–Altman limits of agreement with multiple observations per individual. Statistical methods in medical research, 22(6), 630-642.
#'
#' King, TS and Chinchilli, VM. (2001). A generalized concordance correlation coefficient for continuous and categorical data. Statistics in Medicine, 20, 2131:2147.
#'
#' King, TS; Chinchilli, VM; Carrasco, JL. (2007). A repeated measures concordance correlation coefficient. Statistics in Medicine, 26, 3095:3113.
#'
#' Carrasco, JL; Phillips, BR; Puig-Martinez, J; King, TS; Chinchilli, VM. (2013). Estimation of the concordance correlation coefficient for repeated measures using SAS and R. Computer Methods and Programs in Biomedicine, 109, 293-304.
#' @importFrom stats pnorm qnorm lm anova dchisq qchisq sd var
#' @importFrom tidyselect all_of
Expand Down
8 changes: 5 additions & 3 deletions R/agree_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#'
#' }

#' @examples #to be added
#' @examples
#' data('reps')
#' agree_test(x=reps$x, y=reps$y, delta = 2)
#'
#' @section References:
#' Gwowen Shieh (2019): Assessing Agreement Between Two Methods of Quantitative Measurements: Exact Test Procedure and Sample Size Calculation, Statistics in Biopharmaceutical Research, <https://doi.org/10.1080/19466315.2019.1677495>
Expand Down Expand Up @@ -111,8 +113,8 @@ agree_test <- function(x,
the_int <- summary(z)$coefficients[1,1]
the_slope <- summary(z)$coefficients[2,1]
tmp.lm <- data.frame(the_int, the_slope)
scalemin = min(c(min(x),min(y)))
scalemax = max(c(max(x),max(y)))
scalemin = min(c(min(x, na.rm = TRUE),min(y, na.rm = TRUE)))
scalemax = max(c(max(x, na.rm = TRUE),max(y, na.rm = TRUE)))

identity.plot = ggplot(ccc_res$df_diff,
aes(x = x, y = y)) +
Expand Down
4 changes: 3 additions & 1 deletion R/blandPowerCurve.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @param conf.level the confidence level(s) required. Default is 95\%. More than one confidence level can be provided.
#' @param agree.level the agreement level(s) required. Default is 95\%. The proportion of data that should lie between the thresholds, for 95\% limits of agreement this should be 0.95. More than one confidence level can be provided.

#' @return a dataframe containing the power analysis results. The results can then be plotted with the plot.powerCurve function.
#' @return A dataframe is returned containing the power analysis results. The results can then be plotted with the plot.powerCurve function.
#' @section references:
#' Lu, M. J., Zhong, W. H., Liu, Y. X., Miao, H. Z., Li, Y. C., & Ji, M. H. (2016). Sample Size for Assessing Agreement between Two Methods of Measurement by Bland-Altman Method. The international journal of biostatistics, 12(2), <https://doi.org/10.1515/ijb-2015-0039>
#' @examples
Expand All @@ -23,6 +23,8 @@
#' # Find at what N power of .8 is achieved
#' find_n(powerCurve, power = .8)
#' }
#' # If the desired power is not found then
#' ## Sample size range must be expanded
#' @importFrom magrittr "%>%"
#' @import dplyr
#' @export
Expand Down
6 changes: 3 additions & 3 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @title temps
#' @description A dataset from a study on the reliability of human body temperature at diferents times of day before and after exercise.
#' @description A dataset from a study on the reliability of human body temperature at different times of day before and after exercise.
#' @format A data frame with 60 rows and 10 variables:
#' \describe{
#' \item{id}{Subject identifier}
Expand All @@ -14,7 +14,7 @@
#' \item{teso_delta}{Change in esophageal temperature}
#'
#' }
#' @source \url{https://doi.org/10.1249/MSS.0000000000002575}
#' @source Ravanelli N, Jay O. The Change in Core Temperature and Sweating Response during Exercise Are Unaffected by Time of Day within the Wake Period. Med Sci Sports Exerc. 2020 Dec 1. doi: 10.1249/MSS.0000000000002575. Epub ahead of print. PMID: 33273272.
"temps"

#' @rdname temps
Expand All @@ -25,7 +25,7 @@
#' @format A data frame with 20 rows with 3 variables
#' \describe{
#' \item{id}{Subject identifier}
#' \item{X}{X measurment}
#' \item{X}{X measurement}
#' \item{Y}{Y measurement}

#'
Expand Down
119 changes: 119 additions & 0 deletions R/jmvagree.b.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@

# This file is a generated template, your changes will not be overwritten

jmvagreeClass <- if (requireNamespace('jmvcore', quietly=TRUE)) R6::R6Class(
"jmvagreeClass",
inherit = jmvagreeBase,
private = list(
.run = function() {

# `self$data` contains the data
# `self$options` contains the options
# `self$results` contains the results object (to populate)

if ( !is.null(self$options$method1) && !is.null(self$options$method2) ) {
# read the option values into shorter variable names
method1 <- self$options$method1
method2 <- self$options$method2

plotba <- self$results$plotba
plotcon <- self$results$plotcon

# get the data
data <- self$data

# convert to appropriate type
data[[method1]] <- jmvcore::toNumeric(data[[method1]])
data[[method2]] <- jmvcore::toNumeric(data[[method2]])

ciWidth = self$options$ciWidth
agreeWidth = self$options$agreeWidth
delta_val = self$options$testValue
res = agree_test(x = data[[method1]],
y = data[[method2]],
delta = delta_val,
conf.level = ciWidth,
agree.level = agreeWidth)

pr_res = paste0("Limit of Agreement = ", res$shieh_test$prop0*100, "%",
"\n",
"alpha =", (1-res$conf.level), "|", res$conf.level*100,"% Confidence Interval",
"\n",
"\n",
"Shieh Test of Agreement",
"\n",
"Exact C.I.:"," [",round(res$shieh_test$lower.ci,4),", ",round(res$shieh_test$upper.ci, 4), "]",
"\n",
"\n",
"Hypothesis Test: ",res$shieh_test$h0_test)

self$results$text$setContent(pr_res)
table1 <- self$results$blandtab
table1$setRow(rowNo=1, values=list(
var="Mean Bias",
estimate=res$loa$estimate[1],
lowerci=res$loa$lower.ci[1],
upperci=res$loa$upper.ci[1]
))

table1$setRow(rowNo=2, values=list(
var="Lower Limit of Agreement",
estimate=res$loa$estimate[2],
lowerci=res$loa$lower.ci[2],
upperci=res$loa$upper.ci[2]
))
table1$setRow(rowNo=3, values=list(
var="Upper Limit of Agreement",
estimate=res$loa$estimate[3],
lowerci=res$loa$lower.ci[3],
upperci=res$loa$upper.ci[3]
))

table2 <- self$results$ccctab
table2$setRow(rowNo=1, values=list(
var="CCC",
estimate=res$ccc.xy$est.ccc[1],
lowerci=res$ccc.xy$lower.ci[1],
upperci=res$ccc.xy$upper.ci[1]
))

plotba$setState(res)
plotcon$setState(res)
}



#citethis = paste0(
# "Shieh (2019). Assessing Agreement Between Two Methods of Quantitative Measurements: Exact Test Procedure and Sample Size Calculation,
# Statistics in Biopharmaceutical Research,
# <https://doi.org/10.1080/19466315.2019.1677495>"
#)
#self$results$cites$setContent(citethis)
},
.plotba = function(image,...){

if (is.null(image$state))
return(FALSE)

plotpr = plot(image$state)


print(plotpr)

return(TRUE)

},
.plotcon = function(image,...){

if (is.null(image$state))
return(FALSE)

plotpr = image$state


print(plotpr$identity.plot)

return(TRUE)

})
)
Loading

0 comments on commit 2836caf

Please sign in to comment.