FAQ Database Discussion Community

## small line x-axis for years

r,time-series
I have data covering a time period of over 25 years. In the data set are over 6300 days. I would like to show the years on the x-axix. dates <- as.Date(DOL[,1], "%d.%m.%Y") DOL <- as.xts(DOL[,2], dates) plot(DOL, xaxt = "n", main="SMA", ann = FALSE) axis(1, at=as.POSIXct(dates),labels=format(dates,"%Y"),tick=TRUE) title(ylab = "Value")...

## i10test for integration/stationary time series

matlab,time-series
In http://www.mathworks.com/help/econ/examples/time-series-regression-iv-spurious-regression.html, I am examing the use of the i10test for integration/stationary time series. The online help at http://www.mathworks.com/help/econ/i10test.html shows that this is done through a series of hypothesis tests. From my (OK, limited) exposure to hypthothesis testing, there is usually a threshold for the p-value, e.g. the alpha, that...

## Why does R give me a time series of row numbers instead of values?

r,time-series
Why does R give me a time series of row numbers instead of values? I load a CSV with a single column of values in the order I need them. I'm trying to make it a time series. Instead of giving me the values I've entered, R gives me the...

## multi-monthly mean with pandas' Series

python,pandas,time-series
I have a sequence of datetime objects and a series of data which spans through several years. A can create a Series object and resample it to group it by months: df=pd.Series(varv,index=dates) multiMmean=df.resample("M", how='mean') print multiMmean This, however, outputs 2005-10-31 172.4 2005-11-30 69.3 2005-12-31 187.6 2006-01-31 126.4 2006-02-28 187.0 2006-03-31...

## Calculate the maximum price fluctuation in a 24 hour window

r,time-series
I have a data frame that contains two columns - time and price. It contains a series of observations for price of a certain item at various times. Here is a sample. > df time price 1 2014-12-12 14:57:15 45.81 2 2014-12-12 14:57:15 45.90 3 2014-12-12 15:00:08 45.76 4 2014-12-12...

## value from a past, potentially missing month in dataframe

python,pandas,time-series
Assume I have a DataFrame like the following: Month, Gender, State, Value 2010-01, M, S1, 10 2010-02, M, S1, 20 2010-05, M, S1, 26 2010-03, F, S2, 11 I want to add another column for the given Gender and state from the previous month (or X months past) if it...

## Lag dependent variable [closed]

r,time-series
I want to compute the following time series regression using R: $\Delta y_t=\beta_1 \Delta x_t+\beta_2 \Delta z_t+\beta_3 \Delta m_t+\beta_4 \Delta y_{t−1}$ Since I have not that much experience with R I want to ask if the following R code gives me what I want: y <- ts(diff(YY)) x <- ts(diff(XX))...

## Dates on x-axis, time series

r,date,time-series,as.date
I have data covering a time period of over 25 years and I would like to see the years on the x-axis. dates <- as.Date(Dollar[,1], "%d.%m.%Y") Dollar <- as.xts(Dollar[,2], dates) plot(SWEDOLall, xaxt = "n", main="SMA", ann = FALSE) axis.Date(side = 1, dates, at = labDates, format = "%y", labels =...

## Combining time series data into a single data frame

r,date,data.frame,time-series
I have multiple data frames that look like this: > head(Standard.df) Count.S Date Month Week Year 552 15 2008-01-01 2008-01-01 2007-12-31 2008-01-01 594 11 2008-01-02 2008-01-01 2007-12-31 2008-01-01 1049 10 2008-01-03 2008-01-01 2007-12-31 2008-01-01 511 12 2008-01-04 2008-01-01 2007-12-31 2008-01-01 717 10 2008-01-06 2008-01-01 2007-12-31 2008-01-01 1744 3 2008-01-07 2008-01-01...

## R: compute waldtest using dynlm

r,time-series
I ran the following two regressions: library("dynlm") library("lmtest") zoop <- (test1[, -1]) f <- d(y) ~ d(x)+ d(z) + d(m) + d(log(p)) m1 <- dynlm(f, data = zoop, start = 1,end = 15) coeftest(m1, vcov=NeweyWest) m2 <- dynlm(f, data = zoop, start = 16,end = 31) coeftest(m2, vcov=NeweyWest) which gives...

## Replace -inf, NaN and NA values with zero in a dataset in R

r,time-series,nan,zoo
I am trying to run some trading strategies in R. I have downloaded some stock prices and calculated returns. The new return dataset has a number of -inf, NaN, and NA values. I am reproducing a row of the dataset (log_ret). Its a zoo dataset. library(zoo) log_ret <- structure( c(0.234,-0.012,-Inf,NaN,0.454,Inf),...

## Fitting a subset model with just one lag, using R package FitAR

r,time-series
I am trying to fit a subset model with only lag 4. In the manual it's written "you must use p=c(0,0,0,4) since p=4 will fit a full AR(4)". I did this. #fit a subset model with just lag 4 Fit=FitAR(p=c(0,0,0,4), lag.max = "default", ARModel = "ARz") However, I get the...

## Plot monthly Time series from a data frame with daily data

r,plot,time-series,legend
I have a data set for motor vehicle crashes happening daily in NYC from 1 Jan 2014 to 31 Dec 2012. I want to plot time series of the number of injured cyclists, and motorists, monthly in a single plot. My data looks like this: Date Time Location Cyclists injured...

## Enlarge time series and fill with -9999 R

r,merge,time-series
I run am model from 2007-01-01 00 to 2013-12-31 23. Not all my observations are that long, they start later and/or end earlier. In that case I want to fill in -9999 values. I have: [1,] "2003 09 01 01" "0" [2,] "2003 09 01 02" "0" [3,] "2003 09...

## R: HAC by NeweyWest using dynlm

r,time-series,regression

## How to use parameters from data frame in R and loop through time holding them constant

r,nested,time-series,lapply,sapply
I have a function (weisurv) that has 2 parameters - sc and shp. It is a function through time (t). Time is a sequence, i.e. t<-seq(1:100). weisurv<-function(t,sc,shp){ surv<-exp(-(t/sc)^shp) return(surv) } I have a data frame (df) that contains a list of sc and shp values (like 300+ of them). For...

## Read Data into Time Series Object in R

r,data,time-series
My data looks as follows: Month/Year;Number 01/2010; 1.0 02/2010;19.0 03/2010; 1.0 ... How can I read this into a ts(object) in R?...

## 150x150 crosstab in stata, showing timeseries movement between categories

time-series,stata,crosstab
I'm a bit over my head here and I hope you can help me, or at least point me in the right direction. I got a massive dataset (5.8 mio observations per year, over 14 years), which deals with individuals' occupation over time. I need to sum up the changes...

## Measure the STD of RMSE

matlab,time-series,forecasting
I'm working on a time series forecasting problem and I would like to confirm if it makes sense to compute the standard deviation of the root mean squared error. If so, is this the correct way? STD_test = std(sqrt((y_real-y_pred).^2)) Also, imagine that the output of the model is 100, the...

## Setting limits with scale_x_datetime and time data

r,ggplot2,time-series
I want to set bounds for the x-axis for a plot of time-series data which features only time (no dates). My limits are: lims <- strptime(c("03:00","16:00"), format = "%H:%M") And my ggplot prints fine, but when I add this to scale_x_datetime scale_x_datetime(limits = lims) I get Error: Invalid input: time_trans...