[R] code for latex function in Hmisc
Forgive my ignorance, but how I can take a look at the code for the latex function in the Hmisc library? I tried just typing "latex" but all I got was this: > latex function (object, title = first.word(deparse(substitute(object))), ...) { if (!length(oldClass(object))) oldClass(object) <- data.class(object) UseMethod("latex") } What should I do? Thanks, BQ __ R-help@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
Re: [R] problem installing Econometrics view
When I named a specific mirror it worked. Thanks for the help. 2006/5/1, Brian Quinif <[EMAIL PROTECTED]>: > When I try to install hte Econometrics view I get the following error: > > CRAN task view Econometrics not available in: install.views("Econometrics") > > I have already install the ctv package and loaded it before trying to > install the above... > > Any ideas as to what's going on? > __ R-help@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
[R] problem installing Econometrics view
When I try to install hte Econometrics view I get the following error: CRAN task view Econometrics not available in: install.views("Econometrics") I have already install the ctv package and loaded it before trying to install the above... Any ideas as to what's going on? __ R-help@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
[R] displaying numbers not in scientific notation
Sorry for asking such a simple question, but I couldn't find the answer through a search... How can I get R to show me the values of estimates *not* in scientific notation? When I use summary() after using lm() I am getting numbers like 4.485107e-01, when what I want to see is 0.4485 Thanks, Brian __ R-help@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
Re: [R] function for linear regression with White std. errors
John, Thanks for the suggestion, but tomorrow I am teaching a little seminar for my department trying to convince people about how wonderful R is. These people are all Stata users, and they really like the idea that they only have to type ", robust" to get het. consistent std. errors. My pitch to a lot of them has been that R is a great and flexible tool which one doesn't have to be a programming whiz to use. If they have to start writing functions to do something as basic as this, then my colleagues will probably stay in Stata-land. I'm trying to prevent that! Regards, Brian 2006/4/27, John Fox <[EMAIL PROTECTED]>: > Dear Brian, > > How about sqrt(diag(hccm(mod)))? If that's too onerous, then you could > define a function to do it, e.g., > > wse <- function(mod) sqrt(diag(hccm(mod))) > > and then enter wse(mod). If you want a more complete, table-like summary of > the model using White standard errors, then you could easily write a > function to provide that. > > Regards, > John > > > John Fox > Department of Sociology > McMaster University > Hamilton, Ontario > Canada L8S 4M4 > 905-525-9140x23604 > http://socserv.mcmaster.ca/jfox > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Brian Quinif > > Sent: Thursday, April 27, 2006 7:34 PM > > To: r-help@stat.math.ethz.ch > > Subject: [R] function for linear regression with White std. errors > > > > I would like to know if there is a function that will run a > > linear regression and report the White (heteroscedasticity > > consistent) std. > > errors. > > > > I've found the hccm() function in the car library, but that > > just gives me the White covariance matrix. I'd like to be > > able to see the White std. errors without having to do much > > more work, if possible. > > > > Thanks, > > > > Brian > > > > __ > > R-help@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 > > __ R-help@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
[R] function for linear regression with White std. errors
I would like to know if there is a function that will run a linear regression and report the White (heteroscedasticity consistent) std. errors. I've found the hccm() function in the car library, but that just gives me the White covariance matrix. I'd like to be able to see the White std. errors without having to do much more work, if possible. Thanks, Brian __ R-help@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
Re: [R] number of matches when using Match()
> > Speaking of standard errors, when correcting for heteroscedasticity, > > how many matches do you use (this is the Var.cal option). It seems to > > me that it might make sense to use the same number of matches as > > above, but that's just a guess... > > These are related but separate issues. The number of matches is all > about covariate balance (bias reduction). And the Var.cal option is > related to the heterogeneity of the causal effect. It could be that > the data is such that one needs to do 1-to-1 matching to get good > covariate balance, but that the causal effect is homogeneous so > Var.cal can be set to 0 etc. Ok, but in my case, I think that the treatment effect *is* hetergenous, and I even partition my sample based on a number of characteristics and find very different effects for these subsamples. Given that, it seems that I certainly should not use Var.cal=0. My question is how do I go about deciding what I should set Var.cal equal to? Should it be 1, or perhaps the number of matches I use for the treatment effect? Regards, Brian __ R-help@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
[R] Var.calc in Match()
Does anyone else find that using the Var.calc option (for heteroscedasticity consistent std. errors) in Match() (from the Matching library) slows down computation of the matching estimator by a lot? I don't really understand why when I use this option it slows down so much, but for me it does significantly. I want to use the heteroscedasticity consistent std. errors in my project, but as long as it takes to compute them, I don't know if I will be able to. Thanks, BQ __ R-help@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
[R] dcolumn
Does anyone out there use dcolumn=TRUE in the latex() function in the Hmisc library? I would like to line up the data in a latex table I'm making using latex(), but I'm having some issues with this feature. Since there is no description of it in the help, I thought that it might be incomplete or something like that. On a related note, if anyone knows how to get the end result I want (LaTeX table with data aligned by decimal point), I'd love to hear it. I have been having issues with this which I think might be related to the fact that I have std. errors enclosed in parentheses. Thanks, BQ __ R-help@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
[R] another very simple loop question
I have a dataset with 4 years of students, and normally I want to estimate things using each individual year, so I have a for loop as follows for (i in 1:4){} However, the only way I know how to calculate estimates using all four years of data is to put the estimations outside of the loop. Is there anyway to make a for loop that uses all four years at once, then uses each individual year? Thanks, BQ __ R-help@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
[R] number of matches when using Match()
To anyone who uses the Match() function in the Matching library... How do you go about deciding how many matches you will use? With my data, my standard errors generally get smaller if I use more matches. Speaking of standard errors, when correcting for heteroscedasticity, how many matches do you use (this is the Var.cal option). It seems to me that it might make sense to use the same number of matches as above, but that's just a guess... One more question about Match()... I am calculating a number of SATT's that all have the same covariates (X's) and treatment variables (Tr's). I would like to take advantage of the matching that I do the first time to then quickly calculate the SATT for various different Y's? How can I do that? It would save serious computational time. In case I'm not explaining myself well, in the example below, I would like to calculate satt.Y2 without having to perform the matching all over again, since with more data, the process can be very slow. #make up some data X <- matrix(rnorm(1000*5), ncol=5) Tr <- c(rep(1,500),rep(0,500)) Y1 <- as.vector(rnorm(1000)) Y2 <- as.vector(rnorm(1000)) satt.Y1 <- Match(Y=Y1, X=X1, Tr=Tr, M=1) satt.Y2 <- Match(Y=Y2, X=X1, Tr=Tr, M=1) Thanks, BQ __ R-help@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
Re: [R] extremely simple "for loop" question
Thanks. The c(...) is what i was missing. BQ 2006/4/12, David Scott <[EMAIL PROTECTED]>: > On Wed, 12 Apr 2006, Brian Quinif wrote: > > > I am sorry to ask such a simple question, but my knowledge of > > programming language is extremely limited, and I couldn't find the > > answer in any of the normal resources. > > > > I want to do a for loop in which m takes on the values 1, 5, 10, 15, > > 20. What is the syntax for doing that? > > > > I had been doing a loop for m in 1:20, but I only want those values above. > > > > Thanks, > > > > Brian > > > > An easy one that doesn't need an answer from Gabor > > for (m in c(1,5,10,15,20)){ > print(m) > } > > or > > for (m in c(1,5*(1:4))){ > print(m) > } > > > David Scott > > _ > David Scott Department of Statistics, Tamaki Campus >The University of Auckland, PB 92019 >AucklandNEW ZEALAND > Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000 > Email: [EMAIL PROTECTED] > > > Graduate Officer, Department of Statistics > > ASC/NZSA 2006: "Statistical Connections" > The joint conference of the Statistical Society of Australia Inc. > and the New Zealand Statistical Association, July 3--6, 2006 > in Auckland. Go to: > > http://www.statsnz2006.com/ > > __ R-help@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
[R] extremely simple "for loop" question
I am sorry to ask such a simple question, but my knowledge of programming language is extremely limited, and I couldn't find the answer in any of the normal resources. I want to do a for loop in which m takes on the values 1, 5, 10, 15, 20. What is the syntax for doing that? I had been doing a loop for m in 1:20, but I only want those values above. Thanks, Brian __ R-help@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
Re: [R] long captions -- new issue
I just found that out thanks to Frank Harrell. Thanks, though. 2006/4/12, Prof Brian Ripley <[EMAIL PROTECTED]>: > On Wed, 12 Apr 2006, Brian Quinif wrote: > > > I have found out that the way to have a break apart a long caption in > > the way that one desires is to have a short caption for use in the > > list of tables that is not broken with \\ > > > > I can manually adjust the LaTeX output from the Hmisc function latex() > > to get the tables how I want them. However, I would like to automate > > the creation of these tables. > > > > Inside the latex() function, I tried this: > > caption='Estimated HOPE Effects on \\ Typical First-Year Students, > > 1990/1995 \\ > > (Robust Std. Errors in Parentheses)', > > caption.lot='HOPE Effects on Typical First-Year Students' > > > > The resulting latex output however, turns the "\\" into "\", which > > will not create the line breaks that I want. > > > > How can I remedy this? > > You inserted \ not \\ ! (Remember that R character strings use C-style > escapes: see e.g. ?Quotes.) Use "" to insert \\ > > -- > Brian D. Ripley, [EMAIL PROTECTED] > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > __ R-help@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
[R] long captions -- new issue
I have found out that the way to have a break apart a long caption in the way that one desires is to have a short caption for use in the list of tables that is not broken with \\ I can manually adjust the LaTeX output from the Hmisc function latex() to get the tables how I want them. However, I would like to automate the creation of these tables. Inside the latex() function, I tried this: caption='Estimated HOPE Effects on \\ Typical First-Year Students, 1990/1995 \\ (Robust Std. Errors in Parentheses)', caption.lot='HOPE Effects on Typical First-Year Students' The resulting latex output however, turns the "\\" into "\", which will not create the line breaks that I want. How can I remedy this? Thanks, BQ __ R-help@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
[R] long caption titles for tables
I am using using the latex() function in the Hmisc package. I want to create some table captions that are relatively long and need to take up more than one line. When I do this, the LaTeX output has the majority of the text on one line with the remainder spilling over into the second line as if it were a normal sentence. How can I get a long caption such as "Estimated HOPE Effects on Typical First-Year Students, 1990/1995 Robust Std. Errors in Parentheses" to appear as Estimated HOPE Effects on Typical First-Year Students, 1990/1995 Robust Std. Errors in Parentheses where that would be centered above the table? Thanks, BQ __ R-help@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
[R] problems with rounding in output
Perhaps someone will have a solution to my more general problem, but here is the specific one: I used the round() function to round some estimates to 3 decimal places. I then sent put the rounded estimates in a matrix and used latex() to make a LaTeX table from them. However, in my table, there are estimtes which only have 2 decimal places. I assume that the third decimal place in these numbers was equal to zero, so the round() function simply cut off the superfluous zero. However, I want all of my estimates to have the same number of digits. Is there a way to force R to keep all three digits, even if the last one is zero? Now, getting to the more general issue, to which a solution might negate the need for a solution to the first part of this email. I want to create a table in which all of the standard errors are in parentheses. The solution I used was to input the std. errors into the matrix to be used for making the table as follows paste('(',satt.yr.hrs$se,')',sep='') However, after doing so, my LaTeX output had all of the digits that R output without rounding like it normally does. So, I tried using the round() command as described above. Another problem with my solution is that the negative signs in my LaTeX tables come out as hyphens, not the usual negative signs from math mode. Does anyone have a better solution for how to put my std. errors in parentheses? Thanks, BQ __ R-help@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
[R] using latex() function with other .sty files
I am having some problems using the latex() function in the Hmisc package. When I turned on the "ctable" option in latex(), the LaTeX code produced by latex()somehow conflicts with the style back my unversity uses for theses. Has anyone on the list had a similar conflict and been able to fix it. One simple fix I know of is to have ctable=FALSE. The tables work fine then, but I prefer the look (and other options) of ctable=TRUE. This is by no means an urgent request, since I can simply turn of the ctable option, but if anyone does know of a fix, I'd certainly appreciate the help. Thanks Brian __ R-help@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
Re: [R] saving estimates from a for loop for later use
Hi Andy, I apologize for the flat structure of my code. I do not know much about programming conventions. I think your solution will work quite well, but could you clarify a couple of things? In the line x <- array('', c(4, 1, 6, 2, 3)) where do the numbers 4, 1, 6, 2, 3 come from. Here are my guesses: 4 = number of rows in orignal matrix Estimates 1 = ? 6 comes from m (m in 1:6) 2 comes from j (j in 1:2) 3 comes from i (i in 1:3) BQ 2006/4/7, Liaw, Andy <[EMAIL PROTECTED]>: > If all the looping variables are of the form 1:k for some k (i.e., they can > be use as indices in arrays), you can do something like: > > x <- array('', c(4, 1, 6, 2, 3)) > for (m in 1:6) { >for (i in 1:2) { >for (j in 1:3) { >compute `Estimates' >x[, , m, i, j] <- Estimates >} >} > } > > You still need to tack on the rownames and colnames to x. > > Andy > > From: Brian Quinif > > > > Thanks for the suggestion, but I do not know how to get it to > > work for the actual matrix I want to create. This is not > > reproducible, but here is the form of the matrix I want: > > > > #above I compute satt.yr.hrs and satt.full.load using Match() > > > > Estimates <- matrix(c(satt.yr.hrs$est, > > paste('(',satt.yr.hrs$se,')',sep=''), satt.full.load$est, > > paste('(',satt.full.load$se,')',sep='')), nrow=4) > > > > In my real program, I have 3 loops with i in 1:3, j in 1:3 > > and m in 1:6. I want to be able to combine the various > > versions of Estimates in many combinations to make tables. > > > > BQ > > > > 2006/4/7, Liaw, Andy <[EMAIL PROTECTED]>: > > > If the matrices you're storing inside the loop are all the same > > > dimension (as in your example), it's probably better to > > store them in > > > an array; e.g.: > > > > > > i1 <- 2:3 > > > i2 <- 11:12 > > > x <- array(0, c(4, 1, length(i1), length(i2))) > > > > > > for (i in seq(along=i1)) { > > >for (j in seq(along=i2)) { > > >x[, , i, j] <- matrix(c(i1[i], i2[j], i1[i] + i2[j], > > > i1[i]*i2[j]), > > > nrow=4) > > >} > > > } > > > dimnames(x) <- list(NULL, NULL, i1, i2) > > > x[, , "2", "11", drop=FALSE] > > > x[, , "3", "11", drop=FALSE] > > > > > > (Notice you need the drop=FALSE to keep it a matrix, > > because it only > > > has one > > > column.) > > > > > > Andy > > > > > > From: Brian Quinif > > > > > > > > I kind of understand this recommendation, but I can't > > figure out how > > > > to work with x once I have created it. Here is some fully > > > > reproducible code. It creates a 4x1 matrices within the loops. > > > > Once done with the looping, I want to cbind these > > matrices together. > > > > I know it's a simple question, but I can't figure it out. > > > > > > > > x <- list() > > > > for (i in 2:3) > > > > for (j in 11:12) { > > > > estimates <- matrix(c(i,j,i+j,i*j),nrow=4) > > > > x[[as.character(i)]][[as.character(j)]] <- estimates } > > > > > > > > > > > > So, once I've done this, how can I reference, say, the > > "estimates" > > > > matrix created when i=2 and j=12? > > > > > > > > Thanks, > > > > > > > > BQ > > > > > > > > 2006/4/7, jim holtman <[EMAIL PROTECTED]>: > > > > > > > > > > use a 'list'; > > > > > > > > > > x <- list() > > > > > for (i in 1:3) > > > > > for (j in 0:2) { > > > > > .your calculations. > > > > > x[[as.character(i)]][[as.character(j)]] <- yourResults } > > > > > > > > > > > > > > > > > > > > On 4/7/06, Brian Quinif <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > Thanks to the help of many on this list, I am now an R user > > > > and have > > > > > been able to write some functioning code to do matching > > estimation. > > > > > > > > > > I have two for loops (i in 1:3, and j in 0:2). Within > > the loops, I > > > > > had been c
Re: [R] saving estimates from a for loop for later use
Thanks for the suggestion, but I do not know how to get it to work for the actual matrix I want to create. This is not reproducible, but here is the form of the matrix I want: #above I compute satt.yr.hrs and satt.full.load using Match() Estimates <- matrix(c(satt.yr.hrs$est, paste('(',satt.yr.hrs$se,')',sep=''), satt.full.load$est, paste('(',satt.full.load$se,')',sep='')), nrow=4) In my real program, I have 3 loops with i in 1:3, j in 1:3 and m in 1:6. I want to be able to combine the various versions of Estimates in many combinations to make tables. BQ 2006/4/7, Liaw, Andy <[EMAIL PROTECTED]>: > If the matrices you're storing inside the loop are all the same dimension > (as in your example), it's probably better to store them in an array; e.g.: > > i1 <- 2:3 > i2 <- 11:12 > x <- array(0, c(4, 1, length(i1), length(i2))) > > for (i in seq(along=i1)) { >for (j in seq(along=i2)) { >x[, , i, j] <- matrix(c(i1[i], i2[j], i1[i] + i2[j], i1[i]*i2[j]), > nrow=4) >} > } > dimnames(x) <- list(NULL, NULL, i1, i2) > x[, , "2", "11", drop=FALSE] > x[, , "3", "11", drop=FALSE] > > (Notice you need the drop=FALSE to keep it a matrix, because it only has one > column.) > > Andy > > From: Brian Quinif > > > > I kind of understand this recommendation, but I can't figure > > out how to work with x once I have created it. Here is some > > fully reproducible code. It creates a 4x1 matrices within > > the loops. Once done with the looping, I want to cbind these > > matrices together. I know it's a simple question, but I > > can't figure it out. > > > > x <- list() > > for (i in 2:3) > > for (j in 11:12) { > > estimates <- matrix(c(i,j,i+j,i*j),nrow=4) > > x[[as.character(i)]][[as.character(j)]] <- estimates } > > > > > > So, once I've done this, how can I reference, say, the > > "estimates" matrix created when i=2 and j=12? > > > > Thanks, > > > > BQ > > > > 2006/4/7, jim holtman <[EMAIL PROTECTED]>: > > > > > > use a 'list'; > > > > > > x <- list() > > > for (i in 1:3) > > > for (j in 0:2) { > > > .your calculations. > > > x[[as.character(i)]][[as.character(j)]] <- yourResults > > > } > > > > > > > > > > > > On 4/7/06, Brian Quinif <[EMAIL PROTECTED]> wrote: > > > > > > > Thanks to the help of many on this list, I am now an R user > > and have > > > been able to write some functioning code to do matching estimation. > > > > > > I have two for loops (i in 1:3, and j in 0:2). Within the loops, I > > > had been creating matrices of relevant estimation > > coefficents in order > > > to make lots of LaTeX tables. > > > > > > Well, now I want to be able to combine the results of many > > different > > > estimations from within the loops into one larger table outside the > > > loops. > > > > > > How can I save the estimation results from each iteration of the > > > estimation within a loop for later use outside the loop? > > > > > > Thanks, > > > > > > BQ > > > > > > __ > > > R-help@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 > > > > > > > > > > > > > > > -- > > > Jim Holtman > > > Cincinnati, OH > > > +1 513 646 9390 (Cell) > > > +1 513 247 0281 (Home) > > > > > > What the problem you are trying to solve? > > > > __ > > R-help@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 > > > > > > > -- > Notice: This e-mail message, together with any attachment...{{dropped}} __ R-help@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
Re: [R] saving estimates from a for loop for later use
I kind of understand this recommendation, but I can't figure out how to work with x once I have created it. Here is some fully reproducible code. It creates a 4x1 matrices within the loops. Once done with the looping, I want to cbind these matrices together. I know it's a simple question, but I can't figure it out. x <- list() for (i in 2:3) for (j in 11:12) { estimates <- matrix(c(i,j,i+j,i*j),nrow=4) x[[as.character(i)]][[as.character(j)]] <- estimates } So, once I've done this, how can I reference, say, the "estimates" matrix created when i=2 and j=12? Thanks, BQ 2006/4/7, jim holtman <[EMAIL PROTECTED]>: > > use a 'list'; > > x <- list() > for (i in 1:3) > for (j in 0:2) { > .your calculations. > x[[as.character(i)]][[as.character(j)]] <- yourResults > } > > > > On 4/7/06, Brian Quinif <[EMAIL PROTECTED]> wrote: > > > Thanks to the help of many on this list, I am now an R user and have > been able to write some functioning code to do matching estimation. > > I have two for loops (i in 1:3, and j in 0:2). Within the loops, I > had been creating matrices of relevant estimation coefficents in order > to make lots of LaTeX tables. > > Well, now I want to be able to combine the results of many different > estimations from within the loops into one larger table outside the > loops. > > How can I save the estimation results from each iteration of the > estimation within a loop for later use outside the loop? > > Thanks, > > BQ > > __ > R-help@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 > > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 (Cell) > +1 513 247 0281 (Home) > > What the problem you are trying to solve? __ R-help@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
[R] saving estimates from a for loop for later use
Thanks to the help of many on this list, I am now an R user and have been able to write some functioning code to do matching estimation. I have two for loops (i in 1:3, and j in 0:2). Within the loops, I had been creating matrices of relevant estimation coefficents in order to make lots of LaTeX tables. Well, now I want to be able to combine the results of many different estimations from within the loops into one larger table outside the loops. How can I save the estimation results from each iteration of the estimation within a loop for later use outside the loop? Thanks, BQ __ R-help@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
Re: [R] simple if statement
Hi Ken, Thanks for the help, but I should have mentioned that I want to do this within a loop. Perhaps it would be better for me to explain my exact situation. I am running two loops so that I can calculate estimates for years 1,2,3,4 and a categorical GPA variable that takes on three values 0,1,2 with only one set of commands. Within the two loops I want to make LaTeX tables with the estimates. I want to create a caption with some thing like "Low GPA Freshmen" (Low GPA corresponds to 0) and so on for each table generated by the loops. The year variable is called uga.yr and the GPA variable is c.gpa Do you know of a good way to do that? Right now I have this command: #Generate LaTeX output of table latex(Estimates, file=paste(i, j, "tex", sep = "."), caption=paste(i, j ,sep = "."), ctable=TRUE, rowlabel='',digits=3) i is the variable for the loop for the years j is the variable for the loop for the gpa Right now I get tables with captions that say "1.0" (for example) whereas I would like them to say "Low GPA Freshmen" Thanks, BQ 2006/4/7, Ken Knoblauch <[EMAIL PROTECTED]>: > How about the following, if you really want characters or just leave as > factor > > i <- round(runif(10, 1, 4)) > years <- as.character(factor(i, labels = c("Freshman", "Sophomore", > "Junior", "Senior"))) > > HTH, > > ken > > __ R-help@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
[R] simple if statement
I am ashamed to be asking this question, but I couldn't find the solution anywhere. Searching for "if" and "R" is not very productive... I cannot get a simple if statement to work. I have data on college students. I want to make a string variable that has the names of the years. That is, when the year variable i is equal to 1, I want to have a variable called years equal to "Freshmen". I tried this years <- "Freshmen" if i==1 years <- "Sophomores" if i==2 and so on, but I couldn't get it to work. How can I get this variable to work? Thanks, BQ __ R-help@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
Re: [R] creating files using for loop
I tried that, and the problem seems to be that the results of the 'paste'ing are enclosed in quotes...that is the paste yields '101.tex'. Of course, that is what I said I wanted above, and it should work for that particular instance, but I also want to be able to create estimates.101 and estimates.201, for example. That is, I want to be able to just generate the value of sub.dataset[i] and follow it or precede it by whatever I choose, not necessarily quotation marks. Thanks, BQ 2006/4/7, Gabor Grothendieck <[EMAIL PROTECTED]>: > See ?paste and try: > > paste(sub.dataset[i], "tex", sep = ".") > > On 4/7/06, Brian Quinif <[EMAIL PROTECTED]> wrote: > > I would like to use a for loop to run estimations on 12 different > > subsets of a dataset. > > > > I have the basics of my script figured out, but I am having problems > > getting the loop to name some files as I would like. Here is a > > sketch of my code: > > > > sub.dataset <- c(101, 201) > > #Assume I only have two subsets which I call 101 and 201 > > > > for (i in 1:length(sub.dataset)) { > > #Estimation commands here...unimportant for this question > > #Estimates <- matrix of estimation resultsI will write out to LaTeX > > latex(Estimates, file=sub.dataset[i].tex) > > } > > > > So, the latex command is what's problematic here. How can I get my > > for loop to put file='101.tex' and file='201.tex' (or many similar > > things) where I want it to. I could just as easily want to put > > something like 101$variable1 or 201$variable1. > > > > Sorry for such a basic question regarding for loops, but thanks for the > > help. > > > > Brian > > > > __ > > R-help@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 > > > __ R-help@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
[R] creating files using for loop
I would like to use a for loop to run estimations on 12 different subsets of a dataset. I have the basics of my script figured out, but I am having problems getting the loop to name some files as I would like. Here is a sketch of my code: sub.dataset <- c(101, 201) #Assume I only have two subsets which I call 101 and 201 for (i in 1:length(sub.dataset)) { #Estimation commands here...unimportant for this question #Estimates <- matrix of estimation resultsI will write out to LaTeX latex(Estimates, file=sub.dataset[i].tex) } So, the latex command is what's problematic here. How can I get my for loop to put file='101.tex' and file='201.tex' (or many similar things) where I want it to. I could just as easily want to put something like 101$variable1 or 201$variable1. Sorry for such a basic question regarding for loops, but thanks for the help. Brian __ R-help@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
[R] Referencing variables in a dataframe.
I have a question about how to reference variables in a dataframe. Normally, after I have read in some Stata data using the following command all <- read.dta('all.dta') Whenever I want to use the variable "sat.vr1" in the "all" data frame, I do so using all$sat.vr1 However, I'd like to be able to use the sat.vr1 variable without the "all$" (as well as all of the other variables of the dataframe). Is there some way to make a particular dataframe the "active" or "default" one so that a can do this? Thanks, Brian __ R-help@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
[R] Creating tables with std errors beneath estimates
I have recently become familiar with the latex() function thanks to the help of many people on this list. However, now I need to figure out how to make the right dataframe for the tables I want to make. What I need to do is make tables with the std. errors beneath the estimates in parentheses (standard econ style). How can I make a dataframe with that format? Thanks, Brian __ R-help@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
Re: [R] using latex() in R for Unix
I seem to have straightened out the problem I was having by typing ls -ald /home/b/bquinif/bq/9095/ before running R. Thanks again to the ever helpful people on this list. BQ before you start 05 Apr 2006 23:11:12 +0200, Peter Dalgaard <[EMAIL PROTECTED]>: > "Brian Quinif" <[EMAIL PROTECTED]> writes: > > > Yes, Peter, I do mean the later() function from the Hmsic package. > > Below is a reproducible example. Also, does anyone know how to stop R > > from automatically running LaTeX on the file produced by latex() > > The last bit is easy. It's the print method that does that, so just > don't print. E.g. > > invisible(latex()) > > -- > O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B > c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K > (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > __ R-help@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
Re: [R] using latex() in R for Unix
Yes, Peter, I do mean the later() function from the Hmsic package. Below is a reproducible example. Also, does anyone know how to stop R from automatically running LaTeX on the file produced by latex() library(Matching) library(Hmisc) #make up some data X <- matrix(rnorm(1000*5), ncol=5) Y1 <- as.vector(rnorm(1000)) Tr <- c(rep(1,500),rep(0,500)) #estimate nearest neighbor, 1-1 matching, ATT a <- Match(Y=Y1, X=X, Tr=Tr, M=1) summary(a) #make up some more data Y2 <- as.vector(rnorm(1000)) #estimate nearest neighbor, 1-1 matching, ATT b <- Match(Y=Y2, X=X, Tr=Tr, M=1) summary(b) #Generate table of estimates Estimates <- matrix(c(a$est, b$est, a$se, b$se),nrow=2) rownames(Estimates) = c("a","b") colnames(Estimates) = c("Estimate","Standard Error") print(Estimates) #I use the next line of code for running in Windows--it works, and I can find the file out.tex #latex(Estimates, file='out.tex', rowlabel='',digits=3) #I use the next line of code for running in Unix--I get an error message saying the file/directory does not exist #latex(Estimates, file='/home/b/bquinif/bq/9095/out.tex', rowlabel='',digits=3) 05 Apr 2006 22:29:54 +0200, Peter Dalgaard <[EMAIL PROTECTED]>: > "Brian Quinif" <[EMAIL PROTECTED]> writes: > > > I am using R for Unix and want to make some LaTeX tables. I have > > already played around in R for Windows and have succeeded in making > > tables that I want using the following code: > > > > latex(Estimates, file='out.tex', rowlabel='',digits=3) > > > > However, when I use this code in Unix, I can never find the file > > "out.tex". I assumed that R would send the file to whatever directory > > I was working in, but that does not seem to be the case. So, I tried > > specifiying the exact location where I want the file: > > > > latex(Estimates, file='/home/b/bquinif/bq/9095/out.tex', > > rowlabel='',digits=3) > > > > When I do that, I get an error message sayin that the file/directory > > does not exist. I have written lots of files from Stata to locations > > specified like above, so I don't understand what's going on. > > > > Can anyone help me straighten this out? > > I assume you mean latex() from the Hmisc package? You might want to > ask its maintainer. I can't reproduce your problem though; I get the > file nicely in the current directory. (I got slightly bugged by > Frank's idea of having the print method run latex on the file and fire > up a viewer - didn't play well with a terminal login. However, that's > completely unrelated). > > Can you give a completely reproducible example that others might try? > > -- > O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B > c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K > (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > __ R-help@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
[R] using latex() in R for Unix
I am using R for Unix and want to make some LaTeX tables. I have already played around in R for Windows and have succeeded in making tables that I want using the following code: latex(Estimates, file='out.tex', rowlabel='',digits=3) However, when I use this code in Unix, I can never find the file "out.tex". I assumed that R would send the file to whatever directory I was working in, but that does not seem to be the case. So, I tried specifiying the exact location where I want the file: latex(Estimates, file='/home/b/bquinif/bq/9095/out.tex', rowlabel='',digits=3) When I do that, I get an error message sayin that the file/directory does not exist. I have written lots of files from Stata to locations specified like above, so I don't understand what's going on. Can anyone help me straighten this out? Thanks, Brian __ R-help@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
[R] generating LaTeX tables from Match output
Dear R users, I am using the Match function to generate nearest neighbor matching estimators. On that front I am ok, but where I am having problems is getting my output into nice LaTeX tables. Here is some basic code imitating the estimation I'm doing. No problem there. library(Matching) #make up some data X1 <- matrix(rnorm(1000*5), ncol=5) Y1 <- as.vector(rnorm(1000)) Tr1 <- c(rep(1,500),rep(0,500)) #estimate nearest neighbor, 1-1 matching, ATT a <- Match(Y=Y1, X=X1, Tr=Tr1, M=1) summary(a) #make up some more data X2 <- matrix(rnorm(1000*5), ncol=5) Y2 <- as.vector(rnorm(1000)) Tr2 <- c(rep(1,500),rep(0,500)) b <- Match(Y=Y2, X=X2, Tr=Tr2, M=1) summary(b) I have tried the xtable and latex functions but have not been able to get what I wanted. One thing you should know if you are unfamiliar with Match is that it only generates *one* estimator. What I want to do is take the coefficient a (along with its SE) and the coefficient in b (along with its SE) and put them into a nice table. Once I get that accomplished, I'll worry about titles, etc. Eventually, though, I will want to put the results from many (say, 10) estimations in one table. If anyone has some recommended code, I'd really appreciate it. Thanks, Brian __ R-help@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
[R] New R user looking from help
Dear R users, I am trying to become a convert to R (from Stata), and I'm having some growing pains. Is there anyone would be willing to answer a few basic questions I have? Of course I am using the relevant help guides... Thanks, Brian Quinif ps. If there is anyone at UGA on this list, I'd love to hear from someone local. __ R-help@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