#=======================================================================
plot.prof.aov <- function(mleobj, nseg=7, ratio=log(8),
                          which=NULL, legenda="bottomleft") {
  if( class(mleobj)[1] != "profile.mle" &
     class(mleobj)[1] != "profile.mle2") 
    stop( "Object should have class \'profile.mle\' or \'profile.mle2\'")
  mleprof <- mleobj@profile
  npar <- length(mleprof)
  if( is.null(which) )
    parseq = 1:npar
  else
    parseq = which
  mmx <- range(sapply(mleprof[parseq],function(x)range(x[2])))
  mmy <- c(0,max(sapply(mleprof[parseq],function(x)max(x[1]))))
  mmy <- mmy^2/2
  cores <- rainbow(length(parseq))
  plot(0,0, type="n", xlim=mmx,ylim=mmy,
       xlab="Valor do ParÃ¢metro", 
       ylab="Log-VerossimilhanÃ§a Negativa Relativa")
  z=1
  for(i in parseq)
    {
      tmp <- mleprof[i][[1]]
      varname <- names(mleprof[i])
      y <- tmp[,1]^2/2
      x <- (tmp[,2][,i])
      interpol = spline(x, y, n=nseg*length(x) )
      points(interpol, 
             type="l",lwd=2, 
             col=cores[z])
      z <- z+1
    }
  abline(h=ratio,lty=2,col="blue")
  legend(legenda,names(mleprof[parseq]),lty=1,lwd=2,col=cores,bty="n")
}


