Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Nov 10, 2024
1 parent c7f1424 commit e26bdb7
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions R/simdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -473,34 +473,35 @@ simdata <- function(a, d, N, itemtype, sigma = NULL, mu = NULL, guess = 0,
if(itemtype[i] == 'nestlogit'){
par <- na.omit(c(a[i, ],d[i,1], guess[i], upper[i], nominal[i,-1L],d[i,-1L]))
obj <- new(itemtype[i], par=par, nfact=nfact, correctcat=1L)
} else {
if(itemtype[i] == 'gpcm'){
if(!use_gpcm_mats[i]){
par <- na.omit(c(a[i, ],0:(K[i]-1), d[i,]))
} else {
stopifnot(nrow(gpcm_mats[[i]]) == K[i])
stopifnot(ncol(gpcm_mats[[i]]) == nfact)
par <- na.omit(c(a[i, ],as.vector(gpcm_mats[[i]]), d[i,]))
}
} else if(itemtype[i] == 'ideal'){
if(K[i] > 2) stop('ideal point models for dichotomous items only', call.=FALSE)
if(d[i,1] > 0) stop('ideal point intercepts must be negative', call.=FALSE)
par <- na.omit(c(a[i, ],d[i,]))
} else if(itemtype[i] == 'lca'){
par <- na.omit(a[i, ])
} else if(itemtype[i] == 'nominal'){
if(length(na.omit(nominal[i,])) != length(na.omit(d[i,])))
stop('nominal and d inputs must have same length for nominal reponse model', call.=FALSE)
par <- na.omit(c(a[i, ],nominal[i,],d[i,],guess[i],upper[i]))
} else if(itemtype[i] == 'partcomp'){
par <- na.omit(c(a[i, ],d[i,],guess[i],upper[i]))
} else if(itemtype[i] == 'gpcm'){
if(!use_gpcm_mats[i]){
par <- na.omit(c(a[i, ],0:(K[i]-1), d[i,]))
} else {
par <- na.omit(c(a[i, ],d[i,],guess[i],upper[i]))
stopifnot(nrow(gpcm_mats[[i]]) == K[i])
stopifnot(ncol(gpcm_mats[[i]]) == nfact)
par <- na.omit(c(a[i, ],as.vector(gpcm_mats[[i]]), d[i,]))
}
obj <- new(itemtype[i], par=par, nfact=nfact, ncat=K[i])
if(itemtype[i] %in% c('gpcm', 'nominal')) obj@mat <- FALSE
if(use_gpcm_mats[i]) obj@mat <- TRUE
}
} else if(itemtype[i] == 'ideal'){
if(K[i] > 2) stop('ideal point models for dichotomous items only', call.=FALSE)
if(d[i,1] > 0) stop('ideal point intercepts must be negative', call.=FALSE)
par <- na.omit(c(a[i, ],d[i,]))
} else if(itemtype[i] == 'lca'){
par <- na.omit(a[i, ])
item.Q <- matrix(1, K[i], nfact)
item.Q[1,] <- 0
} else if(itemtype[i] == 'nominal'){
if(length(na.omit(nominal[i,])) != length(na.omit(d[i,])))
stop('nominal and d inputs must have same length for nominal reponse model', call.=FALSE)
par <- na.omit(c(a[i, ],nominal[i,],d[i,],guess[i],upper[i]))
} else if(itemtype[i] == 'partcomp'){
par <- na.omit(c(a[i, ],d[i,],guess[i],upper[i]))
} else {
par <- na.omit(c(a[i, ],d[i,],guess[i],upper[i]))
}
obj <- new(itemtype[i], par=par, nfact=nfact, ncat=K[i])
if(itemtype[i] %in% c('gpcm', 'nominal')) obj@mat <- FALSE
if(use_gpcm_mats[i]) obj@mat <- TRUE
if(itemtype[i] == 'lca') obj@item.Q <- item.Q
if(itemtype[i] == 'ggum'){
if(length(na.omit(a[i,])) != length(na.omit(d[i,])))
stop('ggums must have the same number of a and d values per item', call.=FALSE)
Expand Down

0 comments on commit e26bdb7

Please sign in to comment.