Sounds like a homework question ...
if y = a + bx + e, where e ~ N(0, sigma^2)
the log likelihood of the slope parameter and intercept parameters, a and b, and
variance sigma^2 given n data points y and covariates x is
f(a,b, sigma; y, x) = -0.5*n*log(2 * pi) - n*log(sigma) - 0.5 / sigma^2 * sum_i
[ (y_i - (a + b*x_i))^2 ]
You can simplyfiy this function if you condition on the variance and intercept.
You are then left with a simple function coresponding to the log-likelihood
curve.
This function is trivial to minimise.
Hope this helps.
Colin.
________________________________
From: r-help-bounces@r-project.org on behalf of mat7770
Sent: Sun 08/11/2009 19:12
To: r-help@r-project.org
Subject: [R] negative log likelihood
I have two related variables, each with 16 points (x and Y). I am given
variance and the y-intercept. I know how to create a regression line and
find the residuals, but here is my problem. I have to make a loop that uses
the seq() function, so that it changes the slope value of the y=mx + B
equation ranging from 0-5 in increments of 0.01. The loop also needs to
calculate the negative log likelihood at each slope value and determine the
lowest one. I know that R can compute the best regression line by using
lm(y~x), but I need to see if that value matches the loop functions.
--
View this message in context:
http://old.nabble.com/negative-log-likelihood-tp26256881p26256881.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@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.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
[[alternative HTML version deleted]]