# R/ordagr.R In AyaMitani/ModelKappa: Calculates model-based kappa for agreement and association and their standard errors

#### Defines functions ordagr

```#' @export

ordagr <- function(rho, sigma2u, sigma2v, numitems, numraters, numcat){

rho <- sigma2u/(sigma2u + sigma2v + 1)
var.rho <- (2*sigma2u^2*(sigma2v+1)^2)/(numitems*(sigma2u+sigma2v+1)^4) + (2*sigma2v^2*sigma2u^2)/(numraters*(sigma2u+sigma2v+1)^4)

### kappa for agreement
integrand <- function(z)
{
for (c in 1:numcat){
}
}
integral <- integrate(integrand,lower=-800,upper=800)
kappam <- (numcat/(numcat-1)) * integral\$value - 1/(numcat-1)

### standard error for agreement
integrand <- function(z)
{
(dnorm((qnorm(1/numcat)-z*sqrt(rho))/sqrt(1-rho))*(-z/(2*sqrt(rho*(1-rho)))+(qnorm(1/numcat)-z*sqrt(rho))/(2*(1-rho)^(3/2))))

for (c in 2:(numcat-1))
{
2*(pnorm((qnorm(c/numcat)-z*sqrt(rho))/sqrt(1-rho))-pnorm((qnorm((c-1)/numcat)-z*sqrt(rho))/sqrt(1-rho)))*
(dnorm((qnorm(c/numcat)-z*sqrt(rho))/sqrt(1-rho))*(-z/(2*sqrt(rho*(1-rho)))+(qnorm(c/numcat)-z*sqrt(rho))/(2*(1-rho)^(3/2)) -
dnorm((qnorm((c-1)/numcat)-z*sqrt(rho))/sqrt(1-rho))*(-z/(2*sqrt(rho*(1-rho)))+(qnorm((c-1)/numcat)-z*sqrt(rho))/(2*(1-rho)^(3/2)))))
}
2*(1-pnorm((qnorm((numcat-1)/numcat)-z*sqrt(rho))/sqrt(1-rho)))*
(0-dnorm((qnorm((numcat-1)/numcat)-z*sqrt(rho))/sqrt(1-rho))*(-z/(2*sqrt(rho*(1-rho)))+(qnorm((numcat-1)/numcat)-z*sqrt(rho))/(2*(1-rho)^(3/2))))