Displaying 3 results from an estimated 3 matches for "diseasedtru".
Did you mean:
diseasedtrue
2019 Aug 31
0
inconsistent handling of factor, character, and logical predictors in lm()
...roblem, which would become more
> noticeable if logicals were treated as factors.
>
>> d <- data.frame(Age=c(2,4,6,8,10), Weight=c(878, 890, 930, 800, 750),
> Diseased=c(FALSE,FALSE,FALSE,TRUE,TRUE))
>> coef(lm(data=d, Weight ~ Age + Diseased))
> (Intercept) Age DiseasedTRUE
> 877.7333 5.4000 -151.3333
>> coef(lm(data=d, Weight ~ Age + factor(Diseased)))
> (Intercept) Age factor(Diseased)TRUE
> 877.7333 5.4000 -151.3333
>> coef(lm(data=d, Weight ~ Age + Diseased, subset=Age&l...
2019 Aug 31
2
inconsistent handling of factor, character, and logical predictors in lm()
Dear Abby,
> On Aug 30, 2019, at 8:20 PM, Abby Spurdle <spurdle.a at gmail.com> wrote:
>
>> I think that it would be better to handle factors, character predictors, and logical predictors consistently.
>
> "logical predictors" can be regarded as categorical or continuous (i.e. 0 or 1).
> And the model matrix should be the same, either way.
I think that
2019 Aug 30
3
inconsistent handling of factor, character, and logical predictors in lm()
Dear R-devel list members,
I've discovered an inconsistency in how lm() and similar functions handle logical predictors as opposed to factor or character predictors. An "lm" object for a model that includes factor or character predictors includes the levels of a factor or unique values of a character predictor in the $xlevels component of the object, but not the FALSE/TRUE values