I have simulated 1000 realizations of two independent random walks of length 100
N <- 1000
n <- 100
set.seed(1)
M.x <- sapply(1:N, \(k) cumsum(rnorm(n)))
M.y <- sapply(1:N, \(k) cumsum(rnorm(n)))
In matrices M.x, M.y are the realizations in columns.
For every combination "column to column" I'd like estimate the regression coefficient by using simple linear regression lm(y ~ -1 + x) and extract the regression coefficient.
I'd like to avoid cycles. I would prefer to use something from the map() family from package purrr, that I don't know much about yet.
I'd be grateful for your help.
You can just use
sapplyagain: