Skip to content

Commit

Permalink
1. Update la.anova.R to replace reshape2::acast with convertDFtoScore…
Browse files Browse the repository at this point in the history
…Matrix

2. Import aov rnorm rgamma rbeta var from stats
  • Loading branch information
SiWen314 committed Nov 14, 2020
1 parent 08d562a commit 4504f0e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Rpackage/iMRMC/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ export(uStat11.conditionalD)
export(uStat11.jointD)
export(undoIMRMCdf)
import(parallel)
import(reshape2)
importFrom(stats,aov)
importFrom(stats,qnorm)
importFrom(stats,rbeta)
importFrom(stats,rgamma)
importFrom(stats,rnorm)
importFrom(stats,var)
10 changes: 6 additions & 4 deletions Rpackage/iMRMC/R/la.anova.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#' @description
#' These two functions calculate two types of Limits of Agreement using ANOVA: Within-Reader Between-Modality(WRBM)
#' and Between-Reader Between-Modality(BRBM). The 95\% confidence interval of the mean difference is also provided.
#' The ANOVA method are realized either by applying stats::aov or by matrix multiplication. See more details below
#' about the model structure.
#'
#' @details
#' Suppose the score from reader j for case k under modality i is\eqn{X_{ijk}}, then the difference score from the
Expand Down Expand Up @@ -61,7 +63,7 @@
#'
#' The two function shows the same 95\% CI for the mean difference score, but difference Limits of Agreements.
#'
#' @import reshape2
#' @importFrom stats aov var
#'
#' @export
#'
Expand Down Expand Up @@ -118,7 +120,7 @@ laWRBM.anova <- function(df, modalitiesToCompare = c("testA","testB"),
MSB <- MS[2]
sigma2 <- MS[3]
}else{
diff.mat <- acast(diff.df, readerID ~caseID, value.var = "score")
diff.mat <- t(convertDFtoScoreMatrix(droplevels(diff.df)))

MSA <- var(rowMeans(diff.mat)) * nCase
MSB <- var(colMeans(diff.mat)) * nReader
Expand Down Expand Up @@ -202,8 +204,8 @@ laBRBM.anova <- function(df, modalitiesToCompare = c("testA","testB"),
# Generate 3-dimentional matrix, reader x case x modality
rcm_mat <-array(0,dim=c(nR, nC, nM))

rcm_mat[,,1] <- acast(df.A, readerID ~caseID, value.var = "score")
rcm_mat[,,2] <- acast(df.B, readerID ~caseID, value.var = "score")
rcm_mat[,,1] <- t(convertDFtoScoreMatrix(droplevels(df.A)))
rcm_mat[,,2] <- t(convertDFtoScoreMatrix(droplevels(df.B)))

MSR <- var(rowMeans(rcm_mat)) * nC * nM
MSC <- var(rowMeans(colMeans(rcm_mat))) * nR * nM
Expand Down
3 changes: 3 additions & 0 deletions Rpackage/iMRMC/R/sim.new.Hierarchical.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
#' \item modalityID: [Factor] w/ 1 level config$modalityID
#' \item score: [num] reader score
#' }
#'
#' @importFrom stats rbeta rgamma rnorm
#'
#' @export
#'
# @examples
Expand Down
2 changes: 2 additions & 0 deletions Rpackage/iMRMC/inst/extra/man/la.anova.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ <h3>Description</h3>

<p>These two functions calculate two types of Limits of Agreement using ANOVA: Within-Reader Between-Modality(WRBM)
and Between-Reader Between-Modality(BRBM). The 95% confidence interval of the mean difference is also provided.
The ANOVA method are realized either by applying stats::aov or by matrix multiplication. See more details below
about the model structure.
</p>


Expand Down

0 comments on commit 4504f0e

Please sign in to comment.