Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:22:43+00:00 2026-06-09T11:22:43+00:00

I have been doing some data analysis in R and I am trying to

  • 0

I have been doing some data analysis in R and I am trying to figure out how to fit my data to a 3 parameter Weibull distribution. I found how to do it with a 2 parameter Weibull but have come up short in finding how to do it with a 3 parameter.

Here is how I fit the data using the fitdistr function from the MASS package:

y <- fitdistr(x[[6]], 'weibull')

x[[6]] is a subset of my data and y is where I am storing the result of the fitting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:22:44+00:00Added an answer on June 9, 2026 at 11:22 am

    First, you might want to look at FAdist package. However, that is not so hard to go from rweibull3 to rweibull:

    > rweibull3
    function (n, shape, scale = 1, thres = 0) 
    thres + rweibull(n, shape, scale)
    <environment: namespace:FAdist>
    

    and similarly from dweibull3 to dweibull

    > dweibull3
    function (x, shape, scale = 1, thres = 0, log = FALSE) 
    dweibull(x - thres, shape, scale, log)
    <environment: namespace:FAdist>
    

    so we have this

    > x <- rweibull3(200, shape = 3, scale = 1, thres = 100)
    > fitdistr(x, function(x, shape, scale, thres) 
           dweibull(x-thres, shape, scale), list(shape = 0.1, scale = 1, thres = 0))
          shape          scale          thres    
        2.42498383     0.85074556   100.12372297 
     (  0.26380861) (  0.07235804) (  0.06020083)
    

    Edit: As mentioned in the comment, there appears various warnings when trying to fit the distribution in this way

    Error in optim(x = c(60.7075705026659, 60.6300379017397, 60.7669410153573,  : 
      non-finite finite-difference value [3]
    There were 20 warnings (use warnings() to see them)
    Error in optim(x = c(60.7075705026659, 60.6300379017397, 60.7669410153573,  : 
      L-BFGS-B needs finite values of 'fn'
    In dweibull(x, shape, scale, log) : NaNs produced
    

    For me at first it was only NaNs produced, and that is not the first time when I see it so I thought that it isn’t so meaningful since estimates were good. After some searching it seemed to be quite popular problem and I couldn’t find neither cause nor solution. One alternative could be using stats4 package and mle() function, but it seemed to have some problems too. But I can offer you to use a modified version of code by danielmedic which I have checked a few times:

    thres <- 60
    x <- rweibull(200, 3, 1) + thres
    
    EPS = sqrt(.Machine$double.eps) # "epsilon" for very small numbers
    
    llik.weibull <- function(shape, scale, thres, x)
    { 
      sum(dweibull(x - thres, shape, scale, log=T))
    }
    
    thetahat.weibull <- function(x)
    { 
      if(any(x <= 0)) stop("x values must be positive")
    
      toptim <- function(theta) -llik.weibull(theta[1], theta[2], theta[3], x)
    
      mu = mean(log(x))
      sigma2 = var(log(x))
      shape.guess = 1.2 / sqrt(sigma2)
      scale.guess = exp(mu + (0.572 / shape.guess))
      thres.guess = 1
    
      res = nlminb(c(shape.guess, scale.guess, thres.guess), toptim, lower=EPS)
    
      c(shape=res$par[1], scale=res$par[2], thres=res$par[3])
    }
    
    thetahat.weibull(x)
        shape     scale     thres 
     3.325556  1.021171 59.975470 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing some unsafe bitmap operations and have found out that increasing
I have been doing some customization to this jQuery paging script I found here
I have been trying to think of a way to retrieve some data from
I'm not a WinForms developer, but have been doing ASP.NET for quite some time.
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
I have been doing some research lately over my work project, i am trying
I have been trying to access some data from a website. I have been
I have been doing some research on test driven development and find it pretty
I have been doing some research for using MSMQ. Following 2 gave me fundamental
I have been doing some x86 programming in Windows with NASM and I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.