Andrew Wang wrote:
I am trying to understand NLM package, so I generated this data set consisting y and x using
y= a + b*x +c*x^2 + N(0,10), with a=3.5,b=4.5,c=5.5
Given y and x, I am trying to use NLM to have estimates of parameters a, b and c that minimize the least square error
my code looks like
f<- function(y,x,a,b,c) {sum((y-(a+b*x+c*x^2))^2)}
nlm(f, y, x, a=3, b=4,c=5)
But it comes up with rediculous result. My understanding of this NLM must be
wrong.
See ?nlm for the arguments you have to pass to nlm() and how the
function needs to be written. There are also some examples on that help
page.
Uwe Ligges
Please help!
Andy
______________________________________________
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.
______________________________________________
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.