% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mean.detrended.dm.R
\name{mean_detrended.dm}
\alias{mean_detrended.dm}
\title{Calculate the mean detrended dendrometer series}
\usage{
mean_detrended.dm(
  detrended_dm,
  series = NULL,
  ac1.remove = TRUE,
  robust.mean = TRUE,
  trim = 0.15,
  seasonal_rescale = TRUE
)
}
\arguments{
\item{detrended_dm}{An object of class \code{"dm_detrended"} returned by
\code{dm.detrend.fit()}, or a data frame in the same wide format as
\code{$detrended_data}.}

\item{series}{Optional character vector of tree/series names to include.
Default is \code{NULL}, meaning all available detrended series are used.}

\item{ac1.remove}{Logical. If \code{TRUE}, removes temporal autocorrelation
from the mean detrended series using \code{forecast::auto.arima()} applied
separately within each season. Default is \code{TRUE}.}

\item{robust.mean}{Logical. If \code{TRUE}, calculates a trimmed mean across
trees at each time step. Default is \code{TRUE}.}

\item{trim}{Proportion to trim from each tail when \code{robust.mean = TRUE}.
Default is \code{0.15}.}

\item{seasonal_rescale}{Logical. If \code{TRUE}, the autocorrelation-removed
series is shifted to non-negative values and rescaled to mean = 1 within
each season. Default is \code{TRUE}.}
}
\value{
A tibble of class \code{"mean_dm_detrended"} containing:
\itemize{
  \item metadata columns copied from the detrended input,
  \item \code{STD_DDM}: the mean detrended series,
  \item \code{RES_DDM}: the autocorrelation-removed mean detrended series
        (returned only when \code{ac1.remove = TRUE}).
}
}
\description{
Computes a mean detrended dendrometer series across multiple trees from the
output of \code{dm.detrend.fit()}.

This is useful for creating one representative detrended series for a species,
site, or treatment group after detrending individual dendrometer series.

Optionally, the function can:
\itemize{
  \item calculate a \strong{robust mean} using a trimmed mean across trees,
  \item remove temporal autocorrelation from the mean detrended series using
  \code{forecast::auto.arima()},
  \item rescale the autocorrelation-removed series so it stays non-negative
  and has mean = 1 within each vegetation season.
}
}
\examples{
\donttest{
fit1 <- dm.growth.fit(
  df = gf_nepa17,
  TreeNum = 1:2,
  method = "gompertz",
  year_mode = "yearly",
  verbose = FALSE
)

det1 <- dm.detrend.fit(fit1)

m_det <- mean_detrended.dm(det1)
head(m_det, 10)
}

}
