% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sim.missing.data.R
\name{sim.missing.data}
\alias{sim.missing.data}
\title{Remove morphological character data}
\usage{
sim.missing.data(
  data = NULL,
  seq = NULL,
  method = NULL,
  probability = NULL,
  traits = NULL,
  taxa = NULL
)
}
\arguments{
\item{data}{A `morpho` object with sequence data.}

\item{seq}{Character. Which sequence data to use: "tips", "nodes", or "SA".}

\item{method}{Character. Method for removing data. Options:
\itemize{
  \item \code{"random"}: removes characters randomly across the entire matrix.
  \item \code{"partition"}: removes characters by partition
  (one probability per partition).
  \item \code{"rate"}: removes characters by rate category
  (one probability per rate category, ordered from slowest to fastest).
  \item \code{"trait"}: removes characters from specific traits across all taxa.
  \item \code{"taxa"}: removes characters from specific taxa across all traits.
  \item \code{"extinct"}: removes data from extinct taxa only.
  Requires \code{seq = "tips"} as extinct taxa are only present at the tips of the tree.
  \item \code{"trait_taxa"}: removes characters at the intersection of specific traits and
    specific taxa, reflecting scenarios where certain anatomical regions are less likely
    to be preserved in particular lineages.
}}

\item{probability}{Numeric. Probability of missing data (single value or vector depending on method).}

\item{traits}{Integer vector. Indices of traits to remove. Required when
\code{method = "trait"} or \code{method = "trait_taxa"}.}

\item{taxa}{Character vector. Names of taxa to remove data from. Required when
\code{method = "taxa"} or \code{method = "trait_taxa"}.}
}
\value{
An object of class morpho.
}
\description{
This function removes characters from a morphological matrix simulated using morphsim
}
\examples{
# simulate a phylogenetic tree
phy <- ape::rtree(10)

# simulate characters along the branches of the tree
morpho_data <-  sim.morpho(tree = phy,
                           k = c(2,3,4),
                           trait.num = 20,
                           ancestral = TRUE,
                           partition = c(10,5,5),
                           ACRV = "gamma",
                           variable = TRUE,
                           ACRV.ncats = 4,
                           define.Q = NULL)

# randomly remove data
missing.data <- sim.missing.data(data = morpho_data,
                                  method = "random",
                                  seq = "tips",
                                  probability = 0.5)


# remove data based on the partition
missing.data <- sim.missing.data(data = morpho_data,
                                 method = "partition",
                                 seq = "tips",
                                 probability = c(0.7, 0, 0.5))

# remove data based on the rate it was simulated under
missing.data <- sim.missing.data(data = morpho_data,
                                        method = "rate",
                                        seq = "tips",
                                        probability = c(0,0,0.2,1))

# remove characters from specific traits
missing.data <- sim.missing.data(data = morpho_data,
                                 method = "trait",
                                 seq = "tips",
                                 probability = 1,
                                 traits = c(1,2,5))

# remove characters from specific taxa
missing.data <- sim.missing.data(data = morpho_data,
                                 method = "taxa",
                                 seq = "tips",
                                 probability = 1,
                                 taxa = c("t1", "t2"))

# remove specific character traits from specific taxa
missing.data <- sim.missing.data(data = morpho_data,
                                 method = "trait_taxa",
                                 seq = "tips",
                                 probability = 0.8,
                                 traits = c(1,2,5),
                                 taxa = c("t1", "t2"))
}
