简体   繁体   中英

Finding the x value of a curve given f(x) in R?

I was wondering why I can't find the other existing value of x whose f(x) equals the f(.6) ?

In other words, I'm wondering how to find the x value of the point indicated by the red X in the picture below ?

Here is what I have tried without success:

source("https://raw.githubusercontent.com/rnorouzian/i/master/ii.r") # source the function

f <- function(x, n.pred = 5, N = 100, conf.level = .95){ 
  ci <- R2.ci(R2 = x, n.pred = n.pred, N = N, conf.level = conf.level)  # The objective function
  ci$upper - ci$lower
}

curve(f, panel.f = abline(v = .6, h = f(.6), col = 2, lty = c(2, 1)))  # curve the function

uniroot(function(x) f(.6) - f(x), c(0, 1))[[1]]  # find the requested 'x' value

`Error: f() values at end points not of opposite sign`

在此处输入图片说明

 abline(v=uniroot(function(x) f(.6) - f(x), c(0, 0.4))[[1]])

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM