FindBestBandwidth: Method to find optimal bandwidth (between 0.05 and 30) that...

View source: R/Kernel Equating Functions.R

FindBestBandwidthR Documentation

Method to find optimal bandwidth (between 0.05 and 30) that minimses cross-validation error between two half-samples.

Description

Takes the median optimal bandwidth across multiple half-samples. Based on paper by Liang and von Davier (2014).

Usage

FindBestBandwidth(scores, fX, niters = 100, randseed = 1234567)

Arguments

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).

Value

The function returns a single value representing the optimal bandwidth.

References

Liang, T., & von Davier, A. A. (2014). Cross-validation: An alternative bandwidth-selection method in kernel equating. Applied Psychological Measurement, 38(4), 281-295.

Examples

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

CambridgeAssessmentResearch/KernEqWPS documentation built on Feb. 23, 2024, 9:34 p.m.