envel.res {Kmisc}R Documentation

~~function to do ... ~~

Description

~~ A concise (1-5 lines) description of what the function does. ~~

Usage

envel.res(obj, NMC = 199)

Arguments

obj ~~Describe obj here~~
NMC ~~Describe NMC here~~

Details

~~ If necessary, more details than the description above ~~

Value

~Describe the value returned If it is a LIST, use

comp1 Description of 'comp1'
comp2 Description of 'comp2'

...

Warning

....

Note

~~further notes~~

~Make other sections like Warning with section{Warning }{....} ~

Author(s)

~~who you are~~

References

~put references to the literature/web site here ~

See Also

~~objects to See Also as help, ~~~

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--    or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(obj, NMC=199) {
  fit <- fitted(obj)
  X <- model.matrix(obj)
  td <- my.res(obj)
  n <- nrow(X)
  res <- matrix(0, NMC, n)
  for (i in 1:NMC) {
    if (all(class(obj)=="lm")) {
      y <- rnorm(n, fit)
      res[i, ] <- sort(my.res(glm(y~X, family=gaussian)))
    }
    else {
      if (obj$family$family=="binomial") {
        y <- rbinom(n, 1, fit)
      }
      if (obj$family$family=="poisson") {
        y <- rpois(n, fit)
      }
    res[i, ] <- sort(my.res(glm(y~X, family=obj$family)))
    }
  }
  faixa <- range(res)
  par.ori <- par(no.readonly = TRUE)
  par(mfrow=c(1,1), mar=c(3,3,3,1), mgp=c(1.7,0.7,0), las=1)
  qqnorm(td, xlab="Percentis da N(0,1)",
  ylab="Componente do Desvio", ylim=faixa, pch=16)
  par(new=T)
  qqnorm(apply(res, 2, quantile, 0.05), axes=FALSE, 
    xlab="", ylab="", type="l", ylim=faixa, lty=1)
  par(new=T)
  qqnorm(apply(res, 2, quantile, 0.95), axes=FALSE, 
    xlab="", ylab="", type="l", ylim=faixa, lty=1)
  par(par.ori)
  colnames(res) <- paste("a", 1:n, sep="")
  rownames(res) <- paste("s", 1:NMC, sep="")
  return(res)
  }

[Package Kmisc version 1.0 Index]