Error when running gpcm with ltm library

Hi, I'm trying to run this command:

gpcm(data, constraint = "gpcm")

with full code:

data<-read.csv("OJ_FIX3.csv", sep=c(",",";"),header = TRUE)
library(ltm)
gpcm(data, constraint = "gpcm")

but it gives me:

Error in if (any(ind <- out == 1)) out[ind] <- 1 - eps :
missing value where TRUE/FALSE needed

I tried to use reprex but reprex itself give me an error

This is the data I used:

I'm not sure why, but it appears you cannot use all the variables

library(ltm)
#> Loading required package: MASS
#> Loading required package: msm
#> Loading required package: polycor
d <- read.csv("~/Downloads/OJ_FIX3 - OJ_FIX3.csv")
gpcm(data = d[1:19], constraint = "gpcm")
#> 
#> Call:
#> gpcm(data = d[1:19], constraint = "gpcm")
#> 
#> Coefficients:
#> $D101
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -2.770   -2.634    1.541    1.057  
#> 
#> $D102
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -0.892   -5.491   -0.477    0.747  
#> 
#> $D103
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -4.359   -5.982    5.373    0.323  
#> 
#> $D104
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -2.738   -4.094    0.071    0.449  
#> 
#> $D105
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#> -10.816   -0.709    0.728    0.328  
#> 
#> $D201
#> Catgr.1  Catgr.2   Dscrmn  
#>  -2.858    0.481    0.777  
#> 
#> $D202
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -3.052   -2.323    1.040    1.032  
#> 
#> $D203
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -2.426   -1.934    0.309    1.099  
#> 
#> $D204
#> Catgr.1  Catgr.2   Dscrmn  
#>  -1.735    0.089    2.786  
#> 
#> $D205
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -3.272   -2.502    0.152    0.875  
#> 
#> $D301
#> Catgr.1  Catgr.2   Dscrmn  
#>  -1.749    0.302    2.766  
#> 
#> $D302
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -1.798   -2.054    0.348    2.420  
#> 
#> $D303
#> Catgr.1  Catgr.2   Dscrmn  
#>  -1.542    0.431    2.626  
#> 
#> $D304
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -3.013   -2.300    1.013    0.656  
#> 
#> $D305
#> Catgr.1  Catgr.2   Dscrmn  
#>  -1.833    0.091    2.809  
#> 
#> $D401
#> Catgr.1  Catgr.2   Dscrmn  
#>  -2.115    0.778    1.312  
#> 
#> $D402
#> Catgr.1  Catgr.2   Dscrmn  
#>  -1.561    0.844    1.480  
#> 
#> $D403
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -3.659   -1.583    0.740    0.995  
#> 
#> $D404
#> Catgr.1  Catgr.2  Catgr.3   Dscrmn  
#>  -3.286   -1.981    0.470    1.017  
#> 
#> 
#> Log.Lik: -1580.136

Created on 2023-06-24 with reprex v2.0.2

The 20th item is causing the error?

Yes. I'm not sure why. When I replace the contents of the 20th column with the first, it runs, so it's not that there needs to be one fewer than the length of the data frame, and I don't see anything special about the 20th column.

Okay, thank you so much. I will try to look into it. If you got what's wrong with it, please kindly let me know.

1 Like

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.