Estimating the parameters of a weibull distribution to two data sets simultaneously in R

429 Views Asked by At

I´m trying to estimate the parameters of a 3-parameter weibull distribution (translation parameter beta= -0.5). The problem is that I have to fit two sets of data simultaneously. Using nlc (see code below) i was able to estimate the parameters of the distribution for each set of data individually, but not simultaneously. GAMMA is something like a shared parameter (the estimated GAMMA has to be the same in both nlc estimations).

My data looks like this:

x = seq(from =0, to =10, by =1)
y = c(0.1315, 0.2368, 0.2631, 0.1578, 0.1578, 0.0000, 0.0526, 0.0000, 0.0000, 0.0000, 0.0000)
z = c(0.3684, 0.3157, 0.2105, 0.0789, 0.0263, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)

And this is my code

# WEIBULL FUNCTION WITH ALPHA_GS and beta=-0.5
weibull_GS = function(x, GAMMA, ALPHA_GS){
  (GAMMA/ALPHA_GS)*(((x-(-0.5))/ALPHA_GS)^(GAMMA-1))*exp(-((x-(-0.5))/ALPHA_GS)^GAMMA)
}

#ESTIMATE ALPHA_GS
nlc <- nls.control(maxiter=100)
n <- nls(y ~ weibull_GS(x, GAMMA, ALPHA_GS), control="nlc",
         start = list(GAMMA=2, ALPHA_GS=3), trace=T, model=F)

summary(n)

# WEIBULL FUNCTION WITH ALPHA_GA beta=-0.5
weibull_GA = function(x, GAMMA, ALPHA_GA){
  (GAMMA/ALPHA_GA)*(((x-(-0.5))/ALPHA_GA)^(GAMMA-1))*exp(-((x-(-0.5))/ALPHA_GA)^GAMMA)
}

# ESTIMATE ALPHA_GA
nlc <- nls.control(maxiter=100)
m <- nls(z ~ weibull_GA(x, GAMMA, ALPHA_GA), control="nlc",
         start = list(GAMMA=2, ALPHA_GA=3), trace=T, model=F)

summary(m)
1

There are 1 best solutions below

0
On BEST ANSWER

What you are doing is fitting a nonlinear regression model y = f(x) + error with f the density function of a Weibull distribution. This has nothing to do with fitting a Weibull distribution to the sample.

If this is really what you want to do, here is how to answer your question:

f <- function(x1, x2, GAMMA, ALPHA_GS, ALPHA_GA){
  c(weibull_GS(x1, GAMMA, ALPHA_GS), weibull_GA(x2, GAMMA, ALPHA_GA))
}
Sample <- c(y, z)
nls(Sample ~ f(x, x, GAMMA, ALPHA_GS, ALPHA_GA), ......)