% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/psar.R
\name{psar}
\alias{psar}
\title{Profile Boosting for Spatial Auto-regressive Model}
\usage{
psar(x, y, w, stopFun = "EBIC", keep = NULL, maxK = NULL, verbose = FALSE)
}
\arguments{
\item{x}{Numeric feature matrix.}

\item{y}{Response vector.}

\item{w}{Weight matrix (row-sum scaled being one).}

\item{stopFun}{Parameter passed to \link{pboost}.}

\item{keep}{Parameter passed to \link{pboost}.}

\item{maxK}{Parameter passed to \link{pboost}.}

\item{verbose}{Parameter passed to \link{pboost}.}
}
\value{
Model object fitted on the selected features.
}
\description{
Profile boosting variable selection for spatial auto-regressive (SAR) model
\deqn{\bm{y} = \rho W \bm{y} + X \beta + \bm{\varepsilon},}
where \eqn{\bm{y}, \bm{\varepsilon} \in \mathbb{R}^n}, \eqn{X \in \mathbb{R}^{n \times p}},
\eqn{\rho \in (-1, 1)}.

\code{psar()} implements the PVS procedure for data matrix.
}
\examples{
set.seed(2026)

w <- set_rook_matrix(9, 9)

n <- NROW(w)
p <- 300
x <- matrix(rnorm(n*p), n) \%*\% chol(0.7^abs(outer(1:p, 1:p, "-")))
eta <- drop(x[, 1:3] \%*\% runif(3, 1.5, 2.0))

rho0 <- 0.2
sig0 <- 1.0
y <- solve(diag(n) - rho0 * w, rnorm(n, eta, sd=sig0)) |> drop()

## ---------- pboost ----------
system.time( egg <- psar(x, y, w, verbose=TRUE) )
y.tilde <- (diag(NROW(x)) - egg[["rho"]] * w) \%*\% y

beta.hat <- egg[["beta"]]
idx <- as.integer(sub("[[:alpha:]]", "", names(beta.hat)))
sig2.hat <- mean( (y.tilde - drop(x[, idx, drop=FALSE] \%*\% beta.hat))^2 )
print( egg[["sig2"]] - sig2.hat )

## ---------- frs ----------
fsar(x, y, w, verbose=TRUE)

}
