% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mensalize-sidra-series.R
\name{compute_series_starting_points}
\alias{compute_series_starting_points}
\title{Compute Starting Points from Microdata}
\usage{
compute_series_starting_points(
  monthly_estimates,
  rolling_quarters,
  calibration_start = NULL,
  calibration_end = NULL,
  scale_factor = 1000,
  use_series_specific_periods = TRUE,
  verbose = TRUE
)
}
\arguments{
\item{monthly_estimates}{data.table with columns:
\itemize{
\item \code{anomesexato}: YYYYMM exact month
\item \code{z_*}: Monthly estimates from calibrated microdata (one column per series)
}}

\item{rolling_quarters}{data.table from \code{fetch_sidra_rolling_quarters}}

\item{calibration_start}{Integer. Start of calibration period (YYYYMM).
Default NULL uses .PNADC_DATES$DEFAULT_CALIB_START (201301).
Note: CNPJ series automatically use CNPJ_CALIB_START (201601) regardless.}

\item{calibration_end}{Integer. End of calibration period (YYYYMM).
Default NULL uses .PNADC_DATES$DEFAULT_CALIB_END (201912).}

\item{scale_factor}{Numeric. Scale factor for z_ values (usually 1000). Default 1000.}

\item{use_series_specific_periods}{Logical. If TRUE (default), use series-specific
calibration periods for CNPJ series (201601-201912) and cumsum starting dates
(201510). Set to FALSE to use uniform calibration for all series.}

\item{verbose}{Logical. Print progress? Default TRUE.}
}
\value{
data.table with columns:
\describe{
\item{series_name}{Character. Series name}
\item{mesnotrim}{Integer. Month position (1, 2, or 3)}
\item{y0}{Numeric. Starting point value}
}
}
\description{
For advanced users who want to compute custom starting points using their
own calibrated microdata estimates.
}
\details{
The starting points (y0) are computed by:
\enumerate{
\item Calculating cumulative variations from SIDRA rolling quarters
\item Computing backprojection: e0 = z / scale_factor - cum
\item Averaging e0 by mesnotrim over the calibration period
}
}
\section{Series-Specific Handling}{

When \code{use_series_specific_periods = TRUE}, the following series receive
special handling for series-specific data availability:
\describe{
\item{CNPJ series}{empregadorcomcnpj, empregadorsemcnpj, contapropriacomcnpj,
contapropriasemcnpj use calibration period 201601-201912 and cumsum starts
from 201510 (when V4019 became available)}
}
}

\examples{
\dontrun{
rq <- fetch_sidra_rolling_quarters()
z_agg <- compute_z_aggregates(calibrated_data)
y0 <- compute_series_starting_points(z_agg, rq)
monthly <- mensalize_sidra_series(rq, starting_points = y0)
}

}
