3

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)    
  • 1
    `fitinvgauss <- fitdist(RTtotal, "invgauss", start = list(mu=776, delta=314, delta=0.007, beta=-0.05))` you're passing `delta` twice and not passing `alpha`. Is this mistake in your code, or was it just a typo in the question? – mikeck Aug 22 '19 at 23:49
  • We don't have `RTtotal` and I cannot seen any distribution named "invgauss" in base packages or in the package you loaded. Voting to close as not reproducible error. Please read [ask]. – IRTFM Aug 22 '19 at 23:57
  • @mikeck sorry, it was a typo here. –  Aug 23 '19 at 00:32
  • @42- i added a sample of RTtotal that produces the same error. also fitdist() from the library fitdistrplus should be able to work with inverse gaussian as long as we provide the start parameteres, or this is what i got from its help. –  Aug 23 '19 at 00:34
  • Yes, `fitdist` can work with the inverse gaussian but you need to give it a correct name. My point was that I was unable to find any functions that might use that name. Instead I found `inverse.gaussian" and "gig" as possible names. Perhaps this question should be closed as just a typo? – IRTFM Aug 23 '19 at 00:52
  • Even without RTtotal being defined the first error that interupts execution is nte lack of the proper distribution family: "`Error in fitdist(RTtotal, "invgauss", start = list(mu = 776, delta = 314, : The dinvgauss function must be defined`" – IRTFM Aug 23 '19 at 01:13
  • @42- it wasn't a typo i'd looked it up and couldn't find any alternative name except for nig which didn't work either. also i tried and neither of the names you suggested helped. thank you anyway –  Aug 23 '19 at 01:14
  • You cannot just make up names that you think might work. You need to identify a proper distribution "family". See `?family` – IRTFM Aug 23 '19 at 01:15
  • @42- i didn't have to make it up, the function dinvgauss{rmutil} exists and distr "is acharacter string naming a distribution for which the corresponding density function dname exists" so it seemed like it should work –  Aug 23 '19 at 01:24
  • Well, it does "exist" on my system and I have both of the packages you cited. You apparently have an unnamed package also loaded that you haven't told us about. – IRTFM Aug 23 '19 at 01:31
  • Please include all dependencies in your original question. – Roman Luštrik Aug 24 '19 at 07:24
  • A while back a new user post a not-an-answer hoping to get visibility for “ May I ask you for the reference that the invGauss suits RT distributions better?” – IRTFM Feb 01 '22 at 07:36

1 Answers1

2

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.)

IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • Thanks for your help! (i didn't have the statmod package installed, and i wasn't aware the rmutil package which included the dinvgauss function was loaded on my system until you asked.) –  Aug 23 '19 at 01:59