% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/estimate_AD_from_OSDR.R
\name{estimate_AD_from_OSDR}
\alias{estimate_AD_from_OSDR}
\title{Estimate Factor Loadings and Uniquenesses from OSDR Output}
\usage{
estimate_AD_from_OSDR(data, res, m)
}
\arguments{
\item{data}{The original data matrix (n x p) used in the online SIR procedure.}

\item{res}{A list returned by \code{\link{online_sir_lfm}}, containing at least the component \code{B_hat} (p x K_est matrix).}

\item{m}{The target number of factors (structural dimension). If \code{B_hat} has fewer columns, the missing directions are filled with zeros; if more, only the first \code{m} columns are retained.}
}
\value{
A list with components:
\item{A_est}{Estimated factor loading matrix of dimension p x m.}
\item{D_est}{Estimated diagonal noise covariance matrix of dimension p x p, with diagonal entries forced to be at least 0.01.}
}
\description{
Extracts the estimated factor loading matrix \eqn{A} and the diagonal noise covariance matrix \eqn{D} from the output of \code{\link{online_sir_lfm}}. The subspace estimate \code{B_hat} is truncated or padded to have exactly \code{m} columns, used as \eqn{A}, and \eqn{D} is obtained by subtracting the factor covariance contribution from the sample covariance matrix, with a lower bound on the diagonal entries to ensure positivity.
}
\examples{
\dontrun{
set.seed(123)
n <- 500; p <- 20; m <- 3
B_true <- qr.Q(qr(matrix(rnorm(p * m), p, m)))
f <- matrix(rnorm(n * m), n, m)
eps <- matrix(rexp(n * p, rate = 1) - 1, n, p) # Laplace noise
X <- f \%*\% t(B_true) + eps

# Run online SIR
res <- online_sir_lfm(X, K_true = m, method = "gradient", verbose = FALSE)

# Estimate A and D from the result
AD <- estimate_AD_from_OSDR(X, res, m)
print(head(AD$A_est))
print(diag(AD$D_est)[1:5])
}

}
