Title: | Measure of Agreement Between Two Raters |
---|---|
Description: | Measure of agreement delta was originally by MartÃn & Femia (2004) <DOI:10.1348/000711004849268>. Since then has been considered as agreement measure for different fields, since their behavior is usually better than the usual kappa index by Cohen (1960) <DOI:10.1177/001316446002000104>. The main issue with delta is that can not be computed by hand contrary to kappa. The current algorithm is based on the Version 5 of the delta windows program that can be found on <https://www.ugr.es/~bioest/software/delta/cmd.php?seccion=downloads>. |
Authors: | Antonio Rodriguez [aut, cre], Pedro Femia [cph, ctb], Antonio Martin [cph, ctb] |
Maintainer: | Antonio Rodriguez <[email protected]> |
License: | GPL-3 |
Version: | 0.2.0.3 |
Built: | 2024-11-04 06:47:19 UTC |
Source: | CRAN |
This function perform multiple tasks. First of all, check the parameters specified by the user. Also asign default values to some parameters not defined by the user. Finally it generates error messages and halt the execution in case it is needed.
CheckInput(datatable, fixedrows = FALSE, gstandard = "No", maxits = 1000, tol = 1e-12, dplaces = 4, showall = FALSE)
CheckInput(datatable, fixedrows = FALSE, gstandard = "No", maxits = 1000, tol = 1e-12, dplaces = 4, showall = FALSE)
datatable |
Matrix. Expected to be square matrix with at least 2 rows (columns), non negative values and at least an element different of zero. |
fixedrows |
Boolean. Indicate if sample rows are fixed beforehand. Default is TRUE. |
gstandard |
Text. Indicate if there are a Gold Standard by Rows or columns. Only first letter matter without Case sensitivity. Options are: "N" for None, "R" for in Rows and "C" for in Columns. Default is "N". |
maxits |
Whole number. Indicate the maximum number of iterations of the numeric method to calculate B. Expected to be 100 <= maxits <= 5000. Default is 1000. |
tol |
Double number. Indicate the precision of the numeric method to calculate B. Expected to be 1e-6 <= tol <= 1e-15.Default is 1e-12. |
dplaces |
Whole number. Decimal placed to be shown in the result. Expected to be 1 <= dplaces <0 6. Default 4. |
showall |
Boolean. Indicate if all output should be shown. If TRUE also shown hidden results. If FALSE shown only main output. By default is FALSE. |
CheckInput(matrix(c(1,2,3,4),2,2),fixedrows=FALSE,gstandard="No",maxits=100,tol=1e-12,dplaces=4)
CheckInput(matrix(c(1,2,3,4),2,2),fixedrows=FALSE,gstandard="No",maxits=100,tol=1e-12,dplaces=4)
This function checks that matrix introduced is as expected. Should be a matrix, squared, with a dimension greater or equal to two, without negative entries and at least an entry different of 0.
CheckInputData(datatable)
CheckInputData(datatable)
datatable |
Matrix. Expected to be square matrix with at least 2 rows (columns), non negative values and at least an element different of zero. |
CheckInputData(matrix(c(1,2,3,4),2,2))
CheckInputData(matrix(c(1,2,3,4),2,2))
This function checks that fixedrows and gstandard parameters are correct. Also return a value indicating if it is or not valid and what kind of output should be shown at the end of the execution.
CheckSampling(fixedrows, gstandard)
CheckSampling(fixedrows, gstandard)
fixedrows |
Boolean. Indicate if sample rows are fixed beforehand. Default is TRUE. |
gstandard |
Text. Indicate if there are a Gold Standard by Rows or columns. Only first letter matter without Case sensitivity. Options are: "N" for None, "R" for in Rows and "C" for in Columns. Default is "N". |
CheckSampling(TRUE,"rows") CheckSampling(TRUE,"Columns")
CheckSampling(TRUE,"rows") CheckSampling(TRUE,"Columns")
This function provides an analysis of the matrix provided, returning all all the parameters estimations and SE calculations that have sense with the fixedrows and gstandard provided.
Delta(datatable, fixedrows = FALSE, gstandard = "No", maxits = 1000, tol = 1e-12, dplaces = 4, showall = FALSE) ## S3 method for class 'Delta' print(x, ...) ## S3 method for class 'Delta' summary(object, ...)
Delta(datatable, fixedrows = FALSE, gstandard = "No", maxits = 1000, tol = 1e-12, dplaces = 4, showall = FALSE) ## S3 method for class 'Delta' print(x, ...) ## S3 method for class 'Delta' summary(object, ...)
datatable |
Matrix. Expected to be square matrix with at least 2 rows (columns), non negative values and at least an element different of zero. |
fixedrows |
Boolean. Indicate if sample rows are fixed beforehand. Default is TRUE. |
gstandard |
Text. Indicate if there are a Gold Standard by Rows or columns. Only first letter matter without Case sensitivity. Options are: "N" for None, "R" for in Rows and "C" for in Columns. Default is "N". |
maxits |
Whole number. Indicate the maximum number of iterations of the numeric method to calculate B. Expected to be 100 <= maxits <= 5000. Default is 1000. |
tol |
Double number. Indicate the precision of the numeric method to calculate B. Expected to be 1e-6 <= tol <= 1e-15.Default is 1e-12. |
dplaces |
Whole number. Decimal placed to be shown in the result. Expected to be 1 <= dplaces <0 6. Default 4. |
showall |
Boolean. Indicate if all output should be shown. If TRUE also shown hidden results. If FALSE shown only main output. By default is FALSE. |
x |
List produced by Delta |
... |
Other print options |
object |
List produced by Delta |
This function study the matrix provided by the user. This function modify the matrix deleting missing rows and columns and if it is needed for the estimation, adding 0.5 to each cell.
Also calculate Cohen's Kappa coefficient and the goodness of fit for the Delta model.
NULL
NULL
Delta(matrix(c(1,2,3,4),2,2)) Delta(matrix(c(65,5,10,20),2,2),fixedrows=TRUE,gstandard="Row")
Delta(matrix(c(1,2,3,4),2,2)) Delta(matrix(c(65,5,10,20),2,2),fixedrows=TRUE,gstandard="Row")
This function perform all needed calculations to get all Delta related parameters, for a 2x2 matrix. All calculations are asintotics.
GetAsinDeltaParams(mx, fixedrows = TRUE) ## S3 method for class 'GetAsinDeltaParams' print(x, ...)
GetAsinDeltaParams(mx, fixedrows = TRUE) ## S3 method for class 'GetAsinDeltaParams' print(x, ...)
mx |
Matrix. Agreement contingency table to perform calculations |
fixedrows |
Boolean. Indicate if sample rows are fixed beforehand. |
x |
List produced by GetAsinDeltaParams |
... |
Other print options |
NULL
GetAsinDeltaParams(matrix(c(60,10,10,20),2,2),TRUE)
GetAsinDeltaParams(matrix(c(60,10,10,20),2,2),TRUE)
This function solve numericaly the non lineal inequation of the Delta system. Also return the s(i) values of the equation.
GetB(mx, tol = 1e-12, maxits = 1000)
GetB(mx, tol = 1e-12, maxits = 1000)
mx |
Matrix. Modified matrix to have a solution. Usually GetMx$M1 for k>2 and GetMx$M2 in case of k = 2. |
tol |
Double number. Indicate the precision of the numeric method to calculate B. Expected to be 1e-6 <= tol <= 1e-15.Default is 1e-12. |
maxits |
Whole number. Indicate the maximum number of iterations of the numeric method to calculate B. Expected to be 100 <= maxits <= 5000. Default is 1000. |
GetB(mx = matrix(c(1,0,0,0,2,0,0,0,3),3,3),tol = 1e-12, maxits = 1000) GetB(mx = matrix(c(1,2,0,3,4,0,0,0,1),3,3),tol = 1e-12, maxits = 1000)
GetB(mx = matrix(c(1,0,0,0,2,0,0,0,3),3,3),tol = 1e-12, maxits = 1000) GetB(mx = matrix(c(1,2,0,3,4,0,0,0,1),3,3),tol = 1e-12, maxits = 1000)
This function calculate covariance for combinations Cov(Delta,Delta), Cov(Delta,Pi) and Cov(Pi,Pi).
GetCovariance(mx, Delta, Pi, B)
GetCovariance(mx, Delta, Pi, B)
mx |
Matrix. Modified matrix to have a solution. Usually GetMx$M1 for k>2 and GetMx$M2 in case of k = 2. |
Delta |
Vector. Each element indicate the probability of recognize an element i. |
Pi |
Vector. Each element indicate the probability of classify at random an element in category i. |
B |
Double. Numerical solution to the equation given by the model. |
GetCovariance(mx = matrix(c(1.5,0.5,0.5,0.5,2.5,0.5,0.5,0.5,3.5),3,3), Delta = c(0.4,0.5714286,0.666667), Pi = c(0.3333,0.333333,0.33333),B = 4.5) GetCovariance(mx = matrix(c(60,0,3,2,50,1,3,2,79),3,3), Delta = c( 0.8945724, 0.9522836, 0.8962094), Pi = c( 0.2703707, 0.1939561, 0.5356732), B = 17.94867)
GetCovariance(mx = matrix(c(1.5,0.5,0.5,0.5,2.5,0.5,0.5,0.5,3.5),3,3), Delta = c(0.4,0.5714286,0.666667), Pi = c(0.3333,0.333333,0.33333),B = 4.5) GetCovariance(mx = matrix(c(60,0,3,2,50,1,3,2,79),3,3), Delta = c( 0.8945724, 0.9522836, 0.8962094), Pi = c( 0.2703707, 0.1939561, 0.5356732), B = 17.94867)
This function perform all needed calculations to get all Delta related parameters. For do the exact calculations some variables previously calculated are needed.
GetDeltaParams(mx, Delta, Pi, k)
GetDeltaParams(mx, Delta, Pi, k)
mx |
Matrix. Agreement contingency table to perform calculations |
Delta |
Vector. Each element indicate the probability of recognize an element i. |
Pi |
Vector. Each element indicate the probability of classify at random an element in category i. |
k |
Integer. Dimension of the problem. |
GetDeltaParams(mx = matrix(c(60,0,3,2,50,1,3,2,79),3,3), Delta = c( 0.8945724, 0.9522836, 0.8962094), Pi = c( 0.2703707, 0.1939561, 0.5356732), k = 3)
GetDeltaParams(mx = matrix(c(60,0,3,2,50,1,3,2,79),3,3), Delta = c( 0.8945724, 0.9522836, 0.8962094), Pi = c( 0.2703707, 0.1939561, 0.5356732), k = 3)
This function perform all needed calculations to get all Delta related parameters variance. For do the exact calculations some variables previously calculated are needed.
GetDeltaParamsVar(mx, fixedrows = FALSE, Delta, Pi, k, Cov, E)
GetDeltaParamsVar(mx, fixedrows = FALSE, Delta, Pi, k, Cov, E)
mx |
Matrix. Agreement contingency table to perform calculations |
fixedrows |
Boolean. Indicate if sample rows are fixed beforehand. |
Delta |
Vector. Each element indicate the probability of recognize an element i. |
Pi |
Vector. Each element indicate the probability of classify at random an element in category i. |
k |
Integer. Dimension of the problem. |
Cov |
Matrix. Covariance matrix of Delta. |
E |
Double. Value calculated for Cov matrix derivation. |
GetDeltaParamsVar(mx = matrix(c(60,0,3,2,50,1,3,2,79),3,3), fixedrows = FALSE,Delta = c( 0.8945724, 0.9522836, 0.8962094), Pi = c( 0.2703707, 0.1939561, 0.5356732), k = 3, Cov = matrix(c(0.002736490, 0.000004188, -0.001074704, 0.000004188, 0.001141059, -0.000181746, -0.001074704, -0.000181746, 0.004912131),3,3), E = c(0.03159824, 0.01304313, -0.88650011))
GetDeltaParamsVar(mx = matrix(c(60,0,3,2,50,1,3,2,79),3,3), fixedrows = FALSE,Delta = c( 0.8945724, 0.9522836, 0.8962094), Pi = c( 0.2703707, 0.1939561, 0.5356732), k = 3, Cov = matrix(c(0.002736490, 0.000004188, -0.001074704, 0.000004188, 0.001141059, -0.000181746, -0.001074704, -0.000181746, 0.004912131),3,3), E = c(0.03159824, 0.01304313, -0.88650011))
This function provide an estimation of Pi and Delta for each category. To do so, it is needed to solve the non-linear equation of B, given by the function GetB.
GetDeltaPi(mx, dtp, tol = 1e-12, maxits = 1000, original.mx = TRUE)
GetDeltaPi(mx, dtp, tol = 1e-12, maxits = 1000, original.mx = TRUE)
mx |
Matrix. Modified matrix to have a solution. Usually GetMx$M1 for k>2 and GetMx$M2 in case of k = 2. |
dtp |
String. Type of delta problem. |
tol |
Double number. Indicate the precision of the numeric method to calculate B. Expected to be 1e-6 <= tol <= 1e-15.Default is 1e-12. |
maxits |
Whole number. Indicate the maximum number of iterations of the numeric method to calculate B. Expected to be 100 <= maxits <= 5000. Default is 1000. |
original.mx |
Boolean. Indicate if the dtp parameter correspond to the current mx parameter. By default TRUE. |
In some type of problems, the solution is on the borderline, and in those situation we may have not solutions at all, only one or infinity of them.
GetDeltaPi(mx = matrix(c(1,0,0,0,2,0,0,0,3),3,3), dtp = "DN0", tol = 1e-12, maxits = 1000) GetDeltaPi(mx = matrix(c(1.5,2.5,0.5,3.5,4.5,0.5,0.5,0.5,1.5),3,3), dtp = "DN2", tol = 1e-12, maxits = 1000, original.mx = FALSE)
GetDeltaPi(mx = matrix(c(1,0,0,0,2,0,0,0,3),3,3), dtp = "DN0", tol = 1e-12, maxits = 1000) GetDeltaPi(mx = matrix(c(1.5,2.5,0.5,3.5,4.5,0.5,0.5,0.5,1.5),3,3), dtp = "DN2", tol = 1e-12, maxits = 1000, original.mx = FALSE)
This function apply Test to identify where are the solution located. We have mainly 3 situations for k > 2 and 2 for k = 2. For k > 2 we have: DN2 = No estimators in the boundary. DN1 = Some estimator in the boundary and global agreement imaginary. DN0 = Any other case For k = 2 we have: DA0 = Some estimator in the boundary. DA1 = Any other case
GetDeltaProblemType(Mx)
GetDeltaProblemType(Mx)
Mx |
Matrix. Matrix reduced. |
GetDeltaProblemType(matrix(c(1,2,0,3,4,0,0,0,1),3,3)) GetDeltaProblemType(matrix(c(1,0,0,0,2,0,0,0,3),3,3))
GetDeltaProblemType(matrix(c(1,2,0,3,4,0,0,0,1),3,3)) GetDeltaProblemType(matrix(c(1,0,0,0,2,0,0,0,3),3,3))
This function provide an Chi-square test for the given matrix, Delta and Pi provided.
GetGoodness(mx, Pi, Delta) ## S3 method for class 'GetGoodness' print(x, ...)
GetGoodness(mx, Pi, Delta) ## S3 method for class 'GetGoodness' print(x, ...)
mx |
Matrix. Modified matrix to have a solution. Usually GetMx$M1 for k>2 and GetMx$M2 in case of k = 2. |
Pi |
Vector. Each element indicate the probability of classify at random an element in category i. |
Delta |
Vector. Each element indicate the probability of recognize an element i. |
x |
List produced by GetGoodness |
... |
Other print options |
NULL
GetGoodness(mx = matrix(c(1,0,0,0,2,0,0,0,3),3,3), Delta = c(1,1,1), Pi = NULL) GetGoodness(mx = matrix(c(1.5,2.5,0.5,3.5,4.5,0.5,0.5,0.5,1.5),3,3), Delta = c(-0.2662395, 0.2047577, 0.5664672), Pi = c(0.42564365, 0.49700867, 0.07734769)) GetGoodness(mx = matrix(c(60,0,3,2,50,1,3,2,79),3,3), Delta = c( 0.8945724, 0.9522836, 0.8962094), Pi = c( 0.2703707, 0.1939561, 0.5356732))
GetGoodness(mx = matrix(c(1,0,0,0,2,0,0,0,3),3,3), Delta = c(1,1,1), Pi = NULL) GetGoodness(mx = matrix(c(1.5,2.5,0.5,3.5,4.5,0.5,0.5,0.5,1.5),3,3), Delta = c(-0.2662395, 0.2047577, 0.5664672), Pi = c(0.42564365, 0.49700867, 0.07734769)) GetGoodness(mx = matrix(c(60,0,3,2,50,1,3,2,79),3,3), Delta = c( 0.8945724, 0.9522836, 0.8962094), Pi = c( 0.2703707, 0.1939561, 0.5356732))
This function perform Cohen's Kappa coefficient calculations. The function provide the Kappa coefficient and SE.
GetKappa(mx) ## S3 method for class 'GetKappa' print(x, ...)
GetKappa(mx) ## S3 method for class 'GetKappa' print(x, ...)
mx |
Matrix. Agreement contingency table to perform calculations |
x |
List produced by GetKappa |
... |
Other print options |
NULL
GetKappa(matrix(c(50,10,10,20),2,2))
GetKappa(matrix(c(50,10,10,20),2,2))
This function apply Test to identify where kappa solutions are placed K0 = Full agreement (diagonal matrix) K1 = Any other case
GetKappaProblemType(Mx)
GetKappaProblemType(Mx)
Mx |
Matrix. Matrix reduced. |
GetKappaProblemType(matrix(c(1,2,0,3,4,0,0,0,1),3,3)) GetKappaProblemType(matrix(c(1,0,0,0,2,0,0,0,3),3,3))
GetKappaProblemType(matrix(c(1,2,0,3,4,0,0,0,1),3,3)) GetKappaProblemType(matrix(c(1,0,0,0,2,0,0,0,3),3,3))
This function reduce matrix provided by the user deleting missing categories, those j where sum(datatable[j,]) = sum(datatable[,j]) = 0. Also provide a list of the categories deleted and provides the new size of the problem
GetM1(datatable) ## S3 method for class 'GetM1' print(x, ...)
GetM1(datatable) ## S3 method for class 'GetM1' print(x, ...)
datatable |
Matrix. Expected to be square matrix with at least 2 rows (columns), non negative values and at least an element different of zero. |
x |
List produced by GetM1 |
... |
Other print options |
NULL
GetM1(matrix(c(1,2,0,3,4,0,0,0,0),3,3))
GetM1(matrix(c(1,2,0,3,4,0,0,0,0),3,3))
This function produce 3 new auxiliar matrix. Those matrix are always defined, but depending of the problem they will be used or not. All the auxiliar matrices are created to be able to solve the problem and avoid issues with solutions in the boundary or not completly defined.
GetMx(M1)
GetMx(M1)
M1 |
Matrix. Initial matrix without missing categories. |
The matrix are defined as follows - M2: Extended M1 with $c_33$ of 1 and increased by 0.5 - M3: M1 increased by 0.5 - M4: M1 increased by 1
In case of M1 is not 2x2, M2 and M3 are the same matrix.
GetMx(matrix(c(1,2,0,3,4,0,0,0,1),3,3))
GetMx(matrix(c(1,2,0,3,4,0,0,0,1),3,3))