Git Product home page Git Product logo

Comments (7)

alexanderrobitzsch avatar alexanderrobitzsch commented on August 28, 2024

Please provide reproducible script and data.

from sirt.

ellaninomiya avatar ellaninomiya commented on August 28, 2024

hi, I upload the data as Rdata in this zip file. (Sample Size is 5000 and Test Length is 20)
dat.zip
And the script is

P_PGenlogis <- function( par, Theta, ncat){
  a <- par[1]
  b <- par[2]
  talpha1 <- par[3]
  talpha2 <- par[4]
  TP <- nrow(Theta)
  P <- matrix( NA, nrow=TP, ncol=ncat)
  P[,2] <- sirt::pgenlogis((a*(Theta[,1]- b)), alpha1=(exp(2*talpha1)-1)/(exp(2*talpha1)+1), alpha2=(exp(2*talpha2)-1)/(exp(2*talpha2)+1))
  P[,1] <- 1 - P[,2]
  return(P)
}

par <- c("a" = 1, "b" = 0, "talpha1" = 0, "talpha2" = 0)
item_1PGenlogis <- xxirt_createDiscItem( name = "1PGenlogis" , par = par, est = c(FALSE,TRUE,TRUE,TRUE), P = P_PGenlogis)
item_2PGenlogis <- xxirt_createDiscItem( name = "2PGenlogis" , par = par, est = c(TRUE,TRUE,TRUE,TRUE), P = P_PGenlogis)
customItems <- list(item_1PGenlogis, item_2PGenlogis)


mod.2PGenlogis.estimate <- function(dat, j){
  itemtype = rep( "2PGenlogis", j)
  partable = xxirt_createParTable(dat, itemtype = itemtype, customItems = customItems)
  parindex1 <- partable[ partable$parname=="talpha1","parindex"]
  parindex2 <- partable[ partable$parname=="talpha2","parindex"]
  lambda <- 1
  penalty_fun_item <- function(x){
    val <- (sum(sapply(x[parindex1], "-", x[parindex1])^2) + sum(sapply(x[parindex2], "-", x[parindex2])^2)) * lambda
    return(val)
  }
  smod2.2PGenlogis <- xxirt( dat=dat, Theta=Theta, partable=partable, maxit=3000, customItems=customItems, customTheta=customTheta, conv = 0.001, penalty_fun_item=penalty_fun_item, verbose = F)
  return(smod2.2PGenlogis)
}

Theta <- matrix( seq(-6,6,len=61) , ncol=1 )
P_Theta1 <- function( par , Theta , G){
  mu <- par[1]
  sigma <- max( par[2] , .01 )
  TP <- nrow(Theta)
  pi_Theta <- matrix( 0 , nrow=TP , ncol=G)
  pi1 <- dnorm( Theta[,1] , mean = mu , sd = sigma )
  pi1 <- pi1 / sum(pi1)
  pi_Theta[,1] <- pi1
  return(pi_Theta)
}

par_Theta <- c( "mu"=0, "sigma" = 1 )  
customTheta  <- xxirt_createThetaDistribution( par=par_Theta , est=c(F,T), P=P_Theta1 )

set.seed(2)
mod.2PGenlogis <- mod.2PGenlogis.estimate(dat = dat, j = 20)

And when I estimated this data without regularized estimation, same error shows.

mod.2PGenlogis.estimate <- function(dat, j){
  itemtype = rep( "2PGenlogis", j)
  partable = xxirt_createParTable(dat, itemtype = itemtype, customItems = customItems)
  smod1.2PGenlogis <- xxirt( dat=dat, Theta=Theta, partable=partable, maxit=10000, customItems=customItems, customTheta=customTheta, conv = 0.001, verbose = T)
  return(smod1.2PGenlogis)
}

from sirt.

alexanderrobitzsch avatar alexanderrobitzsch commented on August 28, 2024

A slightly more condensed script would be more helpful in order to focus on the primary issue. I do want to dive into your mod.2PGenlogis.estimate function. Could you please ensure that the dimensions of itemtype and dat are properly chosen?

from sirt.

ellaninomiya avatar ellaninomiya commented on August 28, 2024

This data is simulated using the generation process of the second simulation study mentioned in the atricle [An Alternative to the 3PL: Using Asymmetric Item Characteristic Curves to Address Guessing Effects - Lee - 2018 - Journal of Educational Measurement - Wiley Online Library](https://onlinelibrary.wiley.com/doi/10.1111/jedm.12165), expect that I rearrange item order from easier to moer difficult. According to this generation process, I think it might be some multidimensional problem.(This estimation focuses on unidimensional and dichotomous item) The generation model from this article is :
image
And I followed your excellent work in [Information | Free Full-Text | Regularized Generalized Logistic Item Response Model (mdpi.com)](https://www.mdpi.com/2078-2489/14/6/306) with fisher transformation as: (hope I didn't get these wrong)

alpha1=(exp(2*talpha1)-1)/(exp(2*talpha1)+1), alpha2=(exp(2*talpha2)-1)/(exp(2*talpha2)+1)

and regularized estimation with lambda = 1 as:

partable = xxirt_createParTable(dat, itemtype = itemtype, customItems = customItems)
parindex1 <- partable[ partable$parname=="talpha1","parindex"]
parindex2 <- partable[ partable$parname=="talpha2","parindex"]
lambda <- 1
penalty_fun_item <- function(x){
   val <- (sum(sapply(x[parindex1], "-", x[parindex1])^2) + sum(sapply(x[parindex2], "-", x[parindex2])^2)) * lambda
   return(val)
  }

The full simulation script is quite long and comments are kind of messy to read, so I have to appolzise to take some time to tidy it. I will send it as soon as I finish organize the comments. But all the script lines involving the mod.2PGenlogis.estimate function are posted.
Thank you!

from sirt.

alexanderrobitzsch avatar alexanderrobitzsch commented on August 28, 2024

I played a bit with script and data. I strongly recommend using lower and upper bounds for talpha1 and talpha2 (e.g., -4 and 4).

from sirt.

ellaninomiya avatar ellaninomiya commented on August 28, 2024

It finally works! And adding lower and upper bounds doesn't cost much extra time to converge.
Thank you so much for your responsiveness and time!

from sirt.

alexanderrobitzsch avatar alexanderrobitzsch commented on August 28, 2024

As an alternative, one can prevent numerical overflow in the inverse Fisher transformation (exp(2*talpha)-1)/(exp(2*talpha)+1). This formula can be safely used for talpha <= 0. For talpha > 0, one can compute (1-exp(-2*talpha)-1)/(1+exp(-2*talpha)).

from sirt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.