% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pheno_pls.R
\name{pheno_pls}
\alias{pheno_pls}
\title{Partial Least Squares Analysis for Phenology-Temperature Relationships}
\usage{
pheno_pls(
  pep,
  temp_data,
  by = NULL,
  method = c("robust", "standard"),
  split_month = 6,
  runn_mean = 11,
  ncomp = NULL,
  expl_var = 30,
  max_iter = 20,
  tol = 1e-04
)
}
\arguments{
\item{pep}{A \code{pep} object or data.frame with phenological observations.
Must contain \code{year} and \code{day} columns.}

\item{temp_data}{A data.frame with daily temperature data. Must contain
columns \code{year}, \code{doy} (day of year), and either \code{Tmean} or
both \code{Tmin} and \code{Tmax}.}

\item{by}{Character vector of grouping columns to match phenology and
temperature data (e.g., \code{"s_id"} for station-specific analysis).
Default \code{NULL} uses the same temperature for all observations per year.}

\item{method}{Character. PLS method to use:
\describe{
\item{"robust"}{(Default) Iteratively reweighted PLS using bisquare weights.
Resistant to outliers in both phenology and temperature data.}
\item{"standard"}{Classical PLS regression without robust weighting.}
}}

\item{split_month}{Integer (1-12). The last month to include in the
phenological year. Default 6 (June) means July-June phenological years.
This is important for spring phenology where relevant temperatures
span the previous autumn/winter.}

\item{runn_mean}{Integer (odd). Window size for running mean smoothing of
temperatures. Default 11 days. Larger values produce smoother results.}

\item{ncomp}{Integer or NULL. Number of PLS components. If NULL (default),
automatically determined to explain at least \code{expl_var} percent
of variance.}

\item{expl_var}{Numeric. Minimum percentage of variance to explain when
automatically selecting components. Default 30.}

\item{max_iter}{Integer. Maximum iterations for robust method. Default 20.}

\item{tol}{Numeric. Convergence tolerance for robust method. Default 1e-4.}
}
\value{
An object of class \code{pheno_pls} containing:
\describe{
\item{vip}{Data.frame with Variable Importance in Projection scores
for each day of the phenological year.}
\item{coefficients}{PLS regression coefficients for each day.}
\item{model}{The fitted PLS model object.}
\item{weights}{Observation weights (all 1 for standard method).}
\item{r_squared}{Model R-squared.}
\item{ncomp}{Number of components used.}
\item{method}{Method used ("robust" or "standard").}
\item{n_obs}{Number of observations.}
\item{n_years}{Number of years analyzed.}
}
}
\description{
Performs PLS regression to identify temperature-sensitive periods affecting
phenological timing. This is useful for understanding which parts of the
year have the strongest influence on phenological events.
}
\details{
PLS regression is particularly useful for phenology-temperature analysis
because it handles the high collinearity between daily temperatures
(adjacent days are highly correlated) while identifying which periods
have the strongest influence on phenological timing.

The robust method uses iteratively reweighted PLS with bisquare weights,
which downweights observations with large residuals. This is important
for phenological data which may contain outliers from observation errors
or unusual weather events.
}
\section{Interpreting Results}{

\describe{
\item{VIP scores}{Values > 0.8 indicate important variables. Days with
high VIP scores have strong influence on phenology timing.}
\item{Coefficients}{Negative coefficients indicate that warmer temperatures
during that period lead to earlier phenology (lower DOY).}
}
}

\section{Phenological Year}{

Spring phenology (e.g., flowering) is influenced by temperatures from the
previous autumn through spring. The \code{split_month} parameter defines
where to split the calendar year. With \code{split_month = 6}, a flowering
event in April 2020 is analyzed against temperatures from July 2019
through June 2020.
}

\examples{
\donttest{
data(pep_seed)

# Create example temperature data (fewer years for speed)
years <- 2005:2012
temp <- data.frame(
  year = rep(years, each = 365),
  doy = rep(1:365, length(years)),
  Tmin = rnorm(365 * length(years), mean = 5, sd = 8),
  Tmax = rnorm(365 * length(years), mean = 15, sd = 8)
)

# Run standard PLS (fast: no CV, fixed components)
result <- pheno_pls(pep_seed, temp, method = "standard", ncomp = 2)
print(result)
}

}
\references{
Luedeling E, Gassner A (2012). Partial Least Squares Regression for
analyzing walnut phenology in California. Agricultural and Forest
Meteorology 158-159:104-113.

Wold S, Sjostrom M, Eriksson L (2001). PLS-regression: a basic tool of
chemometrics. Chemometrics and Intelligent Laboratory Systems 58:109-130.
}
\seealso{
\code{\link{pheno_trend_turning}} for trend analysis,
\code{\link{pheno_anomaly}} for anomaly detection
}
\author{
Matthias Templ
}
