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 6999453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:32:35+00:00 2026-05-27T20:32:35+00:00

I am using the fitdist function in the fitdistrplus package in R. I have

  • 0

I am using the fitdist function in the fitdistrplus package in R.
I have the following data (that I read using read.table):

A <- structure(list(V1 = c(-0.00707717, -0.000947418, -0.00189753, 
-0.000474947, -0.00190205, -0.000476077, 0.00237812, 0.000949668, 
0.000474496, 0.00284226, -0.000473149, -0.000473373, 0, 0, 0.00283688, 
-0.0037843, -0.0047506, -0.00238379, -0.00286807, 0.000478583, 
0.000478354, -0.00143575, 0.00143575, 0.00238835, 0.0042847, 
0.00237248, -0.00142281, -0.00142484, 0, 0.00142484, 0.000948767, 
0.00378609, -0.000472478, 0.000472478, -0.0014181, 0, -0.000946522, 
-0.00284495, 0, 0.00331832, 0.00283554, 0.00141476, -0.00141476, 
-0.00188947, 0.00141743, -0.00236351, 0.00236351, 0.00235794, 
0.00235239, -0.000940292, -0.0014121, -0.00283019, 0.000472255, 
0.000472032, 0.000471809, -0.0014161, 0.0014161, -0.000943842, 
0.000472032, -0.000944287, -0.00094518, -0.00189304, -0.000473821, 
-0.000474046, 0.00331361, -0.000472701, -0.000946074, 0.00141878, 
-0.000945627, -0.00189394, -0.00189753, -0.0057143, -0.00143369, 
-0.00383326, 0.00143919, 0.000479272, -0.00191847, -0.000480192, 
0.000960154, 0.000479731, 0, 0.000479501, 0.000958313, -0.00383878, 
-0.00240674, 0.000963391, 0.000962464, -0.00192586, 0.000481812, 
-0.00241138, -0.00144963)), .Names = "V1", row.names = c(NA, 
-91L), class = "data.frame")

I ran the following command:

fitdist(A$V1,"norm",method="mge",gof="CvM")

and it generates the following:

Fitting of the distribution ' norm ' by maximum goodness-of-fit 
Parameters:
  estimate
1       NA
2       NA
Warning message:
In pnorm(q, mean, sd, lower.tail, log.p) : NaNs produced

given the above error message, I ran the below:

> mu=mean(A$V1)
> sigma=sd(A$V1)
> mu
[1] -0.0003091273
> sigma
[1] 0.002051825
> pnorm(A$V1,mu,sigma)
 [1] 0.0004859313 0.3778682282 0.2194235651 0.4677942525 0.2187728328
 [6] 0.4675752645 0.9048490462 0.7302272325 0.6487379052 0.9377179215
[11] 0.4681427154 0.4680993016 0.5598779146 0.5598779146 0.9373956798
[16] 0.0451612910 0.0152074342 0.1559769817 0.1061704134 0.6494763806
[21] 0.6494350178 0.2914741494 0.8024493726 0.9056899734 0.9874187360
[26] 0.9043830715 0.2936417791 0.2933012328 0.5598779146 0.8009684336
[31] 0.7300820807 0.9770270687 0.4682727654 0.6483730677 0.2944326177
[36] 0.5598779146 0.3780342225 0.1082503682 0.5598779146 0.9614622560
[41] 0.9373152170 0.7995942319 0.2949940199 0.2205866970 0.7999587855
[46] 0.1583537921 0.9036385181 0.9031740418 0.9027096003 0.3791890228
[51] 0.2954414771 0.1095934742 0.6483327428 0.6482924162 0.6482520879
[56] 0.2947687275 0.7997772412 0.3785308577 0.6482924162 0.3784483801
[61] 0.3782828856 0.2200710780 0.4680124750 0.4679688685 0.9612699580
[66] 0.4682295443 0.3781172281 0.8001429585 0.3782000541 0.2199411992
[71] 0.2194235651 0.0042152418 0.2918187280 0.0429384302 0.8029149383
[76] 0.6496008197 0.2164182554 0.4667778828 0.7319136560 0.6496837100
[81] 0.5598779146 0.6496421754 0.7316179594 0.0426934572 0.1533157552
[86] 0.7324331764 0.7322844499 0.2153633562 0.6500594259 0.1527813896
[91] 0.2891573876

So now I am confused why I got the above error message regarding NaN. Anyone have any suggestions what might be the reason and the fix?

for the cauchy distribution, I have tried the following:

`> fitdist(A$V1*10^9,"cauchy",method="mle")
Error in fitdist(A$V1 * 10^9, "cauchy", method = "mle") : 
  the function mle failed to estimate the parameters, 
                with the error code 100
In addition: Warning message:
In dcauchy(x, location, scale, log) : NaNs produced
> fitdist(A$V1*10^5,"cauchy",method="mle")
Error in fitdist(A$V1 * 10^5, "cauchy", method = "mle") : 
  the function mle failed to estimate the parameters, 
                with the error code 100
In addition: Warning message:
In dcauchy(x, location, scale, log) : NaNs produced
> fitdist(A$V1*10^5,"cauchy",method="mge",gof="CvM")
Fitting of the distribution ' cauchy ' by maximum goodness-of-fit 
Parameters:
  estimate
1       NA
2       NA
Warning message:
In pcauchy(q, location, scale, lower.tail, log.p) : NaNs produced
> fitdist(A$V1*10^5,"cauchy",method="mge",gof="AD")
Fitting of the distribution ' cauchy ' by maximum goodness-of-fit 
Parameters:
  estimate
1       NA
2       NA
Warning message:
In pcauchy(q, location, scale, lower.tail, log.p) : NaNs produced
> fitdist(A$V1*10^9,"cauchy",method="mge",gof="AD")
Fitting of the distribution ' cauchy ' by maximum goodness-of-fit 
Parameters:
  estimate
1       NA
2       NA
Warning message:
In pcauchy(q, location, scale, lower.tail, log.p) : NaNs produced
> fitdist(A$V1+10^3,"cauchy",method="mle")
Error in fitdist(A$V1 + 10^3, "cauchy", method = "mle") : 
  the function mle failed to estimate the parameters, 
                with the error code 100
In addition: Warning message:
In dcauchy(x, location, scale, log) : NaNs produced

Any suggestions on the fix for this…thanks!

  • 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-05-27T20:32:35+00:00Added an answer on May 27, 2026 at 8:32 pm

    Answer below.

    library(fitdistrplus)
    
    
    A <- structure(list(V1 = c(-0.00707717, -0.000947418, -0.00189753, 
    -0.000474947, -0.00190205, -0.000476077, 0.00237812, 0.000949668, 
    0.000474496, 0.00284226, -0.000473149, -0.000473373, 0, 0, 0.00283688, 
    -0.0037843, -0.0047506, -0.00238379, -0.00286807, 0.000478583, 
    0.000478354, -0.00143575, 0.00143575, 0.00238835, 0.0042847, 
    0.00237248, -0.00142281, -0.00142484, 0, 0.00142484, 0.000948767, 
    0.00378609, -0.000472478, 0.000472478, -0.0014181, 0, -0.000946522, 
    -0.00284495, 0, 0.00331832, 0.00283554, 0.00141476, -0.00141476, 
    -0.00188947, 0.00141743, -0.00236351, 0.00236351, 0.00235794, 
    0.00235239, -0.000940292, -0.0014121, -0.00283019, 0.000472255, 
    0.000472032, 0.000471809, -0.0014161, 0.0014161, -0.000943842, 
    0.000472032, -0.000944287, -0.00094518, -0.00189304, -0.000473821, 
    -0.000474046, 0.00331361, -0.000472701, -0.000946074, 0.00141878, 
    -0.000945627, -0.00189394, -0.00189753, -0.0057143, -0.00143369, 
    -0.00383326, 0.00143919, 0.000479272, -0.00191847, -0.000480192, 
    0.000960154, 0.000479731, 0, 0.000479501, 0.000958313, -0.00383878, 
    -0.00240674, 0.000963391, 0.000962464, -0.00192586, 0.000481812, 
    -0.00241138, -0.00144963)), .Names = "V1", row.names = c(NA, 
    -91L), class = "data.frame")
    
    #your data are very small 
    summary(A$V1)
    
    #fit dist does not converge with parameter
    fitdist(A$V1,"norm",method="mge",gof="CvM")
    
    #arguments are correctly specified
    ?fitdist
    
    #equivalent call of mgedist -> same problem
    mgedist(A$V1,"norm",gof="CvM")
    
    #with uniform distribution it works
    fitdist(A$V1,"unif",method="mge")
    
    #as well as with mme and mle
    fitdist(A$V1,"norm",method="mme")
    fitdist(A$V1,"norm",method="mle")
    
    #so the problem comes with the mean or the sd parameters of the normal distribution.
    #as returns a result, sd is the problem
    mgedist(A$V1,"norm",gof="CvM", fix.arg=list(sd=sd(A$V1)), start=list(mean=0))
    
    #fixing a lower bound for sd returns a result
    mgedist(A$V1,"norm",gof="CvM", lower=c(-1, .01))
    
    #but the appropriate answer to your problem is to rescale your data.
    #it works perfectly.
    mgedist(1000*A$V1,"norm",gof="CvM", lower=c(-1, 1e-3))
    #we don't even need to use lower bounds.
    mgedist(1000*A$V1,"norm",gof="CvM")
    
    
    #looking at the source code of mgedist, one can see, that the distance
    #of Cramer von Mises is defined as follows.
    fnobj <- function(par, fix.arg, obs, pdistnam) {
                    n <- length(obs)
                    s <- sort(obs)
                    theop <- do.call(pdistnam, c(list(q = s), as.list(par), 
                      as.list(fix.arg)))
                    1/(12 * n) + sum((theop - (2 * seq(1:n) - 1)/(2 * 
                      n))^2)
                }
    
    #a NaN is produced with negative sd            
    fnobj(c(1,1), NULL, A$V1, pnorm)
    fnobj(c(mean=1,sd=1), NULL, A$V1, pnorm)
    fnobj(c(mean=0,sd=0), NULL, A$V1, pnorm)
    fnobj(c(mean=0,sd=-1), NULL, A$V1, pnorm)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using Core Data, I have a fetch request to fetch the minimum of a
Using report builder 3.0, I have a report that queries a cube. How do
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
Using CRM 4, I have an entity form that contains a tab with an
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C#, I need a class called User that has a username, password, active
Using android 2.3.3, I have a background Service which has a socket connection. There's

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.