简体   繁体   中英

How to fit an inverse guassian distribution to my data, preferably using fitdist {fitdistrplus}

I am trying to analyze some Reaction Time data using GLMM. to find a distribution that fits my data best.I used fitdist() for gamma and lognormal distributions. the results showed that lognormal fits my data better. However, recently i read that the inverse gaussian distribution might be a better fit for reaction time data.

I used nigFitStart to obtain the start values:

    library(GeneralizedHyperbolic)
    invstrt <- nigFitStart(RTtotal, startValues = "FN")

which gave me this:

    $paramStart
       mu         delta         alpha          beta 
    775.953984862 314.662306398   0.007477984  -0.004930604 

so i tried using the start parameteres for fitdist:

    require(fitdistrplus)

    fitinvgauss <- fitdist(RTtotal, "invgauss", start = list(mu=776, delta=314, alpha=0.007, beta=-0.05))

but i get the following error:

    Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg,  : 
    'start' must specify names which are arguments to 'distr'.

i also used ig_fit{goft} and got the following results:

    Inverse Gaussian MLE 
    mu                   775.954
    lambda              5279.089

so, this time i used these two parameters for the start argument in fitdist and still got the exact same error:

    > fitinvgauss <- fitdist(RTtotal, "invgauss", start = list(mu=776, lambda=5279))
    Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg,  : 
     'start' must specify names which are arguments to 'distr'. 

someone had mentioned that changing the parametere names from mu and lambda to mean and shape had solved their problem, but i tried it and still got the same error.

Any idea how i can fix this? or could you suggest an alternative way to fit inverse gaussian to my data?

thank you

    dput(RTtotal)
    c(594.96, 659.5, 706.14, 620.92, 811.05, 420.63, 457.08, 585.53, 
    488.59, 484.87, 496.72, 769.01, 458.92, 521.76, 889.08, 514.11, 
    553.09, 564.68, 1057.19, 437.79, 660.33, 639.58, 643.45, 419.47, 
    469.16, 457.78, 530.58, 538.73, 557.17, 1140.09, 560.03, 543.18, 
    1093.29, 607.59, 430.2, 712.06, 716.6, 566.69, 989.71, 449.96, 
    653.22, 556.52, 654.8, 472.54, 600.26, 548.36, 597.51, 471.97, 
    596.72, 600.29, 706.77, 511.6, 475.89, 599.13, 570.12, 767.57, 
    402.68, 601.56, 610.02, 891.95, 483.22, 588.78, 505.95, 554.15, 
    445.54, 489.02, 678.13, 532.06, 652.61, 654.79, 535.08, 1215.66, 
    633.6, 645.92, 454.37, 535.81, 508.97, 690.78, 685.97, 703.04, 
    731.99, 592.75, 662.03, 1400.33, 599.73, 1021.34, 1232.35, 855.1, 
    780.32, 554.4, 1965.77, 841.89, 1262.76, 721.62, 788.95, 1104.24, 
    1237.4, 1193.04, 513.91, 474.74, 380.56, 570.63, 700.96, 380.89, 
    481.96, 723.63, 835.22, 781.1, 468.76, 555.1, 522.22, 944.29, 
    541.06, 559.18, 738.68, 880.58, 500.14, 1856.97, 1001.59, 703.7, 
    1022.35, 1813.35, 1128.73, 864.75, 1166.77, 1220.4, 776.56, 2073.72, 
    1223.88, 617, 1387.71, 595.57, 1506.13, 678.41, 1797.87, 2111.04, 
    1116.61, 1038.6, 894.25, 778.51, 908.51, 1346.69, 989.09, 1334.17, 
    877.31, 649.31, 978.22, 1276.84, 1001.58, 1049.66, 1131.83, 700.8, 
    1267.21, 693.52, 1182.3)    

So I'm guessing that you failed to tell us that you also have the statmod -package loaded (or perhaps some other package with a 'invgauss'-family including a dinvgauss function). You should be able to tell which package dinvgauss comes from by reading the top line of the help page for the function, So after installing that package and reading the help page (which one should ALWAYS do) for ?dinvgauss :

fitinvgauss <- fitdist(RTtotal, "invgauss", 
                                 start = list(mean=776, dispersion=314, shape=1))
fitinvgauss
# --------------
Fitting of the distribution ' invgauss ' by maximum likelihood 
Parameters:
             estimate Std. Error
mean         779.2535         NA
dispersion -1007.5490         NA
shape       4972.5745         NA

All I did was read the error message and then read the help page and use the correct names for that function's parameters. (And then play around a bit to get the parameter starting values into the feasible range of values.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM