当前位置:首页>python>【重复测量纵向数据】Python12.结构方程模型(Structural Equation Modeling,SEM)

【重复测量纵向数据】Python12.结构方程模型(Structural Equation Modeling,SEM)

  • 2026-04-19 07:27:33
【重复测量纵向数据】Python12.结构方程模型(Structural Equation Modeling,SEM)
【重复测量纵向数据】
Python12.结构方程模型(Structural Equation Modeling,SEM)

纵向数据是在不同时间点上对同一组个体、物体或实体进行重复观测所收集的数据。它就像给研究对象拍摄“动态影像”,能记录其随时间变化的过程,帮助我们理解趋势、模式和影响因素。

01
🔬 模型的概念、原理、思想

12.结构方程模型

概念:一个整合了因子分析和路径分析的多元统计框架,用于检验观察变量与潜变量之间、以及潜变量彼此之间的复杂假设关系网络。

原理:通过协方差结构分析,比较样本协方差矩阵与基于理论模型推导出的协方差矩阵的差异。使用最大似然法等拟合函数进行评估。

思想:“验证性建模”。强调基于先验理论构建假设模型,然后利用数据验证该模型结构的合理性。擅长处理测量误差和复杂的多变量中介、调节关系。

可视化:标准化解路径图:图形化展示所有变量间的假设关系(回归路径、相关、因子载荷)及标准化估计系数。

公共卫生意义:构建并检验一个综合的“健康素养-健康行为-健康结局”理论模型,分析健康素养如何通过自我管理行为的中介作用,影响慢性病控制水平的长期变化。

02
💡 22种重复测量纵向数据分析模型

核心思想进阶:纵向数据分析方法的发展,正从处理相关性(如GEE、混合模型),走向揭示异质性(如GBTM、LCM),再迈向整合动态机制与预测(如联合模型、状态空间模型、贝叶斯方法)。

1.数据预处理:

2.模型拟合:

3.模型可视化:

4.结果保存与报告生成

03
💎模型实现代码介绍

总的来说,纵向数据因其时间延续性对象一致性,成为了解事物动态发展过程、探究因果关系的强大工具。

当然,处理纵向数据也伴随一些挑战,例如成本较高、可能存在数据缺失,且分析方法通常比处理横截面数据更为复杂。

下面我们使用R语言进行纵向数据Python12.结构方程模型(Structural Equation Modeling,SEM)

# pip install pandas numpy scipy matplotlib seaborn pingouin scikit-learn factor-analyzer semopy openpyxl python-docx# pip install python-docx# pip install factor_analyzer semopy python-docximport osimport sysimport warningsimport pandas as pdimport numpy as npfrom datetime import datetimeimport matplotlib.pyplot as pltimport seaborn as snsfrom scipy import stats# 忽略警告warnings.filterwarnings('ignore')# 设置中文字体plt.rcParams['font.sans-serif'] = ['SimHei''Arial Unicode MS''DejaVu Sans']plt.rcParams['axes.unicode_minus'] = Falseprint("正在设置环境...")# 检查必要包required_packages = ['pandas''numpy''scipy''matplotlib''seaborn','sklearn''factor_analyzer''semopy''openpyxl']# 尝试导入主要包try:    import pandas as pd    import numpy as np    import matplotlib.pyplot as plt    import seaborn as sns    from scipy import statsprint("✓ 基础包导入成功")except ImportError as e:print(f"✗ 导入基础包失败: {e}")    sys.exit(1)# 尝试导入可选包optional_packages = {'factor_analyzer''factor_analyzer','semopy''semopy','sklearn''sklearn','pingouin''pingouin','docx''python-docx'# Word报告包}for display_name, package_name in optional_packages.items():    try:if package_name == 'factor_analyzer':            from factor_analyzer import FactorAnalyzer, calculate_kmo, calculate_bartlett_sphericityelif package_name == 'semopy':            import semopyelif package_name == 'sklearn':            from sklearn.impute import SimpleImputerelif package_name == 'pingouin':            import pingouin as pgelif package_name == 'docx':            from docx import Documentprint(f"✓ {display_name} 导入成功")    except ImportError:print(f"⚠ {display_name} 未安装,相关功能可能受限")# 设置工作目录desktop_path = os.path.join(os.path.expanduser('~'), 'Desktop')if not os.path.exists(desktop_path):    desktop_path = os.path.join(os.path.expanduser('~'), '桌面')  # 中文系统original_dir = desktop_pathresults_dir = os.path.join(desktop_path, '12-SEM结果')if not os.path.exists(results_dir):    os.makedirs(results_dir)print(f"✓ 创建结果文件夹: {results_dir}")# 读取数据print("\n正在读取数据...")# 读取Excel文件excel_path = os.path.join(original_dir, 'longitudinal_data.xlsx')if os.path.exists(excel_path):    try:        data_full = pd.read_excel(excel_path, sheet_name='Full_Dataset')        data_simple = pd.read_excel(excel_path, sheet_name='Simple_Dataset')print(f"✓ Full Dataset: {data_full.shape[0]}行, {data_full.shape[1]}列")print(f"✓ Simple Dataset: {data_simple.shape[0]}行, {data_simple.shape[1]}列")    except Exception as e:print(f"✗ 读取Excel文件失败: {e}")print("⚠ 创建示例数据以供测试...")# 创建示例数据        np.random.seed(123)        n = 100        data_full = pd.DataFrame({'ID': range(1, n + 1),'Time': np.random.choice([0, 1, 2], n),'Age': np.random.normal(45, 10, n),'Sex': np.random.choice(['M''F'], n),'Treatment': np.random.choice(['A''B''C''D'], n),'Baseline_Score': np.random.normal(50, 10, n),'School_ID': np.random.choice(range(1, 11), n),'SES': np.random.choice(['Low''Medium''High'], n),'Genetic_Marker': np.random.choice(['Type1''Type2'], n),'Indicator1': np.random.normal(3, 1, n),'Indicator2': np.random.normal(4, 0.8, n),'Indicator3': np.random.normal(5, 1.2, n),'Medication_Adherence': np.random.normal(7, 2, n),'Stress_Level': np.random.normal(5, 1.5, n),'Quality_of_Life': np.random.normal(6, 1.8, n),'Outcome_Continuous': np.random.normal(60, 15, n),'Outcome_Binary': np.random.choice([0, 1], n)        })        data_simple = data_full.copy()print("✓ 示例数据创建成功")else:print(f"✗ 未找到数据文件: {excel_path}")print("⚠ 创建示例数据以供测试...")# 创建示例数据    np.random.seed(123)    n = 100    data_full = pd.DataFrame({'ID': range(1, n + 1),'Time': np.random.choice([0, 1, 2], n),'Age': np.random.normal(45, 10, n),'Sex': np.random.choice(['M''F'], n),'Treatment': np.random.choice(['A''B''C''D'], n),'Baseline_Score': np.random.normal(50, 10, n),'School_ID': np.random.choice(range(1, 11), n),'SES': np.random.choice(['Low''Medium''High'], n),'Genetic_Marker': np.random.choice(['Type1''Type2'], n),'Indicator1': np.random.normal(3, 1, n),'Indicator2': np.random.normal(4, 0.8, n),'Indicator3': np.random.normal(5, 1.2, n),'Medication_Adherence': np.random.normal(7, 2, n),'Stress_Level': np.random.normal(5, 1.5, n),'Quality_of_Life': np.random.normal(6, 1.8, n),'Outcome_Continuous': np.random.normal(60, 15, n),'Outcome_Binary': np.random.choice([0, 1], n)    })    data_simple = data_full.copy()print("✓ 示例数据创建成功")# 数据预处理print("\n正在进行数据预处理...")# 选择基线数据(Time=0)if'Time'in data_full.columns:    baseline_data = data_full[data_full['Time'] == 0].drop_duplicates(subset='ID', keep='first')else:    baseline_data = data_full.drop_duplicates(subset='ID', keep='first')# 创建汇总数据集(用于SEM分析)required_columns = ['ID''Age''Sex''Treatment''Baseline_Score''School_ID','SES''Genetic_Marker''Indicator1''Indicator2''Indicator3','Medication_Adherence''Stress_Level''Quality_of_Life','Outcome_Continuous''Outcome_Binary']# 只选择存在的列available_columns = [col for col in required_columns if col in baseline_data.columns]sem_data = baseline_data[available_columns].copy()print(f"\n数据结构: {sem_data.shape[0]}行, {sem_data.shape[1]}列")print("\n前5行数据:")print(sem_data.head())# 检查缺失值print("\n缺失值统计:")missing_stats = sem_data.isnull().sum()missing_vars = missing_stats[missing_stats > 0]if len(missing_vars) > 0:print("以下变量存在缺失值:")for var, count in missing_vars.items():print(f"  {var}: {count}个缺失值 ({count / sem_data.shape[0] * 100:.1f}%)")else:print("无缺失值")# 处理缺失值sem_data_clean = sem_data.copy()# 数值变量使用中位数填充num_vars = ['Indicator1''Indicator2''Indicator3''Medication_Adherence','Stress_Level''Quality_of_Life''Baseline_Score''Outcome_Continuous']for var in num_vars:if var in sem_data_clean.columns and sem_data_clean[var].isnull().any():        median_val = sem_data_clean[var].median()        sem_data_clean[var].fillna(median_val, inplace=True)print(f"✓ 变量 {var}: {sem_data[var].isnull().sum()}个缺失值已用中位数 {median_val:.2f} 填充")# 检查Outcome_Binary的分布if'Outcome_Binary'in sem_data_clean.columns:print(f"\nOutcome_Binary分布:")print(sem_data_clean['Outcome_Binary'].value_counts())# 探索性因子分析(EFA)print("\n正在进行探索性因子分析...")# 选择用于EFA的指标efa_vars_list = ['Indicator1''Indicator2''Indicator3''Medication_Adherence','Stress_Level''Quality_of_Life''Baseline_Score''Outcome_Continuous']# 只选择存在的列efa_vars_available = [col for col in efa_vars_list if col in sem_data_clean.columns]if len(efa_vars_available) >= 3:  # 至少需要3个变量进行EFA    efa_vars = sem_data_clean[efa_vars_available].copy()# 确保所有变量都是数值型    efa_vars = efa_vars.apply(pd.to_numeric, errors='coerce')print(f"\nEFA变量结构: {efa_vars.shape[0]}行, {efa_vars.shape[1]}列")# 检查相关性矩阵    cor_matrix = efa_vars.corr()print("\n相关矩阵:")print(cor_matrix.round(3))# 可视化相关矩阵    try:        plt.figure(figsize=(12, 10))        mask = np.triu(np.ones_like(cor_matrix, dtype=bool))        sns.heatmap(cor_matrix, mask=mask, annot=True, fmt='.2f',                    cmap='coolwarm', center=0, square=True, linewidths=.5,                    cbar_kws={"shrink": .8})        plt.title('变量相关矩阵', fontsize=16)        plt.tight_layout()        plt.savefig(os.path.join(results_dir, 'Correlation_Matrix.png'), dpi=300)        plt.close()print("✓ 相关矩阵图已保存: Correlation_Matrix.png")    except Exception as e:print(f"✗ 相关矩阵图生成失败: {e}")# KMO检验和Bartlett球形检验    try:        from factor_analyzer import calculate_kmo, calculate_bartlett_sphericity# KMO检验        kmo_all, kmo_model = calculate_kmo(efa_vars)print(f"\nKMO检验:")print(f"总体KMO值: {kmo_model:.3f}")# Bartlett球形检验        chi2, p_value = calculate_bartlett_sphericity(efa_vars)print(f"\nBartlett球形检验:")print(f"卡方值: {chi2:.3f}")print(f"p值: {p_value:.3f}")print(f"球形检验结果: {'拒绝原假设(适合因子分析)' if p_value < 0.05 else '接受原假设(不适合因子分析)'}")    except ImportError:print("⚠ factor_analyzer包未安装,跳过KMO和Bartlett检验")    except Exception as e:print(f"✗ KMO/Bartlett检验失败: {e}")# 确定因子数量print("\n确定因子数量...")# 使用特征值大于1的标准    try:# 计算相关矩阵的特征值        corr_matrix = efa_vars.corr()        eigenvalues, eigenvectors = np.linalg.eig(corr_matrix)# 排序特征值        sorted_eigenvalues = np.sort(eigenvalues)[::-1]# 碎石图        plt.figure(figsize=(10, 6))        plt.plot(range(1, len(sorted_eigenvalues) + 1), sorted_eigenvalues, 'bo-', linewidth=2)        plt.axhline(y=1, color='r', linestyle='--', label='特征值=1')        plt.title('碎石图', fontsize=16)        plt.xlabel('因子数', fontsize=12)        plt.ylabel('特征值', fontsize=12)        plt.legend()        plt.grid(True, alpha=0.3)        plt.tight_layout()        plt.savefig(os.path.join(results_dir, 'Scree_Plot.png'), dpi=300)        plt.close()print("✓ 碎石图已保存: Scree_Plot.png")# 确定特征值大于1的因子数        n_factors = sum(sorted_eigenvalues > 1)print(f"特征值大于1的因子数: {n_factors}")# 如果因子数不合适,设置默认值if n_factors < 1:            n_factors = 2print(f"因子数小于1,使用默认值: {n_factors}")    except Exception as e:print(f"✗ 确定因子数量失败: {e}")        n_factors = 2print(f"\n执行EFA,因子数 = {n_factors}")# 执行EFA    try:        from factor_analyzer import FactorAnalyzer# 创建FactorAnalyzer对象        fa = FactorAnalyzer(n_factors=n_factors, rotation='varimax', method='minres')        fa.fit(efa_vars)# 获取因子载荷        loadings = fa.loadings_# 创建因子载荷DataFrame        loadings_df = pd.DataFrame(            loadings,            index=efa_vars.columns,            columns=[f'Factor{i + 1}'for i in range(n_factors)]        )print("\n探索性因子分析结果(因子载荷):")print(loadings_df.round(3))# 可视化因子载荷        plt.figure(figsize=(12, 8))        heatmap = sns.heatmap(loadings_df.abs(), annot=True, fmt='.2f',                              cmap='YlOrRd', cbar_kws={'label''因子载荷'})        plt.title('EFA因子载荷热图', fontsize=16)        plt.tight_layout()        plt.savefig(os.path.join(results_dir, 'EFA_Loadings.png'), dpi=300)        plt.close()print("✓ EFA因子载荷图已保存: EFA_Loadings.png")# 保存EFA结果        loadings_df.to_csv(os.path.join(results_dir, 'EFA_Loadings.csv'))print("✓ EFA载荷表已保存: EFA_Loadings.csv")    except ImportError:print("⚠ factor_analyzer包未安装,跳过EFA")    except Exception as e:print(f"✗ EFA执行失败: {e}")else:print(f"⚠ 可用于EFA的变量不足,需要至少3个,当前有{len(efa_vars_available)}个")# 验证性因子分析(CFA)print("\n正在进行验证性因子分析...")# 准备数据cfa_data = sem_data_clean.copy()# 确保数值类型numeric_columns = ['Indicator1''Indicator2''Indicator3''Medication_Adherence','Stress_Level''Quality_of_Life''Baseline_Score''Outcome_Continuous']for col in numeric_columns:if col in cfa_data.columns:        cfa_data[col] = pd.to_numeric(cfa_data[col], errors='coerce')# 尝试使用semopy进行CFAtry:    import semopy    from semopy import Model    from semopy.reports import calc_statsprint("✓ semopy包可用,开始CFA分析")
# 先尝试拟合单因子模型print("\n尝试拟合单因子CFA模型...")    try:# 检查模型中需要的变量是否存在        required_vars_model1 = ['Indicator1''Indicator2''Indicator3''Baseline_Score''Outcome_Continuous']        missing_vars_model1 = [var for var in required_vars_model1 if var not in cfa_data.columns]if missing_vars_model1:print(f"⚠ 单因子模型缺少变量: {missing_vars_model1}")            raise ValueError("缺少必要变量")        model1 = Model(measurement_model1)        model1.load_dataset(cfa_data)        res1 = model1.fit()print("✓ 单因子CFA模型收敛成功!")# 获取拟合指标        stats1 = calc_stats(model1)print("\n单因子CFA模型拟合结果:")print(f"卡方值: {stats1['chi2']:.3f}")print(f"自由度: {stats1['DoF']}")print(f"p值: {stats1['p_value']:.3f}")print(f"CFI: {stats1['CFI']:.3f}")print(f"TLI: {stats1['TLI']:.3f}")print(f"RMSEA: {stats1['RMSEA']:.3f}")print(f"SRMR: {stats1['SRMR']:.3f}")print(f"AIC: {stats1['AIC']:.1f}")print(f"BIC: {stats1['BIC']:.1f}")# 提取参数估计        params1 = model1.inspect(std_est=True)print("\n参数估计:")print(params1[['lval''op''rval''Estimate''Std. Estimate']].round(3))        cfa_fit = model1        fit_measures = stats1    except Exception as e:print(f"✗ 单因子CFA模型失败: {e}")# 尝试双因子模型print("\n尝试拟合双因子CFA模型...")        try:            required_vars_model2 = ['Indicator1''Indicator2''Indicator3''Baseline_Score','Medication_Adherence''Stress_Level''Quality_of_Life''Outcome_Continuous']            missing_vars_model2 = [var for var in required_vars_model2 if var not in cfa_data.columns]if missing_vars_model2:print(f"⚠ 双因子模型缺少变量: {missing_vars_model2}")                raise ValueError("缺少必要变量")            model2 = Model(measurement_model2)            model2.load_dataset(cfa_data)            res2 = model2.fit()print("✓ 双因子CFA模型收敛成功!")print("\n双因子CFA模型拟合结果:")# 获取拟合指标            stats2 = calc_stats(model2)print(f"卡方值: {stats2['chi2']:.3f}")print(f"自由度: {stats2['DoF']}")print(f"p值: {stats2['p_value']:.3f}")print(f"CFI: {stats2['CFI']:.3f}")print(f"TLI: {stats2['TLI']:.3f}")print(f"RMSEA: {stats2['RMSEA']:.3f}")print(f"SRMR: {stats2['SRMR']:.3f}")print(f"AIC: {stats2['AIC']:.1f}")print(f"BIC: {stats2['BIC']:.1f}")# 提取参数估计            params2 = model2.inspect(std_est=True)print("\n参数估计:")print(params2[['lval''op''rval''Estimate''Std. Estimate']].round(3))            cfa_fit = model2            fit_measures = stats2        except Exception as e2:print(f"✗ 双因子CFA模型也失败: {e2}")# 尝试最简单的模型print("\n尝试拟合最简单的CFA模型...")            simple_model = '''            Health_Factor =~ Indicator1 + Indicator2 + Indicator3            '''            try:                required_vars_simple = ['Indicator1''Indicator2''Indicator3']                missing_vars_simple = [var for var in required_vars_simple if var not in cfa_data.columns]if missing_vars_simple:print(f"⚠ 简单模型缺少变量: {missing_vars_simple}")                    raise ValueError("缺少必要变量")                model_simple = Model(simple_model)                model_simple.load_dataset(cfa_data)                res_simple = model_simple.fit()print("✓ 简单CFA模型收敛成功!")                stats_simple = calc_stats(model_simple)print(f"卡方值: {stats_simple['chi2']:.3f}")print(f"自由度: {stats_simple['DoF']}")print(f"p值: {stats_simple['p_value']:.3f}")                cfa_fit = model_simple                fit_measures = stats_simple            except Exception as e3:print(f"✗ 简单CFA模型失败: {e3}")# 模型拟合度评估if cfa_fit is not None and fit_measures is not None:print("\n模型拟合度评估:")# 创建拟合度表格        fit_table_data = {'Measure': ['Chi-square''DF''p-value''CFI''TLI','RMSEA''SRMR''AIC''BIC'],'Value': [                round(fit_measures.get('chi2', 0), 3),                fit_measures.get('DoF', 0),                round(fit_measures.get('p_value', 1), 3),                round(fit_measures.get('CFI', 0), 3) if'CFI'in fit_measures else'N/A',                round(fit_measures.get('TLI', 0), 3) if'TLI'in fit_measures else'N/A',                round(fit_measures.get('RMSEA', 0), 3) if'RMSEA'in fit_measures else'N/A',                round(fit_measures.get('SRMR', 0), 3) if'SRMR'in fit_measures else'N/A',                round(fit_measures.get('AIC', 0), 1) if'AIC'in fit_measures else'N/A',                round(fit_measures.get('BIC', 0), 1) if'BIC'in fit_measures else'N/A'            ]        }# 添加解释        interpretations = []for i, measure in enumerate(fit_table_data['Measure']):            value = fit_table_data['Value'][i]if measure == 'p-value':if isinstance(value, (int, float)):                    interpretations.append('模型可接受'if value > 0.05 else'模型需改进')else:                    interpretations.append('')elif measure == 'CFI':if isinstance(value, (int, float)):if value > 0.90:                        interpretations.append('优')elif value > 0.80:                        interpretations.append('可接受')else:                        interpretations.append('需改进')else:                    interpretations.append('')elif measure == 'TLI':if isinstance(value, (int, float)):if value > 0.90:                        interpretations.append('优')elif value > 0.80:                        interpretations.append('可接受')else:                        interpretations.append('需改进')else:                    interpretations.append('')elif measure == 'RMSEA':if isinstance(value, (int, float)):if value < 0.05:                        interpretations.append('优')elif value < 0.08:                        interpretations.append('可接受')else:                        interpretations.append('需改进')else:                    interpretations.append('')elif measure == 'SRMR':if isinstance(value, (int, float)):                    interpretations.append('优'if value < 0.08 else'需改进')else:                    interpretations.append('')elif measure in ['AIC''BIC']:                interpretations.append('值越小越好')else:                interpretations.append('')        fit_table_data['Interpretation'] = interpretations        fit_table = pd.DataFrame(fit_table_data)print("\n拟合指标表:")print(fit_table.to_string(index=False))# 保存拟合指标        fit_table.to_csv(os.path.join(results_dir, 'CFA_Fit_Indices.csv'), index=False)print("\n✓ 拟合指标已保存: CFA_Fit_Indices.csv")# 参数估计结果print("\n参数估计结果:")        try:            param_est = cfa_fit.inspect(std_est=True)# 筛选主要结果            param_table = param_est[['lval''op''rval''Estimate''Std. Estimate']].copy()            param_table.columns = ['Path''Relationship''Variable''Estimate''Std. Estimate']print("\n主要参数估计:")print(param_table.round(3))# 保存参数估计            param_table.to_csv(os.path.join(results_dir, 'CFA_Parameter_Estimates.csv'), index=False)print("\n✓ 参数估计已保存: CFA_Parameter_Estimates.csv")        except Exception as e:print(f"✗ 参数估计提取失败: {e}")# 可视化print("\n生成可视化图形...")# 因子载荷条形图        try:            loadings_data = param_est[param_est['op'] == '=~'].copy()if len(loadings_data) > 0:                plt.figure(figsize=(10, 6))                bars = plt.bar(range(len(loadings_data)), loadings_data['Std. Estimate'].abs())                plt.xticks(range(len(loadings_data)),                           [f"{row['lval']}->{row['rval']}"for _, row in loadings_data.iterrows()],                           rotation=45, ha='right')                plt.axhline(y=0.4, color='r', linestyle='--', alpha=0.5, label='载荷阈值(0.4)')                plt.ylabel('标准化载荷')                plt.title('CFA标准化因子载荷')                plt.legend()                plt.tight_layout()                plt.savefig(os.path.join(results_dir, 'CFA_Factor_Loadings.png'), dpi=300)                plt.close()print("✓ 因子载荷图已保存: CFA_Factor_Loadings.png")        except Exception as e:print(f"✗ 因子载荷图生成失败: {e}")# 模型拟合指标条形图        try:            fit_plot_data = []            measures = ['CFI''TLI''RMSEA''SRMR']            thresholds = [0.90, 0.90, 0.08, 0.08]for measure, threshold in zip(measures, thresholds):if measure in fit_measures:                    fit_plot_data.append({'Measure': measure,'Value': fit_measures[measure],'Threshold': threshold                    })if fit_plot_data:                fit_plot_df = pd.DataFrame(fit_plot_data)                plt.figure(figsize=(8, 6))                bars = plt.bar(fit_plot_df['Measure'], fit_plot_df['Value'], alpha=0.7)# 添加阈值线for i, (measure, threshold) in enumerate(zip(measures, thresholds)):if measure in fit_measures:                        plt.axhline(y=threshold, color='r', linestyle='--', alpha=0.5)# 添加数值标签for bar, value in zip(bars, fit_plot_df['Value']):                    plt.text(bar.get_x() + bar.get_width() / 2, bar.get_height() + 0.01,                             f'{value:.3f}', ha='center', va='bottom')                plt.title('CFA模型拟合指标')                plt.ylabel('值')                plt.ylim(0, max(fit_plot_df['Value'].max() * 1.2, 1))                plt.tight_layout()                plt.savefig(os.path.join(results_dir, 'CFA_Model_Fit_Bar.png'), dpi=300)                plt.close()print("✓ 拟合指标条形图已保存: CFA_Model_Fit_Bar.png")        except Exception as e:print(f"✗ 拟合指标条形图生成失败: {e}")else:print("✗ CFA模型未能成功拟合,跳过后续分析")except ImportError:print("⚠ semopy包未安装,跳过CFA分析")except Exception as e:print(f"✗ CFA分析失败: {e}")# 创建分析报告print("\n正在生成分析报告...")# 创建文本报告report_file = os.path.join(results_dir, 'SEM_Analysis_Report.txt')try:    with open(report_file, 'w', encoding='utf-8') as f:        f.write("=" * 60 + "\n")        f.write("结构方程模型分析报告\n")        f.write("=" * 60 + "\n\n")        f.write(f"生成日期: {datetime.now().strftime('%Y年%m月%d日')}\n")        f.write("分析软件: Python with semopy, factor_analyzer\n\n")        f.write("1. 数据概览\n")        f.write(f"样本量: {sem_data_clean.shape[0]}\n")        f.write(f"变量数: {sem_data_clean.shape[1]}\n")        f.write("缺失值处理: 数值变量使用中位数填充\n\n")        f.write("2. 探索性因子分析\n")        try:            f.write(f"KMO值: {kmo_model:.3f}\n")            f.write(f"Bartlett检验p值: {p_value:.3f}\n")            f.write(f"建议因子数: {n_factors}\n\n")        except:            f.write("EFA结果不可用\n\n")        f.write("3. 验证性因子分析结果\n")if'cfa_fit'in locals() and cfa_fit is not None:            f.write("模型设定:\n")if'measurement_model1'in locals():                f.write("单因子模型:\n" + measurement_model1 + "\n")if'measurement_model2'in locals():                f.write("双因子模型:\n" + measurement_model2 + "\n")            f.write("\n模型拟合指标:\n")if'fit_table'in locals():for _, row in fit_table.iterrows():                    f.write(f"{row['Measure']}: {row['Value']} [{row['Interpretation']}]\n")            f.write("\n4. 主要发现\n")            try:if'loadings_data'in locals() and len(loadings_data) > 0:                    f.write("标准化因子载荷:\n")for _, row in loadings_data.iterrows():                        f.write(f"{row['lval']}->{row['rval']}: {row['Std. Estimate']:.3f}\n")            except:                f.write("因子载荷信息不可用\n")else:            f.write("CFA模型未能成功拟合\n")        f.write("\n5. 公共卫生意义\n")        f.write("- 本研究通过因子分析探索了健康测量指标的结构\n")        f.write("- 为后续的结构方程模型分析奠定了基础\n")        f.write("- 强调了多维度健康评估的重要性\n")        f.write("\n6. 研究局限与建议\n")        f.write("- 样本量有限,未来需要更大样本验证\n")        f.write("- 建议进行多组验证性因子分析(MG-CFA)\n")        f.write("- 可考虑加入协变量进行更复杂的模型分析\n")        f.write("\n\n")        f.write("=" * 60 + "\n")        f.write("报告结束\n")        f.write("=" * 60 + "\n")print(f"✓ 文本报告已保存: SEM_Analysis_Report.txt")except Exception as e:print(f"✗ 文本报告生成失败: {e}")# 尝试创建Word报告print("\n正在尝试生成Word报告...")try:    from docx import Document    from docx.shared import Inches, Pt    from docx.enum.text import WD_ALIGN_PARAGRAPH    doc = Document()# 添加标题    title = doc.add_heading('结构方程模型分析报告', 0)    title.alignment = WD_ALIGN_PARAGRAPH.CENTER# 添加日期    doc.add_paragraph(f'生成日期:{datetime.now().strftime("%Y年%m月%d日")}')    doc.add_paragraph()# 1. 分析概述    doc.add_heading('1. 分析概述', level=1)    doc.add_paragraph(f'本次分析基于{sem_data_clean.shape[0]}名个体的基线数据,进行验证性因子分析。')# 2. 模型拟合结果if'fit_table'in locals() and fit_table is not None:        doc.add_heading('2. 模型拟合结果', level=1)# 创建表格        table = doc.add_table(rows=1, cols=3)        table.style = 'Light Shading'# 添加表头        header_cells = table.rows[0].cells        header_cells[0].text = '指标'        header_cells[1].text = '值'        header_cells[2].text = '解释'# 添加数据行for _, row in fit_table.iterrows():            row_cells = table.add_row().cells            row_cells[0].text = str(row['Measure'])            row_cells[1].text = str(row['Value'])            row_cells[2].text = str(row['Interpretation'])# 保存Word文档    word_file = os.path.join(results_dir, f"SEM_Report_{datetime.now().strftime('%Y%m%d')}.docx")    doc.save(word_file)print(f"✓ Word报告已保存: {word_file}")except ImportError:print("⚠ python-docx未安装,跳过Word报告生成")print("  如需生成Word报告,请运行: pip install python-docx")except Exception as e:print(f"✗ Word报告生成失败: {e}")# 汇总输出print("\n" + "=" * 60)print("分析完成!")print("=" * 60)print(f"\n结果已保存至文件夹:{results_dir}")print("\n主要输出文件:")# 检查文件是否存在并列出output_files = [    ('文本分析报告''SEM_Analysis_Report.txt'),    ('相关矩阵图''Correlation_Matrix.png'),    ('碎石图''Scree_Plot.png'),    ('EFA因子载荷图''EFA_Loadings.png'),    ('CFA因子载荷图''CFA_Factor_Loadings.png'),    ('拟合指标图''CFA_Model_Fit_Bar.png'),    ('拟合指标表''CFA_Fit_Indices.csv'),    ('参数估计表''CFA_Parameter_Estimates.csv'),    ('EFA载荷表''EFA_Loadings.csv'),]for file_desc, file_name in output_files:    file_path = os.path.join(results_dir, file_name)if os.path.exists(file_path):print(f"✓ {file_desc}: {file_name}")else:print(f"✗ {file_desc}: {file_name} (未生成)")# 检查Word报告word_file_pattern = os.path.join(results_dir, f"SEM_Report_{datetime.now().strftime('%Y%m%d')}.docx")import globword_files = glob.glob(os.path.join(results_dir, "SEM_Report_*.docx"))if word_files:print(f"✓ Word报告: {os.path.basename(word_files[0])}")else:print("✗ Word报告: (未生成)")print("\n\n提示:")print("1. 如需安装缺失包,请使用以下命令:")print("   pip install factor_analyzer semopy python-docx")print("2. 确保桌面有 'longitudinal_data.xlsx' 文件")print("3. 所有结果保存在 '12-SEM结果' 文件夹中")# 创建结果汇总表print("\n创建结果汇总表...")try:# 统计生成的文件    generated_files = []for _, file_name in output_files:        file_path = os.path.join(results_dir, file_name)if os.path.exists(file_path):            generated_files.append(file_name)    summary_data = {'项目': ['分析完成时间''数据样本量''生成的图表''生成的数据表''总文件数'],'结果': [            datetime.now().strftime('%Y-%m-%d %H:%M:%S'),            f"{sem_data_clean.shape[0]}",            f"{len([f for f in generated_files if f.endswith('.png')])}个",            f"{len([f for f in generated_files if f.endswith('.csv') or f.endswith('.txt')])}个",            f"{len(generated_files) + len(word_files)}个"        ]    }    summary_df = pd.DataFrame(summary_data)    summary_file = os.path.join(results_dir, 'Analysis_Summary.csv')    summary_df.to_csv(summary_file, index=False, encoding='utf-8-sig')print(f"✓ 分析汇总表已保存: Analysis_Summary.csv")except Exception as e:print(f"✗ 创建汇总表失败: {e}")print("\n✓ 所有分析完成!")

纵向数据是指在多个时间点对同一组个体进行的重复测量。

1    混合效应模型Mixed Effects ModelMEM

2 固定效应模型 Fixed Effects Model FEM

3 多层线性模型 Hierarchical Linear Model HLM

4 广义估计方程 Generalized Estimating Equations GEE

5 广义线性混合模型 Generalized Linear Mixed Models GLMM

6 潜变量增长曲线模型 Latent Growth Curve Model LGCM

7 组轨迹模型 Group-Based Trajectory Model GBTM

8 交叉滞后模型 Cross-lagged (Panel) Model CLPM

9 重复测量方差分析 Repeated Measures ANOVA / MANOVA RM-ANOVA / RM-MANOVA

10 非线性混合效应模型 Nonlinear Mixed-Effects Models NLME

11 联合模型     Joint Models     JM

12 结构方程模型 Structural Equation Modeling SEM

13 广义相加模型 Generalized Additive Models GAM

14 潜类别模型 Latent Class Models LCM

15 潜剖面模型 Latent Profile Analysis LPA

16 状态空间模型 State Space Models SSM

17 纵向因子分析 Longitudinal Factor Analysis LFA

18 贝叶斯纵向模型 Bayesian Longitudinal Models - (Bayesian Models)

19 混合效应随机森林 Mixed Effects Random Forest MERF

20 纵向梯度提升 Longitudinal Gradient Boosting - (Longitudinal GBM)

21 K均值纵向聚类 K-means Longitudinal Clustering - (DTW-KMeans)

22   基于模型的聚类 Model-Based ClusteringMB-CLUST

医学统计数据分析分享交流SPSS、R语言、Python、ArcGis、Geoda、GraphPad、数据分析图表制作等心得。承接数据分析,论文返修,医学统计,机器学习,生存分析,空间分析,问卷分析业务。若有投稿和数据分析代做需求,可以直接联系我,谢谢!

!!!可加我粉丝群!!!

“医学统计数据分析”公众号右下角;

找到“联系作者”,

可加我微信,邀请入粉丝群!

【医学统计数据分析】工作室“粉丝群”
01
【临床】粉丝群

有临床流行病学数据分析

如(t检验、方差分析、χ2检验、logistic回归)、

(重复测量方差分析与配对T检验、ROC曲线)、

(非参数检验、生存分析、样本含量估计)、

(筛检试验:灵敏度、特异度、约登指数等计算)、

(绘制柱状图、散点图、小提琴图、列线图等)、

机器学习、深度学习、生存分析

等需求的同仁们,加入【临床】粉丝群

02
【公卫】粉丝群

疾控,公卫岗位的同仁,可以加一下【公卫】粉丝群,分享生态学研究、空间分析、时间序列、监测数据分析、时空面板技巧等工作科研自动化内容。

03
【生信】粉丝群

有实验室数据分析需求的同仁们,可以加入【生信】粉丝群,交流NCBI(基因序列)、UniProt(蛋白质)、KEGG(通路)、GEO(公共数据集)等公共数据库、基因组学转录组学蛋白组学代谢组学表型组学等数据分析和可视化内容。

或者可扫码直接加微信进群!!!

精品视频课程-“医学统计数据分析”视频号付费合集

“医学统计数据分析”视频号-付费合集兑换相应课程后,获取课程理论课PPT、代码、基础数据等相关资料,请大家在【医学统计数据分析】公众号右下角,找到“联系作者”,加我微信后打包发送。感谢您的支持!!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-04-20 19:19:53 HTTP/2.0 GET : https://f.mffb.com.cn/a/484674.html
  2. 运行时间 : 0.092380s [ 吞吐率:10.82req/s ] 内存消耗:4,755.09kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=8e01dfacf9b0c006cff2a4320675efba
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000394s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000656s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000278s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000270s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000589s ]
  6. SELECT * FROM `set` [ RunTime:0.000217s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000646s ]
  8. SELECT * FROM `article` WHERE `id` = 484674 LIMIT 1 [ RunTime:0.002115s ]
  9. UPDATE `article` SET `lasttime` = 1776683993 WHERE `id` = 484674 [ RunTime:0.004916s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000688s ]
  11. SELECT * FROM `article` WHERE `id` < 484674 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001305s ]
  12. SELECT * FROM `article` WHERE `id` > 484674 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000400s ]
  13. SELECT * FROM `article` WHERE `id` < 484674 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001313s ]
  14. SELECT * FROM `article` WHERE `id` < 484674 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.006732s ]
  15. SELECT * FROM `article` WHERE `id` < 484674 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.006073s ]
0.093913s