ltm theta estimation

My data is 2688 by 200, with 0/1 coded. I am trying to estimate both parameters and ability(theta) using 2PL logistic model.
First I use the following code to get parameter estimate:
fit2PL = ltm(dat ~ z1, IRT.param = TRUE)

Then use the following to get theta estimate
theta<-ltm::factor.scores(fit2PL)

Now I want to extract zl column (i.e., theta estimate) from theta, the following code is not working. please help

theta1<-theta$zl

thank you!

Hi, and welcome!

A minimum working example, called a reprex will attract more and better answers.

library(ltm)
#> Loading required package: MASS
#> Loading required package: msm
#> Loading required package: polycor
# example from help(factor.scores)
fit <- rasch(LSAT)
f_scores <- factor.scores(fit) # Empirical Bayes
# f_scores is NOT a data frame
class(f_scores)
#> [1] "fscores"
# show the structure
str(f_scores)
#> List of 6
#>  $ score.dat:'data.frame':   30 obs. of  9 variables:
#>   ..$ Item 1: num [1:30] 0 0 0 0 0 0 0 0 0 0 ...
#>   ..$ Item 2: num [1:30] 0 0 0 0 0 0 0 0 1 1 ...
#>   ..$ Item 3: num [1:30] 0 0 0 0 1 1 1 1 0 0 ...
#>   ..$ Item 4: num [1:30] 0 0 1 1 0 0 1 1 0 0 ...
#>   ..$ Item 5: num [1:30] 0 1 0 1 0 1 0 1 0 1 ...
#>   ..$ Obs   : num [1:30] 3 6 2 11 1 1 3 4 1 8 ...
#>   ..$ Exp   : num [1:30] 2.364 5.468 2.474 8.249 0.852 ...
#>   ..$ z1    : num [1:30] -1.91 -1.439 -1.439 -0.959 -1.439 ...
#>   ..$ se.z1 : num [1:30] 0.79 0.793 0.793 0.801 0.793 ...
#>  $ method   : chr "EB"
#>  $ B        : num 5
#>  $ call     : language rasch(data = LSAT)
#>  $ resp.pats: logi FALSE
#>  $ coef     : num [1:5, 1:2] -3.615 -1.322 -0.318 -1.73 -2.78 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : chr [1:5] "Item 1" "Item 2" "Item 3" "Item 4" ...
#>   .. ..$ : chr [1:2] "Dffclt" "Dscrmn"
#>  - attr(*, "class")= chr "fscores"
# now we know how to call z1
f_scores$score.dat$z1
#>  [1] -1.91035438 -1.43850427 -1.43850427 -0.95942992 -1.43850427 -0.95942992
#>  [7] -0.95942992 -0.46601739 -1.43850427 -0.95942992 -0.46601739 -0.46601739
#> [13] -0.46601739  0.04900961 -1.43850427 -0.95942992 -0.95942992 -0.46601739
#> [19] -0.95942992 -0.46601739 -0.46601739  0.04900960 -0.95942992 -0.46601739
#> [25] -0.46601739  0.04900961 -0.46601739  0.04900960  0.04900961  0.59301137

@technocrat
It worked, thanks much for the help!

Great! Great. Please mark the solution for the benefit of those to follow.

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