indirectCalibration is a function for the indirect calibration procedure as described by Ragin (2008). It uses a binomial or a beta regression for tranforming raw scores into calibrated scores. In our opinion, using a fractional polynomial may not be appropriate to this case. In fact, we do not deal with proportions. This function requires the package betareg.
Usage
indirectCalibration(x, x_cal, binom = TRUE)
Arguments
x
vector of raw scores.
x_cal
vector of theoretically calibrated scores.
binom
logical. If indirect calibration has to be performed using binomial regression or beta regression. The default is TRUE, which means that binomial regression is used.
Value
It returns a vector of indirectly calibrated values.
Author(s)
Mario Quaranta
References
Ragin, C. C. (2008) Redesigning Social Inquiry: Fuzzy Sets and Beyond, The Chicago University Press: Chicago and London.
Schneider, C. Q., Wagemann, C. (2012) Set-Theoretic Methods for the Social Sciences, Cambridge University Press: Cambridge.
Schneider, C. Q., Wagemann, C., Quaranta, M. (2012) How To... Use Software for Set-Theoretic Analysis. Online Appendix to "Set-Theoretic Methods for the Social Sciences". Available at www.cambridge.org/schneider-wagemann
Examples
# Generate fake data
set.seed(4)
x <- runif(20, 0, 1)
# Find quantiles
quant <- quantile(x, c(.2, .4, .5, .6, .8))
# Theoretical calibration
x_cal <- NA
x_cal[x <= quant[1]] <- 0
x_cal[x > quant[1] & x <= quant[2]] <- .2
x_cal[x > quant[2] & x <= quant[3]] <- .4
x_cal[x > quant[3] & x <= quant[4]] <- .6
x_cal[x > quant[4] & x <= quant[5]] <- .8
x_cal[x > quant[5]] <- 1
x_cal
# Indirect calibration (binomial)
a <- indirectCalibration(x, x_cal, binom = TRUE)
# Indirect calibration (beta regression)
b <- indirectCalibration(x, x_cal, binom = FALSE)
# Correlation
cor(a, b)
# Plot
plot(x, a); points(x, b, col = "red")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SetMethods)
Loading required package: lattice
Loading required package: betareg
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SetMethods/indirectCalibration.Rd_%03d_medium.png", width=480, height=480)
> ### Name: indirectCalibration
> ### Title: Function performing the indirect calibration
> ### Aliases: indirectCalibration
>
> ### ** Examples
>
>
> # Generate fake data
> set.seed(4)
> x <- runif(20, 0, 1)
>
> # Find quantiles
> quant <- quantile(x, c(.2, .4, .5, .6, .8))
>
> # Theoretical calibration
> x_cal <- NA
> x_cal[x <= quant[1]] <- 0
> x_cal[x > quant[1] & x <= quant[2]] <- .2
> x_cal[x > quant[2] & x <= quant[3]] <- .4
> x_cal[x > quant[3] & x <= quant[4]] <- .6
> x_cal[x > quant[4] & x <= quant[5]] <- .8
> x_cal[x > quant[5]] <- 1
> x_cal
[1] 0.6 0.0 0.2 0.2 0.8 0.0 0.6 0.8 1.0 0.0 0.8 0.2 0.0 1.0 0.2 0.4 1.0 0.4 1.0
[20] 0.8
>
> # Indirect calibration (binomial)
> a <- indirectCalibration(x, x_cal, binom = TRUE)
>
> # Indirect calibration (beta regression)
> b <- indirectCalibration(x, x_cal, binom = FALSE)
>
> # Correlation
> cor(a, b)
[1] 0.9996942
>
> # Plot
> plot(x, a); points(x, b, col = "red")
>
>
>
>
>
> dev.off()
null device
1
>