how to work with prais.winsten results in stargazer and broom (r)

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-07 09:13:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!