Skip to content

finding roots (Max Like Est)

2 messages · stathelp, Charles C. Berry

#
I have this maximum liklihood estimate problem

i need to find the roots of the following:

[sum (from i=1 to n) ] ((2(x[i]-parameter)/(1+(x[i]-parameter)^2))=0

given to me is the x vector which has length 100

how would I find the roots using R? 

I have 2 thoughts...... 1 is using a grid search ... eg. brute force, just
choosing a whole bunch of different values for my parameter .... such as
parameter=seq(0,100,.1) .... and this is what I have so far, 

            
	john=rep(0,length(x))
	for(i in 1:length(x)) {
	john[i]=((x[i]-0)/(1+(x[i]-0)^2))
             }
             sum(john)

then 

	john=rep(0,length(x))
	for(i in 1:length(x)) {
	john[i]=((x[i]-.1)/(1+(x[i]-.1)^2))
             }
             sum(john)

then 

	john=rep(0,length(x))
	for(i in 1:length(x)) {
	john[i]=((x[i]-.2)/(1+(x[i]-.2)^2))
             }
             sum(john)

something like this ... 
             
             theta=seq(0,100,.1)
	john=rep(0,length(x))
	for(i in 1:length(x)) {
	john[i]=((x[i]-theta[j])/(1+(x[i]-theta[j])^2))
             }
             sum(john)

but something is wrong with my code because its not working. Anyone have any
ideas? (I am very new to R and statistical software in general)

The 2nd thought was to use the Newton Raphson Method, but, I dont even know
where to start with that. 

Any thoughts help. 

Thanks
#
On Thu, 29 Nov 2007, stathelp wrote:

            
Dear 'stathelp',

Did you follow the Posting Guide?

It would suggest that you issue something like

 	help.search("roots")
or
 	help.search("root")

which will list functions that perform root finding.

Read the help pages, run the examples, then adapt one to your problem.

Chuck
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901