Dear Peter,
The easy way to just look at the coefficients is to transpose the matrix
before you write it out:
# Change this line
myCoeffs_myFile <- z.out_myFile$coefficients
# to
myCoeffs_myFile <- t(as.matrix(z.out_myFile$coefficients))
# Then verify that there's just one row in the output by doing
dim(myCoeffs_myFile)
# Then write to your CSV file:
write.csv(myCoeffs_myFile, ..., row.names = FALSE, col.names = TRUE, ...)
# where ... represent the options you had before (e.g, only row.names and
col.names changes)
# This writes out each simulation or set of coefficents as a row.
# When you read it back in, you will need to transpose it to get sims x
coef:
coefs <- t(read.table(...))
To write out the standard errors, t-stats, etc, it's tricker because each
set of output is a matrix. You need something like (I make no claims that
the code below will work out of the box, but it should with minor
tweaking):
summ <- summary(z.out_myFile)$coef
# Define a vector of file names
files <- c("C:/coefs.csv", "C:/ses.csv",
"C:/tstats.csv")
for (i in 1:3) {
tmp <- t(summ[,i])
write.table(tmp, file = files[i], row.names = FALSE, col.names = TRUE,
...)
}
In the first run, again verify that tmp has one row and many columns using
dim(tmp).
Good luck,
Olivia
On 5/1/07, peter jameson <dysgraphia2325(a)lycos.com> wrote:
Hi Zeligers!
Using R 2.5 / Zelig 2.8
I am running the following code:
z.out_myFile <- zelig(as.factor(Tumor_1_8) ~ Q1+Q2+Q3+Q4+Q5+Q6 , model =
"oprobit", data = myFile)
mySummary_myFile <- summary(z.out_myFile)
myCoeffs_myFile <- z.out_myFile$coefficients
# send the coefficients to a .csv file
write.csv(myCoeffs_myFile , file = "C:/myCoeffs_myFile.csv",
append = TRUE, sep = ",",eol = "\n",na = "NA",dec =
".",
row.names = TRUE,col.names = FALSE,qmethod = c("escape","double"))
Two questions:
1.) This code works fine and sends the coefficients to my file.
After each run the coefficients are appended to the next available row of
the .csv file.
For easier viewing and comparison it would be useful for me to have the
coefficients appended to the nex! t available column of the .csv file
rather than
the next available row.
I have looked for help in the faq's and Zelig docs but am still none the
wiser
as to how this may be done!
2.) I would like also to send to my .csv file along with the coefficients,
the
related errors and t-values but I cannot formulate the syntax to do this.
Any suggestions appreciated!
Thank you for your interest!...cheers, Peter
------------------------------
*Love Games? Gamesville is Waiting for You...*
Free Online Games, Fat Cash $ Prizes
Plus Bingo, Solitaire, Poker & Much More!
*http://www.gamesville.com*<http://www.gamesville.com?if_Event=LYCOSMAILgvilletxt>
- Zelig Mailing List, served by Harvard-MIT Data Center Send messages:
zelig(a)lists.gking.harvard.edu [un]subscribe Options:
http://lists.gking.harvard.edu/?info=zelig Zelig program information:
http://gking.harvard.edu/zelig/