# Roughly estimating parameters for an assumed distribution # Apr.27,2004, by Minato NAKAZAWA # Sample size should be set as N N <- 1000 # Data should be set as x # here, parameters 1 and 2 are in fact unknown x <- rweibull(N,1,2) # Calculating cumulative distribution cx <- qqplot(x,1:N/N,plot=F) # Obtaining the shape parameter as a, the scale parameter as b # by nonlinear regression. User must state start by intuition. nls(y ~ pweibull(x,a,b), data=cx, start=list(a=0.5,b=1.5)) # Alternatively, function optim() can be used, but the result was worse. # fr <- function(x) { (cx$y-pweibull(cx$x,x[1],x[2]))^2 } # optim(c(0.5,1.5),fr)