[R] mle

From: Antonio Gasparrini <Antonio.Gasparrini_at_lshtm.ac.uk>
Date: Tue, 08 Jan 2008 16:17:15 +0000

 

Hello,  

I'm trying to obtain a maximum likelyhood estimate of a gaussian model by the MLE command, as I did with a Poisson model:  

x <- rep(1:2,each=500)
y <- rnorm(length(x), mean=10+3*x, sd=1)  

glm1 <- glm(y ~ x , family=gaussian())  

library(stats4)
func1 <- function(alfa=10, beta=3, sigma=1)

    -sum(dnorm(y, mean=alfa+beta*x, sd=sigma), log=FALSE) mle(func1, method = "BFGS")

func2 <- function(alfa=10, beta=3, sigma=1)    

-sum((1/sqrt(2*pi*sigma^2))*exp(-0.5*(((y-alfa-beta*x)^2)/sigma^2))) mle(func2, method = "BFGS")  

I don't understand why it doesn't work.
Have you some suggestions?  

Thank you so much for your help  

Antonio Gasparrini
Public and Environmental Health Research Unit (PEHRU) London School of Hygiene & Tropical Medicine Keppel Street, London WC1E 7HT, UK
Office: 0044 (0)20 79272406
Mobile: 0044 (0)79 64925523
www.lshtm.ac.uk/pehru/
antonio.gasparrini_at_lshtm.ac.uk

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 08 Jan 2008 - 16:25:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Jan 2008 - 17:30:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive