# finding roots (Max Like Est)

3 messages
Open this post in threaded view
|

## finding roots (Max Like Est)

 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