time-series

Vectorized implementation of exponentially weighted moving standard deviation using R?

纵然是瞬间 提交于 2021-02-20 05:13:26
问题 I am trying to implement a vectorized exponentially weighted moving standard deviation using R. Is this the correct approach? ewma <- function (x, alpha) { c(stats::filter(x * ratio, 1 - ratio, "recursive", init = x[1])) } ewmsd <- function(x, alpha) { sqerror <- na.omit((x - lag(ewma(x, ratio)))^2) ewmvar <- c(stats::filter(sqerror * ratio, 1 - ratio, "recursive", init = 0)) c(NA, sqrt(ewmvar)) } I'm guessing it's not, since its output is different from Python's pandas.Series.ewm.std()

Vectorized implementation of exponentially weighted moving standard deviation using R?

▼魔方 西西 提交于 2021-02-20 05:12:33
问题 I am trying to implement a vectorized exponentially weighted moving standard deviation using R. Is this the correct approach? ewma <- function (x, alpha) { c(stats::filter(x * ratio, 1 - ratio, "recursive", init = x[1])) } ewmsd <- function(x, alpha) { sqerror <- na.omit((x - lag(ewma(x, ratio)))^2) ewmvar <- c(stats::filter(sqerror * ratio, 1 - ratio, "recursive", init = 0)) c(NA, sqrt(ewmvar)) } I'm guessing it's not, since its output is different from Python's pandas.Series.ewm.std()

Managing timeseries in c#

旧街凉风 提交于 2021-02-19 08:35:50
问题 I wanted to have your opinion on what is the best way to manage time series in c# according to you. I need to have a 2 dimensions matrix-like with Datetime object as an index of rows (ordered and without duplicate) and each columns would represent the stock value for the relevant Datetime. I would like to know if any of those objects would be able to handle missing data for a date: adding a column or a time serie would add the missing date in the row index and would add "null" or "N/a" for

R - How to create a seasonal plot - Different lines for years

ⅰ亾dé卋堺 提交于 2021-02-19 03:50:10
问题 I already asked the same question yesterday, but I didnt get any suggestions until now, so I decided to delete the old one and ask again, giving additional infos. So here again: I have a dataframe like this: Link to the original dataframe: https://megastore.uni-augsburg.de/get/JVu_V51GvQ/ Date DENI011 1 1993-01-01 9.946 2 1993-01-02 13.663 3 1993-01-03 6.502 4 1993-01-04 6.031 5 1993-01-05 15.241 6 1993-01-06 6.561 .... .... 6569 2010-12-26 44.113 6570 2010-12-27 34.764 6571 2010-12-28 51.659

pandas resample to specific weekday in month

六月ゝ 毕业季﹏ 提交于 2021-02-18 07:39:06
问题 I have a Pandas dataframe where I'd like to resample to every third Friday of the month. np.random.seed(0) #requested output: dates = pd.date_range("2018-01-01", "2018-08-31") dates_df = pd.DataFrame(data=np.random.random(len(dates)), index=dates) mask = (dates.weekday == 4) & (14 < dates.day) & (dates.day < 22) dates_df.loc[mask] But when a third Friday is missing (e.g. dropping Feb third Friday), I want to have the latest value (so as of 2018-02-15). Using the mask gives me the next value

Removing one level/group from Facet_wrap ggplot2 in R

你说的曾经没有我的故事 提交于 2021-02-17 07:15:06
问题 My tbl_df: > str(p2p_dt_SKILL_A) Classes ‘tbl_dt’, ‘tbl’, ‘data.table’ and 'data.frame': 693 obs. of 35 variables: $ Patch : Factor w/ 7 levels "BVG1","BVG11",..: 1 2 3 4 5 6 7 1 2 3 ... $ Skill : Factor w/ 15 levels "A","BROADBAND",..: 1 1 1 1 1 1 1 1 1 1 ... $ Date : Date, format: "2015-12-04" "2015-12-04" "2015-12-04" "2015-12-04" ... $ SOD_FWIH_A : num 1.09 1.14 1.09 1.1 1.09 1.07 1.09 1.07 1.12 1.07 ... $ Prod_MWF : num 5.06 5.06 5.44 5.34 4.22 4.72 4.89 4.68 4.68 5.22 ... $ Prod_MA :

Plot time series with years in different columns

流过昼夜 提交于 2021-02-17 07:06:20
问题 I have the following data frame dt(head,6) : I need to create a graph in which I have the years (2015, 2016, 2017, 2018, 2019) on the x-axis , different columns (W15, W16, W17, W18, W19 - each one relates to one year) on the y-axis. They are all should be grouped by the column TEAM. I tried using ggplot2 to no avail. 回答1: You need to convert your data from wide to long and then use ggplot . Look below; library(tidyverse) dt %>% pivot_longer(., -Team, values_to = "W", names_to = "Year") %>%

R converting intraday tick dataframe to timesiers

折月煮酒 提交于 2021-02-17 03:01:52
问题 I have an intraday dataframe called SPX containing 5 minute tick data of the SPX index. It is currently in a dataframe and I wish to convert it into a wonderful timeseries. This is what it looks like currently: timestamp open high low close volume 1 2020-04-03 09:35:00 2516. 2524. 2513. 2522. 0 2 2020-04-03 09:40:00 2523. 2528. 2519. 2528. 45796799 3 2020-04-03 09:45:00 2528. 2538. 2526. 2533. 46888484 4 2020-04-03 09:50:00 2533. 2535. 2527. 2528 37476420 5 2020-04-03 09:55:00 2528. 2530.

R converting intraday tick dataframe to timesiers

别等时光非礼了梦想. 提交于 2021-02-17 03:01:03
问题 I have an intraday dataframe called SPX containing 5 minute tick data of the SPX index. It is currently in a dataframe and I wish to convert it into a wonderful timeseries. This is what it looks like currently: timestamp open high low close volume 1 2020-04-03 09:35:00 2516. 2524. 2513. 2522. 0 2 2020-04-03 09:40:00 2523. 2528. 2519. 2528. 45796799 3 2020-04-03 09:45:00 2528. 2538. 2526. 2533. 46888484 4 2020-04-03 09:50:00 2533. 2535. 2527. 2528 37476420 5 2020-04-03 09:55:00 2528. 2530.

Plotting a list of timeseries of class(forecast) in [R]

拥有回忆 提交于 2021-02-16 13:47:20
问题 I am trying to plot a faceted grid of timeseries plots (ideally 3X3) using a list of forecast timeseries data. The data is nested within a list and is of class forecast::forecast. > class(forecasts) [1] "list" > class(forecasts$`1_1`) [1] "forecast" > head(forecasts, 2) $`1_1` Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 Dec 2016 7.370299 7.335176 7.405422 7.316583 7.424015 $`1_10` Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 Dec 2016 7.396656 7.359845 7.433467 7.340359 7.452953 I would like to plot the