twokappafn = function(sigma2u, beta1) |
{ |
integrand1 = function(z) |
{
|
term1=pnorm(sqrt(sigma2u)*z − beta1)
|
term2= pnorm(sqrt(sigma2u)*z + beta1)
|
fullintegrand= term1*term2*dnorm(z) |
} |
result1 = integrate (integrand1, lower=−100, upper=100) |
integrand2=function(z) |
{ |
term3=(1-pnorm(sqrt(sigma2u)*z − beta1))
|
term4=(1-pnorm(sqrt(sigma2u)*z + beta1))
|
fullintegrand2=term3*term4*dnorm(z) |
} |
result2= integrate(integrand2, lower=−100, upper=100) |
res2=result2 $value |
# two-rater model-based kappa |
2*(res1 + res2)−1 |
} |
# Calculation of variance: need to enter values for varbeta1, varsigmasqu, sigmasqu and beta1. |
integrand1a = function(z) |
{term=(0.5*(1/sqrt(sigmasqu))*dnorm(sqrt(sigmasqu)*z + beta1/2)*pnorm(sqrt(sigmasqu)*z − beta1/2) |
+ 0.5*(1/sqrt (sigmasqu))*pnorm(sqrt(sigmasqu)*z + beta1/2)*dnorm(sqrt(sigmasqu)*z − beta1/2)) |
*dnorm(z)*z } |
result1a=integrate(integrand1a, lower=−100, upper=100) |
integrand1b = function(z) |
{term=(−0.5*(1/sqrt(sigmasqu))*dnorm(sqrt(sigmasqu)*z + beta1/2)*(1-pnorm(sqrt(sigmasqu)*z − beta1/2))*z |
−0.5*(1/sqrt(sigmasqu))*pnorm(sqrt(sigmasqu)*z + beta1/2)*dnorm(sqrt(sigmasqu)*z − beta1/2)) |
*dnorm(z)*z} |
result1b=integrate(integrand1b, lower=−100, upper=100) |
vectorh1=result1a$value+result1b$value |
integrand1b = function(z) |
{term=(0.5*dnorm(sqrt(sigmasqu)*z + beta1/2)*pnorm(sqrt(sigmasqu)*z − beta1/2) − 0.5*pnorm(sqrt(sigmasqu)*z |
+ beta1/2)*dnorm(sqrt(sigmasqu)*z − beta1/2))*dnorm(z)} |
result2a=integrate(integrand2a, lower=−100, upper=100) |
integrand2b = function(z) |
{term=(−0.5*dnorm(sqrt(sigmasqu)*z + beta1/2)*(1-pnorm(sqrt(sigmasqu)*z − beta1/2)) |
+ 0.5*(1-pnorm(sqrt(sigmasqu)*z + beta1/2))*dnorm(sqrt(sigmasqu)*z − beta1/2))*dnorm(z)} |
result2b=integrate(integrand2b, lower=−100, upper=100) |
vectorh2=result2a$value+result2b$value |
covarmat = matrix(c(varsigmasqu,0,0,varbeta1), ncol=2) |
vectorh = c(vectorh1, vectorh2) |
varkappam = 4*(vectorh %*% covarmat %*% vectorh) |
} |