similar to: How to speed up regressions (related to data.frame)

Displaying 20 results from an estimated 10000 matches similar to: "How to speed up regressions (related to data.frame)"

2011 Sep 08
3
How to specify a variable name in the regression formula without hard coding it
I have a matrix called mat and y is the column number of my response and x is a vector of the column numbers of my terms. The variable name of y can change, so I don't want to hardcode it. I can find out the name as follows: > names(mat)[y] [1] "er12.l" Then I can run the regression by hard coding the variable name as follows: > mod <-
2009 Nov 20
3
Remove leading and trailing white spaces
I have a character string and I would like to remove the leading and tailing white spaces. The example for 'sub' shows how to remove the trailing white spaces, but I still can't figure out how to remove both trailing and leading white spaces because I can't find any documentation for what "+$" means or what "\\s+$" means. Maybe its because I don't have a
2010 Aug 26
3
Help with ddply to eliminate a for..loop
I created a small example to show something that I do a lot of. "scale" data by month and return a data.frame with the output. "id" represents repeated observations over "time" and I want to scale the "slope" variable. The "out" variable shows the output I want. My for..loop does the job but is probably very slow versus other methods. ddply
2007 Feb 22
3
How to print a double quote
Can anyone tell me how to get R to include a double quote in the middle of a character string? For example, the following code is close: > fnd<-"Open fnd 'test'" > cat(fnd) Open fnd 'test'> > But instead of Open fnd 'test' I need: Open fnd "test". Difference seems minor, but I am writing batch files for another
2012 Feb 15
1
LaTeX and Sweave on windows
I am completely new to LaTeX and Sweave, so I am trying to follow the tutorial in the following link: http://www.r-bloggers.com/using-latex-r-and-sweave-to-create-reports-in- windows/ I installed MiKTeX 2.9 and TeXnicCenter, but I get a build error when compiler the example file: The two errors are: "Error: running 'texi2dvi' on 'test.tex' failed" and "R> !
2010 Mar 23
2
Creating pdfs using qplot in qqplot2
I am trying to create plots within a for loop and output them to a pdf. Here is a working example using plot: gg <- data.frame(datadate=1:4, spread=5:8) pdf() for (i in 1:3) { plot(gg$datadate, gg$spread, main=i) } dev.off() I am trying to learn more about ggplot2 so I try a slight modification and it doesn't work. Anyone
2008 Jun 10
1
Sweave, ggplot2 and two-page figures
I am using Sweave to generate a document in which ggplot2 figures are embedded. I am using the following code in a particular plot within a subfloat environment: <<qplotARbosreg, echo = FALSE, fig = TRUE>>= print(qplot(bosday2, Arday2, data= arbostimearonlyNArm, colour=factor(bos2), shape=factor(bos2), size=factor(cumARscore), position="jitter", main="Days to BOS by
2011 Jul 12
2
foreach not recognizing functions in memory
All, I am not understanding the scoping used in foreach when it is used inside a function. I keep getting "could not find function" errors for functions that are in memory when I try to use foreach within a function call. I have a simple example below. "testFun" is in memory and works when called by foreach directly, but when I place foreach in a function called
2008 May 02
1
How to parse XML
I would like to learn how to parse a mixed text/xml document I downloaded from the sec.gov website (see example below). I would like to parse this to get the value for each xml tag and then access it within R, but I don't know much about xml so I don't even know where to start debugging the errors I am getting in this example code. Can anyone help me get started? Thanks, Roger ftp
2011 Sep 08
2
Variable scoping question
I modified an example in the object.size help page to create a function I want to be able to run: "mysize" <- function() { z <- sapply(ls(), function(w) object.size(get(w))) as.matrix(rev(sort(z))[1:5]) } mysize() When I test the lines inside the function it works fine: > z <- sapply(ls(), function(w) object.size(get(w))) > as.matrix(rev(sort(z))[1:5])
2006 Apr 06
5
pros and cons of "robust regression"? (i.e. rlm vs lm)
Can anyone comment or point me to a discussion of the pros and cons of robust regressions, vs. a more "manual" approach to trimming outliers and/or "normalizing" data used in regression analysis?
2007 Mar 01
2
FTP download from ftp.sec.gov
All, I have managed to download files from web sites and ftp sites using R, so just for fun I tried to do so from the SEC's ftp site using the following code: ftp <- "ftp://anonymous:test at ftp.sec.gov/edgar/full-index/company.idx" download.file(url=ftp, destfile="test.txt") And it does not work. R says it cannot open the URL. If I paste the ftp part into IE it
2011 Jul 18
1
R on a server (Windows Server 2008)
Apologies for a naive question: Can R be installed and run on a server (operating system Windows Server 2008)? Thank you! -- Dimitri Liakhovitski
2008 Aug 20
1
How to send Html using SQL Server db mail
All, I have a variable called `go` and it has a single quote in the name column of line 47 that I am trying to get rid of. I have tried using gsub, but I cannot get the syntax correct to tell R to remove the ' (single quote). > go[47,] gvkey Symbol Name Rank MarketCap MemoDate Action Analyst Reason SharesHeld 75 065105 BJ BJ'S WHOLESALE CLUB INC 0.9579
2005 Mar 24
1
Robust multivariate regression with rlm
Dear Group, I am having trouble with using rlm on multivariate data sets. When I call rlm I get Error in lm.wfit(x, y, w, method = "qr") : incompatible dimensions lm on the same data sets seem to work well (see code example). Am I doing something wrong? I have already browsed through the forums and google but could not find any related discussions. I use Windows XP and R
2011 Mar 14
1
discrepancy between lm and MASS:rlm
Dear R-devel, There seems to be a discrepancy in the order in which lm and rlm evaluate their arguments. This causes rlm to sometimes produce an error where lm is just fine. Here is a little script that illustrate the issue: > library(MASS) > ## create data > n <- 100 > dat <- data.frame(x=rep(c(-1,0,1), n), y=rnorm(3*n)) > > ## call lm, works fine > summary(lm(y ~
2004 Jun 11
1
comparing regression slopes
Dear List, I used rlm to calculate two regression models for two data sets (rlm due to two outlying values in one of the data sets). Now I want to compare the two regression slopes. I came across some R-code of Spencer Graves in reply to a similar problem: http://www.mail-archive.com/r-help at stat.math.ethz.ch/msg06666.html The code was: > df1 <- data.frame(x=1:10, y=1:10+rnorm(10))
2012 Jul 24
1
quantstrat questions
Quantstrat useRs, I have a number of questions about how to use quantstrat that I have accumulated since I have begun playing with it. First, can the orderqty be dynamic? All of the examples I have seen are based on placing an order for 100 shares when a rule is triggered. Is it possible to set it up to buy the maximum number of shares given the starting or current equity? Similar to that
2004 Sep 16
1
linear regression: evaluating the result Q
On Thu, 16 Sep 2004, RenE J.V. Bertin wrote: > Dear all, > > A few quick questions about interpreting and evaluating the results of > linear regressions, to which I hope equally quick answers are possible. > > 1) The summary.lm method prints the R and R^2 correlation coefficients > (something reviewers like to see). It works on glm objects and (after > tweaking it to
2007 Nov 29
1
relative importance of predictors
Hei Group, I want to compare the relative importance of predictors in a multiple linear regression y~a+bx1+cx2... However, bptest indicates heteroskedasticity of my model. I therefore perform a robust regression (rlm), in combination with bootstrapping (as outlined in J. Fox, Bootstrapping Regression Models). Now I want to compare the relative importance of my predictors. Can I rely on the