# Hierarchical partitioning using the “glmm.hp” package in R version 4.4.0 # Analyze the relative importance of different variables for the yield of Ophiopogon japonicus library(glmm.hp) mydata <- read.csv("maidong_hp1.csv") head(mydata) m1 <- lm(yield~PR+SA+APA+UA+MYSH,mydata) m2 <- glmm.hp(m1) m2 # Analyze the relative importance of different variables for the drying rate of Ophiopogon japonicus library(glmm.hp) mydata <- read.csv("maidong_hp2.csv") head(mydata) m1 <- lm(DR ~PR+SA+APA+UA+MYSH,mydata) m2 <- glmm.hp(m1) m2 # Partial least squares path modeling using the “plspm” package in R version 4.4.0 # Analyze the mechanisms underlying the interactions of different variables for the yield of Ophiopogon japonicus library(plspm) library(igraph) f.tx <- list( yield ~ PR + SA + MYSH, SA ~ PR + MYSH, PR ~ MYSH ) edge.mat <- do.call( rbind, lapply( f.tx, function(i) { from <- all.vars(i)[-1] to <- all.vars(i)[1] cbind(from, to) } ) ) dag <- graph_from_edgelist( edge.mat, directed = TRUE ) par(mar = c(0, 0, 0, 0), family = "Source Sans Pro", cex = 1) igraph::plot.igraph( dag, layout = layout_in_circle, vertex.size = 20, vertex.color = "grey100", vertex.label.color = "green4", vertex.label.family = "Source Sans Pro", edge.color = "grey0", edge.arrow.mode = 2, # 2 is for forward arrows edge.arrow.size = 1, edge.arrow.width = 1 ) adj.mat0 <- as_adjacency_matrix( dag, type = "lower", sparse = FALSE ) adj.mat0 g.tp <- igraph::topo_sort(dag)$name g.tp rd <- match(g.tp, rownames(adj.mat0)) cd <- match(g.tp, colnames(adj.mat0)) adj.mat1 <- t(adj.mat0[rd, cd]) adj.mat1 MYSH = c(0,0,0,0) PR = c(1,0,0,0) SA = c(1,1,0,0) yield = c(1,1,1,0) foot_path = rbind(MYSH,PR,SA,yield) colnames(foot_path) = rownames(foot_path) foot_path adj.mat1 == foot_path innerplot(foot_path) foot_blocks=list(7,3,4,1) foot_mod=rep("A",4) mydata <- read.csv("maidong_plspm1.csv") head(mydata) foot_pls=plspm(mydata,foot_path,foot_blocks, scheme = "centroid",modes = foot_mod, plscomp = c(1,1,1,1),tol = 0.0000001) innerplot(foot_pls, colpos = 'red', colneg = 'blue', show.values = TRUE, lcol = 'gray20', box.lwd = 0) outerplot(foot_pls, what = 'loadings', arr.width = 0.1, colpos = 'red', colneg = 'blue', show.values = TRUE, lcol = 'black') summary(foot_pls) # Analyze the mechanisms underlying the interactions of different variables for the drying rate of Ophiopogon japonicus library(plspm) library(igraph) f.tx <- list( DR ~ PR + APA + MYSH, APA ~ PR + MYSH, PR ~ MYSH ) edge.mat <- do.call( rbind, lapply( f.tx, function(i) { from <- all.vars(i)[-1] to <- all.vars(i)[1] cbind(from, to) } ) ) dag <- graph_from_edgelist( edge.mat, directed = TRUE ) par(mar = c(0, 0, 0, 0), family = "Source Sans Pro", cex = 1) igraph::plot.igraph( dag, layout = layout_in_circle, vertex.size = 20, vertex.color = "grey100", vertex.label.color = "green4", vertex.label.family = "Source Sans Pro", edge.color = "grey0", edge.arrow.mode = 2, # 2 is for forward arrows edge.arrow.size = 1, edge.arrow.width = 1 ) adj.mat0 <- as_adjacency_matrix( dag, type = "lower", sparse = FALSE ) adj.mat0 g.tp <- igraph::topo_sort(dag)$name g.tp rd <- match(g.tp, rownames(adj.mat0)) cd <- match(g.tp, colnames(adj.mat0)) adj.mat1 <- t(adj.mat0[rd, cd]) adj.mat1 MYSH = c(0,0,0,0) PR = c(1,0,0,0) APA = c(1,1,0,0) DR = c(1,1,1,0) foot_path = rbind(MYSH,PR,APA,DR) colnames(foot_path) = rownames(foot_path) foot_path adj.mat1 == foot_path innerplot(foot_path) foot_blocks=list(7,3,4,1) foot_mod=rep("A",4) mydata <- read.csv("maidong_plspm2.csv") head(mydata) foot_pls=plspm(mydata,foot_path,foot_blocks, scheme = "centroid",modes = foot_mod, plscomp = c(1,1,1,1),tol = 0.0000001) innerplot(foot_pls, colpos = 'red', colneg = 'blue', show.values = TRUE, lcol = 'gray20', box.lwd = 0) outerplot(foot_pls, what = 'loadings', arr.width = 0.1, colpos = 'red', colneg = 'blue', show.values = TRUE, lcol = 'black') summary(foot_pls)