Dear List Members,I am trying to set up a large system of equations and I am trying to find a simple way to set up the list command under the package system fit. Here is the example from system fit and what I am trying to do: EQ1 <- Y1 ~ X1 + X2 + X4EQ2 <- Y2 ~ X2 + X3EQ3 <- Y3 ~ X2 + X3 + X4EQ4 <- Y4 ~ X1 + X3 + X4eqSystem <-list(form1 = EQ1, form2 = EQ2, form3 = EQ3, form4 = EQ4) #atempt 1 to "automate" above:eqSystem1 <-paste(paste("form", 1:4, sep=""), paste("EQ", 1:4,sep=""),sep="=") #attempt 2 "automate" above:eqSystem2 <-as.list(paste(paste("form", 1:4, sep=""), paste("EQ", 1:4,sep=""),sep="=")) Here are the results: The results that I want to get:> eqSystem1$form1Y1 ~ X1 + X2 + X4 $form2Y2 ~ X2 + X3 $form3Y3 ~ X2 + X3 + X4 $form4Y4 ~ X1 + X3 + X4 The results of my attempts:attempt 1: > eqSystem1 [1] "form1=EQ1" "form2=EQ2" "form3=EQ3" "form4=EQ4" attempt 2:> eqSystem2[[1]] [1] "form1=EQ1" [[2]] [1] "form2=EQ2" [[3]] [1] "form3=EQ3" [[4]] [1] "form4=EQ4" Does anyone have any ideas on how to correct my code? Thanks, Rita ===================================== "If you think education is expensive, try ignorance."--Derek Bok [[alternative HTML version deleted]]
Denis Kazakiewicz
2011-Jun-21 22:36 UTC
[R] Setting up list of many equations for systemfit
Why don't try as.formula() function On 22.06.2011 01:22, Rita Carreira wrote:> Dear List Members,I am trying to set up a large system of equations and I am trying to find a simple way to set up the list command under the package system fit. Here is the example from system fit and what I am trying to do: > EQ1<- Y1 ~ X1 + X2 + X4EQ2<- Y2 ~ X2 + X3EQ3<- Y3 ~ X2 + X3 + X4EQ4<- Y4 ~ X1 + X3 + X4eqSystem<-list(form1 = EQ1, form2 = EQ2, form3 = EQ3, form4 = EQ4) > #atempt 1 to "automate" above:eqSystem1<-paste(paste("form", 1:4, sep=""), paste("EQ", 1:4,sep=""),sep="=") > #attempt 2 "automate" above:eqSystem2<-as.list(paste(paste("form", 1:4, sep=""), paste("EQ", 1:4,sep=""),sep="=")) > > Here are the results: > The results that I want to get:> eqSystem1$form1Y1 ~ X1 + X2 + X4 > $form2Y2 ~ X2 + X3 > $form3Y3 ~ X2 + X3 + X4 > $form4Y4 ~ X1 + X3 + X4 > The results of my attempts:attempt 1:> eqSystem1 [1] "form1=EQ1" "form2=EQ2" "form3=EQ3" "form4=EQ4" > attempt 2:> eqSystem2[[1]] > [1] "form1=EQ1" > > [[2]] > [1] "form2=EQ2" > > [[3]] > [1] "form3=EQ3" > > [[4]] > [1] "form4=EQ4" > > Does anyone have any ideas on how to correct my code? > Thanks, > Rita ===================================== "If you think education is expensive, try ignorance."--Derek Bok > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.
Possibly Parallel Threads
- How do I output all the R-squares of an SUR? summary(fitSUR$eq[[1:4]])$r.squared does not work
- Loops, Paste, Apply? What is the best way to set up a list of many equations?
- indexing in a function doesn't work?
- Forms lost focus in KDE
- pdf() and histogram() in function call