Hello Julia users!
I have been playing with TimeSeries
package and found one operation that doesn’t make much sense to me. I know that applying lag()
to a Tx1 TimeArray
A creates a (T-1)x1 TimeArray
and lag(A)./A
creates a (T-1)x1 TimeArray
. However, doing this to different TimeArrays
in one line does not work. Please have a look at the code below for illustration:
using InstantiateFromURL; github_project("QuantEcon/quantecon-notebooks-julia", version = "0.8.0")
using LinearAlgebra, Statistics, Distributions, Random
using CSV, DataFrames
using TimeSeries
t = collect(Date(1998, 1, 1):Month(1):Date(2000, 2, 1))
v1 = randn(26)
v2 = randn(26)
df = DataFrame()
df = DataFrame(x=v1,y=v2,date=t)
tArray = TimeArray(df,timestamp=:date)
x= tArray.x
y= tArray.y
A= x./lag(x)
B= lag(y)./y
C= A.*B
z = (x./lag(x)).*(lag(y)./y)strong text
C
takes 25×1 TimeArray{Float64,1,Date,Array{Float64,1}}
, a result I wanted. However, C
returns an error:
DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 25 and 26")
Is this behavior a known issue? Or is there something I am missing that it makes sense that it should not work?
Thank you for your input!