Stargazer produces very pleasant latex tables for lm objects (and others). Suppose I placed the model at the maximum probability. I would like stargazer to create an lm-like table for my ratings. How can i do this?
Although this is a bit hacky, one way would be to create a โfakeโ lm object containing my grades โ I think this will work as long as summary (my.fake.lm.object) works. Is it easy to do?
Example:
library(stargazer) N <- 200 df <- data.frame(x=runif(N, 0, 50)) df$y <- 10 + 2 * df$x + 4 * rt(N, 4)
To be more precise: with lm objects, stargazer beautifully prints the dependent variable at the top of the table, includes SE in brackets below the corresponding estimates and has R ^ 2 and the number of observations at the bottom of the table. Is there a (simple way) to get the same behavior with a โcustomizableโ model rated at maximum probability, as described above?
Here are my weak attempts to come up with my optimal output as an lm object:
model2.lm <- list() # Mimic an lm object class(model2.lm) <- c(class(model2.lm), "lm") model2.lm$rank <- model1$rank # Problematic? model2.lm$coefficients <- model2$par names(model2.lm$coefficients)[1:2] <- names(model1$coefficients) model2.lm$fitted.values <- model2$par["const"] + model2$par["beta"]*df$x model2.lm$residuals <- df$y - model2.lm$fitted.values model2.lm$model <- df model2.lm$terms <- model1$terms # Problematic? summary(model2.lm) # Not working
optimization r lm stargazer
Adrian Jan 24 '14 at 17:17 2014-01-24 17:17
source share