R/hatvalues.R

Defines functions hatvalues.gsm hatvalues.sm hatvalues.ss

Documented in hatvalues.gsm hatvalues.sm hatvalues.ss

hatvalues.ss <- 
  function(model, ...){
    if(is.null(model$data)) {
      warning("Input 'object' has no data. Returning object$lev as leverages.")
      hat <- model$lev
    } else {
      hat <- weights(model) * (predict(model, x = model$data$x)$se / model$sigma)^2
    }
    hat[hat > 1 - 10 * .Machine$double.eps] <- 1
    return(hat)
  }

hatvalues.sm <- 
  function(model, ...){
    hat <- weights(model) * (model$se.fit / model$sigma)^2 
    hat[hat > 1 - 10 * .Machine$double.eps] <- 1
    return(hat)
  }

hatvalues.gsm <- 
  function(model, ...){
    hat <- weights(model) * model$se.lp^2 / model$dispersion
    hat[hat > 1 - 10 * .Machine$double.eps] <- 1
    return(hat)
  }

Try the npreg package in your browser

Any scripts or data that you put into this service are public.

npreg documentation built on July 21, 2022, 1:06 a.m.