I tried to specify a vector defining which items are unfolding, while the rests are gpcm but it does not work unfortunately.
```
library(mirt)
#> Warning: package 'mirt' was built under R version 4.3.3
#> Loading required package: stats4
#> Loading required package: lattice
```
```
set.seed(123)
# Simulate data for GGUM items (unfolding construct)
a_ggum <- matrix(rnorm(5, mean=1, sd=0.5), ncol=1)
d_ggum <- matrix(rnorm(5, mean=0, sd=1), ncol=1)
t_ggum <- matrix(rnorm(5, mean=0, sd=1), ncol=1) # threshold parameters for GGUM
theta_ggum <- matrix(rnorm(1000, mean=0, sd=1)) # latent trait for GGUM
data_ggum <- simdata(a=a_ggum, d=d_ggum, t=t_ggum, itemtype='ggum', Theta=theta_ggum)
# Simulate data for GPCM items (dominance construct)
a_gpcm <- matrix(rnorm(4, mean=1, sd=0.5), ncol=1)
d_gpcm <- matrix(rnorm(4 * 3, mean=0, sd=1), ncol=3) # GPCM requires multiple thresholds (3 categories, 2 thresholds per item)
theta_gpcm <- matrix(rnorm(1000, mean=0, sd=1)) # latent trait for GPCM
data_gpcm <- simdata(a=a_gpcm, d=d_gpcm, itemtype='gpcm', Theta=theta_gpcm)
colnames(data_ggum) <- paste0("ggum", 1:5)
colnames(data_gpcm) <- paste0("gpcm", 1:4)
# Combine the simulated datasets
mixed.irt <- cbind(data_ggum, data_gpcm)
print(head(mixed.irt))
#> ggum1 ggum2 ggum3 ggum4 ggum5 gpcm1 gpcm2 gpcm3 gpcm4
#> [1,] 0 0 1 0 1 1 2 0 1
#> [2,] 0 0 0 1 0 0 0 2 0
#> [3,] 1 0 0 0 0 1 0 1 1
#> [4,] 0 0 1 0 0 2 2 1 0
#> [5,] 0 1 0 0 1 0 0 0 0
#> [6,] 1 0 0 1 0 0 2 1 1
```
```
# Check the range of responses
apply(mixed.irt, 2, table)
#> $ggum1
#>
#> 0 1
#> 527 473
#>
#> $ggum2
#>
#> 0 1
#> 555 445
#>
#> $ggum3
#>
#> 0 1
#> 769 231
#>
#> $ggum4
#>
#> 0 1
#> 644 356
#>
#> $ggum5
#>
#> 0 1
#> 782 218
#>
#> $gpcm1
#>
#> 0 1 2
#> 459 156 385
#>
#> $gpcm2
#>
#> 0 1 2
#> 375 41 584
#>
#> $gpcm3
#>
#> 0 1 2
#> 202 316 482
#>
#> $gpcm4
#>
#> 0 1 2
#> 430 503 67
```
```
# Specify item types vector
itemtypes <- c(rep('ggum', 5), rep('gpcm', 4))
# Define the model structure with two correlated factors
model <- 'F1 = 1-5
F2 = 6-9
F1*F2'
# Fit the model
mixed.irt.model <- mirt(mixed.irt, model = model, itemtype = itemtypes, SE = TRUE,
SE.type = "Oakes", optimizer = "nlminb")
#> Warning in model.elements(model = model$x, itemtype = itemtype, factorNames =
#> factorNames, : NAs introduced by coercion
#> Error in tmp2[1L]:tmp2[2L]: NA/NaN argument
```