The paper introduces the piecewise structural equation modeling (SEM) approach, a method that extends traditional SEM to handle complex, multifaceted datasets in ecology and evolutionary biology. The author presents the `piecewiseSEM` R package, which facilitates the implementation of piecewise SEM, allowing for the incorporation of hierarchical structures and phylogenetic contrasts. Two examples are provided to illustrate the application of piecewise SEM: one on the impact of storm frequency on kelp forest food webs and another on the relationship between eusociality and ecological success in sponge-dwelling shrimp. The results show that acknowledging the non-independence of data points and incorporating phylogenetic contrasts can lead to different inferences compared to traditional SEM. The paper also discusses the limitations of piecewise SEM, such as the inability to handle cyclic relationships and reciprocal relationships, and suggests future developments to address these limitations.The paper introduces the piecewise structural equation modeling (SEM) approach, a method that extends traditional SEM to handle complex, multifaceted datasets in ecology and evolutionary biology. The author presents the `piecewiseSEM` R package, which facilitates the implementation of piecewise SEM, allowing for the incorporation of hierarchical structures and phylogenetic contrasts. Two examples are provided to illustrate the application of piecewise SEM: one on the impact of storm frequency on kelp forest food webs and another on the relationship between eusociality and ecological success in sponge-dwelling shrimp. The results show that acknowledging the non-independence of data points and incorporating phylogenetic contrasts can lead to different inferences compared to traditional SEM. The paper also discusses the limitations of piecewise SEM, such as the inability to handle cyclic relationships and reciprocal relationships, and suggests future developments to address these limitations.