Create lm object from data/coefficients

后端 未结 2 2143
旧巷少年郎
旧巷少年郎 2021-02-14 09:47

Does anyone know of a function that can create an lm object given a dataset and coefficients?

I\'m interested in this because I started playing with Bayesian model avera

2条回答
  •  温柔的废话
    2021-02-14 10:25

    There is no function that I am aware of that does this. One could of course be made. All that your magicFunction would need to do is create a list with elements:

    > names(fakeModel)
    [1] "coefficients"  "residuals"     "effects"       "rank"         
     [5] "fitted.values" "assign"        "qr"            "df.residual"  
     [9] "xlevels"       "call"          "terms"         "model"  
    

    then make it an lm object

    > class(fakeModel) <- c("lm")
    

    Let me just say that I think that this is a bad idea though. Whose to say that the generic function that you apply will be applicable to a bicreg object. For example, how would you interpret AIC(fakeModel)?

    You are better off creating your own functions to do diagnostics and prediction.

提交回复
热议问题