SHARE
TWEET

Untitled

a guest Apr 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Eko <- read.csv("C:/Users/mpady/Desktop/SPY.csv",sep=";")
  2. SPY<-Eko[5822:6073,1]
  3. SPY<-as.numeric(gsub(",", ".", gsub("\\.", "", SPY)))
  4. MA200<-Eko[5822:6073,2]
  5. MA200<-as.numeric(gsub(",", ".", gsub("\\.", "",MA200)))
  6. j<-rep(1,length(MA200))
  7. X<-cbind(j,MA200)
  8. n<-length(SPY)
  9. Linmodel<-lm(SPY~MA200)
  10. summary(Linmodel)
  11. sigmahl<-summary(Linmodel)$sigma
  12. #test normality rezidui
  13. epsilonHAT<-SPY-X%*%Linmodel$coefficients
  14. shapiro.test(epsilonHAT)
  15. ks.test(epsilonHAT,"pnorm", mean=mean(epsilonHAT),sd=sqrt(var(epsilonHAT)))
  16. #vykreslenie dat a regresnej krivky
  17. plot(MA200,SPY)
  18. abline(Linmodel$coefficients,col="red")
  19. #CUSUM
  20. # vypocet s^2 z celej vzorky
  21. k<-length(Linmodel$coefficients)
  22. SPYfitted<-X%*%solve(t(X)%*%X)%*%t(X)%*%SPY
  23. RSS<-t(SPY-SPYfitted)%*%(SPY-SPYfitted)
  24. s2<-RSS/(n-k)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top