Lavaan’s output is copious. Especially when fitting a complex model, lavaan’s output is literally a mine of information. Finding what is relevant is not always easy, therefore I will try to describe a way to summarize lavaan’s summary output. Continue reading “Multiple mediation: extracting output”

# R

# Plotting multiple mediation

This posts on multiple mediation on lavaan supplements the two previous ones (1 – introducing multiple mediator analysis with lavaan and 2 – showing an example analysis) by describing how to process lavaan’s output graphically. I discovered the handy package semPlot and I am very positive about it. I will make the example as reproducible as possible, so that each step can be repeated. Also, I am going to try to provide more explanation about the R commands I used because a friend pointed out that the description of the steps was sometimes a bit dry and abstract.

Continue reading “Plotting multiple mediation”

# Multiple-mediation example with lavaan

This post extends this previous one on multiple-mediation with lavaan. Here I modeled a ‘real’ dataset instead of a randomly generated one. This dataset we used previously for a paper published some time ago. There we investigated whether fear of an imperfect fat self was a stronger mediator than hope of a perfect thin self on dietary restraint in college women. At the time of the paper’s publication we performed the analysis using the SPSS macro INDIRECT . However,

Continue reading “Multiple-mediation example with lavaan”

# Multiple-mediator analysis with lavaan

I wrote this brief introductory post for my friend Simon. I want to show how easy the transition from SPSS to R can be. In the specific case of mediation analysis the transition to R can be very smooth because, thanks to lavaan, the R knowledge required to use the package is minimal. Analysis of mediator effects in lavaan requires only the specification of the model, all the other processes are automated by the package. So, after reading in the data, running the test is trivial.

Continue reading “Multiple-mediator analysis with lavaan”

# Streamgraphs in base::R [e.II]

Until recently I did not have a practical application in which to use streamgraphs. In fact, I still find the visualisation complex to understand, abstract and a bit too artistic. While I recognise that the strength of streamgraphs is the display of all the time seriesâ€™ values into one (possibly interactive) plot, the amount of data displayed is massive, with many streams and even more data points. Because of the amount of data displayed Continue reading “Streamgraphs in base::R [e.II]”

# Streamgraphs in base::R [e.I]

This is a very simple script plotting a streamgraphs in R. I wanted to be able to plot a streamgraph in base R, without requiring additional libraries. For example, here I made an interactive streamgraph visualization depicting temperatures measured worldwide in the last 150 years.

Continue reading “Streamgraphs in base::R [e.I]”

# Color-coded parallel coordinates in R

Parallel coordinates can be very helpful in understanding relationships among more than two variables. The first time I encountered parallel coordinates I did not understand their potential, until I saw Alberto Cairo’s slopegraph. In that slopegraph Cairo color-coded the Continue reading “Color-coded parallel coordinates in R”