The error msg puts it quite clearly -- the initial parameters 1,1,1,1 are 
inadmissible for
your function. You need to have valid initial parameters for the variable 
metric method
(option BFGS).

This is one of the main problems users have with any optimization method. It is 
ALWAYS a
good idea to actually evaluate your function outside of the optimizer i.e., 
simply put in
the initial parameters and find out what function value you get.

It should also be noted (as the package optimx does) that the VM and CG based 
methods
really don't do very well without analytic gradients.

JN


On 06/15/2011 06:00 AM, r-help-requ...@r-project.org wrote:
> Message: 46
> Date: Tue, 14 Jun 2011 13:04:55 -0400 (GMT-04:00)
> From: boyla...@earthlink.net
> To: r-help@r-project.org
> Subject: [R] Using MLE Method to Estimate Regression Coefficients
> Message-ID:
>       
> <11895593.1308071096125.javamail.r...@mswamui-andean.atl.sa.earthlink.net>
>       
> Content-Type: text/plain; charset="utf-8"
> 
> Good Afternoon,
> 
>   I am relatively new to R and have been trying to figure out how to estimate 
> regression coefficients using the MLE method.  Some background: I am trying 
> to examine scenarios in which certain estimators might be preferred to 
> others, starting with MLE.  I understand that MLE will (should) produce the 
> same results as Ordinary Least Squares if the assumption of normality holds. 
> That said, in the following code (my apologies up front for any lack of 
> elegance) I use the data from the printing press study (commonly used in the 
> QE and stats literature) to develop first and second order models using OLS.  
> Then, using some code I found online, I tried to use MLE to do the same 
> thing. However, I cannot get it to work, as I get an error in my attempt to 
> use the optim function.  I have been studying the optim function in R; I have 
> also explored the use of MLE in the R documentation via the stats4, MASS, and 
> a few other packages but to little avail.  My questions are as follows:
> 
> 1) Is there a particular error in the MLE code below that I am just not 
> seeing?
> 2) Is there a simpler, more direct, or otherwise better way to approach it?
> 3) Which package should I use for MLE regression?
> 
> Sorry for the length and thanks in advance for any assistance someone might 
> have; I know your time is valuable.  I have pasted my code below but have 
> also attached as a .txt file.
> 
> v/r,
> Greg
> Doctoral Student, 
> Dept. of Industrial Eng, Clemson University

[snip]
> 
> # Now let's use the above function to estimate the model. 
> model <- optim(c(1,1,1,1), llik.regress, method="BFGS", 
> control=list(fnscale=-1),
>          hessian=TRUE)
> Error in optim(c(1, 1, 1, 1), llik.regress, method = "BFGS", control = 
> list(fnscale = -1),  : 
>   initial value in 'vmmin' is not finite
>  
> 
> ------------------------------

______________________________________________
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.

Reply via email to