全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 悬赏大厅
464 0
2019-07-14
悬赏 8 个论坛币 未解决
明天交作业...共8论坛币,若不足可以微信,谢谢!
Exercise 3
Consider the data set from the file sunspot.XLSX. This set contains sunspots, which are “are temporary phenomena on the Sun's photosphere that appear as spots darker than the surrounding areas” [Wikipedia].
a) Are there missing values? If yes, how to replace them? Carry your idea out.
b) Are there outliers or irregular values? Check and if yes, please filter.
c) Is there are trend and other deterministic effects? Please extract trend and seasonality.
Exercise 4
Consider the data set from the file sampleSeries.xlsx.
a) Fit an appropriate time series model to the data set. Describe your decisions.
b) Create a set of 1000 simulations with length 500.


以上是原题,以下是我的code,问题是C)和4a)b),在最底下
#3.
#a)
library(readxl)
sunspots<-read_excel("C:/Users/Pretty-PC/Desktop/Homework_Assignment/Homework_Assignment/Sunspots.xlsx")
sun<-as.numeric(unlist(sunspots[,3]))
sum(is.na(sun))
lag=10
ma = numeric(length(sun))
for (k in (lag+1):(length(sun)-lag))
{
  ma[k]<-mean(sun[(k-lag):(k + lag)],na.rm=TRUE)
}
plot(sun,type="l")
lines(ma,col="blue")
sum(is.na(sun))
sum(is.na(ma))
sun<-ma
#b)
x=sun[1:2000]
y=sun[1:2000]-mean(sun[1:2000])
z=diff(lag(x))
plot(z,type="l")
mean(z)
var(z)
sd(z)
a=z/sd(z)
plot(a,type="l")
sd(a)
y<-z[(z>-0.1)&(z<+0.1)]  
plot(y,type = "l")
sd(y)
y<-numeric(length(z)-1)
counter=1
for(k in 1:length(z))
{
  if(z[k]>-0.3)
  {
    y[counter]=z[k]
    counter-counter+1
  }
  else
    {
  }
  }  
#c)如何取趋势....

for(k in 2:length(x))
{
  epsilon=rnorm(1,mean=0,sd=0.5)
  sun[k]=sun[k-1]+epsilon
}
plot(x,type="l")





#4.???求助如何选模型

Sunspots.xlsx
大小:(61.84 KB)

 马上下载







二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群