Error in nlsystemfit when use different instruments for each equation

24 views Asked by At

I'm trying to estimate a non-linear set of equations with 3SLS, with different sets of instruments for each equation.

delta=0.9
nminimo=min(total_emp$nbancos) #=63

eq1<- preco~(((desp_op+desp_intermed)/p_inter)/op_cred)*
  (gamma_y+gamma_yy*log(op_cred)+gamma_ypop*log(p_op/p_inter))-
  delta*marketshare_mais1*(nbancos/(nbancos-1))*
  s*
  txcresc_mais1-(1/alpha1)*marketshare

eq2<-marketshare-marketshare_menos1~s*
  alpha1*
  (-marketshare_menos1*(nbancos/(nbancos-1))+
     marketshare_menos2*(nbancos_menos1/(nbancos_menos1-1)))+
  alpha1*(preco-preco_menos1 -(preco_medio-preco_medio_menos1)+
            s*
            (1/(nbancos-1)-1/(nbancos_menos1-1)))

modelo=list(eq1,eq2)
labels<-list("oferta","demanda")
inst1=~log(op_cred_menos1)+num_agencias_menos1+
  marketshare_menos2+marketshare_menos3+marketshare_menos4+marketshare_menos5+
  nbancos+nbancos_menos1+txcresc_mais1+
  p_op+p_inter
inst2=~log(op_cred_menos1)+num_agencias_menos1+
  marketshare_menos2+marketshare_menos3+marketshare_menos4+marketshare_menos5+
  nbancos+nbancos_menos1
inst=list(inst1,inst2)

inicial=c(s=0.3,alpha1=-0.3,gamma_y=1,gamma_yy=1,gamma_ypop=1)

resultado24 <- nlsystemfit( "3SLS", modelo, inicial, 
                            data=base_cor_reg,
                            eqnlabels=labels, inst=inst)

But I receive an error:

Error in h(simpleError(msg, call)) : 
  error evaluating argument 'x' when selecting method for function 'as.matrix': 'invalid formula'

But when I use just one set of instruments, I can estimate the model.

inst=~log(op_cred_menos1)+num_agencias_menos1+
  marketshare_menos2+marketshare_menos3+marketshare_menos4+marketshare_menos5+
  nbancos+nbancos_menos1+txcresc_mais1+
  p_op+p_inter

resultado24 <- nlsystemfit( "3SLS", modelo, inicial, 
                            data=base_cor_reg,
                            eqnlabels=labels, inst=inst)

I would like any help.

0

There are 0 answers