【发布时间】:2022-01-23 04:41:56
【问题描述】:
当我们像这样拟合线性模型时,
x <- c(1.52, 1.6, 1.68, 1.75, 1.83)
y <- c(1.69, 1.74, 1.80, 1.93, 2.0)
fit <- lm(y ~ x)
summary(fit)
输出:
Call:
lm(formula = y ~ x)
Residuals:
1 2 3 4 5
0.021416 -0.012387 -0.036190 0.020482 0.006679
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.07633 0.19447 0.392 0.72093
x 1.04754 0.11579 9.047 0.00285 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.0282 on 3 degrees of freedom
Multiple R-squared: 0.9646, Adjusted R-squared: 0.9529
F-statistic: 81.85 on 1 and 3 DF, p-value: 0.002852
所以,我想要的是这个“精确”表的乳胶输出,用于Rmarkdown pdf 输出文件。我不希望生成的输出会更改表或不包含该表中的某些信息。我的意思是,完全相同的输出,但在latex 输出中。
示例输出类似于此图像,但对于单个回归模型,并且还包含summary(lm(y~x))生成的所有信息
注意:我使用过 sjPlot、stargazer、texreg 等这些库。
目前我正在使用R version 4.1.2
【问题讨论】:
-
所以你想要完全相同的输出,但不同。您希望它包含与
summary()完全相同的信息,但您的示例不(例如)包含summary()具有的残差,它确实包含N和置信区间,summary()不包含't have... 和stargazer和texreg还不够好,但你还没说为什么?
标签: r latex r-markdown