if(!require(devtools)) install.packages("devtools")
library(nltsa)
library(astsa) # load astsa package sunspot = sqrt(sunspot.year) # transform sunspot data plot(sunspot, xlab="year") # plot data
acf2(sunspot) # not shown
ACF PACF
[1,] 0.82 0.82
[2,] 0.46 -0.65
[3,] 0.06 -0.15
[4,] -0.25 0.01
[5,] -0.42 -0.05
[6,] -0.40 0.20
[7,] -0.
Here we explore time series type dataset. Inbuilt Airpassenger dataset was used.
Load the data set notice Class is labeled “ts”-indicating a time series format
data("AirPassengers")
class(AirPassengers)
[1] "ts"
end(AirPassengers)
[1] 1960 12
We can define the cycle of this time series in years
frequency(24)
[1] 1
Summary
summary(AirPassengers)
plot(AirPassengers)
plot(AirPassengers)
abline(reg= lm (AirPassengers~time(AirPassengers)))
pritn cycle across years, then aggregate cycles and display a year on year trend
cycle(AirPassengers)
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1949 1 2 3 4 5 6 7 8 9 10 11 12
1950 1 2 3 4 5 6 7 8 9 10 11 12
1951 1 2 3 4 5 6 7 8 9 10 11 12
1952 1 2 3 4 5 6 7 8 9 10 11 12
1953 1 2 3 4 5 6 7 8 9 10 11 12
1954 1 2 3 4 5 6 7 8 9 10 11 12
1955 1 2 3 4 5 6 7 8 9 10 11 12
1956 1 2 3 4 5 6 7 8 9 10 11 12
1957 1 2 3 4 5 6 7 8 9 10 11 12
1958 1 2 3 4 5 6 7 8 9 10 11 12
1959 1 2 3 4 5 6 7 8 9 10 11 12
1960 1 2 3 4 5 6 7 8 9 10 11 12
plot(aggregate(AirPassengers,FUN = mean))
boxplot on seasonal data
boxplot(AirPassengers~cycle(AirPassengers))
The variance and the mean value in July and August is much higher than rest of the months.
The main purpose of P-value Analysis was to use the Tooth Growth dataset. I wanted to showcase various R packages such as ggpubr and dplyr that use default methods such “wilcos.test”,“t.test”" etc. I intend to add more details of this analysis later. I wanted to demonstrate the working code here first.
if(!require(devtools)) install.packages("devtools")
devtools::install_github("kassambara/ggpubr")
Skipping install of 'ggpubr' from a github remote, the SHA1 (cb0f308d) has not changed since last install.