# MLE model fit with GeneralizedLinearModelFit

I'm a bit lost with GeneralizedLinearModelFit function.

I want to do a Maximum Likelihood Estimation (MLE) of parameters vector $\theta = (\theta_1,\theta_2)$.

Imagine I have a set of recorded observed data: $(t_1,y_1),(t_2,y_2),...,(t_n,y_n)$ and I believe that the underlying model is given by:

$m(\theta_1,\theta_2,t) = 1+\theta_1 t + \theta_2 t^2$

I could estimate the parameters $\theta_i$ using:

NonLinearModelFit(data,{1+theta_1 t + theta_2 t^2},{theta_1,theta_2},t]


but I want to make a MLE estimation, and for that I believe I need to use GeneralizedLinearModelFit.

So, how do I translate the problem to GeneralizedLinearModelFit syntax?

• What is the underlying distribution? Poisson? Binomial? Something else? I think you need to add more details. (And your code has an error which suggests you haven't tried that code: It is NonlinearModelFit rather than NonLinearModelFit.) – JimB Oct 6 '16 at 18:36
• I want to try different distributions, but lets suppose is Poisson. No, I haven't actually executed the NonLinearModelFit (sorry for the typo...). As I explained I'm not interested in it. I'm interest in GeneralizedLinearModelFit. – Miguel Oct 6 '16 at 19:13
• I think you'll find that you'll get more help if you are specific and supply your code attempts (and giving data - simulated or otherwise - doesn't hurt either.) – JimB Oct 6 '16 at 20:43

If you are considering a Poisson distribution with the log of the Poisson parameter given by

$$m(θ_1,θ_2,t)=1+θ_1 t+θ_2 t^2$$

the following code should be helpful. I've set $\theta_1=0.2$ and $\theta_2=0.01$ and have $t$ going from 0.1 to 10 in steps of 0.1.

SeedRandom[123];
data = Table[{i/10,
RandomVariate[PoissonDistribution[Exp[1 + 0.2 (i/10) + 0.01 (i/10)^2]], 1][[1]]},
{i, 100}];
glm = GeneralizedLinearModelFit[data, {t, t^2}, t,
LinearOffsetFunction -> 1,
IncludeConstantBasis -> False,
ExponentialFamily -> "Poisson"];
glm["BestFitParameters"]
(*{0.2333189854264314,0.006285605637233075}*)
Show[ListPlot[data], Plot[glm // Normal, {t, 0, 10}]]