% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/adaptivelocaldiffexp.R
\name{adaptivelocaldiffexp}
\alias{adaptivelocaldiffexp}
\title{Compute local diffusion exponents with adaptive fitting range}
\usage{
adaptivelocaldiffexp(adj, max_time, t_min, t_max_min, t_max_max)
}
\arguments{
\item{adj}{Symmetric adjacency matrix (0/1, no self-loops) of a connected graph.}

\item{max_time}{Maximum number of steps (t = 1, ..., max_time) for MSD calculation.}

\item{t_min}{Fixed starting time for fitting (>= 1).}

\item{t_max_min}{Minimum end time to try (must be >= t_min + 2 to have at least 3 points).}

\item{t_max_max}{Maximum end time to try (must be <= max_time).}
}
\value{
A list with components:
  \item{H}{Numeric vector of length n, estimated local diffusion exponents.}
  \item{best_R2}{Numeric vector of length n, the best R^2 achieved.}
  \item{best_tmax}{Integer vector of length n, the t_max that gave the best R^2.}
  \item{msd}{Matrix of size max_time x n, where rows are times 1:max_time and columns are nodes.}
  \item{fit_objects}{List of lm objects for the best fit (one per node).}
}
\description{
For each node, the mean squared resistance displacement is computed exactly
via transition matrix powers. Then, for a fixed starting time t_min, we try
all possible end times t_max from t_max_min to t_max_max, perform a log-log
linear regression, and select the t_max that maximizes the coefficient of
determination (R^2). The corresponding H_i is returned.
}
\examples{
# Path graph with 4 nodes
adj <- matrix(c(0,1,0,0,
                1,0,1,0,
                0,1,0,1,
                0,0,1,0), nrow=4, byrow=TRUE)
res <- adaptivelocaldiffexp(adj, max_time = 50,
                                           t_min = 10, t_max_min = 20, t_max_max = 40)
print(res$H)
}
\references{
Nie, Chun-Xiao. "Vertex‑level diffusion scaling from resistance distance."  .Chaos, Under Review.
}
