Displaying 9 results from an estimated 9 matches for "getxlevels".
2018 Dec 19
0
logical variables in models
...] "A" "B" ?C"
- - - - snip- - - - -
Why the discrepancy? It?s true that the level-set (i.e., TRUE, FALSE) for a logical ?factor? is known, but examining the $levels component is a simple way to detect variables treated as factors in the model. For example, I?d argue that .getXlevels() returns misleading information:
- - - - snip- - - - -
> .getXlevels(terms(mod), model.frame(mod))
$c
[1] "a" "b" "c"
$f
[1] "A" "B" ?C"
- - - - snip- - - - -
An alternative for detecting ?factors? is to examine the 'contrasts'...
2019 Aug 30
3
inconsistent handling of factor, character, and logical predictors in lm()
..."setosa"),
data = iris)
Coefficients:
(Intercept) Sepal.Width I(Species == "setosa")TRUE
3.5571 0.9418 -1.7797
------------ snip --------------
I believe that the culprit is .getXlevels(), which makes provision for factor and character predictors but not for logical predictors:
------------ snip --------------
> .getXlevels
function (Terms, m)
{
xvars <- vapply(attr(Terms, "variables"), deparse2,
"")[-1L]
if ((yvar <- attr(Terms, &q...
2025 Jan 07
2
Extracting specific arguments from "..."
...m.wfit(x, y, w, offset = offset, singular.ok = singular.ok,
...)
}
class(z) <- c(if (mlm) "mlm", "lm")
z$na.action <- attr(mf, "na.action")
z$offset <- offset
z$contrasts <- attr(x, "contrasts")
z$xlevels <- .getXlevels(mt, mf)
z$call <- cl
z$terms <- mt
if (model)
z$model <- mf
if (ret.x)
z$x <- x
if (ret.y)
z$y <- y
if (!qr)
z$qr <- NULL
z
}
John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medici...
2025 Jan 07
1
Extracting specific arguments from "..."
...ok = singular.ok,
> ...)
> }
> class(z) <- c(if (mlm) "mlm", "lm")
> z$na.action <- attr(mf, "na.action")
> z$offset <- offset
> z$contrasts <- attr(x, "contrasts")
> z$xlevels <- .getXlevels(mt, mf)
> z$call <- cl
> z$terms <- mt
> if (model)
> z$model <- mf
> if (ret.x)
> z$x <- x
> if (ret.y)
> z$y <- y
> if (!qr)
> z$qr <- NULL
> z
> }
>
>
>
> J...
2025 Jan 07
1
Extracting specific arguments from "..."
...ok = singular.ok,
> ...)
> }
> class(z) <- c(if (mlm) "mlm", "lm")
> z$na.action <- attr(mf, "na.action")
> z$offset <- offset
> z$contrasts <- attr(x, "contrasts")
> z$xlevels <- .getXlevels(mt, mf)
> z$call <- cl
> z$terms <- mt
> if (model)
> z$model <- mf
> if (ret.x)
> z$x <- x
> if (ret.y)
> z$y <- y
> if (!qr)
> z$qr <- NULL
> z
> }
>
>
>
> John...
2025 Jan 07
1
Extracting specific arguments from "..."
Interesting discussion. A few things occurred to me.
Apologies to Iris Simmons: I mixed up his answer with Bert's question.
Bert raises questions about promises, and I think they are related to John Sorkin's question. A big difference between R and most other languages is that function arguments are computed lazily. match.call & substitute tell us what expressions will be evaluated
2008 Nov 28
2
AIC function and Step function
I would like to figure out the equations for calculating "AIC" in both
"step() function" and "AIC () function". They are different. Then I
just type "step" in the R console, and found the "AIC" used in "step()
function" is "extractAIC". I went to the R help, and found:
"The criterion used is
AIC = - 2*log L + k *
2007 Oct 03
1
R-2.6.0 is released
...paths on all
interfaces (they used to on some and not others).
o The find() argument is now named 'numeric' and not 'numeric.':
the latter was needed to avoid warnings about name clashes
many years ago, but partial matching was used.
o stats:::.getXlevels() confines attention to factors since some
users expected R to treat unclass(<a factor>) as a numeric
vector.
o grep(), strsplit() and friends now warn if incompatible sets
of options are used, instead of silently using the documented
priority.
o...
2007 Oct 03
1
R-2.6.0 is released
...paths on all
interfaces (they used to on some and not others).
o The find() argument is now named 'numeric' and not 'numeric.':
the latter was needed to avoid warnings about name clashes
many years ago, but partial matching was used.
o stats:::.getXlevels() confines attention to factors since some
users expected R to treat unclass(<a factor>) as a numeric
vector.
o grep(), strsplit() and friends now warn if incompatible sets
of options are used, instead of silently using the documented
priority.
o...