R/residuals.probit.R

Defines functions residuals.probit

Documented in residuals.probit

residuals.probit <- function( object, type = "deviance", ... ) {

   fitVal <- fitted( object )
   response <- model.frame( object )[ , 1 ]
   if( type == "response" ) {
      result <- response - fitVal
   } else if( type == "deviance" ) {
      result <- ifelse( response == 1,
         sqrt( -2 * log( fitVal ) ), -sqrt( -2 * log( 1 - fitVal ) ) )
   } else if( type == "pearson" ) {
      result <- ( response - fitVal ) / sqrt( fitVal * ( 1 - fitVal ) )
   } else {
      stop( "argument 'type' must be either 'deviance', 'pearson',",
         " or 'response'" )
   }
   result <- drop( result )
   
   if( !is.null( object$weights ) && type %in% c( "pearson", "deviance" ) ) {
      result <- result * sqrt( object$weights )
   }

   names( result ) <- names( fitted( object ) )
   return( result )
}

Try the sampleSelection package in your browser

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

sampleSelection documentation built on Jan. 13, 2021, 7:49 p.m.