How to reverse differing of natural log in R? my attempts are not working

38 Views Asked by At

Simple inverse differencing is easy however, after differencing the natural log I cannot get the original data back. For instance, my data is in a timeseries:

des_rev_ts<-
           Jan       Feb       Mar       Apr       May       Jun       Jul       Aug       Sep
2021                      70522628  59767437 118271143 135205849 124415379 128579517 159797367
2022 189112589 239643807 305211630 261793324 303619377 272318109 230714682 211389213 212722519
2023 354727754 296675320 361912341                                                            
           Oct       Nov       Dec
2021 173839195 143396322  73942001
2022 253461903 200651343 166996312

for the transformation I did the following:

ln_des<-log(des_rev_ts)

final<-diff(ln_des)

to reverse the transformation instead I did:

 reverse<- diffinv(exp(ln_des))

which outputs:

 Jan        Feb        Mar        Apr        May        Jun        Jul        Aug
2021                     0   70522628  130290065  248561208  383767057  508182436  636761953
2022 1376849427 1616493234 1921704864 2183498188 2487117565 2759435674 2990150356 3201539569
2023 4390099400 4686774720 5048687061                                                       
            Sep        Oct        Nov        Dec
2021  796559320  970398515 1113794837 1187736838
2022 3414262088 3667723991 3868375334 4035371646
2023       

as you can see, it's completely different apart from the first month. What am I missing?

Thanks