---
title: "Getting Started with AutoStrataK: Automatic Stratification for Survey Sampling"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Getting Started with AutoStrataK}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(AutoStrataK)
```

# Introduction

AutoStrataK provides tools for automatic stratification of survey
populations using clustering-based approaches. The package assists
researchers and survey practitioners in constructing homogeneous strata
to improve sampling efficiency and precision.

# Example Data

Create a small synthetic dataset.

```{r}
data <- data.frame(
  income = c(15, 18, 20, 25, 30, 35, 40, 50),
  expenditure = c(10, 12, 14, 18, 22, 26, 30, 38)
)

head(data)
```

# Generate Strata

Use `autostrata()` to automatically generate strata.

```{r}
result <- autostrata(
  data = data,
  target = income,
  n_strata = 4
)

head(result)
```

# Evaluate Stratification

Assess the quality of the generated strata.

```{r}
evaluate_strata(
  result,
  target = "income"
)
```

# Summary

Display summary information.

```{r}
summary(result)
```

# Visualization

Visualize the resulting strata.

```{r}
plot(result)
```

# Conclusion

AutoStrataK provides a simple workflow for automatic stratification,
evaluation, summarization, and visualization of survey populations.
