leifeld/texreg

setMethod issue for cdfquantreg

fangsly opened this issue · 0 comments

Hello,

First of all, thank you for the amazing package!

I have some problem and I can't quite understand why my code isn't working.
I'm new to programming in R and I've never written extension, so I just don't know why it won't work.

I'm trying to write the extract function for CDF-quantile regression from the library cdfquantreg.

extract.cdfquantreg <- function(model, include.nobs = TRUE, include.loglik = TRUE, ...) {
  s <- summary(model, ...)
  
  names <- rownames(s$coef$location)
  cf <- s$coef$location[, 1]
  se <- s$coef$location[, 2]
  p <- s$coef$location[, ncol(s$coef$location)]
  
  gof <- numeric()
  gof.names <- character()
  gof.decimal <- logical()

  if (include.nobs == TRUE) {
    n <- nobs(model)
    gof <- c(gof, n)
    gof.names <- c(gof.names, "Num.\\ obs.")
    gof.decimal <- c(gof.decimal, FALSE)
    
  }
  if (include.loglik == TRUE) {
    ll <- s$logLik
    gof <- c(gof, ll)
    gof.names <- c(gof.names, "Log Likelihood")
    gof.decimal <- c(gof.decimal, TRUE)
  }
  tr <- createTexreg(
    coef.names = names, 
    coef = cf, 
    se = se, 
    pvalues = p, 
    gof.names = gof.names, 
    gof = gof, 
    gof.decimal = gof.decimal
  )
  return(tr)
}

setMethod("extract", signature = className("cdfquantreg", "cdfquantreg"),definition = extract.cdfquantreg)

If you could help in any way, it will be very nice of you.