问题
The package "prais"
contains the function prais.winsten
to run a regression models with Prais Winsten estimator. However, neither stargazer
nor broom
packages seem to work with the results from the prais.winsten
function.
After fitting a model of the form
pw<- prais.winsten(speed ~ dist, cars)
When I try to report the results with stargazer I get the following error:
stargazer(pw, out = "pw.html")
Error: $ operator is invalid for atomic vectors
and likewise tidying the model with the broom
package I get
tidy(pw)
Error in names(object) <- nm :
'names' attribute [1] must be the same length as the vector [0]
Is there any way to work with prais.wisten
results in stargazer
and broom
?
Or alternatively, is there any way to run a Prais Winsten estimator in glm
?
回答1:
The easiest way to do this is to edit the Prais.Winsten function to return an lm object.
getAnywhere(prais.winsten())
will return the function. You can then copy the code into your script and just change return function from "results" to "lm".
来源:https://stackoverflow.com/questions/49109282/how-to-work-with-prais-winsten-results-in-stargazer-and-broom-r