I have one equation, two unknowns, so I am trying to build the solution
set by running through possible values for one unknown, and then using
uniroot to solve for the accompanying second solution, then graphing the
two vectors.
p0 = .36
f = function(x) 0.29 * exp(5.66*(x - p0))
f.integral = integrate(f, p0, 1)
p1 = p0 + .01
i = 1
n = (1 - p0)/.01
p1.vector = rep(0,n)
p2.vector = rep(0,n)
for (i in 1:n) {
p1.vector[i] = p1
fcn = function(p2) p1*f(p1) + (.20/5.66)*(exp(5.66*(p2 - p0)) -
exp(5.66*(p1 - p0))) + (1 - p2)*f(p2) - as.numeric(f.integral$value)
sol = uniroot(try, lower = p1, upper = 1)
p2.vector[i] = p2
i = i+1
p1 = p1 + .01
}
plot(p1.vector,p2.vector)
p1, p2 both have to be between p0 and 1, p1 < p2. Is there a better way
to do this? I keep getting the error that my lower and upper bounds are
not of opposite sign, but I don't know how to find the correct interval
values in that case. This may not even be a uniroot question (although I
don't know how to find those values in a general sense), if there is a
better way to do the same thing.