Here is an example of the dataset where I have date, two mutual funds and the market excess return.
datapasta::df_paste(head(dataframe, 5)[, c('Date','Alfred Berg Global C (NOK)', 'APS Global Equity R', 'mkt-rf')])
data.frame(
check.names = FALSE,
Date = c("2016-01-01","2016-02-01","2016-03-01",
"2016-04-01","2016-05-01"),
Alfred Berg Global C (NOK)
= c(-0.0708041333333334,0.0115925,0.00619040000000006,
-0.0366933,0.0415465333333334),
APS Global Equity R
= c(-0.0681767333333333,0.0077110000000001,
0.00870629999999997,-0.00214280000000002,
0.0217895333333334),
mkt-rf
= c(-0.0743514443678082,-0.00884050754326752,
0.018302499067988,-0.0128197204370558,
0.0391929254039709)
)
I want to regress both of the funds individually on the market return.
I have written the following code for the linear model:
summary(lm(df.t18$Alfred Berg Global C (NOK
~ df.t18$mkt-rf
))
Is there a way I can do this regression on all the mutual funds at the same time? Now I manually change the name of the dependent variable for every regression, but this is very time consuming.
I appreciate all help I can get!