I need to change few lines in a function in package called mirt
.
That function is fscores.internal
and is not a main function where you can just use edit
or fix
to change the code lines.
How can do this in RStudio?
I tried following:
library(mirt)
data(LSAT7)
LSAT7=expand.table(LSAT7)
mod=mirt(LSAT7, 1,itemtype = '3PL')
fscor=fscores(object = mod,method = "ML",response.pattern = c(1,NA,NA,NA,NA),theta_lim = c(-4, 4))
fscor
Item.1 Item.2 Item.3 Item.4 Item.5 F1 SE_F1
[1,] 1 NA NA NA NA Inf NA
This is the final output. I need "theta_lim[2]" instead of "Inf" as F1's output which can be obtained when you replace the Inf by theta_lim[2] and -Inf by theta_lim[1] (at lines no. 278 and 280 respectively, in fscores.internal code. This is the only change I want to make.
After using fixInNamespace("fscores.internal", "mirt")
A window appeared containing :
function (object, ...)
standardGeneric("fscores.internal")
(fixInNamespace
was not helpful)
After using
myfscores.internal <- function() { ... }
assignInNamespace("fscores.internal", myfscores.internal, "mirt")
I got following error, when I ran
fscor=fscores(object = mod,method = "ML",response.pattern = c(1,1,1,1,1),theta_lim = c(-4, 4))
## Error in .local(object, ...) : could not find function "ExtractGroupPars"
Then I compiled ExtractGroupPars
function separately.
then the out was
> fscor=fscores(object = mod,method = "ML",response.pattern = c(1,1,1,1,1),theta_lim = c(-4, 4))
Error in .local(object, ...) : could not find function "rotateLambdas"
After this I compiled rotateLambdas
function
and I ran
fscor=fscores(object = mod,method = "ML",response.pattern = c(1,1,1,1,1),theta_lim = c(-4, 4))
Then I got following error:
Error in matrix(rep(sqrt(1 - h2), ncol(F)), ncol = ncol(F)) :
non-numeric matrix extent
Called from: .rs.breakOnError(TRUE)
Don't know what to do after this.