Home:ALL Converter>Estimating the parameters of a weibull distribution to two data sets simultaneously in R

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

Ask Time:2021-04-25T22:17:21         Author:schlukki99

Json Formatter

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)

Author:schlukki99,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/67254355/estimating-the-parameters-of-a-weibull-distribution-to-two-data-sets-simultaneou
yy