haziqj / lavaan

an R package for structural equation modeling and more
http://lavaan.org
0 stars 0 forks source link

Understanding `{lavaan}` internals #2

Open haziqj opened 1 month ago

haziqj commented 1 month ago

Hi @giuseppealfonzetti. Sorry for the radio silence. I am currently travelling so not able to look at our project just yet.

However I wanted to share with you some broad ideas on what needs to be done. To understand better I share with you this R script by Yves: https://github.com/yrosseel/lavaan/blob/master/inst/understanding_lavaan_internals.R It's a little outdated but in principle I think it's still the same. When lavaan is called it goes through a series of steps, and the steps are often conditional on the estimation method.

Our job essentially is to create a new estimator = "SPML" (which stands for stochastic pairwise max likelihood), and then replace the necessary functions with functions you created in the {plFA} package.

Importantly Yves requests that {lavaan} contain no C/C++ code (at least for now), which means that the {plFA} will have to coexist with {lavaan}. Might require some tinkering at the plFA side to get things working smoothly too.

Anyway I will pick this up closer to July, when I can afford to dedicate time to this. If you have any questions in the mean time feel free to ask.

Haziq

giuseppealfonzetti commented 1 month ago

Hi @haziqj! No worries. Thank you for the update, I'll take a look at Yves' script.

Thus, the idea is to let the C++ code be fully contained in {plFA}, which should export some wrapper functions directly callable in {lavaan}. Did I understand correctly?

Sure, no rush on my side. It's a busy period for me, too, but I'll start looking into it.

Best, Giuseppe

haziqj commented 1 month ago

Thus, the idea is to let the C++ code be fully contained in {plFA}, which should export some wrapper functions directly callable in {lavaan}. Did I understand correctly?

Yes, correct. In a sense we are creating a plugin for lavaan. At the top of my head, it could be as follows:

  1. User calls "estimator = SPLA"
  2. Check whether plFA is installed
  3. If not, then stop
  4. If yes then proceed estimation using plFA routines
  5. Return back output that lavaan understands for print/summary/etc methods
giuseppealfonzetti commented 1 month ago

Ok, I see. It sounds good. Surely it requires some tinkering on the {plFA} side, but it should be feasible.

I'll pick it up in the next weeks.

Have a nice weekend :)