Skip to content

Commit

Permalink
Add interrater reliability and update 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunsooseol committed Jul 12, 2020
1 parent 9250d4a commit 5b5297b
Show file tree
Hide file tree
Showing 20 changed files with 671 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
14 changes: 6 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
Package: seolmatrix
Type: Package
Title: Correlations suite for jamovi
Version: 0.0.3
Version: 1.0.0
Date: 2020-06-17
Author: Hyunsoo Seol
Maintainer: Hyunsoo Seol <[email protected]>
Description:This module is a tool for calculating correlations, such as Pearson, Partial, Point-Biserial,Tetrachoric and allows users to produce
Description: This module is a tool for calculating correlations, such as Pearson, Partial, Point-Biserial,Tetrachoric, rater, and allows users to produce
Gaussian Graphical Model.
License: GPL (>= 2)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
Imports:
janitor,
jmvcore (>= 1.0.8),
knitr,
R6,
magrittr,
tidyverse,
stats,
qgraph,
psych


psych,
lpSolve,
irr
Binary file added Data/dicho.omv
Binary file not shown.
Binary file added Data/partial.omv
Binary file not shown.
Binary file added Data/rater.omv
Binary file not shown.
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ export(dichotomous)
export(dichotomousClass)
export(partial)
export(partialClass)
export(rater)
export(raterClass)
import(irr)
import(jmvcore)
import(lpSolve)
import(psych)
import(qgraph)
importFrom(R6,R6Class)
importFrom(irr,kappam.light)
importFrom(magrittr,"%>%")
importFrom(psych,partial.r)
importFrom(psych,polychoric)
8 changes: 7 additions & 1 deletion R/00jmv.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@
`year`=2012,
`title`="qgraph: Network Visualizations of Relationships in Psychometric Data",
`publisher`="[R package]. Retrieved from https://CRAN.R-project.org/package=qgraph",
`url`="https://CRAN.R-project.org/package=qgraph"))
`url`="https://CRAN.R-project.org/package=qgraph"),
`irr`=list(
`type`="software",
`author`="Matthias Gamer and Jim Lemon and Ian Fellows Puspendra Singh",
`year`=2019,
`title`="irr: Various Coefficients of Interrater Reliability and Agreement",
`url`="https://CRAN.R-project.org/package=irr"))
4 changes: 3 additions & 1 deletion R/dichotomous.b.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ self$results$instructions$setContent(
<p>- The input dataset require dichotomous data with the type of <b>numeric-continuous</b> in jamovi.</p>
<p>- Just highlight the variables and click the arrow to move it across into the 'Variables' box.</p>
<p>If you encounter any errors, or have questions, please e-mail me: [email protected]</a></p>
<p>- Feature requests and bug reports can be made on my <a href='https://github.com/hyunsooseol/seolmatrix/' target = '_blank'>GitHub</a></p>
<p>If you have any questions, please e-mail me: [email protected]</a></p>
</div>
</body>
</html>"
Expand Down
5 changes: 3 additions & 2 deletions R/dichotomous.h.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ dichotomousResults <- if (requireNamespace('jmvcore')) R6::R6Class(
options=options,
name="instructions",
title="Instructions",
visible=TRUE))
visible=TRUE,
refs="seolmatrix"))
self$add(jmvcore::Table$new(
options=options,
name="matrix",
Expand All @@ -77,7 +78,7 @@ dichotomousResults <- if (requireNamespace('jmvcore')) R6::R6Class(
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Show Gaussian Graphical Model",
title="Gaussian Graphical Model",
width=500,
height=500,
renderFun=".plot",
Expand Down
3 changes: 2 additions & 1 deletion R/partial.b.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ partialClass <- if (requireNamespace('jmvcore'))
<p> Note: When One variable is dichotomous, the other is continuous, the result table is equivalent to a <b>Point-biserial correlation</b>.</P>
<p>If you encounter any errors, or have questions, please e-mail me: [email protected]</a></p>
<p>- Feature requests and bug reports can be made on my <a href='https://github.com/hyunsooseol/seolmatrix/' target = '_blank'>GitHub</a></p>
<p>If you have any questions, please e-mail me: [email protected]</a></p>
</div>
</body>
</html>")
Expand Down
224 changes: 224 additions & 0 deletions R/rater.b.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@

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

#' Interrater Analysis
#' @importFrom R6 R6Class
#' @import jmvcore
#' @importFrom irr kappam.light
#' @import irr
#' @import lpSolve
#' @import qgraph
#' @import psych
#' @importFrom psych polychoric
#' @importFrom psych partial.r
#' @export


raterClass <- if (requireNamespace('jmvcore')) R6::R6Class(
"raterClass",
inherit = raterBase,
private = list(

#==========================================================
.init = function() {


if(is.null(self$data) | is.null(self$options$vars)){
self$results$instructions$setVisible(visible = TRUE)

}

self$results$instructions$setContent(
"<html>
<head>
</head>
<body>
<div class='instructions'>
<p>Welcome to Interrater reliability.</p>
<p><b>To get started:</b></p>
<p>- Just highlight the variables(raters) and click the arrow to move it across into the 'Variables' box.</p>
<p>- To produce Gaussian Graphical Model, partial correlations are calculated from a input matrix of polychoric correlations.</p>
<p>- Feature requests and bug reports can be made on my <a href='https://github.com/hyunsooseol/seolmatrix/' target = '_blank'>GitHub</a></p>
<p>If you have any questions, please e-mail me: [email protected]</a></p>
</div>
</body>
</html>"
)

},

#======================================++++++++++++++++++++++
.run = function() {

# get variables-------

data <- self$data

vars <- self$options$get('vars')


# Ready--------

ready <- TRUE

if (is.null(self$options$vars) ||
length(self$options$vars) < 2)

ready <- FALSE

if (ready) {

data <- private$.cleanData()

results <- private$.compute(data)

# populate rater table-----

private$.populateRaterTable(results)


# prepare plot-----

private$.prepareGgmPlot(data)

}
},

# compute results=====================================================

.compute = function(data) {

# get variables------

data <- self$data

vars <- self$options$get('vars')


# for(v in vars)
# data[[v]] <- jmvcore::toNumeric(data[[v]])

# compute Light's Kappa-----

res<- irr::kappam.light(ratings=data)

# get subjects-------

n <- res$subjects

# get raters--------

rater <- res$raters

# get statistic------------

statistic <- res$value

# z value----------------

z <- res$statistic

# p value-------------------

p <- res$p.value

results <-
list(
'n' = n,
'rater' = rater,
'statistic' = statistic,
'z' = z,
'p' = p

)

},


# populate rater table-----

.populateRaterTable = function(results) {

table <- self$results$interrater

n <- results$n
rater <- results$rater
statistic <- results$statistic
z <- results$z
p <- results$p


row <- list()

row[['n']] <- n
row[['rater']] <- rater
row[['statistic']] <- statistic
row[['z']] <- z
row[['p']] <- p

table$setRow(rowNo = 1, values = row)

},


#### Plot functions ----

.prepareGgmPlot = function(data) {

# Gaussian Graphical Models with polychoric correlation----------------

poly <- psych::polychoric(data)$rho
partial <- psych::partial.r(poly)

# Prepare Data For Plot -------
image <- self$results$plot
image$setState(partial)



},


#================================================================

.plot = function(image, ...) {
ggm <- self$options$ggm

if (!ggm)
return()


partial <- image$state

plot <- qgraph(partial, layout = "spring", details = TRUE)

print(plot)
TRUE
},


#### Helper functions =================================

.cleanData = function() {
items <- self$options$vars

data <- list()

for (item in items)
data[[item]] <- jmvcore::toNumeric(self$data[[item]])

attr(data, 'row.names') <- seq_len(length(data[[1]]))
attr(data, 'class') <- 'data.frame'
data <- jmvcore::naOmit(data)

return(data)
}
)
)



Loading

0 comments on commit 5b5297b

Please sign in to comment.