Learn R Programming

mixComp (version 0.1-2)

faithful: Faithful Dataset

Description

Waiting time between eruptions and the duration of the eruption for the Old Faithful geyser in Yellowstone National Park, Wyoming, USA from datasets.

Usage

data(faithful)

Arguments

Format

A data frame with 272 observations on 2 variables:

eruptions

numeric, eruption time in mins

waiting

numeric, waiting time to next eruption (in mins)

Examples

Run this code
# NOT RUN {
data(faithful)

faithful.obs <- faithful$waiting

# function giving the j^th raw moment of the standard normal distribution,
# needed for calculation of the Hankel matrix via the "translation" method
# (assuming gaussian components with variance 1)
mom.std.norm <- function(j){
  ifelse(j %% 2 == 0, prod(seq(1, j - 1, by = 2)), 0)
}

# generate list of parameter bounds
norm.bound.list <- list("mean" = c(-Inf, Inf), "sd" = c(0, Inf))

# define the MLE functions for the mean and sd: 
MLE.norm.mean <- function(dat) mean(dat)
MLE.norm.sd <- function(dat){
sqrt((length(dat) - 1) / length(dat)) * sd(dat)
} 
MLE.norm.list <- list("MLE.norm.mean" = MLE.norm.mean, "MLE.norm.sd" = MLE.norm.sd)

# construct a 'datMix' object that summarizes all the necessary information:
faithful.dM <- datMix(faithful.obs, dist = "norm", discrete = FALSE,
                      theta.bound.list = norm.bound.list,
                      MLE.function = MLE.norm.list, Hankel.method = "translation",
                      Hankel.function = mom.std.norm)

# estimate the number of components and plot the results:
res <- hellinger.cont(faithful.dM, bandwidth = 4,
                      sample.n = 5000, threshold = "AIC")
plot(res)
# }

Run the code above in your browser using DataLab