View source: R/Kernel Equating Functions.R
FindBestBandwidth | R Documentation |
Takes the median optimal bandwidth across multiple half-samples. Based on paper by Liang and von Davier (2014).
FindBestBandwidth(scores, fX, niters = 100, randseed = 1234567)
scores |
Vector of possible scores. |
fX |
Number of people achieving each score (weighted numbers, probabilities or proportions also acceptable). Must be same length as scores. |
niters |
The number of iterations of applying the algorithm over which to take the median bandwidth (default 100). |
randseed |
Random seed for splits (default 1234567). |
The function returns a single value representing the optimal bandwidth.
Liang, T., & von Davier, A. A. (2014). Cross-validation: An alternative bandwidth-selection method in kernel equating. Applied Psychological Measurement, 38(4), 281-295.
x=sample(c(0,0,1,2,2,2,3,4,4,4,4,5,5,6,6,7,8,9,10),200,replace=TRUE)#create x from an unusual true distribution
counts=200*(ecdf(x)(0:10)-ecdf(x)(-1:9))#used rather than "table" so all scores included even if zero count
FindBestBandwidth(0:10,counts)
FindBestBandwidth(0:10,counts,randseed=987654321)
#EXAMPLE OF FINDING BEST BANDWIDTH TO EQUATE FIRST AND SECOND HALVES OF MATHS TEST
x1=rowSums(mathsdata[,1:62])
y1=rowSums(mathsdata[,63:124])
summary(x1)
summary(y1)
tabx1=table(x1)
taby1=table(y1)
BestHx=FindBestBandwidth(as.numeric(names(tabx1)),as.vector(tabx1))
BestHx
BestHy=FindBestBandwidth(as.numeric(names(taby1)),as.vector(taby1))
BestHy
eq1=KernelEquateFromScoresEG(x1,y1,hX=BestHx,hY=BestHy)
plot(sort(unique(x1)),eq1$yx,type='l')
#compare to default Andersson and von Davier bandwidth approach
eq2=KernelEquateFromScoresEG(x1,y1)
lines(sort(unique(x1)),eq2$yx,lty=2,col="purple")
#very similar in this case
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.