我尝试为毛刺 x 分布绘制 qqplot。编码没问题。为什么画不出来

I try to draw a qqplot for burr x distribution. coding is ok. why can't draw it?

这是我的毛刺X型分布的qqplot程序。我知道编码是对的,但我不明白为什么我不能运行 plot?

burrx.loglike <- function(params, x)
{
theta <- params[1]
sigma <- params[2]
n <- length(x)

if (theta <= 0 || sigma <= 0)
{
 ans <- -Inf
}
else
{
ans <- (n*log(2) + sum(log(x)) + n*log(theta) - 2*n*log(sigma)
        - sum(x^2)/sigma^2 + (theta-1)*sum(log(1-exp(-1*(x/sigma)^2))))
}

return(ans)
}


burrx.mle2 <- function(x, par0=c(1,1))
{
 temp.mle <- optim(par0, burrx.loglike, x=x, method="Nelder-Mead", control=list(fnscale=-1))
return(temp.mle)
}

qqburrx <- function(x, theta, sigma, use.mle=TRUE)
{
 # Check to see if we calculate the MLE.
  if(use.mle == TRUE)
{
  par0 <- c(theta,sigma)
temp.mle <- burrx.mle2(x, par0)
theta <- temp.mle$par[1]
sigma <- temp.mle$par[2]
}

# Sample Quantiles
x.sort <- sort(x)

 # Theoretical Quantiles
n <- length(x)
i <- 1:n
x.quantiles <- qburrx(q=i/(n+1), theta=theta, sigma=sigma)

# Plot the data.
  plot.min <- min(x.sort, x.quantiles)
 plot.max <- max(x.sort, x.quantiles)

plot(x.quantiles, x.sort,
      main="Burr type X Q-Q Plot\nNote: For the BurrX to be appropriate,data must fall near the 40deg line.",
     xlab="Theoretical Quantiles", ylab="Sample Quantiles",
     xlim=c(plot.min,plot.max), ylim=c(plot.min,plot.max))

# Add 45-degree line
line.coord <- c(plot.min, plot.max)
lines(line.coord, line.coord)

}

基本上我是r的初学者。可能是我在输入参数的时候出错了。

只需使用

 qqburrx(1:2000,2,1,use.mle=TRUE)

根据您的参数将 x 更改为 a:b。