item factor analysis performance issues across R versions
cffalk2
Joined: 10/06/2025
I'll try to describe the problem briefly. Can try to provide reprex if this sounds novel.
I have some code based on this paper (https://doi.org/10.1007/s11136-021-02873-7) that fits item factor analysis models. With version R 3.6.2, OpenMx 2.17.2, Windows 10, the models were quick to estimate (e.g., 3 seconds). I can still run them in that environment. I recently revisited the code with R 4.5.1, OpenMx 2.22.10 on the same hardware and estimation is painfully slow (e.g., almost 4 minutes).
Wondering if anyone can point me in the right direction for figuring out why and/or if there are any known performance issues. Going back to older R versions on the same machine, this seems to be an issue with anything R 4.0 (e.g., 4.0.5) and later. I see something in release notes for OpenMx versions (e.g., 2.18) around that time about CSOLNP no longer being the default optimizer in part due to performance issues (changing the optimizer in this case does not seem to make a difference). I also understand that it might be that many on the development team are not using Windows. Though, if I install Ubuntu in a virtual machine and go with the latest R and OpenMx version, I seem to encounter the same performance issues.
Any advice is greatly appreciated. Understand if you folks would ask for more info.
Looks like an R issue, Pls send example
Hi Carl
Sorry to be so late responding! Can you please send a reproducible example?
It seems like this is a problem with R 4.x. The optimizers are running in the C++ backend so should not be affected by the R change. Possibly memory management by R has changed in a bad way. We will investigate.
Log in or register to post comments
In reply to Looks like an R issue, Pls send example by AdminNeale
Thank you, Mike, sorry I'm…
Thank you, Mike, sorry I'm slow to reply now.
I am attempting to attach an RMarkdown's pdf output (.rmd is not allows for attachments?). This is for the new-ish version of R (4.5.2) and OpenMx (2.22.10).
I was going to then also run this under the older environment, but it turns out I would need to jump through hoops to install rmarkdown. So... I'll paste code and relevant part of the output below. Note this is with R 3.6.2 and OpenMx 2.17.2.
There is a tiny bit of benchmarking in here. Under the newer version, it's something like 12 seconds on average to fit some models. Under the older version, microbenchmark switches to milliseconds because it's only something like 0.56 seconds per model on average.
Thank you for taking a look!
All of the code:
And some of the relevant output:
Log in or register to post comments
In reply to Thank you, Mike, sorry I'm… by cffalk2
I am attempting to attach an…
Sorry about that. We should tweak the set of allowable file extensions for attachments. Although, I bet it would work if you changed the extension from '.rmd' to '.txt' or '.rmd.txt'.
I have not actually run your script yet, but I did look through all the release announcements for OpenMx versions 2.17.2 to 2.22.10, and I did not see anything that might explain the performance regression. Sorry! I might have some ideas later, once I grok what your code does.
Log in or register to post comments