Hi,
I am a complete newbee in R, and I have a problem with linear trend fitting.
My data is daily financial data for around 4 years. The financial year is 260 days (5 days a week) so the total amount of data is 913.
For the simplicity, the data is only one cloumb with 913 data and with one header.
I can plot the time series data without problem. But when I try to plot linear trend with lm, I can get the error message:
"formula.default(object, env = baseenv()) : invalid formula"
And when I try to plot the linear trend with abline, I get the error message:
"Error: $ operator is invalid for atomic vectors"
My code is below. So can anyone help me draw linear trend with lm or abline? I check the web to see how lm or abline is used. Some examples used "formula" for lm and abline, but I didn't understand what kind of formula i should use.
I am a complete newbee in R, and I have a problem with linear trend fitting.
My data is daily financial data for around 4 years. The financial year is 260 days (5 days a week) so the total amount of data is 913.
For the simplicity, the data is only one cloumb with 913 data and with one header.
I can plot the time series data without problem. But when I try to plot linear trend with lm, I can get the error message:
"formula.default(object, env = baseenv()) : invalid formula"
And when I try to plot the linear trend with abline, I get the error message:
"Error: $ operator is invalid for atomic vectors"
My code is below. So can anyone help me draw linear trend with lm or abline? I check the web to see how lm or abline is used. Some examples used "formula" for lm and abline, but I didn't understand what kind of formula i should use.
Code:
SE=read.csv(file="SE1.csv",head=TRUE,sep="")
Price<-SE$Closingprice
Price.SEK<-ts(Price, start=2011)
plot(Price.SEK,main="Stockholm 30 Index from August 2011 to March 2015",lwd=1,col=4)
str(Price.SEK)
lm.01<-lm(Price.SEK)