I am applying 100 different model simulations to 83 data points and examining the range of estimates from each model simulation for each data point.
Each calculation itself is the product of 342 variables multiplied by 342 coefficients, plus an intercept added. The code I wrote below calculates the values correctly, but is heinously slow. Is there any way to improve processing speed?
spec = read.csv(spectra)
coef = read.csv(coefficents)
shell = matrix(data=NA,ncol=101,nrow=nrow(spec))
shell = as.data.frame(shell)
heading = paste("Sim_",seq(1,100,1),sep="")
names(shell)[1] = "Filename"
names(shell)[2:101] = heading
shell[1] = spec[1]
for (i in 1:nrow(spec))
{
for (j in 1:100)
{
shell[i,j+1] = sum(spec[i,2:341]*coef[j,3:342]) + coef[j,2]
}
}