#################################### # 第4章 モデリング #################################### ### 確率分布モデルの表示 #  TSSSパッケージ gdensty(xmin=-4, xmax=4) # normal distribution cdensty(xmin=-4, xmax=4) # Cauchy distribution pdensty(shape=2, xmin=-4, xmax=4) # Pearson distribution exdensty(xmin=0, xmax=8) # exponential distribution exdensty(xmin=-4, xmax=4) # exponential distribution chi2densty(df=3, xmin=0, xmax=8) # Chi-square distribution dexdensty(xmin=-4, xmax=2) # double exponential distribution udensty(xmin=0, xmax=1) # uniform distribution ### 正規乱数の生成 # Gauss noise: z <- simssm(trend=NULL,arcoef=NULL, ar=NULL, seasonal.order=0, seasonal=NULL, tau1=NULL, tau2=NULL, tau3=NULL, n=20, ns=1, init=1992092521, sigma2=1.0, plot=TRUE) hist(z$y,breaks=seq(-3,3,0.25)) stripchart(z$y,pch=1,cex=1.5,xlim=c(-2,2)) ############################################# #Computation of Kullback-Leibler Information by numerical integration # g:gauss, f:gauss klinfo(1, c(0, 1), 1, c(0.1, 1.5), 8) # g:gauss, f:cauchy klinfo(1, c(0, 1), 2, c(0, 1), 8) ############################################## # Box-Cox transformation ############################################## # read subspot data and Whard data sunspot <- as.ts(read.csv("sunspot_new.csv")) whard <- as.ts(read.csv("whard_new.csv")) data(Sunspot) # Sun spot number data boxcox(Sunspot) data(Whard) # Wholesale hardware data boxcox(Whard) # Box-Cox変換のAICの図示 x <- boxcox(Whard) plot(x$aic.z,col="red") # Box-Cox変換の計算結果の表示(AIC,対数尤度,平均,分散 x <- boxcox(Whard) x