Displaying 20 results from an estimated 1200 matches similar to: "R: Help xts object Subset Date by Day of the Week"
2012 Aug 01
1
Time Series Have Date Show Days of the Week
I used quantmod to pull in price data from the ticker SPY. The data has
date and closing price. I would like to show the day of the week for each
closing price. Is that possible? Also, I would like to add the back into
the data frame in a new column without changing the structure of the data
set if possible.
SPY
2009-01-02 92.96
2009-01-05 92.85
2009-01-06 93.47
2012 Dec 06
1
Fuction Error
I'm calling a list of symbols and then using a function to build a data
frame from that symbol list. It works great until I introduce this index
symbol from yahoo '^GSPC'. When and index symbol is introduced I get and
error which is below.
> Data <- symbolFrame(symbols)
Error in get(S) : object '^GSPC' not found
Since R does not like the ^ in front of a name it
2008 Sep 22
1
Help for SUR model
I am an R beginner and trying to run a SUR model in R framework.
subset(esasp500, Obs <=449 & Obs>=197, select = -Date) ->ev13sub
c(Obs>=397) & c(Obs<=399) ->d13
c(Obs>=400) & c(Obs<=449) ->f13
SP500*f13 ->SP500f13
BBC~SP500+d13+SP500f13 ->sur132
BOW~SP500+d13+SP500f13 ->sur133
CSK~SP500+d13+SP500f13 ->sur134
2007 Nov 09
1
Problem reading data in Rmetrics
Hi folks - After upgrading to the latest version of Rmetrics, I can't
read in data like I used to. Is anyone seeing the following? It seems
to truncate the dates after I use "as.timeSeries".
-John
SP500<-read.table("SP500.csv",header=TRUE,sep=",")
> head(SP500)
Date Open High Low Close Volume
1 08/04/06 1280.26 1292.92
2008 Jan 24
1
Error using Rmetrics to read data
Hi folks. This set of code used to work, but after upgrading to the
latest version of Rmetrics it no longer does. Any ideas?
SP500<-read.table("SP500.csv",header=TRUE,sep=",")
> head(SP500)
Date Open High Low Close Volume Close2
1 8/4/2006 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40
2 8/3/2006 1278.22 1283.96 1271.25 1280.27
2017 Aug 07
1
tidyquant error downloading symbols for Index
Hi R Helpers,
I recently tried to take advantage of the ability to download all the
tickers in the S&P 500 using the functionality of tidyquant, but it threw
an error.
For summary, the set of commands that I ran was
library(tidyquant)
tq_index_options()
tq_index("SP500")
sessionInfo()
R feedback including error message and sessionInfo are provided below.
Guidance would be
2011 Feb 19
4
Accessing DF index
I have a dataframe called x2. It seems to have a date column but I can't
access it or give it a name or convert it to a date. How do I refer to that
first column and make it a date ? When I try x2[1,] I get the second column.
head(x2)
FAIRX SP500 delta
2000-08-31 0.010101096 0.007426964 0.002674132
2000-09-29 0.096679730 -0.054966292 0.151646023
2000-10-31
2006 Nov 22
2
problems with garchFit
Hi all,
I post it on both r-help and r-finance since I don't know where is most
appropriate for this topic. Sorry if it bothers you.
I did garch fitting on S&P500 monthly returns with garchFit from fSeries. I
got same coefficients from all cond.dist except normal. I thought that is
probabaly usual for the data. But when I play with it, I got another
question.
I plot skew normal with
2008 Jun 19
1
How can I shade the background area of a zoo time series object between specific dates?
Dear list members,
How can I shade the background area of a zoo time series object between
specific dates?
eg.
library(tseries)
library(zoo)
SP500<-get.hist.quote("^GSPC", start = "1990-01-01", quote =
"Close")
plot(SP500)
How can I produce the same plot but with a (say) red background between
2007-04-12
and
2008-05-14
?
2012 Jan 28
1
Using the digest and t distribution.
Hello R community,
I have two questions:
The first might be one of the silliest ever posted here and I
apologize if I've missed some thing very obvious. It relates to using
this digest. When I subscribed to the forum, I had chosen the "digest"
option that bundles all mails every day into a single digest.
Now, I posted a question a while ago on the logistic regression
function and
2007 Jul 12
2
how to get the p-values from an lm function ?
Hi, dear R-users,
I am computing a liner regression by rating category using the 'by' function
as stated below:
tmp <- by(projet, rating, function(x) lm(defaults ~ CGDP+CSAVE+SP500, data =
x))
I would like to get not only the coefficients but also their p-values. I
can't find the command in the help pages to get them.
Does anyone have a suggestion ?
Thank you,
Benoit.
2009 Nov 20
2
Problem at adding lines on a graphics with lines() function
Hello, I am trying to plot a graphic with many lines with the following
command:
plot(datas[1:n,1],datas[1:n,2],type="l",main="SP500 Prices and Moving
Averages",xlab="Date",ylab="Prices",col="black")
lines(datas[1:n,1],datas[1:n,3],type="l",col="green",lty="solid")
But I just see the first curve. I have tried it on
2008 Sep 11
1
how to calcaulate matrices for two subsets
I am an R beginner and trying to run a market model using event study in
R framework.
First, I run a market model, that is lm(stock security~SP500 index,
subset=Obs[197, 396]) ->result1
Then I get predict results for a new dataset using predict (result1,
newdata=Obs[397,399]) ->pred1
Pred1 should have three numbers.
Now I need to calculate abnormal return by the formula stock
2007 Nov 24
5
how to calculate the return?
Hi, R-users,
data is a matrix like this
AMR BS GE HR MO UK SP500
1974 -0.3505 -0.1154 -0.4246 -0.2107 -0.0758 0.2331 -0.2647
1975 0.7083 0.2472 0.3719 0.2227 0.0213 0.3569 0.3720
1976 0.7329 0.3665 0.2550 0.5815 0.1276 0.0781 0.2384
1977 -0.2034 -0.4271 -0.0490 -0.0938 0.0712 -0.2721 -0.0718
1978 0.1663 -0.0452 -0.0573 0.2751 0.1372 -0.1346
2013 Jan 08
3
Conditional Statistics
Hello,
I am a new user of R. I am coming from SAS and do statistics on stock
market data, economic data, and social data. My question is this: How
can you get the mean, standard dev, etc. of a variable based on a
conditional statement on either the same variable or a different
variable in the same data set? So if I had the closing prices of the
S&P from 01/01/1990-12/31/1990, how could I get
2006 Jun 23
3
Problems with weekday extraction from zoo objects
Hi Folks!
I'm struggling with dates - but enough about my personal life.....
I have two daily time series files. In one (x) the date format is Y/m/d
and the other (y) is d/m/y. I used read.zoo on both and they read into
R with no problem.
Then I use: weekdays(as.Date(x$DATE)) and get what I expect - all the
days of the week in my data set.
When I use:
2012 Mar 04
1
Store vectors as values in xts time-series object
Hi R programmers,
I have stumbled across what seems a very simple problem. My goal is to
create a xts time series object which contains vectors as values. In
other words, I try to create something like this:
2009-01-01 => c('aa', 'bb', 'dd')
...
2010-02-01 => c('mm')
I have figured out parts of separately. Here's what works (new xts
time-series with
2006 Nov 22
0
questions about garchFit
Hi all,
I was trying garchFIt() of fSeries to fit volatility of monthly log returns
of S&P500. I tried residuals of normal, student t, skew normal, skew t. But
all innovations except normal got exaxtly same coefficients, even if I
changed their parameters of skew and shape.
Is this correct for the data or something wrong? I am attaching the code,
thank you.
Muster
#GARCH analysis of
2010 Sep 10
2
[xts, quantmod] segfault probelm when I work with memcpy function
Hi,
I work with SEXP C code and with xts and quantmod packages. I try to
touch how xts internal works.
So we have R session and:
> ls()
character(0)
> getSymbols('AAPL') # quantmod package
[1] "AAPL"
> ls()
[1] "AAPL"
> str(AAPL)
An ?xts? object from 2007-01-03 to 2010-09-09 containing:
Data: num [1:929, 1:6] 86.3 84 85.8 86 86.5 ...
- attr(*,
2007 Sep 01
1
Problem in downloading Yahoo Finance data from R
Hi R users,
I have a problem in downloading Yahoo Finance data from R. I have tried
an example given in R, to download. The error is given below:
>library(fCalendar)
> yahooImport("s=IBM&a=11&b=1&c=1999&d=0&q=31&f=2000&z=IBM&x=.csv ",
file = "D:\\ Downlaod",source = "http://ichart.yahoo.com/table.csv?",
save = FALSE,