[tech-spec] R functions

  • From: James Sogi <jsogi@xxxxxxxxxxxxx>
  • To: tech-spec@xxxxxxxxxxxxx
  • Date: Mon, 13 Dec 2004 18:54:52 -1000

Thanks to the Boilermaker's helpful hint, made some progress in R.
Reporting from remedial section. Apologies to advanced group for elementary level.


# got 1000 days SP cash closes from data export with read.csv;
# made it a time series with asPOSIX
#  computed daily difference in closes using diff;
#  created lagged difference columns with edit function
# added lagged columns to dataframe with data.frame function
# renamed columns with colnames function

> r1[1:3,]
     r.Date     r.c      d     d1     d2     d3
1                 NA  -9.20 -11.19 -19.06 -28.78
2 12/13/2000 1359.99 -11.19 -19.06 -28.78  10.59
3 12/14/2000 1340.93 -19.06 -28.78  10.59   0.00

# #looked for change to close day after 3 days down using subset
nr<-subset(r1,d<0 & d1<0 & d2 < 0 , select = d3)
##tested result sample against population
> t.test(nr,d) Welch Two Sample t-test data: nr and d
t = 2.122, df = 116.597, p-value = 0.03595
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval: 0.2133602 6.1864784
sample estimates: mean of x mean of y 3.043069 -0.156850 Got a good result.
Made some progress figuring it out as well.
Finding the R Reference Manuals basic Package Vol 1 & 2 very helpful.
Any suggestions to improve crudeness?








Other related posts: