titanic: Titanic data set

titanicR Documentation

Titanic data set

Description

The data set provides information on the passengers of Titanic.

Usage

data(titanic)

Format

A data.frame with 1309 individuals and 8 variables.

  • survived: 0 = No, 1 = Yes (factor)

  • pclass: ticket class 1st, 2nd, 3rd (factor)

  • sex: male or female (factor)

  • age: age in years

  • sibsp: number of siblings/spouses aboard the Titanic

  • parch: number of parents/children aboard the Titanic

  • fare: ticket price in pounds

  • embarked: port of Embarkation C = Cherbourg, Q = Queenstown, S = Southampton (factor)

Source

Titanic People Database, Encyclopedia Titanica, https://www.encyclopedia-titanica.org/titanic-survivors/

https://www.kaggle.com/c/titanic/data

See Also

Other data: CanadianWeather, prostate, simData

Examples


data(titanic)

head(titanic)

## Use the MixtComp format
dat <- titanic

# refactor categorical data: survived, sex, embarked and pclass
dat$sex <- refactorCategorical(dat$sex, c("male", "female", NA), c(1, 2, "?"))
dat$embarked <- refactorCategorical(dat$embarked, c("C", "Q", "S", NA), c(1, 2, 3, "?"))
dat$survived <- refactorCategorical(dat$survived, c(0, 1, NA), c(1, 2, "?"))
dat$pclass <- refactorCategorical(dat$pclass, c("1st", "2nd", "3rd"), c(1, 2, 3))

# replace all NA by ?
dat[is.na(dat)] <- "?"

# create model
model <- list(
    pclass = "Multinomial",
    survived = "Multinomial",
    sex = "Multinomial",
    age = "Gaussian",
    sibsp = "Poisson",
    parch = "Poisson",
    fare = "Gaussian",
    embarked = "Multinomial"
)

# create algo
algo <- createAlgo()

# run clustering
resLearn <- mixtCompLearn(dat, model, algo, nClass = 2:15, criterion = "ICL", nRun = 3, nCore = 1)
summary(resLearn)

plot(resLearn)


## Use standard data.frame and R format because titanic contains only standard variables.
# mixtCompLearn in "basic" mode without model parameters and data as a data.frame.
# A Multinomial model is used for factor variables, a Poisson for integer
# and a Gaussian for numeric.
resLearn <- mixtCompLearn(titanic, nClass = 2:15, nRun = 3, nCore = 1)

# imputed model
getType(resLearn)



RMixtComp documentation built on July 9, 2023, 6:06 p.m.