Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using btm function with eps = 0 returns error #2

Closed
SanVerhavert opened this issue Jun 13, 2018 · 4 comments
Closed

using btm function with eps = 0 returns error #2

SanVerhavert opened this issue Jun 13, 2018 · 4 comments

Comments

@SanVerhavert
Copy link

Executing the following line of code (with data from data.txt with specs: sep = ";", dec = "." )
Ability_sirt <- btm( data = Data, fix.eta = 0, fix.delta = 0, eps = 0 )
returns the error and warning

Error in while ((iter < maxiter) & (max.change > conv)) { : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In max(theta_ch, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf

The problem is located in the file btm.r on line 62. Calculating the mean of a vector containing INF values results in an INF value. If there is no epsilon correction (i.e. eps = 0) line 60 produces an -INF value (in the example data) because there is a 0 score.

A possible solution, in my opinion, is to insert the block from line 65 to line 76 between line 60 and 61 and add the line of code theta[elim_persons_index] <- NA after the line theta_elim <- theta[ elim_persons_index ] in the moved block.

That part of code should look as follows

theta <- 0.8 * stats::qlogis(propscore)
elim_persons <- FALSE
if (sum(propscore %in% c(0, 1)) > 0) {
  elim_persons <- TRUE
  elim_persons_index <- which(propscore %in% c(0, 1))
  theta_elim <- theta[elim_persons_index]
  theta[elim_persons_index] <- NA
  indicator_elim <- dat0
  indicator_elim[, 3] <- 0
  indicator_elim[indicator_elim[, 1] %in% elim_persons_index, 
                 3] <- 1
  indicator_elim[indicator_elim[, 2] %in% elim_persons_index, 
                 3] <- 1
}
if (center.theta) {
  theta <- theta - mean(theta, na.rm = T )
}
some.fixed.theta <- FALSE

data.txt

@alexanderrobitzsch
Copy link
Owner

I decided to replace the line for calculating initial values by theta <- stats::qlogis( ( propscore + .1 ) / 1.2 ) which avoids inifinite estimates. I submitted a new package version on Github.

@SanVerhavert
Copy link
Author

That is indeed a more elegant solution.
I am unfornunately unable to test the change myself because the devtools::install_github( "alexanderrobitzsch/sirt" ) cannot install the package and returns the following output (last 8 lines)

init.o:init.c:(.text+0x0): multiple definition of `R_init_sirt'
RcppExports.o:RcppExports.cpp:(.text+0x1f0): first defined here
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'sirt'
* removing 'C:/Users/SVerhavert/Documents/R/win-library/3.5/sirt'
In R CMD INSTALL
Installation failed: Command failed (1)

@alexanderrobitzsch
Copy link
Owner

Yes, I agree. This was an incorrect version. I just updated a new version in which the problem should have been solved.

@SanVerhavert
Copy link
Author

The change works fine! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants