Evaluating the hazard function when the CDF is close to 1?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
4
down vote

favorite












I need to evaluate a hazard function $h(t;theta) = dfracf(t;theta)1-F(t;theta)$, where $f$ and $F$ are a pdf and a cdf, respectively, at many values of $t$ (and for several values of the parameter $theta$). In some cases, when I evaluate $F(t;theta)$, it returns the value $1$ for some values of $t$, making $h$ infinite.



For example, in R pweibull(100,1,1) returns 1.



Is there any trick to avoid this problem?



  • I wasn't sure if I should ask this question on stackoverflow instead, but since the question is related to a function that is widely used in statistics, I thought crossvalidated was a better place as some people may know of a "classical" solution.









share|cite|improve this question









New contributor




Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    up vote
    4
    down vote

    favorite












    I need to evaluate a hazard function $h(t;theta) = dfracf(t;theta)1-F(t;theta)$, where $f$ and $F$ are a pdf and a cdf, respectively, at many values of $t$ (and for several values of the parameter $theta$). In some cases, when I evaluate $F(t;theta)$, it returns the value $1$ for some values of $t$, making $h$ infinite.



    For example, in R pweibull(100,1,1) returns 1.



    Is there any trick to avoid this problem?



    • I wasn't sure if I should ask this question on stackoverflow instead, but since the question is related to a function that is widely used in statistics, I thought crossvalidated was a better place as some people may know of a "classical" solution.









    share|cite|improve this question









    New contributor




    Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I need to evaluate a hazard function $h(t;theta) = dfracf(t;theta)1-F(t;theta)$, where $f$ and $F$ are a pdf and a cdf, respectively, at many values of $t$ (and for several values of the parameter $theta$). In some cases, when I evaluate $F(t;theta)$, it returns the value $1$ for some values of $t$, making $h$ infinite.



      For example, in R pweibull(100,1,1) returns 1.



      Is there any trick to avoid this problem?



      • I wasn't sure if I should ask this question on stackoverflow instead, but since the question is related to a function that is widely used in statistics, I thought crossvalidated was a better place as some people may know of a "classical" solution.









      share|cite|improve this question









      New contributor




      Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I need to evaluate a hazard function $h(t;theta) = dfracf(t;theta)1-F(t;theta)$, where $f$ and $F$ are a pdf and a cdf, respectively, at many values of $t$ (and for several values of the parameter $theta$). In some cases, when I evaluate $F(t;theta)$, it returns the value $1$ for some values of $t$, making $h$ infinite.



      For example, in R pweibull(100,1,1) returns 1.



      Is there any trick to avoid this problem?



      • I wasn't sure if I should ask this question on stackoverflow instead, but since the question is related to a function that is widely used in statistics, I thought crossvalidated was a better place as some people may know of a "classical" solution.






      r cdf hazard






      share|cite|improve this question









      New contributor




      Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|cite|improve this question









      New contributor




      Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|cite|improve this question




      share|cite|improve this question








      edited just now









      Ferdi

      3,47842151




      3,47842151






      New contributor




      Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 27 mins ago









      Hazardous

      211




      211




      New contributor




      Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Hazardous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          If the matter is numerical stability, you could look at the log of the hazard function:



          $$log(h(t; theta)) = log(f(t;theta)) - log(1-F(t;theta))$$



          You could use the log / log.p = TRUE flag in R for log values and the lower.tail flag for obtaining $log(1 - F(t;theta))$ values:



          dweibull(100,1,1, log = T) # -100
          pweibull(100, 1, 1, log.p = TRUE, lower.tail = FALSE) # -100


          Which gives you an estimate: $h(t;theta) = exp(-100 + 100) = 1$




          Edit: By the way, when you have a $Weibull(1, 1)$ distribution, I believe that this is an $Exponential(1)$, so it has a constant hazard function.






          share|cite|improve this answer






















            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "65"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            Hazardous is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f371987%2fevaluating-the-hazard-function-when-the-cdf-is-close-to-1%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            If the matter is numerical stability, you could look at the log of the hazard function:



            $$log(h(t; theta)) = log(f(t;theta)) - log(1-F(t;theta))$$



            You could use the log / log.p = TRUE flag in R for log values and the lower.tail flag for obtaining $log(1 - F(t;theta))$ values:



            dweibull(100,1,1, log = T) # -100
            pweibull(100, 1, 1, log.p = TRUE, lower.tail = FALSE) # -100


            Which gives you an estimate: $h(t;theta) = exp(-100 + 100) = 1$




            Edit: By the way, when you have a $Weibull(1, 1)$ distribution, I believe that this is an $Exponential(1)$, so it has a constant hazard function.






            share|cite|improve this answer


























              up vote
              2
              down vote













              If the matter is numerical stability, you could look at the log of the hazard function:



              $$log(h(t; theta)) = log(f(t;theta)) - log(1-F(t;theta))$$



              You could use the log / log.p = TRUE flag in R for log values and the lower.tail flag for obtaining $log(1 - F(t;theta))$ values:



              dweibull(100,1,1, log = T) # -100
              pweibull(100, 1, 1, log.p = TRUE, lower.tail = FALSE) # -100


              Which gives you an estimate: $h(t;theta) = exp(-100 + 100) = 1$




              Edit: By the way, when you have a $Weibull(1, 1)$ distribution, I believe that this is an $Exponential(1)$, so it has a constant hazard function.






              share|cite|improve this answer
























                up vote
                2
                down vote










                up vote
                2
                down vote









                If the matter is numerical stability, you could look at the log of the hazard function:



                $$log(h(t; theta)) = log(f(t;theta)) - log(1-F(t;theta))$$



                You could use the log / log.p = TRUE flag in R for log values and the lower.tail flag for obtaining $log(1 - F(t;theta))$ values:



                dweibull(100,1,1, log = T) # -100
                pweibull(100, 1, 1, log.p = TRUE, lower.tail = FALSE) # -100


                Which gives you an estimate: $h(t;theta) = exp(-100 + 100) = 1$




                Edit: By the way, when you have a $Weibull(1, 1)$ distribution, I believe that this is an $Exponential(1)$, so it has a constant hazard function.






                share|cite|improve this answer














                If the matter is numerical stability, you could look at the log of the hazard function:



                $$log(h(t; theta)) = log(f(t;theta)) - log(1-F(t;theta))$$



                You could use the log / log.p = TRUE flag in R for log values and the lower.tail flag for obtaining $log(1 - F(t;theta))$ values:



                dweibull(100,1,1, log = T) # -100
                pweibull(100, 1, 1, log.p = TRUE, lower.tail = FALSE) # -100


                Which gives you an estimate: $h(t;theta) = exp(-100 + 100) = 1$




                Edit: By the way, when you have a $Weibull(1, 1)$ distribution, I believe that this is an $Exponential(1)$, so it has a constant hazard function.







                share|cite|improve this answer














                share|cite|improve this answer



                share|cite|improve this answer








                edited 7 mins ago

























                answered 13 mins ago









                InfProbSciX

                44910




                44910




















                    Hazardous is a new contributor. Be nice, and check out our Code of Conduct.









                     

                    draft saved


                    draft discarded


















                    Hazardous is a new contributor. Be nice, and check out our Code of Conduct.












                    Hazardous is a new contributor. Be nice, and check out our Code of Conduct.











                    Hazardous is a new contributor. Be nice, and check out our Code of Conduct.













                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f371987%2fevaluating-the-hazard-function-when-the-cdf-is-close-to-1%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery