[Depmix-commits] r590 - in pkg/depmixS4: . data man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 13 17:05:48 CEST 2013


Author: ingmarvisser
Date: 2013-09-13 17:05:47 +0200 (Fri, 13 Sep 2013)
New Revision: 590

Added:
   pkg/depmixS4/data/sp500.rda
   pkg/depmixS4/man/sp500.Rd
Modified:
   pkg/depmixS4/DESCRIPTION
   pkg/depmixS4/man/depmix.Rd
Log:
Added sp500 data set (instead of generating it on the fly as was previously the case in the example on ?depmix); as a result the Suggested package TTR is no longer needed.

Modified: pkg/depmixS4/DESCRIPTION
===================================================================
--- pkg/depmixS4/DESCRIPTION	2013-09-13 14:25:31 UTC (rev 589)
+++ pkg/depmixS4/DESCRIPTION	2013-09-13 15:05:47 UTC (rev 590)
@@ -5,7 +5,7 @@
 Author: Ingmar Visser <i.visser at uva.nl>, Maarten Speekenbrink <m.speekenbrink at ucl.ac.uk>
 Maintainer: Ingmar Visser <i.visser at uva.nl>
 Depends: R (>= 3.0.1), stats, nnet, methods, MASS, Rsolnp, stats4
-Suggests: gamlss, gamlss.dist, TTR
+Suggests: gamlss, gamlss.dist
 Description: Fit latent (hidden) Markov models on mixed categorical and continuous (timeseries)
    data, otherwise known as dependent mixture models
 License: GPL (>=2)

Added: pkg/depmixS4/data/sp500.rda
===================================================================
(Binary files differ)


Property changes on: pkg/depmixS4/data/sp500.rda
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: pkg/depmixS4/man/depmix.Rd
===================================================================
--- pkg/depmixS4/man/depmix.Rd	2013-09-13 14:25:31 UTC (rev 589)
+++ pkg/depmixS4/man/depmix.Rd	2013-09-13 15:05:47 UTC (rev 590)
@@ -236,24 +236,15 @@
 # Volatility of S & P 500 returns
 # (thanks to Chen Haibo for providing this example)
 
-require(TTR)
+data(sp500)
 
-# load SP500 returns
-Sys.setenv(tz='UTC')
-
-sp500 <- getYahooData('^GSPC',start=19500101,end=20110731,freq='daily')
-ep <- endpoints(sp500, on="months", k=1)
-sp500 <- sp500[ep[2:(length(ep)-1)]]
-sp500$sp500_ret <- log(sp500$Close) - lag(log(sp500$Close))
-sp500 <- na.exclude(sp500)
-
 # fit some models
-mod <- depmix(sp500_ret~1,nstates=2,data=sp500)
-set.seed(2)
+mod <- depmix(logret~1,nstates=2,data=sp500)
+set.seed(1)
 fm2 <- fit(mod)	
 
-# plot BIC and posterior state sequence for the 2-state model
-plot(as.ts(posterior(fm2)[,3]),ylab="probability",main="Posterior probability of state 2 (volatile, negative markets).")
+# plot posterior state sequence for the 2-state model
+plot(as.ts(posterior(fm2)[,2]),ylab="probability",main="Posterior probability of state 1 (volatile, negative markets).")
 
 # using "hard" assignment of observations to the states, we can maximise the
 # classification likelihood instead of the usual marginal likelihood

Copied: pkg/depmixS4/man/sp500.Rd (from rev 588, pkg/depmixS4/man/speed.Rd)
===================================================================
--- pkg/depmixS4/man/sp500.Rd	                        (rev 0)
+++ pkg/depmixS4/man/sp500.Rd	2013-09-13 15:05:47 UTC (rev 590)
@@ -0,0 +1,61 @@
+\name{sp500}
+
+\docType{data}
+
+\alias{sp500}
+
+\title{Standard & Poor's 500 index}
+
+\description{
+
+	This data set consists of (monthly) values of the S&P 500 stock exchange
+	index. The variable of interest is the logarithm of the return values, i.e.,
+	the logarithm of the ratio of indices, in this case the closing index is
+	used. 
+	
+}
+
+\usage{data(speed)}
+
+\format{
+  A data frame with 744 observations and 6 variables.
+  \describe{
+	\item{\code{Open}}{Index at the start of trading.}
+	\item{\code{High}}{Highest index.}
+	\item{\code{Low}}{Lowest index.}
+	\item{\code{Close}}{Index at the close of trading.}
+	\item{\code{Volume}}{The volume of trading.}
+	\item{\code{logret}}{The log return of the closing index.}
+  }
+}
+
+\source{
+	
+	Yahoo Data. 
+}
+
+\examples{
+
+data(sp500)
+
+# the data can be made with the following code (eg to include a longer or
+# shorter time span)
+
+\dontrun{
+
+require(TTR)
+
+# load SP500 returns
+Sys.setenv(tz='UTC')
+
+sp500 <- getYahooData('^GSPC',start=19500101,end=20120228,freq='daily')
+ep <- endpoints(sp500, on="months", k=1)
+sp500 <- sp500[ep[2:(length(ep)-1)]]
+sp500$sp500_ret <- log(sp500$Close) - lag(log(sp500$Close))
+sp500 <- na.exclude(sp500)
+
+}
+
+}
+
+\keyword{datasets}



More information about the depmix-commits mailing list