1toMlm<- function(x, ...) {
2  UseMethod("toMlm")
3}
4
5toMlm.default <- function(x){
6  lm(x$model)
7}
8
9toMlm.varest<-function(x){
10  ix <- 1:x$K
11  X<-x$datamat
12  type<-x$type
13  is.const<-type%in%c("const", "both")
14  #remove constant in datamat
15  if(is.const) X<-X[, -grep("const", colnames(X))]
16  #construct formula
17  left <- paste(names(X)[ix], collapse = ",")
18  if(is.const) {
19    fo <- as.formula(paste("cbind(", left, ") ~ ."))
20  } else {
21    fo <- as.formula(paste("cbind(", left, ") ~ .-1")) #remove automatical constant
22  }
23  #apply lm
24  res<-eval(substitute(lm(fo, X), list(fo = fo))) #code suggested by Gabor Groothendick
25  return(res)
26}
27
28coeftest.varest<-function(x, ...){
29  coeftest(toMlm.varest(x), ...)
30}
31
32bread.varest<-function(x, ...){
33  bread(toMlm.varest(x), ...)
34}
35
36vcov.varest<-function(object, ...){
37  vcov(toMlm.varest(object), ...)
38}
39
40vcovHC.varest<-function(x, ...){
41  vcovHC(toMlm.varest(x), ...)
42}
43
44estfun.varest<-function(x, ...){
45  estfun(toMlm.varest(x), ...)
46}