Introduction to ExtendedRtIrtModeling.jl through JuliaConnectoR

Author

JW Tsai

Published

November 19, 2024

I’ve just updated my Julia package, ExtendedRtIrtModeling.jl, to version 0.2.0. There are a few new features in there that I’ll run through in the next few sections.

But that’s not all! If you’re an R user, I’ll introduce you to an R package called JuliaConnectoR that lets you run Julia programs in R. It’ll bridge the two languages seamlessly.

Using in Julia

See the Github page.

Using in R

All you have to do is to install and library the JuliaConnectoR as usual, and then you can use the juliaImport function to import any Julia package. It seems like the package’s version you get depends on which copy version you’ve had on your computer (confirmed). The great thing is, it’ll always download the newest version from Github, but not the stable one.

Code
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
βœ” dplyr     1.1.4     βœ” readr     2.1.5
βœ” forcats   1.0.0     βœ” stringr   1.5.1
βœ” ggplot2   3.5.1     βœ” tibble    3.2.1
βœ” lubridate 1.9.3     βœ” tidyr     1.3.1
βœ” purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
βœ– dplyr::filter() masks stats::filter()
βœ– dplyr::lag()    masks stats::lag()
β„Ή Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Code
library(JuliaConnectoR)
Warning: package 'JuliaConnectoR' was built under R version 4.4.1

I’ve got a toy data set to test, but I’ll run through the demo anyway. As you can see from the data below, the data set includes 25 columns: one for ID, 10 for item responses, 10 for (log-)response time, and four for explanatory variables.

Code
demo <- read.csv('https://raw.githubusercontent.com/jiewenTsai/ExtendedRtIrtModeling.jl/refs/heads/main/data/demo.csv')
head(demo)
    id y1 y2 y3 y4 y5 y6 y7 y8 y9 y10    t1    t2    t3    t4    t5    t6    t7
1 s001  0  0  0  0  1  0  0  0  0   0 2.961 4.225 3.322 2.164 2.273 2.631 2.505
2 s002  0  0  0  0  1  1  1  0  0   0 3.848 3.996 4.434 3.246 2.663 3.819 2.158
3 s003  0  0  0  0  0  1  1  1  0   0 3.122 3.273 4.489 3.891 3.410 3.879 2.951
4 s004  0  1  0  0  0  0  1  0  0   0 3.515 3.162 4.151 3.371 2.885 3.026 1.439
5 s005  0  0  0  0  0  0  1  0  1   0 3.060 3.962 4.058 3.696 2.732 2.560 2.517
6 s006  0  0  0  0  1  0  0  0  0   0 3.546 3.360 3.382 3.262 1.931 1.629 1.463
     t8    t9   t10 x1     x2     x3    x4
1 3.924 2.198 2.878  0 -3.362 -0.200 1.063
2 2.848 2.492 4.038  1 -0.081  2.347 1.063
3 3.891 3.877 3.553  0 -0.829 -1.068 1.063
4 3.243 2.694 3.603  1 -0.829 -0.676 1.063
5 3.339 3.421 3.314  0 -0.829  0.097 1.063
6 2.475 2.373 2.909  1 -1.251 -3.096 1.063
Code
glimpse(demo)
Rows: 300
Columns: 25
$ id  <chr> "s001", "s002", "s003", "s004", "s005", "s006", "s007", "s008", "s…
$ y1  <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, …
$ y2  <int> 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
$ y3  <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
$ y4  <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
$ y5  <int> 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, …
$ y6  <int> 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, …
$ y7  <int> 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, …
$ y8  <int> 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, …
$ y9  <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, …
$ y10 <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
$ t1  <dbl> 2.961, 3.848, 3.122, 3.515, 3.060, 3.546, 2.579, 3.854, 4.516, 2.9…
$ t2  <dbl> 4.225, 3.996, 3.273, 3.162, 3.962, 3.360, 3.448, 3.451, 4.943, 4.1…
$ t3  <dbl> 3.322, 4.434, 4.489, 4.151, 4.058, 3.382, 3.753, 2.875, 2.945, 5.0…
$ t4  <dbl> 2.164, 3.246, 3.891, 3.371, 3.696, 3.262, 3.575, 3.634, 4.444, 4.0…
$ t5  <dbl> 2.273, 2.663, 3.410, 2.885, 2.732, 1.931, 2.846, 2.560, 2.718, 2.8…
$ t6  <dbl> 2.631, 3.819, 3.879, 3.026, 2.560, 1.629, 3.153, 2.499, 1.442, 3.3…
$ t7  <dbl> 2.505, 2.158, 2.951, 1.439, 2.517, 1.463, 3.370, 2.581, 1.666, 3.2…
$ t8  <dbl> 3.924, 2.848, 3.891, 3.243, 3.339, 2.475, 2.424, 2.124, 3.301, 3.3…
$ t9  <dbl> 2.198, 2.492, 3.877, 2.694, 3.421, 2.373, 2.039, 2.749, 1.962, 2.7…
$ t10 <dbl> 2.878, 4.038, 3.553, 3.603, 3.314, 2.909, 2.923, 2.366, 4.804, 3.6…
$ x1  <int> 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, …
$ x2  <dbl> -3.362, -0.081, -0.829, -0.829, -0.829, -1.251, 1.174, -0.829, -1.…
$ x3  <dbl> -0.200, 2.347, -1.068, -0.676, 0.097, -3.096, -1.944, -1.258, -1.4…
$ x4  <dbl> 1.063, 1.063, 1.063, 1.063, 1.063, 1.063, 0.104, -0.587, -2.002, -…

Next, let’s take a look at how accuracy and speed related to each other, barely using the raw data (mean of y and mean of t) to get a rough idea.

Code
tibble(
  accuracy = rowMeans(demo[2:11]),
  speed = -rowMeans(demo[12:21])
) |>
  ggplot(aes(x=accuracy, y=speed)) +
  geom_point() +
  geom_jitter() +
  geom_smooth(method = "loess") 
`geom_smooth()` using formula = 'y ~ x'

The modeling part.

Let’s follow the example from the Github readme post to show how a basic RT-IRT model works. This package is version 0.2.0.

Code
## You have to give a name to the Julia Environment.
ex <- juliaImport("ExtendedRtIrtModeling")
Starting Julia ...
Code
juliaEval('Pkg.status("ExtendedRtIrtModeling")')
Status `~/.julia/environments/v1.10/Project.toml`
  [1fd685a6] ExtendedRtIrtModeling v0.2.0 `https://github.com/jiewenTsai/ExtendedRtIrtModeling.jl#main`

In the original Github post, the user doesn’t have to fill in all five arguments of InputData because the values for \(\kappa\) and logT are automatically calculated by Y and T. However, to get it working with R, I’ve come up with another struct called InputData4R, which is specifically for R users.

Code
## import your data set
Cond = ex$setCond(
  nChain=3, 
  nIter=3000,
  nSubj=300,
  nItem=10,
  nFeat=4
  )
Data = ex$InputData4R(
    Y = as.matrix(demo[2:11]),
    # you must write this line!
    ΞΊ = as.matrix(demo[2:11]-0.5),
    T = as.matrix(exp(demo[12:21])),
    logT = as.matrix(demo[12:21]),
    X = as.matrix(demo[22:25])
)

## build a model and sample it!
MCMC = ex$GibbsRtIrt(Cond, Data=Data)
## Notice the `` style for sample!
ex$`sample!`(MCMC)
<Julia object of type ExtendedRtIrtModeling.GibbsRtIrt>
ExtendedRtIrtModeling.GibbsRtIrt(ExtendedRtIrtModeling.SimConditions(300, 10, 4, 3000, 3, 1500, 1, 10, 0.5, 0.5), ExtendedRtIrtModeling.InputData4R([0 0 … 0 0; 0 0 … 0 0; … ; 0 0 … 1 0; 0 1 … 1 0], [-0.5 -0.5 … -0.5 -0.5; -0.5 -0.5 … -0.5 -0.5; … ; -0.5 -0.5 … 0.5 -0.5; -0.5 0.5 … 0.5 -0.5], [19.31727937946127 68.3745035485581 … 9.006981510434914 17.778680238058843; 46.89917102861648 54.38019363641357 … 12.085422811327593 56.71280369681312; … ; 27.194098966393437 42.182270397465956 … 25.584840292351714 119.46219960089533; 35.05786562994266 82.26946350420168 … 43.991656898689 24.754319523777408], [2.961 4.225 … 2.198 2.878; 3.848 3.996 … 2.492 4.038; … ; 3.303 3.742 … 3.242 4.783; 3.557 4.41 … 3.784 3.209], [0.0 -3.362 -0.2 1.063; 1.0 -0.081 2.347 1.063; … ; 1.0 -0.064 0.445 -0.318; 0.0 -0.449 -0.676 1.063]), Float64[], ExtendedRtIrtModeling.InputPara([0.03803954836290282 0.15232909667566663 … 0.05161322853812894 0.13813548640620224; 0.6820446079265877 0.34147419401485857 … 0.08950104948637522 0.14098614046303293; … ; 0.10597207519925943 0.1647379067865525 … 0.39929612168578055 0.07881275553602582; 0.029065140357117505 0.11420999068850912 … 0.067385411002555 0.08432507233276894], [-3.2940883047383913; -0.8556087208746063; … ; 0.2957471460780982; -0.5130925360110484;;], [1.1729970641986105; 1.5458803495092144; … ; 1.6853029639293666; 1.530409031452339;;], [-0.517568491848459; -0.982877174566527; … ; -0.7583810973883602; -0.09740730421271002;;], [0.5187822333228932; 0.17945796808241804; … ; -0.4089531330263851; -0.28036133076001346;;], [3.3393118348012587; 3.87644094752713; … ; 2.8577060562598415; 3.7101671096169406;;], [0.36835845733426814; 0.32471225592571945; … ; 0.2879305608202483; 0.2535185154875389;;], Float64[], [0.0 0.0; -0.13955836192391025 0.19017204916811675; … ; 0.19452561633168883 -0.02569275995793209; 0.008873056157746655 -0.020109568214501022], Float64[], [1.0320100623914066 -0.07785061758422016; -0.07785061758422016 0.16895129102317735]), ExtendedRtIrtModeling.OutputPost([-2.5316054308599174 -1.0201149676069194 … -0.5075576803546703 -0.08864269630953704; -2.385233298441571 -1.4283258309850775 … -1.4219131141778978 0.2129493136184259; … ; -1.9741175809894413 -1.0250130746899613 … -0.5718654341855209 -0.1284281480151264; -2.844235988213971 -1.316783874105525 … -0.6786711872540668 -0.05857460754134373;;; -4.6483512794741735 0.3493888705714854 … -2.4506544874705565 0.6788249924528524; -3.7301650282003234 -0.35206014753877 … -1.060147038895324 -0.022847830081273553; … ; -2.3228954038123826 -0.7633078075173486 … -0.5218305601114234 -0.006863193064532861; -2.947459210211141 -1.1136049934548102 … -0.7818335114896942 -0.07936515200090292;;; -2.8110340000021417 -0.03212862955989345 … -2.025504239319318 0.45657793306823946; -4.1596980425369825 -0.14333259949396085 … -1.1332579574632875 0.3222192608749193; … ; -2.9995248309035096 -0.5025283160730506 … -0.7183550769803037 0.0676513203886467; -3.2940883047383913 -0.8556087208746063 … -0.7583810973883602 -0.09740730421271002], [1.4408516602399948 0.3119398314847293 … 1.436388830030692 1.7594573686009332; 0.6485769988459371 0.09799817794512869 … 0.31841190001990965 0.24727987392394055; … ; 0.6627543140062743 0.062379143944078154 … 0.2865093185798355 0.24389872189259454; 0.44614964292947934 -0.0009854797366953515 … 0.28884633266179777 0.21660633195557716;;; 0.20771950271501474 0.07470008557255679 … 0.4103878498912844 0.3363959900787248; 0.4426062385974111 0.5151675445567098 … 0.29291788454958345 0.2503375597447657; … ; 0.7070645022178579 0.20368876114203885 … 0.28272533057375293 0.24136415837075093; 0.45753666379890207 -0.18874208624041255 … 0.2834510081524539 0.2551776999849949;;; 0.30915139077679943 0.11755077510470256 … 0.33693480204725546 0.2526349715282094; 0.5271674464554031 -0.03412047093349183 … 0.31415501362293397 0.23995328803270566; … ; 0.4020971899295065 0.0677768958301857 … 0.3122296334816429 0.27227850933927056; 0.5187822333228932 0.17945796808241804 … 0.2879305608202483 0.2535185154875389], [0.0 -0.0887285183553337 … -0.01884626579878293 1.1285784837010724; 0.0 -0.08011816664565659 … -0.04343663237172715 0.18452860531678966; … ; 0.0 0.008086425833789466 … -0.025520812462631465 0.1612415796308012; 0.0 -0.12264846253365731 … -0.07384019130048343 0.17262190728489224;;; 0.0 -0.03664858006607563 … 0.0067944616781861365 0.338624461155973; 0.0 -0.1073789503209682 … -0.029642765491720922 0.19165667155122298; … ; 0.0 0.043887021217047927 … -0.03532031809739464 0.17413726452088615; 0.0 -0.1643751390334616 … -0.010822072367220475 0.18541630144658308;;; 0.0 -0.08211729186350054 … -0.08333707459658027 0.17415795145027568; 0.0 -0.13250855065322767 … -0.08673313781096505 0.187742906364859; … ; 0.0 -0.10128227451428869 … -0.03748007560750125 0.19121942907428163; 0.0 -0.13955836192391025 … -0.07785061758422016 0.16895129102317735], [-6445.598553588707; -4656.228890248507; … ; -4456.902783934122; -4505.806270733834;;; -4920.580097790624; -4651.149283501899; … ; -4485.579809921432; -4486.097395433786;;; -4738.516081862697; -4563.873634836814; … ; -4488.181661060116; -4498.276381449872], ExtendedRtIrtModeling.InputPara(Float64[], [-2.3178527540742926, -0.8727691300728337, -1.1270941644815011, -1.314220325940113, -1.312310125131537, -2.1240213345575376, -1.536219741784194, -0.8795771064111, -1.4058283159119116, -1.0523714562500226  …  -0.5537072915566369, -0.546197426858273, -0.29753429086726474, -0.7788845545983953, -0.4288798781746426, -0.6379621032854847, -0.8723359959589986, -0.7208395955141799, -0.361997792920653, -0.8277817235912058], [1.3646887304206927, 1.6249134397666332, 1.8934917297683258, 2.3652619116146667, 1.18944805219959, 1.6927963067386411, 1.9296843928969347, 0.8667577372850178, 1.3957341191353294, 1.6386217111971437], [-0.44883650701461625, -0.9009311334699093, 0.006551607624680888, -0.031151287825124063, -0.17518461393355453, -0.6986473086575202, -1.6871943987780424, -1.1352908353580398, -0.669812431184789, 0.04696243181135186], [0.509589166741046, 0.1857693357346427, -0.07550905171544396, 0.40371837798105975, 0.2002234493228274, 0.8028492233370474, 0.48629288082779365, 0.6280950508585535, 0.22958288133607635, -0.023509851785120262  …  -0.6163152317061098, -0.29266789451650377, -0.14583684556223742, -0.4492481178106896, -0.03887259744200821, -0.5674806365619091, -0.012016840151132151, 0.2897716967247682, -0.18971397270938126, -0.2222280311361607], [3.3110772418218453, 3.886891015780442, 4.585028345763602, 3.826681898387007, 3.035741278162338, 3.2494618858904034, 2.989106232465927, 3.7133118321634933, 2.871836307215324, 3.744248102212496], [0.37849522314915657, 0.3038684647893873, 0.2969197289574867, 0.3476434750321475, 0.3346892263551741, 0.48005082463379584, 0.26467319279133117, 0.294736952213553, 0.2975538551713775, 0.25231757824913936], Float64[], [0.0, -0.06626064690505433, 0.5352570881253667, 0.20818335593211268, -0.007044876853338413, 0.0, 0.19162663035539299, 0.0034722578078704674, -0.0358442425489261, -0.02106863957469503], Float64[], [1.0021210968899932, -0.04248597908967541, -0.04248597908967541, 0.17550175200038612])))
Code
ex$coef(MCMC)
>> Results for ExtendedRtIrtModeling.GibbsRtIrt.
1) Item Parameters.
β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Item β”‚       a β”‚       b β”‚       Ξ» β”‚     σ²t β”‚
β”‚ Int64 β”‚ Float64 β”‚ Float64 β”‚ Float64 β”‚ Float64 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     1 β”‚   1.365 β”‚  -0.449 β”‚   3.311 β”‚   0.378 β”‚
β”‚     2 β”‚   1.625 β”‚  -0.901 β”‚   3.887 β”‚   0.304 β”‚
β”‚     3 β”‚   1.893 β”‚   0.007 β”‚   4.585 β”‚   0.297 β”‚
β”‚     4 β”‚   2.365 β”‚  -0.031 β”‚   3.827 β”‚   0.348 β”‚
β”‚     5 β”‚   1.189 β”‚  -0.175 β”‚   3.036 β”‚   0.335 β”‚
β”‚     6 β”‚   1.693 β”‚  -0.699 β”‚   3.249 β”‚   0.480 β”‚
β”‚     7 β”‚   1.930 β”‚  -1.687 β”‚   2.989 β”‚   0.265 β”‚
β”‚     8 β”‚   0.867 β”‚  -1.135 β”‚   3.713 β”‚   0.295 β”‚
β”‚     9 β”‚   1.396 β”‚  -0.670 β”‚   2.872 β”‚   0.298 β”‚
β”‚    10 β”‚   1.639 β”‚   0.047 β”‚   3.744 β”‚   0.252 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2) Covariance of Person Parameters.
β”Œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Coef β”‚      ΞΈ β”‚      ΞΆ β”‚
β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    ΞΈ β”‚  1.002 β”‚ -0.042 β”‚
β”‚    ΞΆ β”‚ -0.042 β”‚  0.176 β”‚
β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
3) Regression Coefficients.
β”Œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Coef β”‚      ΞΈ β”‚      ΞΆ β”‚
β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Ξ²0 β”‚  0.000 β”‚  0.000 β”‚
β”‚   Ξ²1 β”‚ -0.066 β”‚  0.192 β”‚
β”‚   Ξ²2 β”‚  0.535 β”‚  0.003 β”‚
β”‚   Ξ²3 β”‚  0.208 β”‚ -0.036 β”‚
β”‚   Ξ²4 β”‚ -0.007 β”‚ -0.021 β”‚
β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
4) Criterion.
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Deviance β”‚      DIC β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 8960.496 β”‚ 9606.992 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Code
ex$precis(MCMC)
>> Results for ExtendedRtIrtModeling.GibbsRtIrt.
1) Item Response Model.
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ parameters β”‚    mean β”‚     std β”‚      ess β”‚    rhat β”‚     q05 β”‚     q95 β”‚    Sig β”‚
β”‚     Symbol β”‚ Float64 β”‚ Float64 β”‚  Float64 β”‚ Float64 β”‚ Float64 β”‚ Float64 β”‚ String β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         a1 β”‚   1.365 β”‚   0.206 β”‚ 2342.603 β”‚   1.002 β”‚   1.035 β”‚   1.722 β”‚      * β”‚
β”‚         a2 β”‚   1.625 β”‚   0.280 β”‚ 1002.293 β”‚   0.999 β”‚   1.217 β”‚   2.111 β”‚      * β”‚
β”‚         a3 β”‚   1.893 β”‚   0.285 β”‚ 1781.794 β”‚   1.000 β”‚   1.445 β”‚   2.378 β”‚      * β”‚
β”‚         a4 β”‚   2.365 β”‚   0.409 β”‚  667.978 β”‚   1.004 β”‚   1.789 β”‚   3.120 β”‚      * β”‚
β”‚         a5 β”‚   1.189 β”‚   0.188 β”‚ 2477.290 β”‚   1.000 β”‚   0.891 β”‚   1.499 β”‚      * β”‚
β”‚         a6 β”‚   1.693 β”‚   0.288 β”‚ 1083.316 β”‚   1.003 β”‚   1.274 β”‚   2.226 β”‚      * β”‚
β”‚         a7 β”‚   1.930 β”‚   0.415 β”‚  437.238 β”‚   1.000 β”‚   1.318 β”‚   2.666 β”‚      * β”‚
β”‚         a8 β”‚   0.867 β”‚   0.166 β”‚ 2222.551 β”‚   0.999 β”‚   0.606 β”‚   1.158 β”‚      * β”‚
β”‚         a9 β”‚   1.396 β”‚   0.231 β”‚ 1552.240 β”‚   1.000 β”‚   1.053 β”‚   1.803 β”‚      * β”‚
β”‚        a10 β”‚   1.639 β”‚   0.246 β”‚ 1767.400 β”‚   1.003 β”‚   1.253 β”‚   2.063 β”‚      * β”‚
β”‚         b1 β”‚  -0.449 β”‚   0.126 β”‚ 2041.894 β”‚   1.000 β”‚  -0.656 β”‚  -0.249 β”‚      * β”‚
β”‚         b2 β”‚  -0.901 β”‚   0.133 β”‚ 1252.257 β”‚   1.000 β”‚  -1.129 β”‚  -0.694 β”‚      * β”‚
β”‚         b3 β”‚   0.007 β”‚   0.105 β”‚ 1805.927 β”‚   0.999 β”‚  -0.165 β”‚   0.184 β”‚        β”‚
β”‚         b4 β”‚  -0.031 β”‚   0.098 β”‚ 1509.874 β”‚   1.000 β”‚  -0.192 β”‚   0.131 β”‚        β”‚
β”‚         b5 β”‚  -0.175 β”‚   0.131 β”‚ 2126.633 β”‚   1.000 β”‚  -0.394 β”‚   0.035 β”‚        β”‚
β”‚         b6 β”‚  -0.699 β”‚   0.120 β”‚ 1534.142 β”‚   1.000 β”‚  -0.901 β”‚  -0.510 β”‚      * β”‚
β”‚         b7 β”‚  -1.687 β”‚   0.204 β”‚  572.695 β”‚   1.000 β”‚  -2.031 β”‚  -1.393 β”‚      * β”‚
β”‚         b8 β”‚  -1.135 β”‚   0.234 β”‚ 2535.208 β”‚   0.999 β”‚  -1.546 β”‚  -0.808 β”‚      * β”‚
β”‚         b9 β”‚  -0.670 β”‚   0.131 β”‚ 1621.498 β”‚   1.002 β”‚  -0.892 β”‚  -0.458 β”‚      * β”‚
β”‚        b10 β”‚   0.047 β”‚   0.113 β”‚ 1964.482 β”‚   1.001 β”‚  -0.135 β”‚   0.232 β”‚        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2) Response Time Model.
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ parameters β”‚    mean β”‚     std β”‚      ess β”‚    rhat β”‚     q05 β”‚     q95 β”‚    Sig β”‚
β”‚     Symbol β”‚ Float64 β”‚ Float64 β”‚  Float64 β”‚ Float64 β”‚ Float64 β”‚ Float64 β”‚ String β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         Ξ»1 β”‚   3.311 β”‚   0.043 β”‚ 2245.581 β”‚   1.000 β”‚   3.241 β”‚   3.383 β”‚      * β”‚
β”‚         Ξ»2 β”‚   3.887 β”‚   0.039 β”‚ 2229.885 β”‚   1.001 β”‚   3.821 β”‚   3.950 β”‚      * β”‚
β”‚         Ξ»3 β”‚   4.585 β”‚   0.040 β”‚ 2065.252 β”‚   1.001 β”‚   4.518 β”‚   4.649 β”‚      * β”‚
β”‚         Ξ»4 β”‚   3.827 β”‚   0.042 β”‚ 2276.559 β”‚   1.001 β”‚   3.757 β”‚   3.895 β”‚      * β”‚
β”‚         Ξ»5 β”‚   3.036 β”‚   0.042 β”‚ 2077.418 β”‚   1.002 β”‚   2.966 β”‚   3.106 β”‚      * β”‚
β”‚         Ξ»6 β”‚   3.249 β”‚   0.047 β”‚ 2262.640 β”‚   1.000 β”‚   3.173 β”‚   3.327 β”‚      * β”‚
β”‚         Ξ»7 β”‚   2.989 β”‚   0.038 β”‚ 2005.202 β”‚   1.001 β”‚   2.926 β”‚   3.051 β”‚      * β”‚
β”‚         Ξ»8 β”‚   3.713 β”‚   0.039 β”‚ 2132.332 β”‚   1.000 β”‚   3.648 β”‚   3.777 β”‚      * β”‚
β”‚         Ξ»9 β”‚   2.872 β”‚   0.040 β”‚ 2067.979 β”‚   1.000 β”‚   2.806 β”‚   2.936 β”‚      * β”‚
β”‚        Ξ»10 β”‚   3.744 β”‚   0.037 β”‚ 1937.055 β”‚   1.001 β”‚   3.685 β”‚   3.806 β”‚      * β”‚
β”‚       σ²t1 β”‚   0.378 β”‚   0.033 β”‚ 4312.348 β”‚   1.000 β”‚   0.326 β”‚   0.437 β”‚      * β”‚
β”‚       σ²t2 β”‚   0.304 β”‚   0.027 β”‚ 4453.444 β”‚   1.000 β”‚   0.261 β”‚   0.352 β”‚      * β”‚
β”‚       σ²t3 β”‚   0.297 β”‚   0.027 β”‚ 4489.086 β”‚   1.000 β”‚   0.255 β”‚   0.345 β”‚      * β”‚
β”‚       σ²t4 β”‚   0.348 β”‚   0.031 β”‚ 4547.821 β”‚   1.000 β”‚   0.299 β”‚   0.403 β”‚      * β”‚
β”‚       σ²t5 β”‚   0.335 β”‚   0.030 β”‚ 4006.528 β”‚   1.000 β”‚   0.288 β”‚   0.386 β”‚      * β”‚
β”‚       σ²t6 β”‚   0.480 β”‚   0.042 β”‚ 4358.406 β”‚   1.001 β”‚   0.416 β”‚   0.552 β”‚      * β”‚
β”‚       σ²t7 β”‚   0.265 β”‚   0.024 β”‚ 4278.401 β”‚   1.000 β”‚   0.227 β”‚   0.306 β”‚      * β”‚
β”‚       σ²t8 β”‚   0.295 β”‚   0.027 β”‚ 4373.160 β”‚   1.000 β”‚   0.253 β”‚   0.342 β”‚      * β”‚
β”‚       σ²t9 β”‚   0.298 β”‚   0.026 β”‚ 4630.517 β”‚   1.000 β”‚   0.257 β”‚   0.344 β”‚      * β”‚
β”‚      σ²t10 β”‚   0.252 β”‚   0.023 β”‚ 4613.353 β”‚   1.000 β”‚   0.216 β”‚   0.292 β”‚      * β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
3) Structural Model.
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ parameters β”‚    mean β”‚     std β”‚      ess β”‚    rhat β”‚     q05 β”‚     q95 β”‚    Sig β”‚
β”‚     Symbol β”‚ Float64 β”‚ Float64 β”‚  Float64 β”‚ Float64 β”‚ Float64 β”‚ Float64 β”‚ String β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     Ξ²[0,1] β”‚   0.000 β”‚   0.000 β”‚      NaN β”‚     NaN β”‚   0.000 β”‚   0.000 β”‚      * β”‚
β”‚     Ξ²[1,1] β”‚  -0.066 β”‚   0.066 β”‚ 3169.522 β”‚   1.000 β”‚  -0.176 β”‚   0.039 β”‚        β”‚
β”‚     Ξ²[2,1] β”‚   0.535 β”‚   0.041 β”‚ 1605.987 β”‚   1.000 β”‚   0.470 β”‚   0.604 β”‚      * β”‚
β”‚     Ξ²[3,1] β”‚   0.208 β”‚   0.035 β”‚ 2846.589 β”‚   1.000 β”‚   0.153 β”‚   0.267 β”‚      * β”‚
β”‚     Ξ²[4,1] β”‚  -0.007 β”‚   0.031 β”‚ 3443.779 β”‚   1.001 β”‚  -0.058 β”‚   0.043 β”‚        β”‚
β”‚     Ξ²[0,2] β”‚   0.000 β”‚   0.000 β”‚      NaN β”‚     NaN β”‚   0.000 β”‚   0.000 β”‚      * β”‚
β”‚     Ξ²[1,2] β”‚   0.192 β”‚   0.020 β”‚ 4490.908 β”‚   1.000 β”‚   0.159 β”‚   0.224 β”‚      * β”‚
β”‚     Ξ²[2,2] β”‚   0.003 β”‚   0.010 β”‚ 3946.057 β”‚   1.000 β”‚  -0.013 β”‚   0.019 β”‚        β”‚
β”‚     Ξ²[3,2] β”‚  -0.036 β”‚   0.010 β”‚ 4445.270 β”‚   1.000 β”‚  -0.052 β”‚  -0.020 β”‚      * β”‚
β”‚     Ξ²[4,2] β”‚  -0.021 β”‚   0.010 β”‚ 4444.982 β”‚   0.999 β”‚  -0.037 β”‚  -0.005 β”‚      * β”‚
β”‚     Ξ£[1,1] β”‚   1.002 β”‚   0.115 β”‚ 2450.285 β”‚   1.000 β”‚   0.827 β”‚   1.206 β”‚      * β”‚
β”‚     Ξ£[1,2] β”‚  -0.042 β”‚   0.029 β”‚ 4313.151 β”‚   1.000 β”‚  -0.089 β”‚   0.005 β”‚        β”‚
β”‚     Ξ£[2,1] β”‚  -0.042 β”‚   0.029 β”‚ 4313.151 β”‚   1.000 β”‚  -0.089 β”‚   0.005 β”‚        β”‚
β”‚     Ξ£[2,2] β”‚   0.176 β”‚   0.017 β”‚ 4028.813 β”‚   1.000 β”‚   0.150 β”‚   0.204 β”‚      * β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜

If you want to use the MCMC class data in R, you can use the juliaGet function to convert Julia’s objects to R’s. But it’ll take a loooooot of time.

Code
time <- Sys.time()
MCMC4R <- juliaGet(MCMC)
Sys.time() - time
Time difference of 2.703941 mins
Code
ls(MCMC4R)
[1] "Cond"     "Data"     "Para"     "Post"     "truePara"
Code
ls(MCMC4R$Post$mean)
 [1] "a"   "b"   "Ξ²"   "ΞΆ"   "ΞΈ"   "Ξ»"   "Ξ½"   "ρ"   "σ²t" "Ξ£p"  "Ο‰"  
Code
MCMC4R$Post$ra[,311,] |> 
  as.data.frame() |>
  pivot_longer(cols = everything(), names_to = "variable", values_to = "value") %>%
  ggplot(aes(x = 1:nrow(.), y = value, color = variable, group = variable)) +
  geom_line() +
  labs(x = "Index", y = "Value", title = "b1 MCMC chains")

Lastly, let’s check out this package.

Code
## See the objects in ex.
ls(ex)
 [1] "coef"                          "drawItemDifficulty"           
 [3] "drawItemDiscrimination"        "drawItemIntensity"            
 [5] "drawItemIntensityCross"        "drawItemIntensityCrossQr"     
 [7] "drawItemTimeResidual"          "drawItemTimeResidualCross"    
 [9] "drawItemTimeResidualCrossQr"   "drawQrWeightsCrossQr"         
[11] "drawQrWeightsLatentQr"         "drawRaPgRandomVariable"       
[13] "drawSubjAbility"               "drawSubjAbilityNull"          
[15] "drawSubjCoefficients"          "drawSubjCorrCross"            
[17] "drawSubjCorrCrossQr"           "drawSubjCovariance"           
[19] "drawSubjCovariance2One"        "drawSubjCovarianceLatent"     
[21] "drawSubjCovarianceLatentQr"    "drawSubjCovarianceNull"       
[23] "drawSubjCovarianceNull2One"    "drawSubjSpeed"                
[25] "drawSubjSpeedCross"            "drawSubjSpeedCrossQr"         
[27] "drawSubjSpeedLatent"           "drawSubjSpeedLatentQr"        
[29] "drawSubjSpeedNull"             "eval"                         
[31] "evaluate"                      "getBias"                      
[33] "getDic"                        "getLogLikelihoodMlIrt"        
[35] "getLogLikelihoodRtIrt"         "getLogLikelihoodRtIrtCross"   
[37] "getLogLikelihoodRtIrtCrossQr"  "getLogLikelihoodRtIrtLatent"  
[39] "getLogLikelihoodRtIrtLatentQr" "getLogLikelihoodRtIrtNull"    
[41] "getPrecisTable"                "getRmse"                      
[43] "getSubjCoefficients"           "getSubjCoefficientsLatent"    
[45] "getSubjCoefficientsLatentQr"   "getSubjCoefficientsMlIrt"     
[47] "GibbsMlIrt"                    "GibbsRtIrt"                   
[49] "GibbsRtIrt2"                   "GibbsRtIrtCross"              
[51] "GibbsRtIrtCross2"              "GibbsRtIrtCrossQr"            
[53] "GibbsRtIrtLatent"              "GibbsRtIrtLatent2"            
[55] "GibbsRtIrtLatentQr"            "GibbsRtIrtNull"               
[57] "include"                       "InputData"                    
[59] "InputData4R"                   "InputPara"                    
[61] "OutputDic"                     "OutputPost"                   
[63] "OutputPostCross"               "OutputPostCrossQr"            
[65] "OutputPostMlIrt"               "OutputPostRtIrtLatent"        
[67] "OutputPostRtIrtLatentQr"       "precis"                       
[69] "sample!"                       "setCond"                      
[71] "setTrueParaRtIrt"              "SimConditions"                
[73] "SimEvaluation"                

Citation

BibTeX citation:
@online{tsai2024,
  author = {Tsai, JW},
  title = {Introduction to {`ExtendedRtIrtModeling.jl`} Through
    {`JuliaConnectoR`}},
  date = {2024-11-19},
  langid = {en}
}
For attribution, please cite this work as:
Tsai, J. (2024, November 19). Introduction to `ExtendedRtIrtModeling.jl` through `JuliaConnectoR`.