How to calculate the autocorrelation coefficient and mean sensitivity?

Hey guys,

I do have a file with tree ring chronologies and would like to calculate Mean Sensitivity (MS) and One Year-Auto Correlation from it. I would like to receive single values and not plots. How to do that?

year num seg age raw std res ars
1849 1, 171,000 1,000 1,150 0,990 0,998 0,997
1850 1, 171,000 2,000 1,190 1,041 1,050 1,047
1851 1, 171,000 3,000 1,250 1,111 1,103 1,117
1852 1, 171,000 4,000 1,090 0,984 0,953 0,991
1853 1, 171,000 5,000 1,060 0,971 0,982 0,977
1854 1, 171,000 6,000 1,090 1,010 1,026 1,016
1855 1, 171,000 7,000 0,680 0,635 0,637 0,641
1856 1, 171,000 8,000 0,980 0,919 1,045 0,920
1857 1, 171,000 9,000 1,080 1,013 1,046 1,016
1858 1, 171,000 10,000 1,090 1,024 1,025 1,029
1859 1, 171,000 11,000 1,130 1,067 1,064 1,072
1860 2, 165,500 6,500 1,745 1,032 1,034 1,057
1861 2, 165,500 7,500 2,110 1,242 1,239 1,257
1862 2, 165,500 8,500 1,615 0,993 0,914 1,001
1863 2, 165,500 9,500 1,610 1,086 1,094 1,092
1864 2, 165,500 10,500 1,630 1,165 1,143 1,173
1865 2, 165,500 11,500 0,770 0,667 0,617 0,674
1866 2, 165,500 12,500 1,285 1,038 1,167 1,052
1867 2, 165,500 13,500 1,175 0,952 0,947 0,963
1868 2, 165,500 14,500 0,995 0,785 0,807 0,792
1869 2, 165,500 15,500 1,005 0,830 0,908 0,835
1870 2, 165,500 16,500 1,180 1,028 1,090 1,031
1871 2, 165,500 17,500 1,040 1,020 1,013 1,022
1872 2, 165,500 18,500 0,795 0,740 0,740 0,745
1873 2, 165,500 19,500 1,335 1,388 1,483 1,393
1874 2, 165,500 20,500 0,925 0,946 0,817 0,951
1875 2, 165,500 21,500 0,725 0,796 0,820 0,801
1876 2, 165,500 22,500 0,995 1,156 1,234 1,163
1877 2, 165,500 23,500 1,070 1,318 1,271 1,326

The file continues until 2020 like that.

Thank you in advance!

Tobias

It is not clear to me what column you want to use in the calculation or if you want to group by any variable. I picked raw and grouping by num. The following code gives you the auto correlation for a lag of one for each value of num.

DF <- read.csv("~/R/Play/Dummy.csv", sep = " ")
library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.3.3
ACF_Func <- function(Vec) {
  tmp <- acf(x = Vec, lag.max = 1, plot = FALSE )$acf
  tmp[2,1,1]
}
DF |> group_by(num) |> 
  summarize(acf = ACF_Func(raw))
#> # A tibble: 2 × 2
#>     num   acf
#>   <dbl> <dbl>
#> 1     1 0.286
#> 2     2 0.514

Created on 2024-04-27 with reprex v2.0.2

I don't know what mean sensitivity means in relation to this kind of data.

1 Like