0
$\begingroup$

Does Maximum Likelihood Estimation Require the Data to be "Scaled"?

For instance, suppose I have the following data in R:

x <- c(3631, 1681, 188, 1065, 733, 643, 2001, 714, 180, 5147, 2541, 
1048, 643, 1356, 270, 4396, 358, 4025, 2004, 1879, 2342, 4138, 
616, 3161, 4904, 4320, 215, 79, 5431, 6551, 97, 889, 6009, 992, 
1487, 336, 840, 612, 769, 680, 5840, 603, 2581, 4087, 2241, 129, 
2366, 3856, 980, 1315, 1050, 7002, 36, 511, 529, 534, 3037, 1123, 
3889, 4611, 2577, 3953, 517, 774, 923, 295, 3152, 524, 714, 5135, 
2529, 1561, 6105, 4305, 3633, 1164, 1663, 791, 11, 225, 940, 
172, 4936, 348, 3410, 3205, 6827, 3846, 1809, 6580, 61, 892, 
4525, 523, 595, 3594, 2245, 999, 343, 856, 106, 1513, 224, 324, 
6725, 323, 2221, 6455, 3955, 3580, 532, 775, 3022, 3049, 1086, 
613, 2866, 4799, 158, 869, 2510, 149, 1809, 2772, 5474, 1096, 
5668, 381, 2428, 428, 308, 932, 1868, 490, 10163, 12, 671, 1676, 
536, 1940, 686, 1590, 5749, 1257, 1389, 3209, 562, 2504, 129, 
1617, 4058, 521, 2541, 57, 10747, 1795, 566, 3290, 372, 5624, 
1229, 252, 257, 1971, 707, 8036, 2934, 466, 378, 675, 1551, 2320, 
248, 2871, 4747, 2987, 6555, 369, 378, 443, 397, 7653, 1471, 
174, 764, 585, 291, 703, 440, 1808, 83, 3346, 2384, 2693, 52, 
678, 1320, 7359, 5367, 1527, 5789, 300, 101, 1749, 4265, 4095, 
2134, 326, 326, 1266, 424, 379, 2275, 206, 1740, 1593, 1448, 
7488, 1862, 4304, 436, 2609, 929, 1583, 325, 5153, 371, 572, 
884, 422, 10905, 2406, 1873, 4371, 75, 150, 1538, 1617, 7756, 
630, 691, 200, 1000, 964, 693, 444, 59, 2059, 1130, 1276, 1847, 
367, 1533, 875, 2434, 495, 2087, 1777, 3709, 335, 156, 280, 2528, 
2401, 1978, 511, 4999, 2568, 1398, 2637, 1668, 2077, 2993, 69, 
3699, 1667, 2584, 1915, 679, 4078, 3014, 555, 2690, 69, 930, 
1026, 324, 991, 973, 566, 459, 2338, 509, 785, 467, 355, 3186, 
5202, 1122, 5077, 4945, 1973, 3029, 377, 4871, 5481, 284, 801, 
444, 1196, 661, 25, 318, 1137, 1317, 2841, 143, 1139, 1662, 1012, 
88, 1764, 1203, 3618, 713, 8657, 1274, 2255, 96, 784, 1687, 62, 
1211, 952, 125, 3260, 879, 430, 3096, 499, 699, 2395, 1704, 5818, 
2754, 2012, 6724, 2891, 959, 1730, 962, 182, 210, 6051, 902, 
3759, 2211, 206, 1408, 1472, 883, 773, 2479, 529, 2932, 1421, 
2111, 1829, 847, 2761, 1060, 1805, 1348, 2049, 2507, 809, 502, 
5877, 1621, 2254, 1329, 2752, 1657, 167, 526, 616, 198, 1648, 
1329, 1643, 360, 1028, 923, 2819, 1856, 4562, 2547, 2517, 6200, 
1704, 10, 1838, 333, 1643, 1561, 985, 2763, 4939, 3116, 855, 
1405, 891, 4503, 210, 4406, 4836, 33, 97, 4957, 2202, 1709, 6048, 
123, 1193, 13006, 271, 781, 2005, 2970, 352, 1600, 1862, 2945, 
5234, 502, 2943, 1666, 167, 4473, 468, 795, 3175, 1114, 6, 579, 
42, 995, 2705, 1929, 594, 809, 572, 871, 470, 802, 773, 7028, 
430, 139, 215, 1328, 117, 1324, 1451, 1455, 157, 1347, 1049, 
2391, 301, 1587, 602, 1197, 199, 4400, 1883, 1971, 1849, 8050, 
7730, 2527, 4066, 4443, 54, 838, 16, 584, 261, 579, 729, 226, 
292, 1367, 1608, 749, 1351, 3710, 2219, 369, 628)

I tried to fit different probability distributions to these observations:

library(fitdistrplus)

fg  <- fitdist(x, "gamma")
fln <- fitdist(x, "lnorm")
fg  <- fitdist(x, "gamma")
fw  <- fitdist(x, "weibull")

But these all returned the following errors:

<simpleError in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs = data,     gr = gradient, ddistnam = ddistname, hessian = TRUE, method = meth,     lower = lower, upper = upper, ...): non-finite finite-difference value [2]>
Error in fitdist(d$df, "gamma") : 
  the function mle failed to estimate the parameters, 
                with the error code 100

However, when the data is "scaled" - the above code seems to work fine:

library(patchwork)
library(ggplot2)

xx <- x/20000
fg <- fitdist(xx, "gamma")
fln <- fitdist(xx, "lnorm")
fw <- fitdist(xx, "weibull")
L <- list(fg, fln, fw)

a <- denscomp(L, plotstyle = "ggplot")
b <- qqcomp(L, plotstyle = "ggplot")
c <- cdfcomp(L, plotstyle = "ggplot")
d <- ppcomp(L, plotstyle = "ggplot")

a+b+c+d

enter image description here

My Question: Does anyone know why this is? In general, does MLE require the data to be "scaled"?

References:

$\endgroup$
9
  • $\begingroup$ What you are doing is unclear, because the statements that you claim produce errors do not appear to have anything to do with the data you initially show. You can find thousands of applications and explanations of MLE on this site and just about any one of them will show you scaling is unnecessary. In many cases it would be counterproductive and produce incorrect results. $\endgroup$
    – whuber
    Nov 24 at 22:52
  • $\begingroup$ @ whuber: thank you for your reply! I have fixed the statements in question $\endgroup$
    – stats555
    Nov 24 at 23:02
  • $\begingroup$ Forgive me for sounding sceptical, but the error message does not match the code that precedes it. $\endgroup$
    – whuber
    Nov 25 at 2:10
  • $\begingroup$ @ Whuber: thank you for your reply! This is the error I get: <simpleError in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs = data, gr = gradient, ddistnam = ddistname, hessian = TRUE, method = meth, lower = lower, upper = upper, ...): non-finite finite-difference value [2]> Error in fitdist(x, "gamma") : the function mle failed to estimate the parameters, with the error code 100 $\endgroup$
    – stats555
    Nov 25 at 2:37
  • 1
    $\begingroup$ The software tells you to do three things, in order. In order to answer your question we need to know the specific outcomes of those actions. $\endgroup$
    – whuber
    Nov 25 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.