Solve multi-variable equations by R

440 Views Asked by At

Here are the equation:

f1<-function(x){miu0-(n1*x[1]-n2*x[2]-n3*x[3])/n}

f2<-function(a){sum((data1-x[1])/(1+a*(data1-x[1])))}

f3<-function(b){sum((data2-x[2])/(1+b*(data2-x[2])))}

f4<-function(c){sum((data3-x[3])/(1+c*(data3-x[3])))}

data1=c(0.028742605 0.098977723 0.129229645 0.006230172 0.265617644 0.165758965 0.517863130 0.210410100 0.106577087)

data2=c(0.09818036 0.30264860 0.32248084 0.37043087 0.20969506 0.13279921 0.01236193 0.44709777)

data3=c(0.40935868 0.07743694 0.06754163)

n1=9;n2=8;n3=3;n=20

Here is the description for the condition:

Initially, miu0 is given and miu0 is a function of x[1], x[2] and x[3]. I need to use x[1], x[2] and x[3] to solve a, b and c. However, I only have 1 equation about x[1], x[2] and x[3]. If I introduce f2, f3, f4, then new unknowns a, b, c will be involved.

The problem is now I have no idea which function/command I should use for calculating x. I tried to use multiroot, but it doesn't seem to work in this case.

0

There are 0 best solutions below