##Calculation of Wald Statistic was causing errors for two-way fe models
##remove that, in order to be able to generate summary reports.

##To find out what method summary() uses with panelAR data:
#getS3method("summary", "panelAR")

summary_panelAR <- function (object, ...) 
{
  rdf <- object$df.residual
  rank <- object$rank
  N <- length(object$residuals)
  k <- length(object$aliased)
  df <- c(rank, rdf, k)
  se <- sqrt(diag(object$vcov))
  coef <- object$coefficients
  t.stat <- (coef)/se
  p.val <- 2 * pt(abs(t.stat), rdf, lower.tail = FALSE)
  tab <- cbind(coef, se, t.stat, p.val)
  dimnames(tab) <- list(names(coef), c("Estimate", "Std. Error", 
                                       "t value", "Pr(>|t|)"))
  hyp <- names(coef)
  hyp <- hyp[hyp != "(Intercept)"]
  # lh <- linearHypothesis(object, hyp, test="F", #test = c("Chisq", "F"), 
  #                        vcov. = object$vcov, singular.ok = T)
  # wald <- c(lh$Chisq[2], lh$Df[2], lh[["Pr(>Chisq)"]][2])
  # names(wald) <- c("value", "df", "Pr(>Chisq)")
  N.panel <- nrow(object$panelStructure$obs.mat)
  N.time <- ncol(object$panelStructure$obs.mat)
  balanced <- ifelse(N.panel * N.time == N, T, F)
  N.per.panel <- rowSums(object$panelStructure$obs.mat)
  N.min <- min(N.per.panel)
  N.max <- max(N.per.panel)
  N.avg <- N/N.panel
  panelStruct <- list(N = N, N.panel = N.panel, N.time = N.time, 
                      balanced = balanced, N.min = N.min, N.max = N.max, N.avg = N.avg, 
                      N.per.panel = N.per.panel)
  out <- list(call = object$call, terms = object$terms, coefficients = tab, 
              residuals = object$residuals, aliased = object$aliased, 
              df = df, rho = object$panelStructure$rho, Sigma = object$panelStructure$Sigma, 
              r2 = object$r2, wald = 0, 
              vcov = object$vcov, na.action = object$na.action, 
              panelStructure = panelStruct)
  class(out) <- "summary.panelAR"
  out
}