I have the following code to get the famafrench regression of a set of data:
#Regression
ff_reg = lm(e25 ~ rmrf+smb+hml, data=dat);
However, I keep getting the error "invalid type (list) for variable e25".
e25
was defined earlier in the program as a set of data obtained from subtracting 'rf' from a matrix made up of 25 columns:
e25 = (dat[,7:31]) - dat$rf;
(where dat is an CSV file read in to R and rf is one of the columns within that file)
Why is this error coming up and how can I resolve it?
On advice, here is the full code that I am running...
dat = read.csv("ff2014.csv", as.is=TRUE);
##excess portfolio returns
e25 = (dat[,7:31]) - dat$rf;
#print(e25);
#Regression
ff_reg = lm(e25 ~ rmrf+smb+hml, data=dat);
print(summary(ffreg));