fit for truncated normal distribution

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

fit for truncated normal distribution

|Juergen Hedderich
Dear R-help list members,

the R Session aborted without any 'comment'  for the following 'small
example':

/library(fitdistrplus)
library(truncnorm)

filter <- c(4.98, 8.60, 6.37, 4.37, 8.03, 7.43, 6.83, 5.64, 5.43, 6.88,
             4.57, 7.50, 5.69, 7.88, 8.98, 6.79, 8.61, 6.70, 5.14, 7.29)

fit  <- fitdist(filter, "truncnorm", fix.arg=list(a=-Inf, b=9),
                 start=list(mean=mean(filter), sd=sd(filter)),
                 optim.method="L-BFGS-B",
                 lower=c(-0.1, -0.1), upper=c(Inf, Inf))/

R worked fine in an 'older'  R-version (environment). Can anyone help me?

Many thanks in advance.

Best regards

J. Hedderich


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: fit for truncated normal distribution

Bert Gunter-2
Inline.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Mar 14, 2020 at 10:36 AM |Juergen Hedderich <[hidden email]>
wrote:

> Dear R-help list members,
>
> the R Session aborted without any 'comment'  for the following 'small
> example':
>
> /library(fitdistrplus)
> library(truncnorm)
>
> filter <- c(4.98, 8.60, 6.37, 4.37, 8.03, 7.43, 6.83, 5.64, 5.43, 6.88,
>              4.57, 7.50, 5.69, 7.88, 8.98, 6.79, 8.61, 6.70, 5.14, 7.29)
>
> fit  <- fitdist(filter, "truncnorm", fix.arg=list(a=-Inf, b=9),
>                  start=list(mean=mean(filter), sd=sd(filter)),
>                  optim.method="L-BFGS-B",
>                  lower=c(-0.1, -0.1), upper=c(Inf, Inf))/
>
> R worked fine in an 'older'  R-version (environment). Can anyone help me?
>

I can't. But without including the specifics of the older and newer
software (including OS version, maybe), maybe no one can.
See ?sessionInfo



>
> Many thanks in advance.
>
> Best regards
>
> J. Hedderich
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: fit for truncated normal distribution

Peter Dalgaard-2
I see it in three different Mac builds, including a quite recent local R-devel build.

It boils down to this:

> dtruncnorm(numeric(0), mean=6.7, sd=1.38, a=-Inf, b=9)
Floating point exception: 8

which looks like a bug in the truncnorm package, where dtruncnorm() is unprepared for a zero-length argument.

(The indirect cause is fitdistrplus:::test1fun, which makes calls like the above.)

-pd

> On 14 Mar 2020, at 19:42 , Bert Gunter <[hidden email]> wrote:
>
> Inline.
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Sat, Mar 14, 2020 at 10:36 AM |Juergen Hedderich <[hidden email]>
> wrote:
>
>> Dear R-help list members,
>>
>> the R Session aborted without any 'comment'  for the following 'small
>> example':
>>
>> /library(fitdistrplus)
>> library(truncnorm)
>>
>> filter <- c(4.98, 8.60, 6.37, 4.37, 8.03, 7.43, 6.83, 5.64, 5.43, 6.88,
>>             4.57, 7.50, 5.69, 7.88, 8.98, 6.79, 8.61, 6.70, 5.14, 7.29)
>>
>> fit  <- fitdist(filter, "truncnorm", fix.arg=list(a=-Inf, b=9),
>>                 start=list(mean=mean(filter), sd=sd(filter)),
>>                 optim.method="L-BFGS-B",
>>                 lower=c(-0.1, -0.1), upper=c(Inf, Inf))/
>>
>> R worked fine in an 'older'  R-version (environment). Can anyone help me?
>>
>
> I can't. But without including the specifics of the older and newer
> software (including OS version, maybe), maybe no one can.
> See ?sessionInfo
>
>
>
>>
>> Many thanks in advance.
>>
>> Best regards
>>
>> J. Hedderich
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: fit for truncated normal distribution

R help mailing list-2
On Linux it says "Program received signal SIGFPE, Arithmetic exception".  I
think the only way to get a SIGFPE (floating point exception) any more (on
machines with IEEE floating point arithmetic) is taking an integer modulo
zero, which do_druncnorm does when length(x) is 0:
       const double cx = x[i % n_x];
Should R catch SIGFPE and turn it into an error condition?

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Sat, Mar 14, 2020 at 12:19 PM peter dalgaard <[hidden email]> wrote:

> I see it in three different Mac builds, including a quite recent local
> R-devel build.
>
> It boils down to this:
>
> > dtruncnorm(numeric(0), mean=6.7, sd=1.38, a=-Inf, b=9)
> Floating point exception: 8
>
> which looks like a bug in the truncnorm package, where dtruncnorm() is
> unprepared for a zero-length argument.
>
> (The indirect cause is fitdistrplus:::test1fun, which makes calls like the
> above.)
>
> -pd
>
> > On 14 Mar 2020, at 19:42 , Bert Gunter <[hidden email]> wrote:
> >
> > Inline.
> >
> > Bert Gunter
> >
> > "The trouble with having an open mind is that people keep coming along
> and
> > sticking things into it."
> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> > On Sat, Mar 14, 2020 at 10:36 AM |Juergen Hedderich <
> [hidden email]>
> > wrote:
> >
> >> Dear R-help list members,
> >>
> >> the R Session aborted without any 'comment'  for the following 'small
> >> example':
> >>
> >> /library(fitdistrplus)
> >> library(truncnorm)
> >>
> >> filter <- c(4.98, 8.60, 6.37, 4.37, 8.03, 7.43, 6.83, 5.64, 5.43, 6.88,
> >>             4.57, 7.50, 5.69, 7.88, 8.98, 6.79, 8.61, 6.70, 5.14, 7.29)
> >>
> >> fit  <- fitdist(filter, "truncnorm", fix.arg=list(a=-Inf, b=9),
> >>                 start=list(mean=mean(filter), sd=sd(filter)),
> >>                 optim.method="L-BFGS-B",
> >>                 lower=c(-0.1, -0.1), upper=c(Inf, Inf))/
> >>
> >> R worked fine in an 'older'  R-version (environment). Can anyone help
> me?
> >>
> >
> > I can't. But without including the specifics of the older and newer
> > software (including OS version, maybe), maybe no one can.
> > See ?sessionInfo
> >
> >
> >
> >>
> >> Many thanks in advance.
> >>
> >> Best regards
> >>
> >> J. Hedderich
> >>
> >>
> >>        [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: [hidden email]  Priv: [hidden email]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: fit for truncated normal distribution

Jeff Newmiller
Uh... yes?!

On March 14, 2020 2:22:14 PM PDT, William Dunlap via R-help <[hidden email]> wrote:

>On Linux it says "Program received signal SIGFPE, Arithmetic
>exception".  I
>think the only way to get a SIGFPE (floating point exception) any more
>(on
>machines with IEEE floating point arithmetic) is taking an integer
>modulo
>zero, which do_druncnorm does when length(x) is 0:
>       const double cx = x[i % n_x];
>Should R catch SIGFPE and turn it into an error condition?
>
>Bill Dunlap
>TIBCO Software
>wdunlap tibco.com
>
>
>On Sat, Mar 14, 2020 at 12:19 PM peter dalgaard <[hidden email]>
>wrote:
>
>> I see it in three different Mac builds, including a quite recent
>local
>> R-devel build.
>>
>> It boils down to this:
>>
>> > dtruncnorm(numeric(0), mean=6.7, sd=1.38, a=-Inf, b=9)
>> Floating point exception: 8
>>
>> which looks like a bug in the truncnorm package, where dtruncnorm()
>is
>> unprepared for a zero-length argument.
>>
>> (The indirect cause is fitdistrplus:::test1fun, which makes calls
>like the
>> above.)
>>
>> -pd
>>
>> > On 14 Mar 2020, at 19:42 , Bert Gunter <[hidden email]>
>wrote:
>> >
>> > Inline.
>> >
>> > Bert Gunter
>> >
>> > "The trouble with having an open mind is that people keep coming
>along
>> and
>> > sticking things into it."
>> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> >
>> >
>> > On Sat, Mar 14, 2020 at 10:36 AM |Juergen Hedderich <
>> [hidden email]>
>> > wrote:
>> >
>> >> Dear R-help list members,
>> >>
>> >> the R Session aborted without any 'comment'  for the following
>'small
>> >> example':
>> >>
>> >> /library(fitdistrplus)
>> >> library(truncnorm)
>> >>
>> >> filter <- c(4.98, 8.60, 6.37, 4.37, 8.03, 7.43, 6.83, 5.64, 5.43,
>6.88,
>> >>             4.57, 7.50, 5.69, 7.88, 8.98, 6.79, 8.61, 6.70, 5.14,
>7.29)
>> >>
>> >> fit  <- fitdist(filter, "truncnorm", fix.arg=list(a=-Inf, b=9),
>> >>                 start=list(mean=mean(filter), sd=sd(filter)),
>> >>                 optim.method="L-BFGS-B",
>> >>                 lower=c(-0.1, -0.1), upper=c(Inf, Inf))/
>> >>
>> >> R worked fine in an 'older'  R-version (environment). Can anyone
>help
>> me?
>> >>
>> >
>> > I can't. But without including the specifics of the older and newer
>> > software (including OS version, maybe), maybe no one can.
>> > See ?sessionInfo
>> >
>> >
>> >
>> >>
>> >> Many thanks in advance.
>> >>
>> >> Best regards
>> >>
>> >> J. Hedderich
>> >>
>> >>
>> >>        [[alternative HTML version deleted]]
>> >>
>> >> ______________________________________________
>> >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the posting guide
>> >> http://www.R-project.org/posting-guide.html
>> >> and provide commented, minimal, self-contained, reproducible code.
>> >>
>> >
>> >       [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> --
>> Peter Dalgaard, Professor,
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Office: A 4.23
>> Email: [hidden email]  Priv: [hidden email]
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: fit for truncated normal distribution

|Juergen Hedderich
Many thanks for all the helpful hints.

There is probably a bug in dtruncnorm() from library(truncnorm).

The workround with function dtnorm() from library(exactDistr) works fine!

/> //library(fitdistrplus); library(extraDistr) //Lade nötiges Paket:
MASS //Lade nötiges Paket: survival //Lade nötiges Paket: npsurv //Lade
nötiges Paket: lsei //> ////> ////> //filter <- c(4.98, 8.60, 6.37,
4.37, 8.03, 7.43, 6.83, 5.64, 5.43, 6.88, //+ //4.57, 7.50, 5.69, 7.88,
8.98, 6.79, 8.61, 6.70, 5.14, 7.29) //> ////> //fit <- fitdist(filter,
dtnorm, fix.arg=list(a=-Inf, b=9), //+ //start=list(mean=mean(filter),
sd=sd(filter)), //+ //optim.method="L-BFGS-B", //+ //lower=c(-0.1,
-0.1), upper=c(Inf, Inf)) //> //summary(fit) //Fitting of the
distribution ' tnorm ' by maximum likelihood Parameters : estimate Std.
Error mean 7.036644 0.5592341 sd 1.622802 0.4099704/ Best regards J.
Hedderich


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.