Skip to content

[Bugzilla#18058] lm(..., subset=...) producing incorrect model matrix #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/library/stats/man/lm.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ lm(formula, data, subset, weights, na.action,
typically the environment from which \code{lm} is called.}

\item{subset}{an optional vector specifying a subset of observations
to be used in the fitting process. (See additional details about how
this argument interacts with data-dependent bases in the
\sQuote{Details} section of the \code{\link{model.frame}}
documentation.)}
to be used in the fitting process. (See additional details about how
this argument interacts with data-dependent bases under \sQuote{Details}
below.)}

\item{weights}{an optional vector of weights to be used in the fitting
process. Should be \code{NULL} or a numeric vector.
Expand Down Expand Up @@ -132,6 +131,10 @@ lm(formula, data, subset, weights, na.action,
All of \code{weights}, \code{subset} and \code{offset} are evaluated
in the same way as variables in \code{formula}, that is first in
\code{data} and then in the environment of \code{formula}.
Note that values calculated inside the formula, such as \code{mean(x)},
are evaluated before subsetting - which may lead to unexpected results
if used with \code{subset}. For more information see the
\sQuote{Details} section of the \code{\link{model.frame}}.
}
\value{
\code{lm} returns an object of \code{\link{class}} \code{"lm"} or for
Expand Down