In the Generalized Linear Model, a Link function maps an arbitrary density function to an underlying Normal Distribution.
Consider the LogNormal distribution, which is a continuous probability distribution of a random variable whose logarithm is normally distributed. It's link function is simply the natural logarithm.
To explain this concept, one may visualise the mapping from the normally distributed space to the original distribution using the following combined graphic:
I would like to reproduce this graphic in Mathematica. In particular, I would like this to become Dynamic
using Manipulate
.
So far, I have created the following sub-parts:
normalDistribution =
Function[{},
ParametricPlot[{PDF[NormalDistribution[], x], x},{x, -3, 3},
PlotRange -> {{0, -0. 4}, {-3, 3}},
AspectRatio -> 1,
Frame -> True,
Axes -> False,
ScalingFunctions -> {"Reverse", "Reverse"}]];
logNormalDistribution =
Function[{a, b},
Plot[PDF[LogNormalDistribution[a, b], x], {x, -1, 15},
PlotRange -> {{-1, 15}, All},
AspectRatio -> 1,
Frame -> True,
Axes -> False,
ScalingFunctions -> {Automatic, Automatic}]];
transformation =
Function[{a, b},
Plot[Log[(x - a)/b], {x, -1, 15},
PlotRange -> {{-1, 15}, {-3, 3}},
AspectRatio -> 1,
Frame -> True,
Axes -> False,
ScalingFunctions -> {Automatic, "Reverse"}]]
Finally, I attempted to combine these using:
Manipulate[
Graphics[
{Inset[normalDistribution[], {0,0},{0,3}],
Inset[logNormalDistribution[a,b], {0,0}, {-1,0}],
Inset[transformation[a,b], {0,0}, {-1,3}],
Dashed, Darker[Green], Line[{{-0.4,-1},{1,-1},{1,0.6}}]}],
{{a,0}, -1,15,0.1},
{{b,1}, 0.1,3,0.1}]
Which resulted in:
Visualisation and plotting questions:
- Is
Inset
the right way to go?- If so, how can I position and scale correctly?
- Is not, what would also work?
- How can I draw lines across plots (the dashed green ones in the original image)?
- How do I know what ${x,y}$ coordinates in my
Graphic
correspond to the coordinated in one of the threePlots
?
- How do I know what ${x,y}$ coordinates in my
- How can I deal with the
Ticks
in my plots? They cause the remainder of the plot to be rescaled so that they don't line up. - Could you provide some general advise when dealing with
Plots
andGraphics
?