I am trying to solve the following two equations simultaneously for a
and b
in R:
0.1 = a /(1+a) * 0.9639 + a(1+b) / (1+a(1+b)) * 0.0324 + a(1+b)^2 / (1+a(1+b)^2) * 0.0036 + a(1+b)^4 / (1+a(1+b)^4) * 0.0001
0.03 = [(a/(1+a)-0.1)^2 * 0.9639 + (a(1+b) / (1+a(1+b))-0.1)^2 * 0.0324 +(a(1+b)^2 / (1+a(1+b)^2)-0.1)^2 * 0.0036 + (a(1+b)^4/(1+a(1+b)^4)-0.1)^2*0.0001]/0.09
I have tried to use the rootSolve package to find a solution and got an error message.
The code that I used was as follows:
library(rootSolve)
model=function(x){
f1=((x[1]/(1+x[1]))*0.9639+((x[1]*(1+x[2]))/(1+x[1]*(1+x[2])))*0.0324+((x[1]*(1+x[2])^2)/(1+x[1]*(1+x[2])^2))*0.0036+(x[1]*(1+x[2])^4)/(1+x[1]*(1+x[2])^4)*0.0001)-0.1
f2=(((x[1]/(1+x[1])-0.1)^2*0.9639+(x[1]*(1+x[2])/(1+x[1]*(1+x[2]))-0.1)^2*0.0324+(x[1]*(1+x[2])^2/(1+x[1]*(1+x[2])^2)-0.1)^2*0.0036+(x[1]*(1+x[2])^4/(1+x[1]*(1+x[2])^4)-0.1)^2*0.0001)/0.09)-0.03
c(f1=f1,f2=f2)
}
solution=multiroot(f=model, start=c(1,1))