0

I want to create a QQ-plot, but I don't want to compare it to a standard normal distribution. I currently have this:

log_amount = runif(100)
  fit = fitdistr(log_amount, "normal") 
  qmy_distribution = function(p) {
      return(qnorm(p, fit$estimate[1], fit$estimate[2]))
  }
  expected = qmy_distribution(ppoints(length(log_amount)))
  qqplot(log_amount, expected, main = title)
  qqline(log_amount, col = 'blue', distribution = qmy_distribution)

I would like to have the confidence intervals which qqPlot from the car package provides, but I can't figure out how to do this. Is there a way to provide my custom quintile function?

Xodarap
  • 11,581
  • 11
  • 56
  • 94
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Oct 08 '19 at 15:08
  • @MrFlick thanks, example is now reproducible (although please note that the example works as written – my question is about how to do the same thing but using `qqPlot` instead of `qqplot`) – Xodarap Oct 08 '19 at 22:40

1 Answers1

0

It turns out you also need to provide a density function:

  log_amount = runif(100)
  qmy_distribution = function(p) {
      return(qnorm(p, fit$estimate[1], fit$estimate[2]))
  }  
  dmy_distribution = function(p) {
    return(dnorm(p, fit$estimate[1], fit$estimate[2]))
  }
  expected = qmy_distribution(ppoints(length(log_amount)))
  qqPlot(log_amount, main = title, distribution = 'my_distribution',
         xlab = 'Predicted Quantiles', ylab = 'Actual Quantiles')
Xodarap
  • 11,581
  • 11
  • 56
  • 94