Coder Social home page Coder Social logo

Comments (5)

sfcheung avatar sfcheung commented on August 25, 2024

Just found out that qgraph already support using labels to specify the matrix for layout:

http://sachaepskamp.com/qgraph/features/1.2.2#Grid_layout

Therefore, no need to write a function for this if the model is a path model that does not have a lot of variables. However, it would still be useful to write a function to easily specify the position of a CFA or SEM model with a lot of indicators.

from semptools.

sfcheung avatar sfcheung commented on August 25, 2024

I am still thinking about how to implement this.

The target users are those willing to use code to generate easily reproducible SEM diagrams. The target users are not those like drawing diagrams using programs like Amos and don't like to use code.

That said, being user friendly to this group of target users, in terms of writing or generating code, is still important.

Approach A:

Specify the latent variables layout as in path models.

layout = matrix(c("x1", NA, NA,
                    NA,"m","y",
                  "x2", NA, NA), byrow = TRUE, 3, 3))

Then just indicate the direction of the indicators for each latent, usually just "up", "right", "down", and "left," and the function will try to calculate the exact position. This will generate a typical SEM diagrams in psychology.

  • Pro:

    • Easy to specify.
  • Con:

    • The function can be a little bit complicate.

Approach B:

Use a shinyapp to specify the exact position. Start the app (call the function) with the semPath call and the data. The app will show the semPath call and the diagram, probably with sliders for each node. The users use the slider to specify the x- and y-positions of each node manually. The required layout, a k-by-2 matrix with the x- and y-positions for the nodes will be generated. Users can copy and paste it and use it as the value for the layout argument.

We can also add a few buttons to allow to automatically align the x or y position of selected nodes (e.g., make all indicators of a latent to have the same x-position).

  • Pros:

    • Full control of the layout.

    • The user can see immediately how semPath will position the nodes.

    • Easy to code because there is no need to compute the positions.

  • Con:

    • Maybe too complicated for some users.

Approach C:

Combing A and B. Use Approach A to generate the starting layout, and use Approach B to adjust the generated layout.

This is not really a third approach. If we decided to do both A and B, then C is subsequently available.

from semptools.

sfcheung avatar sfcheung commented on August 25, 2024

The functions for both CFA models and SEM models have been drafted. I will create a new branch and commit the functions soon.

from semptools.

sfcheung avatar sfcheung commented on August 25, 2024

Will use this branch:

https://github.com/sfcheung/semptools/tree/cfa_sem

from semptools.

sfcheung avatar sfcheung commented on August 25, 2024

set_cfa_position and set_sem_position have been added and tested. They have been merged to the devel and master branches, and the cfa_sem branch has been deleted. Vignettes will be written for them later.

from semptools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.