0

I have two vectors. One of them with SD=0

df[df$reg_d_msv=="South Asia",]$v1

 [1] 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33

[10] 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33

[19] 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33

[28] 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33 14566.33


df[df$reg_d_msv=="South Asia",]$v2

 [1]   93892008   61354653   56241340   65564319   80104514   62496272   67807067

 [8]   75113966   69887703  211011382  147463256   92625401   77542841   74809658

[15]  111813366   81746146  109734003  187239567  175398275  246171797  403854689

[22]  370957478  337306350  417576685 1076913468 1118794398 1075333807 1648913829

[29] 1054600599 1413105344 1224588226 1189857039 1678745102 1277631398

How does runCor (from TTR package) calculate moving window correlation for variables with standard deviation = 0 ??

runCor(df[df$reg_d_msv=="South Asia",]$v1, df[df$reg_d_msv=="South Asia",]$v2)

 [1]            NA            NA            NA            NA            NA            NA

 [7]            NA            NA            NA  0.000000e+00  1.257269e-16 -9.622613e-17

[13]  1.318642e-16  0.000000e+00  1.337180e-16 -6.874287e-17  0.000000e+00 -1.265919e-16

[19]  0.000000e+00  0.000000e+00  1.208610e-16  5.194281e-17  0.000000e+00  0.000000e+00

[25]  0.000000e+00  6.988483e-17  0.000000e+00 -5.031278e-17 -5.276821e-17  0.000000e+00

[31]  0.000000e+00  1.250396e-16  0.000000e+00 -2.167966e-16
Vega
  • 27,856
  • 27
  • 95
  • 103
  • Those numbers are very small. Looks like just rounding errrors to me. See https://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal – dww Jan 15 '20 at 01:02
  • I think you are right! But how dam i round this??? round function does not work. – Marcus Lepesqueur Jan 15 '20 at 02:13

0 Answers0