As an example, this is a short script to show how to run some basic linear models. You can run it after loading the Qlib with .sourceQlib() as this also loads a number of native and essential R packages for data manipulation and analysis.
#request all prices for Lyxor Building Blocks
prices = getLyxorBBs(, asPrice = T)
#ticker for the stoxx 600 ETF (benchmark) is MEUDa
bench = prices[,which(colnames(prices)==‘MEUDa’)]
#exclude benchmark
prices = prices[,-which(colnames(prices)==‘MEUDa’)]
#run single linear regression per ETF against the benchmark. Use daily return series
reg = lm(ROC(prices, 1, type=‘discrete’) ~ ROC(bench, 1, type=‘discrete’)
#check results of each single regression
reg
#extract beta
beta = reg$coefficients[2,]
#extract beta for DAXa
daxBeta = beta[which(names(beta)==‘DAXa’)]
#check r-squared for DAX
summary(reg)[[which(names(beta)==‘DAXa’)]]$r.square
There are some packages that are available to you but that are not loaded in your environment when you call .sourceQlib(). To see what is available, check the “Packages” tab in the bottom right AlphienStudio panel. Ticking the box loads the package in your workspace.