ml_g function

Function to fit linear regression using maximum likelihood.

Function to fit linear regression using maximum likelihood.

This function demonstrates the use of maximum likelihood to fit ordinary least-squares regression models, by maximizing the likelihood as a function of the parameters. Only conditional normal errors are supported.

ml_g(formula, data)

Arguments

  • formula: an object of class '"formula"' (or one that can be coerced to that class): a symbolic description of the model to be fitted. (See the help for 'lm' for more details).
  • data: a data frame containing the variables in the model.

Details

This function has limited functionality compared with R's internal lm function, which should be preferred in general.

Returns

  • fit: the output of optim.

  • X: the design matrix.

  • y: the response variable.

  • call: the call used for the function.

  • beta.hat: the parameter estimates.

  • se.beta.hat: estimated standard errors of the parameter estimates.

  • sigma.hat: the estimated conditional standard deviation of the response variable.

References

Hilbe, J.M., and Robinson, A.P. 2013. Methods of Statistical Model Estimation. Chapman & Hall / CRC.

Author(s)

Andrew Robinson and Joe Hilbe.

Note

We use least squares to get initial estimates, which is a pretty barbaric hack. But the purpose of this function is as a starting point, not to replace existing functions.

See Also

lm

Examples

data(ufc) ufc <- na.omit(ufc) ufc.g.reg <- ml_g(height.m ~ dbh.cm, data = ufc) summary(ufc.g.reg)
  • Maintainer: Andrew Robinson
  • License: GPL-3
  • Last published: 2018-03-18

Useful links