楼主: franciswangziti
463 0

[统计软件与数据分析] 急!数据求助[R](趋势和模型选择) [推广有奖]

  • 0关注
  • 0粉丝

小学生

50%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
193 点
帖子
2
精华
0
在线时间
12 小时
注册时间
2018-3-7
最后登录
2020-3-25

楼主
franciswangziti 发表于 2019-7-14 18:25:19 |AI写论文
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)





您需要登录后才可以回帖 登录 | 我要注册

本版微信群
扫码
拉您进交流群
GMT+8, 2026-2-16 06:40