Comments (5)
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.
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.
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.
Will use this branch:
https://github.com/sfcheung/semptools/tree/cfa_sem
from semptools.
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)
- Add support for 2nd order factors in `set_sem_layout()` HOT 1
- `set_sem_layout()`: Add an argument to shift the indicators to left/right or up/down
- `factor_point_to`: Use named vector to set the argument HOT 1
- `set_cfa_layout()`: Cannot handle a CFA plot with no factor covariances HOT 1
- `set_curve()`: Bug fix: Failed to work for some bidirecational edges
- Updat r-lib GitHub actions HOT 1
- `set_cfa_layout()`: Add support for models with factor covariances fixed to zero HOT 2
- Update the help page of `set_sem_layout()` on manifest vars and 2nd-order factors HOT 1
- When setting curve, positive means outward and negative means inward
- Check the documentation of all functions in v0.2.9 HOT 1
- Finalize the release of v0.2.9
- Models with intercepts are not yet supported
- Update the vignettes to use native forward pipe operator `|>` instead of `%>%` in `magrittr`
- Update `change_node_label` to allow changing options related to drawing the labels
- Update `change_node_label` to use named vectors
- Update quick_start_cfa.Rmd
- Update quick_start_sem.Rmd.
- Helper functions to make it easier to assign indicators to factors and set the orders of indicators HOT 1
- Allow `drop_nodes()` work with output from `lavaan::lavaanify()` without covariance input HOT 1
- Missing support for SEM models with single manifest (non-indicator) variables. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semptools.