arima.sim(list(order = c(1,1,1), ar = 0.7,ma=0.3), n = 200)
#acf()函数中plot是一个逻辑值,他的用法,如果是T,默认也是T就会
#把acf值给画出来,如果是f,ACF值就不会被画出来
set.seed(10);x=rnorm(150)
par(mfrow=c(1,2))#一行两列,两个图
ts.plot(x);acf(x,plot=T)
#注意acf(x,plot=T),acf(x,plot=F)区别
acf(x,plot=T,main="dai T")#如果是f就不会画出图
set.seed(63010)
tw<-arima.sim(n=200,list(ma=c(0.5,0.3)))
tw1<-acf(tw,plot = F)
#==两个等号是恒等于,是个全局变量,一个等号就是赋值,注意theta的书写
plot(tw1,type="o",pch=16,main=expression(paste("ma(2):",theta[1]==0.5,",",theta[2]==0.3)))
plot(acf(arima.sim(n=200,list(ma=c(0.5,0.3))),plot = F),type="o",pch=16,main=expression(paste("ma(2):",theta[1]==0.5,",",theta[2]==0.3)))
#main=expression(paste("ma(2):",theta[1]==0.5,",",theta[2]==0.3)),注意这个expression的用法
#模拟arma(2,2)模型
tw<-arima.sim(n=200,list(ar=c(0.5,0.3),ma=c(0.5,0.3)))
tw1<-acf(arima.sim(n=200,list(ar=c(0.5,0.3),ma=c(0.5,0.3))),plot = F)
plot(tw1,type="o",pch=16,main=expression(paste("arma(2,2):",phi[1]==0.5,",",phi[2]==0.3,",",
theta[1]==0.5,",",theta[2]==0.3)),cex.main=0.7)
#连着写
plot(acf(arima.sim(n=200,list(ar=c(0.5,0.3),ma=c(0.5,0.3))),plot = F),
type="o",pch=16,main=expression(paste("arma(2,2):",phi[1]==0.5,",",
phi[2]==0.3,",",theta[1]==0.5,",",theta[2]==0.3)),cex.main=0.7)
#模拟arma(2,2)模型画pacf图,只需要在上面的acf换成pacf值就行了
tw<-arima.sim(n=200,list(ar=c(0.5,0.3),ma=c(0.5,0.3)))
tw1<-pacf(arima.sim(n=200,list(ar=c(0.5,0.3),ma=c(0.5,0.3))),plot = F)
plot(tw1,type="o",pch=16,main=expression(paste("arma(2,2):",phi[1]==0.5,",",phi[2]==0.3,",",
theta[1]==0.5,",",theta[2]==0.3)),cex.main=0.7)
#连着写
plot(pacf(arima.sim(n=200,list(ar=c(0.5,0.3),ma=c(0.5,0.3))),plot = F),
type="o",pch=16,main=expression(paste("arma(2,2):",phi[1]==0.5,",",
phi[2]==0.3,",",theta[1]==0.5,",",theta[2]==0.3)),cex.main=0.7)
#模拟ARIMA模型,并画出acf、pacf图
set.seed(63010)title(expression(paste("arima(1,1,1):",phi[1]==0.4,",",theta[1]==0.4,cex.main=0.7)))
#注意ar部分,与ma部分系数的书写方式