代码之家  ›  专栏  ›  技术社区  ›  Enosky

如何在RMarkdown上重命名回归表中的协变量和因子水平?

  •  0
  • Enosky  · 技术社区  · 3 年前

    我正在尝试从导入回归模型 用生成它们的表格 在pdf文件中。问题是,我不能重命名协变,以便表是可显示的。问题是,当我试图手动重命名协变量时,我编织文件时的名称和值都与应有的不同。在协变量之间有多个层次的因素(就业、教派和教育),我认为这是造成问题的原因。那么,我如何重命名所有这些协变量(包括因子水平)以使表看起来很好呢?

    如果我打印回归表而不重命名协变量,则数据是正确的。 enter image description here

    然后我输入代码来重命名协变

    stargazer(Model1A, Model1B, Model2A, Model2B, Model3A, Model3B,
              title='My Regression Table',
              order=c("Eco_diff", "Employment", "Pol_Interest", "Reform", "Redistribution", "Trust_Instit", "Voters", "Gov_satisf", "Gov_respons", "infl_gov", "Economy", "Redistribution_past", "Religious", "Corr_national", "Corr_local", "Sect", "Male", "Edu", "Age", "Urban", "Internet_user"),
              covariate.labels = c("Economic difficulties", "Employment Status", "Political Interest", "Implementing reforms", "Redistribution nowadays", "Trust in Institutions", "Voters", "Gov. Satisfaction", "Gov. responsivness to people", "Capacity to influence the Gov.", "Rating Economy", "Redistribution compare to the past", "Religiousness", "Perception of national institutions corruption", "Perception of local institutions corruption", "Sect", "Male", "Education", "Age", "Urban", "Heavy internet user"),
              font.size="tiny", report="vc*s", nobs=TRUE, no.space=TRUE,
              digits.extra=1, digits=2,
              dep.var.labels="Predictors of double participation in the Lebanese October Revolution",
              omit.stat=c("f","ser","rsq"),
              style="apsr",
              star.cutoffs=c(0.05,0.01,0.001),
              notes.append=FALSE, notes.align="l",
              notes.label="",
              notes=c("\\emph{Source}: The Data Frame, 2021-2022.",
                      "\\emph{Note}: Multivariate linear regression.",
                      "$^{*}$p$<$0.05; $^{**}$p$<$0.01; $^{***}$p$<$0.001"))
    

    结果是:

    enter image description here

    0 回复  |  直到 3 年前