The advice to store the summary
results is actually on point for your goal. What you also needed to know was exactly what values stargazer was taking from a model.object. That's not actually described in much detail in the help pages, but its fairly obvious once you look at what the code it doing. Here's the top of the core function used by stargazer
. You might be able to see it if your console stores enough lines of code (but my Rstudio installation does not, so I viewed it in an editor after downloading the package from CRAN and unpacking):
stargazer:::.stargazer.wrap # scrolls off the top of my console
# cut from stargazer-internal.R
.stargazer.wrap <-
function(..., type, title, style, summary, out, out.header, covariate.labels, column.labels, column.separate,
dep.var.caption, dep.var.labels, dep.var.labels.include, align, coef, se, t, p, t.auto,
p.auto, ci, ci.custom, ci.level, ci.separator, add.lines, apply.coef, apply.se, apply.t, apply.p, apply.ci,
colnames,
column.sep.width, decimal.mark, df, digit.separate, digit.separator, digits, digits.extra,
flip, float,
float.env, font.size, header, initial.zero, intercept.bottom, intercept.top, keep, keep.stat,
label, model.names, model.numbers, multicolumn, no.space, notes, notes.align, notes.append,
notes.label, object.names, omit, omit.labels, omit.stat, omit.summary.stat, omit.table.layout,
omit.yes.no, order, ord.intercepts, perl, report, rownames,
rq.se, selection.equation, single.row, star.char, star.cutoffs, suppress.errors,
table.layout, table.placement,
zero.component, summary.logical, summary.stat, nobs, mean.sd, min.max, median, iqr, warn) {
.add.model <-
function(object.name, user.coef=NULL, user.se=NULL, user.t=NULL, user.p=NULL, auto.t=TRUE, auto.p=TRUE, user.ci.lb=NULL, user.ci.rb=NULL) {
if (class(object.name)[1] == "Glm") {
.summary.object <<- summary.glm(object.name)
}
else if (!(.model.identify(object.name) %in% c("aftreg", "coxreg","phreg","weibreg", "Glm", "bj", "cph", "lrm", "ols", "psm", "Rq"))) {
.summary.object <<- summary(object.name)
}
else {
.summary.object <<- object.name
}
So all you need to do in order to trick stargazer is change the class of the summary object contents to the class of the original model.
(saving this and will return with example code.)
Ooops. I went back to your question to set up my tested code but sadly ... it doesn't have a [MCVE]. I would have added code here to accomplish the goal but I generally reserve that service for question with complete examples. You should refer to How to make a great R reproducible example and edit your question if this is not already sufficient.