I want to solve these two equations numerically using R
Equation 1: pnorm((c2+1)/5)-pnorm((c1+1)/5) = 0.025
Equation 2: pnorm((c2-1)/5)-pnorm((c1-1)/5) = 0.025
I need to find the values for c1 and c2
I tried to use rSymPy and Ryacas but couldn't actually figure out how to do it.
R code I tried
solve([Eq(pnorm((c2+1)/5)-pnorm((c1+1)/5), 0.025), Eq(pnorm((c2-1)/5)-pnorm((c1-1)/5), 0.02)]
Have you looked at the package 'nleqslv' in R? Using it, you can easily get a solution. Solve won't work because you have a non-linear system of equations that can't be represented by matrices. See below for your problem:
library(nleqslv)
eqs_fun <- function(x) {
y = numeric(2)
y[1] = pnorm(q = (x[2]+1)/5) - pnorm(q = (x[1]+1)/5) - .025
y[2] = pnorm(q = (x[2]-1)/5) - pnorm(q = (x[1]-1)/5) - .025
y
}
xstart = c(0,1)
nleqslv(xstart, eqs_fun)
Running this should give you the following output:
list(x = c(-0.159856055122849, 0.159854416799285), fvec = c(1.006390991376e-09,
-6.31374431903087e-10), termcd = 1L, message = "Function criterion near zero",
scalex = c(1, 1), nfcnt = 8L, njcnt = 1L, iter = 6L)
and you can yourself verify that c1 = -.16, c2 = .16 will give you a solution!