这有一个求联立方程组的例子,你看下吧,这个就可以用来解你这个
library( systemfit )
rd<-read.csv("sysfit_123.csv")
STEM.formula<-STEM~ a1*DBH^b1/( a1*DBH^b1+ a2*DBH^b2+ a3*DBH^b3+ a4*DBH^b4+ a5*DBH^b5)* (a0*DBH^b0)
SKIN.formula<-SKIN~ a2*DBH^b2/( a1*DBH^b1+ a2*DBH^b2+ a3*DBH^b3+ a4*DBH^b4+ a5*DBH^b5)* (a0*DBH^b0)
LEAF.formula<-LEAF~ a3*DBH^b3/( a1*DBH^b1+ a2*DBH^b2+ a3*DBH^b3+ a4*DBH^b4+ a5*DBH^b5)* (a0*DBH^b0)
BRANCH.formula<-BRANCH~ a4*DBH^b4/( a1*DBH^b1+ a2*DBH^b2+ a3*DBH^b3+ a4*DBH^b4+ a5*DBH^b5)* (a0*DBH^b0)
UNDER.formula<-UNDER~ a5*DBH^b5/( a1*DBH^b1+ a2*DBH^b2+ a3*DBH^b3+ a4*DBH^b4+ a5*DBH^b5)* (a0*DBH^b0)
TOTAL.formula<-UNDER~ (a0*DBH^b0)^2/( a1*DBH^b1+ a2*DBH^b2+ a3*DBH^b3+ a4*DBH^b4+ a5*DBH^b5)
labels <- list( " STEM.formula ", " SKIN.formula ", " LEAF.formula ", " BRANCH.formula ",
" UNDER.formula ", " TOTAL.formula ")
inst <- ~ DBH+STEM+SKIN+LEAF+BRANCH+UNDERL+TOTAL
start.values <- c(a0=4.156704e-02,b0= 2.785912e+00,a1=4.978067e-01,b1=6.936570e+00,a2=2.239998e-02,b2=3.479641e+00,
a3=6.343405e-02,b3=1.741423e+00,a4=6.618161e-09,b4=1.189588e+00 ,a5=3.245551e-02,b5=7.341656e+00)
model<-list(STEM.formula,SKIN.formula,LEAF.formula,BRANCH.formula,UNDER.formula, TOTAL.formula)
model.ols <- nlsystemfit( "OLS", model, start.values, data=rd, eqnlabels=labels )
model.ols
|