Skip to content

finding roots (Max Like Est)

1 message · Berend Hasselman

#
Why exactly the same question?

You were told what to do.
I am new to R. I did what the previous poster said.
I found it. Write your function in terms of vector operations. Avoid  
loops if you can.

Sample input for R follows
-------------------------

# par is the thing that has to be found
# x are the observations

f  <- function(par,x) sum(2*(x-par)/(1+(x-par)^2))

# trial stuff

x  <- 1:10

# use uniroot to find a value for par such that f(par,x) == 0
# interval for par is obvious (lower=1 and upper=10)

paropt  <- uniroot(f,c(1,10),tol=1e-8,x)

paropt
<END OF SAMPLEINPUT>

It works.

Berend Hasselman
On 30 Nov 2007, at 17:59, stathelp wrote: