OK! Here are some codes to help you understand my previous questions:
 
library(mgcv)
library(tseries)
 
# download some test data from YAHOO
spc &lt;- get.hist.quote(instrument = "^gspc", start = "2000-01-01", quote = "Close")
ibm &lt;- get.hist.quote(instrument = "ibm", start = "2000-01-01", quote = "AdjClose")
t30 &lt;- get.hist.quote(instrument = "^TYX", start = "2000-01-01", quote = "Close") 
 
RM &lt;- (diff(log(spc)) - t30 / 365)*100.0 # let's say this is excess market return
R_IBM &lt;- (diff(log(ibm)) - t30 / 365)*100.0 # individual stock's excess return
t &lt;- 1:length(RM) # time trend
 
output &lt;- gam(R_IBM ~ RM + s(t, by=RM)) # the code in the paper
plot(output, rug=F, ylab="Time-Varying Beta") # beta looks two low 
 
output &lt;- gam(R_IBM ~ s(t, by=RM))
plot(output, rug=F, ylab="Time-Varying Beta") 
# now reasonable but I want time-axis like 2000 2001 ... 2010
 
Any help would be appreciated!

	[[alternative HTML version deleted]]

