[英]Stargazer and gam - how to include the whole summary output?
When fitting a generalized additive model with smoothed splines stargazer only returns the main effects and not the smooth terms which you can see in summary(pros.gam)
. 当使用平滑样条函数拟合广义附加模型时,只返回主要效果,而不是您在summary(pros.gam)
可以看到的平滑术语summary(pros.gam)
。 Can stargazer return these as well? 观星者还可以归还这些吗? Or is there another function or package that can do the job? 或者是否有其他功能或包可以完成这项工作?
library(ElemStatLearn)
library(mgcv)
library(stargazer)
pros.gam=gam(lpsa~s(lcavol)+s(lweight)+s(age)+s(lbph)+svi
+s(lcp)+gleason+s(pgg45),data=prostate)
summary(pros.gam) # Table should include the smooth terms that are visible here
stargazer(pros.gam,summary=TRUE)
toLatex
of the utils
package does the job: utils
包的toLatex
完成了这项工作:
require(utils)
toLatex(summary(pros.gam)$s.table)
Output: 输出:
# \begin{tabular}{lD{.}{.}{7}D{.}{.}{7}D{.}{.}{7}D{.}{.}{7}}
# \toprule
# & \multicolumn{1}{c}{edf} & \multicolumn{1}{c}{Ref.df} & \multicolumn{1}{c}{F} & \multicolumn{1}{c}{p-value} \\
# \midrule
# s(lcavol) & 1.0000000 & 1.0000000 & 48.8654347 & 0.0000000 \\
# s(lweight) & 7.4334733 & 8.3759397 & 2.9521585 & 0.0054553 \\
# s(age) & 1.7609527 & 2.1888342 & 3.2466098 & 0.0402275 \\
# s(lbph) & 1.7480193 & 2.1293872 & 2.3329425 & 0.0998080 \\
# s(lcp) & 3.3087460 & 4.0189658 & 1.3792509 & 0.2484695 \\
# s(pgg45) & 1.1277962 & 1.2388741 & 0.2681440 & 0.6563885 \\
# \bottomrule
# \end{tabular}
I was having the same problem converting the output of GAM models (mgcv package), I got what I wanted with the "itsadug" package authored by R. Harald Baayen. 我在转换GAM模型(mgcv包)的输出时遇到了同样的问题,我得到了我想要的R. Harald Baayen撰写的“itsadug”包。
Convert model summary into Latex / HTML table for knitr / R Markdown reports. 将模型摘要转换为Latex / HTML表格,以获取knitr / R Markdown报告。
data(simdat)
m1 <- bam(Y ~ Group+te(Time, Trial, by=Group),data=simdat)
summary(m1)
gamtabs(m1, caption='Summary of m1')
vignette("inspect", package="itsadug")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.