我想计算路径分析模型的直接影响和所有间接影响。路径图如下:
我不确定在[R]中使用的代码。有一些简单的间接效应和中介模型的例子,使用系数a,b等,然后使用:=符号。但我不确定如何在这个稍微复杂的模型中使用它。标准代码可以如下/。
#regression model
V3 ~ V1 + V2
V4 ~ V1 + V2 + V3
V5 ~ V4 + V5
我可以将系数附加到上面的自变量中。那我怎么写间接函数的代码呢?这里我们会对V1和V2产生V5的间接影响,但没有直接影响。这将如何编码?我是Lavaan。还有另一个套餐吗?真的很感激帮助。谢谢。
答案 0 :(得分:1)
唯一剩下的就是在变量前面设置标签。我将尝试向您展示一个更简单的例子。
加载包和样本数据集:
require(tidyverse)
require(lavaan) # for the path analysis
require(semPlot) # To plot the path analysis
#Loading the data set (swiss is part of the Base R datasets).
df <- swiss %>%
select(Fertility, Education, Infant.Mortality)
head(df)
Fertility Education Infant.Mortality
Courtelary 80.2 12 22.2
Delemont 83.1 9 22.2
Franches-Mnt 92.5 5 20.2
Moutier 85.8 7 20.3
Neuveville 76.9 15 20.6
Porrentruy 76.1 7 26.6
接下来,您需要定义模型。模型变量分为两部分:回归和中介。回归与~
形成,中间与:=
形成。请注意,对于回归中的每个变量,我都使用*
附加了标签。标签是用户任意的,几乎可以采用任何形式。例如,Infant.Mortality ~ FerMor*Fertility
我预测变量Infant.Mortality
和变量Fertility
,我给的标签是FerMor
。
接下来,我使用标签来创建中介。我为此示例创建了一个Path1 := FerMor * EDUMor * FerEDU
。 Path1
是我给中介路径的任意名称,FerMor * EDUMor * FerEDU
是我选择指定的中介路径。
我真的建议使用评论。随着变量和中介的数量变得越来越大,阅读脚本真的很难。
Model <-'
# Regression
Infant.Mortality ~ FerMor*Fertility
Infant.Mortality ~ EDUMor*Education
Education ~ FerEDU*Fertility
#Mediation
#Path 1 - Fertility -> Education -> Infant.Mortality
# Fertility -> Infant.Mortality
Path1 := FerMor * EDUMor * FerEDU
'
最后一步是运行模型:
set.seed(1989)
fit <- sem(
Model,
data = scale(df),
likelihood = "wishart",
missing = 'ML',
meanstructure = TRUE)
如果要运行引导程序,可以添加参数:meanstructure = TRUE, se = "bootstrap", bootstrap = 5000
。如果您来自SPSS / AMOS,请使用likelihood = "wishart"
获得相同的结果。
您可以使用semPaths()
semPaths(fit)
最后,要获得完整的模型估计(您可以在定义参数的输出结尾处找到中介),请使用函数summary()
。我建议添加参数fit.measures = TRUE, standardize = TRUE
。
summary(fit, fit.measures = TRUE, standardize = TRUE)
lavaan (0.5-23.1097) converged normally after 13 iterations
Number of observations 47
Number of missing patterns 1
Estimator ML
Minimum Function Test Statistic 0.000
Degrees of freedom 0
Minimum Function Value 0.0000000000000
Model test baseline model:
Minimum Function Test Statistic 38.734
Degrees of freedom 3
P-value 0.000
User model versus baseline model:
Comparative Fit Index (CFI) 1.000
Tucker-Lewis Index (TLI) 1.000
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -178.771
Loglikelihood unrestricted model (H1) -178.771
Number of free parameters 7
Akaike (AIC) 371.543
Bayesian (BIC) 384.343
Sample-size adjusted Bayesian (BIC) 362.395
Root Mean Square Error of Approximation:
RMSEA 0.000
90 Percent Confidence Interval 0.000 0.000
P-value RMSEA <= 0.05 NA
Standardized Root Mean Square Residual:
SRMR 0.000
Parameter Estimates:
Information Observed
Standard Errors Standard
Regressions:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
Infant.Mortality ~
Fertlty (FrMr) 0.627 0.173 3.623 0.000 0.627 0.627
Educatn (EDUM) 0.317 0.173 1.831 0.067 0.317 0.317
Education ~
Fertlty (FEDU) -0.664 0.110 -6.019 0.000 -0.664 -0.664
Intercepts:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.Infant.Mortlty -0.000 0.128 -0.000 1.000 -0.000 -0.000
.Education 0.000 0.109 0.000 1.000 0.000 0.000
Variances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.Infant.Mortlty 0.754 0.157 4.796 0.000 0.754 0.770
.Education 0.547 0.114 4.796 0.000 0.547 0.559
Defined Parameters:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
Path1 -0.132 0.102 -1.288 0.198 -0.132 -0.132
您可以访问here了解详情。
答案 1 :(得分:0)
有类似的问题。在lavaan中,您必须使用跟踪规则,Duncan规则或直接效应矩阵乘法来手动编写间接效应和总效应的语法(请参见《 Maruyama,结构方程模型基础》中的一般说明)。
您可以编写一些代码来生成该语法,这是我的尝试here和下面的摘要。它在r和python中使用符号矩阵库。希望您可以根据需要调整代码或构想。
首先,我将描述没有明确的间接或总体影响的测量和结构模型并运行它:
model.cfa <- "quality =~ Q068_1 + Q068_4
delivery =~ Q069_2 + Q069_5
flexibility =~ Q071_1 + Q071_4 + Q071_5
costs =~ Q070_1 + Q070_2 + Q070_3
innovation =~ Q072_1 + Q072_3 + Q072_2"
model.sem_1a <- paste(model.cfa, "
delivery ~ quality
flexibility ~ delivery
costs ~ flexibility
innovation ~ costs")
fit.sem_1a <- sem(model.sem_1a, data = dataset, missing = "fiml")
summary(fit.sem_1a, fit.measures = T, standardized = T, rsquare = T)
然后我得到标准化直接效应系数的矩阵,并将其转置以使因变量出现在列中,而独立变量出现在行中:
# Get matrix of beta coefficients from lavInspect function:
mtx <- lavInspect(fit.sem_1a, what = "std", add.labels = TRUE, add.class = TRUE,
list.by.group = TRUE,
drop.list.single.group = TRUE)$beta
m <- t(mtx) # transpose matrix
m矩阵的输出:
qualty delvry flxblt costs innvtn
quality 0 0.52 0.000 0.000 0.000
delivery 0 0.00 0.412 0.000 0.000
flexibility 0 0.00 0.000 0.309 0.000
costs 0 0.00 0.000 0.000 0.442
innovation 0 0.00 0.000 0.000 0.000
然后我切换到rSymPy包-在r中实现python Sympy库-并通过将系数的数值替换为字符串标签来重新创建直接系数矩阵:
rn <- rownames(m)
cn <- colnames(m)
library(rSymPy)
symbolic_mtrx <- matrix(nrow=length(rownames(m)), ncol=length(colnames(m))) # initialize empty symbolic matrix with correct dimensions
# Now fill in the matrix with 'z' for zero elements and abbreviations for non-zero path coefficients
for (i in 1:length(rownames(m))){
for (j in 1:length(colnames(m))){
symbolic_mtrx[i,j]<-noquote('z') # noquote not necessary
if (m[i,j]!=0) {
#print(m[i,j])
l<-paste0(substr(rownames(m)[i],1,1),substr(colnames(m)[j],1,1)) # create a name for a coefficient from first letter of each construct name
symbolic_mtrx[i,j]<-noquote(l)
}
}
}
symbolic_mtrx # print the symbolic matrix
symbol_mtrx的输出:
[,1] [,2] [,3] [,4] [,5]
[1,] "z" "qd" "z" "z" "z"
[2,] "z" "z" "df" "z" "z"
[3,] "z" "z" "z" "fc" "z"
[4,] "z" "z" "z" "z" "ci"
[5,] "z" "z" "z" "z" "z"
由于我无法在r中的rSymPy中执行矩阵乘法,因此我切换到python并根据需要将符号矩阵进行多次乘法:
library(reticulate)
```{python}
from sympy import Matrix
rsm_direct = Matrix(r.symbolic_mtrx) #get direct effects matrix from r
rsm_indirect_1 = rsm_direct*rsm_direct # get first order indirect effects by multiplication
rsm_indirect_2 = rsm_indirect_1*rsm_direct # get second order indirect effects by multiplication. Would be nice to know in advance how many levels of indirect effects exist.
rsm_total_indirect = rsm_indirect_1 + rsm_indirect_2 # sum of first and second order indirect effects
rsm_total = rsm_total_indirect + rsm_direct # get total effects
```
rsm_total(总效应公式)的输出,其中z表示零系数:
Matrix([[qd*z + 4*z**2 + z*(df*qd + 4*z**2) + z*(qd*z + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z, 2*qd*z + qd*(qd*z + 4*z**2) + qd + 3*z**2 + z*(df*qd + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2), df*qd + df*(2*qd*z + 3*z**2) + 4*z**2 + z*(df*qd + 4*z**2) + z*(qd*z + 4*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z, fc*z + fc*(df*qd + 4*z**2) + qd*z + 3*z**2 + z*(qd*z + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z, ci*z + ci*(fc*z + qd*z + 3*z**2) + qd*z + 3*z**2 + z*(df*qd + 4*z**2) + z*(qd*z + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z], [df*z + 4*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z, df*z + qd*z + qd*(df*z + 4*z**2) + 3*z**2 + z*(df*fc + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z, 2*df*z + df*(df*z + qd*z + 3*z**2) + df + 3*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2), df*fc + fc*(2*df*z + 3*z**2) + 4*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z, ci*z + ci*(df*fc + 4*z**2) + df*z + 3*z**2 + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z], [fc*z + 4*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z, fc*z + qd*z + qd*(fc*z + 4*z**2) + 3*z**2 + z*(ci*fc + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z, df*z + df*(fc*z + qd*z + 3*z**2) + fc*z + 3*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(df*z + fc*z + 3*z**2) + z, 2*fc*z + fc*(df*z + fc*z + 3*z**2) + fc + 3*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2), ci*fc + ci*(2*fc*z + 3*z**2) + 4*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z], [ci*z + 4*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z, ci*z + qd*z + qd*(ci*z + 4*z**2) + 3*z**2 + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z, ci*z + df*z + df*(ci*z + qd*z + 3*z**2) + 3*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z, ci*z + fc*z + fc*(ci*z + df*z + 3*z**2) + 3*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z, 2*ci*z + ci*(ci*z + fc*z + 3*z**2) + ci + 3*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2)], [5*z**3 + 5*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z, 5*qd*z**2 + qd*z + 4*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z, df*z + df*(qd*z + 4*z**2) + 5*z**3 + 4*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z, fc*z + fc*(df*z + 4*z**2) + 5*z**3 + 4*z**2 + z*(ci*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z, ci*z + ci*(fc*z + 4*z**2) + 5*z**3 + 4*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(qd*z + 4*z**2) + z]])
根据乘法符号矩阵中的文本字符串创建间接效果和总效果的语法(仍在python中,但不一定):
```{python}
l=len(r.rn) # number of matrix rows, taken from r object
total_effects_syntax = str() # initialize empty string for syntax
for i,rname in enumerate(r.rn): # both row index and row elements in matrix are needed, thefore use of enumerate()
for j,cname in enumerate(r.cn): # now traverse through columns
if i!=j: # exclude path coefficients that go from construct to itself
total_effects_syntax+= " "+rname[0]+cname[0]+"_total:= "+str(rsm_total[i*l+j]) + " \n " # create a string for lavaan total effects
# Now indicate that z means zero:
total_effects_syntax = "z:=0" + " \n" + total_effects_syntax + " "
print(total_effects_syntax)
```
输出是将插入到结构模型的描述中的总效果的语法(为显示目的,手动清除了输出):
z:=0
qd_total:= 2*qd*z + qd*(qd*z + 4*z**2) + qd + 3*z**2 + z*(df*qd + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2)
qf_total:= df*qd + df*(2*qd*z + 3*z**2) + 4*z**2 + z*(df*qd + 4*z**2) + z*(qd*z + 4*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
qc_total:= fc*z + fc*(df*qd + 4*z**2) + qd*z + 3*z**2 + z*(qd*z + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
qi_total:= ci*z + ci*(fc*z + qd*z + 3*z**2) + qd*z + 3*z**2 + z*(df*qd + 4*z**2) + z*(qd*z + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z
dq_total:= df*z + 4*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z
df_total:= 2*df*z + df*(df*z + qd*z + 3*z**2) + df + 3*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2)
dc_total:= df*fc + fc*(2*df*z + 3*z**2) + 4*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z
di_total:= ci*z + ci*(df*fc + 4*z**2) + df*z + 3*z**2 + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z
fq_total:= fc*z + 4*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
fd_total:= fc*z + qd*z + qd*(fc*z + 4*z**2) + 3*z**2 + z*(ci*fc + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
fc_total:= 2*fc*z + fc*(df*z + fc*z + 3*z**2) + fc + 3*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2)
fi_total:= ci*fc + ci*(2*fc*z + 3*z**2) + 4*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
cq_total:= ci*z + 4*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z
cd_total:= ci*z + qd*z + qd*(ci*z + 4*z**2) + 3*z**2 + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z
cf_total:= ci*z + df*z + df*(ci*z + qd*z + 3*z**2) + 3*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z
ci_total:= 2*ci*z + ci*(ci*z + fc*z + 3*z**2) + ci + 3*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2)
iq_total:= 5*z**3 + 5*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z
id_total:= 5*qd*z**2 + qd*z + 4*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z
if_total:= df*z + df*(qd*z + 4*z**2) + 5*z**3 + 4*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z
ic_total:= fc*z + fc*(df*z + 4*z**2) + 5*z**3 + 4*z**2 + z*(ci*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z
最后,再次切换回r并第二次运行模型,但是现在将总效果的语法添加到了模型定义中:
model.sem_1a <- paste(model.cfa, "
delivery ~ qd*quality
flexibility ~ df*delivery
costs ~ fc*flexibility
innovation ~ ci*costs
", py$total_effects_syntax)
fit.sem_1a <- sem(model.sem_1a, data = dataset, missing = "fiml")
summary(fit.sem_1a, fit.measures = T, standardized = T, rsquare = T)
这是模型(model.sem_1a)描述,其中添加了用于添加总效果的语法,这是我们的最终目标:
quality =~ Q068_1 + Q068_4
delivery =~ Q069_2 + Q069_5
flexibility =~ Q071_1 + Q071_4 + Q071_5
costs =~ Q070_1 + Q070_2 + Q070_3
innovation =~ Q072_1 + Q072_3 + Q072_2
delivery ~ qd*quality
flexibility ~ df*delivery
costs ~ fc*flexibility
innovation ~ ci*costs
z:=0
qd_total:= 2*qd*z + qd*(qd*z + 4*z**2) + qd + 3*z**2 + z*(df*qd + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2)
qf_total:= df*qd + df*(2*qd*z + 3*z**2) + 4*z**2 + z*(df*qd + 4*z**2) + z*(qd*z + 4*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
qc_total:= fc*z + fc*(df*qd + 4*z**2) + qd*z + 3*z**2 + z*(qd*z + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
qi_total:= ci*z + ci*(fc*z + qd*z + 3*z**2) + qd*z + 3*z**2 + z*(df*qd + 4*z**2) + z*(qd*z + 4*z**2) + z*(2*qd*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z
dq_total:= df*z + 4*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z
df_total:= 2*df*z + df*(df*z + qd*z + 3*z**2) + df + 3*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2)
dc_total:= df*fc + fc*(2*df*z + 3*z**2) + 4*z**2 + z*(df*fc + 4*z**2) + z*(df*z + 4*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z
di_total:= ci*z + ci*(df*fc + 4*z**2) + df*z + 3*z**2 + z*(df*z + 4*z**2) + z*(2*df*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(df*z + qd*z + 3*z**2) + z
fq_total:= fc*z + 4*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
fd_total:= fc*z + qd*z + qd*(fc*z + 4*z**2) + 3*z**2 + z*(ci*fc + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
fc_total:= 2*fc*z + fc*(df*z + fc*z + 3*z**2) + fc + 3*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(2*fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2)
fi_total:= ci*fc + ci*(2*fc*z + 3*z**2) + 4*z**2 + z*(ci*fc + 4*z**2) + z*(fc*z + 4*z**2) + z*(df*z + fc*z + 3*z**2) + z*(fc*z + qd*z + 3*z**2) + z
cq_total:= ci*z + 4*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z
cd_total:= ci*z + qd*z + qd*(ci*z + 4*z**2) + 3*z**2 + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2) + z
cf_total:= ci*z + df*z + df*(ci*z + qd*z + 3*z**2) + 3*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + fc*z + 3*z**2) + z
ci_total:= 2*ci*z + ci*(ci*z + fc*z + 3*z**2) + ci + 3*z**2 + z*(ci*z + 4*z**2) + z*(2*ci*z + 3*z**2) + z*(ci*z + df*z + 3*z**2) + z*(ci*z + qd*z + 3*z**2)
iq_total:= 5*z**3 + 5*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z
id_total:= 5*qd*z**2 + qd*z + 4*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z \n if_total:= df*z + df*(qd*z + 4*z**2) + 5*z**3 + 4*z**2 + z*(ci*z + 4*z**2) + z*(df*z + 4*z**2) + z*(fc*z + 4*z**2) + z
ic_total:= fc*z + fc*(df*z + 4*z**2) + 5*z**3 + 4*z**2 + z*(ci*z + 4*z**2) + z*(fc*z + 4*z**2) + z*(qd*z + 4*z**2) + z