[R] finding roots (Max Like Est)

Charles C. Berry cberry at tajo.ucsd.edu
Fri Nov 30 19:58:43 CET 2007


On Thu, 29 Nov 2007, stathelp wrote:

>
> I have this maximum liklihood estimate problem
>
> i need to find the roots of the following:

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

>
> [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
>
>
> -- 
> View this message in context: http://www.nabble.com/finding-roots-%28Max-Like-Est%29-tf4901659.html#a14040895
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>

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



More information about the R-help mailing list