[R] I made some progress on my previous "systemfit" question but still not quite there

Martin Becker martin.becker at mx.uni-saarland.de
Thu May 24 09:44:45 CEST 2007


Leeds, Mark (IED) schrieb:
> Surprisingly, I played around with some test code and below actually
> creates equations that look correct.
>
> tempmat<-matrix(10,nrow=6,ncol=6)
> restrictmat<-diag(6)
>
> colnames(tempmat)<-c("AUD.l1","CHF.l1","CAD.l1","GBP.l1","EUR.l1","JPY.l
> 1")
> rownames(tempmat)<-c("AUD","CHF","CAD","GBP","EUR","JPY")
>
> eqn<-list()
>
> for ( i in 1:6 ) {
>
> datares <- tempmat[, which(restrictmat[i, ] == 1),drop=FALSE]
> eqn[[i]]<-paste(rownames(tempmat)[i]," ~","-1","+",colnames(datares))
>
> print(eqn[[i]])
>
> }
>
> The only problem now is that I don't know how to name them so that
> I can do the
>
> system<-list( demand = eqDemand, supply = eqSupply)
>
> part that systemfit needs. In fact,  I don't know how to name the actual
> equation eqDemand or the named part demand.
>
>   

I am not sure, what you want to do exactly, but I suppose you need
   eqn <- lapply(eqn,as.formula)
somewhere after creating eqn. You can assign names to the equations via
  names(eqn),
but this is not necessary, you can simply pass the equations with
  systemfit(eqns=eqn...........),
and optionally specify the names of the equations with eqnlabels=.... 
instead.

If you want multiple systemfit calls for subsets of the equations, you 
should be able to select the equations via [], e.g.,
eqns=eqn[1:2] for the first and second equation.

HTH,

  Martin

> I would want demand to be "AUD", supply to be "CHF", etc. If someone has
> time to run the code, they would see what I mean. 
> Thanks a lot.
> --------------------------------------------------------
>
> This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list