data_driven_time_warp - (dtw) is the dynamic curvature of the timeline. An ordinary vector is fed into the function, the output function already gives two x and y coordinates - time (synthetic) and values ​​(vector).

 data_driven_time_warp <- function (y) { cbind( x = cumsum(c(0, abs(diff(y)))),y = y) } y <- cumsum(rnorm(200))+1000 # some data i <- seq(1,length(y),by=10) op <- par(mfrow=c(2,1), mar=c(.1,.1,.1,.1)) plot(y, type="l", axes = FALSE) abline(v=i, col="grey") lines(y, lwd=3) box() d <- data_driven_time_warp(y) plot(d, type="l", axes=FALSE) abline(v=d[i,1], col="grey") lines(d, lwd=3) box() par(op) 

give the usual vector to the function

 > head(y) [1] 999.9084 999.1956 999.8033 999.2182 998.6474 997.0736 

output matrix

 > head(d) xy [1,] 0.0000000 999.9084 [2,] 0.7128334 999.1956 [3,] 1.3205700 999.8033 [4,] 1.9056173 999.2182 [5,] 2.4764494 998.6474 [6,] 4.0502315 997.0736 

in the picture above the row before the conversion, below after in the picture above the row before the conversion, below after

The question is how can I convert this matrix "d" into an ordinary vector, but what would it be the same as in the picture below?

  • y in the matrix d - this is the original y . That is, he is already "the same." In the picture above, there is a graph from one variable, respectively, all points have an equal distance between them on the x-axis. In the second picture, the graph is plotted in two coordinates. - Ogurtsov
  • Well, the question is just how to make a vector from the matrix d that it would look like in picture 2, that is, I don't need the original y - mr.T
  • Once again: there is no non-original vector y . The data_driven_time_warp function data_driven_time_warp n’t do anything with the source vector y , but creates another vector x . Further, the dependence of y on x is drawn. That is, it cannot be said that the second picture "depicts a vector" - it shows the dependence of one variable on another. - Ogurtsov
  • I understand you, I didn’t say that in the second picture I said that I would like to get a vector that it would look like in picture 2, can it be done with some kind of clever prayers? - Tue
  • Then the only thing that comes to mind is to build a model of the dependence of d$y on d$x - any splines or loess. Then predict y at points 1, 2. 3 ... to length(x) . So get some approximation of the desired image. - Ogurtsov

0