Is the PP
package the right package for you?
If you agree to question 1-3 and at least to one of question 4-6, load the package an start estimating person parameters.
Now a simple example.
In this example, we want to gain ability estimates for each person in our sample. Each person answered questions in a test which has been scaled by the 2-PL model. Item parameters (difficulty and slope) are known and are supposed as fixed. What are the next steps?
?PP_4pl
)Getting the data inside the R workspace is quite easy in this case, because we merely load the data set which already comes with the PP package. It contains 60 response sets (60 persons answered to a test of 12 items) - and we have additional information, which we do not take into account for now. We first inspect the data, and in a second step informations about item difficulty and the slope parameters are extracted from the dataset attributes.
library(PP) data(fourpl_df) dim(fourpl_df) head(fourpl_df) # extracting the information diff_par <- attr(fourpl_df,"diffpar") slope_par <- attr(fourpl_df,"slopes")
Now we explore the item response data regarding full or zero score, missing values etc. . Considering this information, we are able to decide which estimation method we will apply.
# extract items and transform the data.frame to matrix itmat <- as.matrix(fourpl_df[,-(1:2)]) # are there any full scores? fullsc <- apply(itmat,1,function(x) (sum(x,na.rm=TRUE)+sum(is.na(x))) == length(x)) any(fullsc) # are there 0 scores? nullsc <- apply(itmat,1,function(x) sum(x,na.rm=TRUE) == 0) any(nullsc) # are there missing values? how many and where? nasc <- apply(itmat,1,function(x) sum(is.na(x))) any(nasc > 0) #which(nasc) # is our data dichotomous as expected? apply(itmat,2,function(x) table(x)) # are there any duplicates? rdup <- duplicated(itmat) sum(rdup)
We use the PP_4pl()
function for our estimation. So perhaps you are thinking:"Why are we using a function to fit the 4-PL model, when we acutally have a dataset which stems from a 2-PL model scaled test?!" This is because with the PP_4pl()
function you can fit the:
In this case, difficulty parameters and slopes are available, so we will submit them, and a 2-PL model is fitted automatically.
We decide to apply a common maximum likelihood estimation (type = "mle"
), and do not remove duplicated response patterns (see argument: ctrl=list()
) from estimation because there are only r sum(rdup)
duplicated patterns. If the data set would have been much larger, duplicated patterns are more likely and therefore choosing to remove these patterns would speed up the estimation process significantly. (Choosing this option or not, does not change the numerical results!)
library(PP) res1plmle <- PP_4pl(respm = itmat, thres = diff_par, slopes = slope_par, type = "mle") summary(res1plmle)
Some facts:
res1plmle$resPP$resPP
).In the last step, we add the estimates to the data.frame we extracted the item responses from in the first place.
dafest <- data.frame(fourpl_df, res1plmle$resPP$resPP) head(dafest,10)
One shortcoming of the plain maximum likelihood estimate is the fact, that the extreme scores do not lead to valid parameter estimates (-Inf
and Inf
are hardly useful for practitioners). One possibility to overcome this issue, is to change the estimation method - for instance type = wle
performs weighted likelihood estimation, which is on the one hand less biased than the mle estimate, and on the other hand provides reasonable estimates for the extreme scores.
library(PP) res1plwle <- PP_4pl(respm = itmat,thres = diff_par, slopes = slope_par, type = "wle") summary(res1plwle)
So, this was what we were finally looking for.
For estimating person parameters and examining person fit in one step, use PPass()
(for ass stands for assessment). Using this function has several advantages over the using the other methods consecutively.
data.frame
data.frame
with person fit statistics addedpres <- PPass(fourpl_df, items = 3:14, mod="2PL", thres = diff_par, slopes = slope_par, type = "wle")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.