Tabloid journalism using R !
Hey list ! Esteemed list-member Pat Burns helped the stock market tabloid Barron's do a cover story last week that tested the returns to the stock picks that Jim Cramer makes on his CNBC show Mad Money. I think the story is accessible without subscription at our website www.barrons.com, but I'll send copies to anyone who cares and can't find it. Since today's Saturday, it's now the past week's edition. We used R to test various investment strategies, such as buying the morning after Cramer's 6 pm show, buying on the second day after the show, etc. One reason we kept testing new strategies is that Cramer and CNBC kept shifting their claim about when Cramer advises his audience to Buy, as we showed them how each successive strategy lagged the market. They also made weasely arguments that you should only count certain of his recommendations -- as if viewers would know that his fingers are crossed some of the times that he tells you to Buy or Sell. As it happened, the segment of his show that he argued most shrilly for us to deselect (his Lightning Round recommendations to phone callers) was the only segment with statistically significant good excess returns -- in this case, on the Sell recommendations. His prepared Sell recommendations went up. We did find that you might make an interesting 20-day return by shorting his Buys the morning after his shows, with offsetting S&P500 positions. We downloaded our stock histories from Edgar Online's I-Metrix service, using some Excel macros cooked up by Edgar Online analyst Elias-John Kies and my neighbor Madison Mcgaffin, who's a rising sophomore at Tufts. My story credits to them got cut in the editing. Pat bootstrapped our 95% confidence intervals. We also did some event study style analyses, incorporating each stock's average return over its prior 250 days. These suggest that Cramer is a momentum guy who probably rips his ideas from the headlines. Very few statistical details made it into the final story. Nor did my appreciative credit to Tim Hesterberg, of Insightful in Seattle, who gave us some good advice but who bears no responsibility for any woebegone errors. Hey Pat ! Feel free to correct any misreporting done here by this misanthropic layman reporter. Bill Alpert Barron's -----Original Message----- From: r-sig-finance-bounces at stat.math.ethz.ch [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of r-sig-finance-request at stat.math.ethz.ch Sent: Saturday, August 25, 2007 6:00 AM To: r-sig-finance at stat.math.ethz.ch Subject: R-SIG-Finance Digest, Vol 39, Issue 23 Send R-SIG-Finance mailing list submissions to r-sig-finance at stat.math.ethz.ch To subscribe or unsubscribe via the World Wide Web, visit https://stat.ethz.ch/mailman/listinfo/r-sig-finance or, via email, send a message with subject or body 'help' to r-sig-finance-request at stat.math.ethz.ch You can reach the person managing the list at r-sig-finance-owner at stat.math.ethz.ch When replying, please edit your Subject line so it is more specific than "Re: Contents of R-SIG-Finance digest..." Today's Topics: 1. Re: Bloomberg (Dan Davison) 2. ARIMA(0,1,0)+c results estimate incorrect drift (Nathan Bryant) 3. Re: Bloomberg (Davy Cielen) ---------------------------------------------------------------------- Message: 1 Date: Fri, 24 Aug 2007 12:11:24 +0100 From: Dan Davison <davison at stats.ox.ac.uk> Subject: Re: [R-SIG-Finance] Bloomberg To: Thomas Steiner <finbref.2006 at gmail.com> Cc: r-sig-finance at stat.math.ethz.ch Message-ID: <20070824111124.GD19118 at stats.ox.ac.uk> Content-Type: text/plain; charset=us-ascii
On Thu, Aug 23, 2007 at 10:38:00PM +0200, Thomas Steiner wrote:
(1) http://commons.wikimedia.org/wiki/Image:Quantile_graph.png The R code is included at the bottom of the page.
:) my image :)) but it's really very "pseudo".
This approach does give a good pure R solution doesn't it? e.g.
something like
gradient.under.graph <- function(n=100, y0=0, mu=-0.7, sd=1,
nrects=1000) {
y <- y0 + cumsum(rnorm(n, mean=mu, sd=sd))
plot(NA, xlim=c(1,n), ylim=range(y), bty="n")
col <- colorRampPalette(colors=c("dark blue","light blue"))(nrects)
incr <- (max(y) - min(y)) / nrects
rect(0, seq(min(y), max(y)-incr, length=nrects), n, seq(min(y)+incr,
max(y), length=nrects), col=col, border=NA)
polygon(x=c(1,1:n,n), y=c(max(y), y, max(y)), col="white",
border=NULL) }
is not slow.
Dan
Thomas
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
------------------------------ Message: 2 Date: Fri, 24 Aug 2007 11:12:09 -0400 From: Nathan Bryant <nbryant at optonline.net> Subject: [R-SIG-Finance] ARIMA(0,1,0)+c results estimate incorrect drift To: r-sig-finance at stat.math.ethz.ch Message-ID: <46CEF549.2060107 at optonline.net> Content-Type: text/plain; charset=UTF-8; format=flowed Hi, I seem to have found a problem. Integrated ARIMA with drift uses a linear regression on xreg and the results don't look numerically stable. Forecasts are inconsistent with an equivalent arima(0,0,0) on differenced data and with rwf. Maybe someone knows if there is a rational explanation? Try this, library(forecast) set.seed(3) rand <- rnorm(1000, mean=.2) mean(rand) fit1 <- arima(diffinv(rand), order=c(0,1,0), include.drift=T) coef(fit1) fit2 <- arima(rand, order=c(0,0,0)) coef(fit2) Without seed you may have to repeat the experiment a few times to see the nuisance, seed is included to show an example of the problem:
library(forecast) set.seed(3) rand <- rnorm(1000, mean=.2) mean(rand)
[1] 0.2063965
fit1 <- arima(diffinv(rand), order=c(0,1,0), include.drift=T) coef(fit1)
drift 0.2073960
fit2 <- arima(rand, order=c(0,0,0)) coef(fit2)
intercept 0.2063965 Nathan Bryant ------------------------------ Message: 3 Date: Fri, 24 Aug 2007 23:36:35 +0200 From: Davy Cielen <dcielen at vub.ac.be> Subject: Re: [R-SIG-Finance] Bloomberg To: Dan Davison <davison at stats.ox.ac.uk> Cc: r-sig-finance at stat.math.ethz.ch Message-ID: <1187991395.15359.10.camel at davy-desktop> Content-Type: text/plain; charset="us-ascii" It looks very nice and is fast indeed, I tried to build a gradient with 100.000 intervals, it was build in no time. Can this type of solution be converted to an overal gradient independent of the direction and then be added to some library? Great work Tom and Dan, Davy
One suggestion as to tentative expected return and risk is to use the observed return and risk for some period of the past. I believe that better methods, which take into account more information, can be found. I believe that what is needed is essentially a "probabilistic" reformulation of security analysis. I wi]l not pursue this subject here, for this is "another story." It is a story of which I have read only the first page of the first chapter. "Markowitz" -------------- next part -------------- An embedded message was scrubbed... From: Dan Davison <davison at stats.ox.ac.uk> Subject: Re: [R-SIG-Finance] Bloomberg Date: Fri, 24 Aug 2007 12:11:24 +0100 Size: 2673 Url: https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20070824/924cf5 05/attachment-0001.mht ------------------------------ _______________________________________________ R-SIG-Finance mailing list R-SIG-Finance at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-finance End of R-SIG-Finance Digest, Vol 39, Issue 23