% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/addSimThresh.R
\name{addSimThresh}
\alias{addSimThresh}
\title{Add "simThresh" Simulated Threshold Feature}
\usage{
addSimThresh(
  data,
  target_column = "y",
  target_type = "default",
  pval_target = 0.049,
  tolerance = 5e-04,
  adj_bonf = FALSE
)
}
\arguments{
\item{data}{A data frame containing the dataset.}

\item{target_column}{Character; name of the target column in the dataset. Default is "y".}

\item{target_type}{Character; specifies the type of the target variable. Can be "default",
"regression", or "classification". If "default", the function will automatically
determine the type based on the target column.}

\item{pval_target}{Numeric; the desired p-value for the simulated feature. Default is 0.049.}

\item{tolerance}{Numeric; the acceptable deviation from the target p-value. Default is 0.0005.}

\item{adj_bonf}{Logical; if TRUE, applies Bonferroni correction when calculating the p-value. Default is FALSE.}
}
\value{
The original data frame with an additional column named "simThresh" containing the simulated feature.
}
\description{
Adds a simulated feature to the dataset that has a p-value close to a specified threshold
when tested against the target variable. This function is useful for testing feature
selection methods and significance thresholds.
}
\examples{
# Example with a regression dataset
df <- data.frame(
  feature1 = rnorm(100),
  feature2 = rnorm(100, mean = 5),
  feature3 = runif(100, min = 0, max = 10),
  y = 1:100
)

# Add a simulated feature with p-value close to 0.05
df_with_sim <- addSimThresh(df, target_column = "y", pval_target = 0.05)

# Check that the correlation between simThresh and the target variable is close to 0.05
print(cor.test(df_with_sim$simThresh, df_with_sim$y)$p.value)

# Example with a classification dataset
df_class <- data.frame(
  feature1 = rnorm(100),
  feature2 = rnorm(100, mean = 5),
  feature3 = runif(100, min = 0, max = 10),
  y = factor(c(rep("A", 50), rep("B", 50)))
)

# Add a simulated feature with p-value close to 0.01
df_class_with_sim <- addSimThresh(df_class, target_column = "y", 
                                 pval_target = 0.05)

# Check that the p-value of the simThresh column is close to 0.05
print(t.test(simThresh ~ y, data = df_class_with_sim)$p.value)


}
