From: Ajay Shah <ajayshah_at_mayin.org>

Date: Tue 31 May 2005 - 03:19:51 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 31 15:41:45 2005

Date: Tue 31 May 2005 - 03:19:51 EST

x <- runif(100) y <- 2 + 3*x + rnorm(100) X <- cbind(1, x)

# True OLS --

lm(y ~ x)

# OLS likelihood function --

ols.lf <- function(theta, K, y, X) {

beta <- theta[1:K]

sigma <- exp(theta[K+1])

e <- (y - X%*%beta)/sigma

logl <- sum(log(dnorm(e)))

return(logl)

}

optim(c(2,3,0), ols.lf, gr=NULL,

method="BFGS", lower=-Inf, upper=Inf, control=list(trace=2, fnscale=-1), # Now for the "..." stuff K, y, X)

I get:

If someone can show me the way, it'll be most appreciated. :-)

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 31 15:41:45 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:32:16 EST
*