# Lognormal curve fitting

Ok I am guessing this is a trivial question however having pondered it for a few days the only thing I have become clear on is my lack of statistical prowess. Yesterday I asked a question on fitting linear regression to a dataset piecewise and this was successfully answered. Now I would like to compare these fits to a lognormal fit of the whole dataset with the reason that this is a standard method for comparing such data (even if it really doesn't fit well); I basically want to highlight that it does not fit as well. So without further ado here is the data:

x<-c(1e-08, 1.1e-08, 1.2e-08, 1.3e-08, 1.4e-08, 1.6e-08, 1.7e-08,
1.9e-08, 2.1e-08, 2.3e-08, 2.6e-08, 2.8e-08, 3.1e-08, 3.5e-08,
4.2e-08, 4.7e-08, 5.2e-08, 5.8e-08, 6.4e-08, 7.1e-08, 7.9e-08,
8.8e-08, 9.8e-08, 1.1e-07, 1.23e-07, 1.38e-07, 1.55e-07, 1.76e-07,
1.98e-07, 2.26e-07, 2.58e-07, 2.95e-07, 3.25e-07, 3.75e-07, 4.25e-07,
4.75e-07, 5.4e-07, 6.15e-07, 6.75e-07, 7.5e-07, 9e-07, 1.15e-06,
1.45e-06, 1.8e-06, 2.25e-06, 2.75e-06, 3.25e-06, 3.75e-06, 4.5e-06,
5.75e-06, 7e-06, 8e-06, 9.25e-06, 1.125e-05, 1.375e-05, 1.625e-05,
1.875e-05, 2.25e-05, 2.75e-05, 3.1e-05)

y2<-c(-0.169718017273307, 7.28508517630734, 71.6802510299446, 164.637259265704,
322.02901173786, 522.719633360006, 631.977073772459, 792.321270345847,
971.810607095548, 1132.27551798986, 1321.01923840546, 1445.33152600664,
1568.14204073109, 1724.30089942149, 1866.79717333592, 1960.12465709003,
2028.46548012508, 2103.16027631327, 2184.10965255236, 2297.53360080873,
2406.98288043262, 2502.95194879366, 2565.31085776325, 2542.7485752473,
2499.42610084412, 2257.31567571328, 2150.92120390084, 1998.13356362596,
1990.25434682546, 2101.21333152526, 2211.08405955931, 1335.27559108724,
381.326449703455, 430.9020598199, 291.370887491989, 219.580548355043,
238.708972427248, 175.583544448326, 106.057481792519, 59.8876372379487,
26.965143266819, 10.2965349811467, 5.07812046132922, 3.19125838983254,
0.788251933518549, 1.67980552001939, 1.97695007279929, 0.770663673279958,
0.209216903989619, 0.0117903221723813, 0.000974437796492681,
0.000668823762763647, 0.000545308757270207, 0.000490042305650751,
0.000468780182460397, 0.000322977916070751, 0.000195423690538495,
0.000175847622407421, 0.000135771259866332, 9.15607623591363e-05)


You can see a plot of the data at the link above for quick interpretation.

So to my question- how to regress a lognormal curve to it? My school stats says this is not univariate data so I cannot use something like fitdistr in R. Am I right? If this is the case how might a find an approximate lognormal curve for this data if at all? Any help or pointers in a relevant direction would be great.

 With reference to the negative value I am wondering whether there is an approach that can handle it? This is because I have a second set of why values as shown below that are all negative and I would like to fit a similar model to these as well.

y3<-c(0.0530500094068018, 0.160928860126123, -0.955328071740233,
-2.53940686389203, -7.3241148240459, -8.32055726147533, -10.1979192158835,
-12.0304091519687, -16.2527095992605, -19.9106624262052, -24.5089014234888,
-28.7705733263437, -31.4294017506492, -35.8411743936776, -37.9005809712801,
-40.2384353560669, -42.5902603334382, -44.6732472915729, -47.6606530197197,
-54.2197956720375, -58.6590075712884, -61.5736755669354, -65.7179971091261,
-63.1056155765268, -65.5404821687269, -59.2950249004724, -57.7385677458644,
-63.3729518981994, -56.9303570422243, -69.2878310104119, -60.3990492926747,
-14.1184714024129, -8.29495412660418, -3.44061704811896, 0.473805205298244,
-5.47720584050456, -4.02534147802113, -2.13820456379, -0.641737730083625,
0.25648844079225, 0.697033621376916, 0.622208830019496, 0.276775608633299,
0.219104625574544, -0.0411577088679307, -0.0191732850594168,
-0.0210255752601919, -0.0156084146143567, -0.00423245275017332,
-0.000297816450447215, -1.24063266749809e-05, -1.53585832955629e-05,
-2.32966128710771e-05, -2.39386641905819e-05, -2.15491949944693e-05,
-1.50167366691665e-05, -8.3066700184436e-06, -7.89314461608438e-06,
-6.20937293357605e-06, -3.64313623751525e-06)

• Unfortunately, that negative value for y2 will hurt when you take logs... If you're interested in running a regression assuming $y2 | x2 \sim \text{Lognormal}$, you could just take the log of $y2$ and regress $x$ on $\log(y2)$; you're back in the Normal distribution world at that point. Is that negative value correct? – jbowman Jan 16 '13 at 18:01
• Thanks for the comments. The negative value is indeed correct unfortunately. Is there a way to deal with negative values? I have another dataset with the same x values and negative y values (it is basically a reflection of this data in the x-axis) so I could really do with an approach that can handle these. – user1912925 Jan 16 '13 at 20:16
• The lognormal distribution is only defined >0, so that negative value, should it be real, cannot have come from a lognormal. – Avraham Dec 6 '18 at 17:06