Skip to content

keeping a variable as qualitative even if it is coded with numbers

1 message · Gi-Mick Wu

#
Hi Amelie,

Could it be ok as it is?

If the only values are 0 & 1, it should similar to coding for a binary qualitative variable (e.g. presence/absence, male/female). I believe qualitative variables are "dummy-coded" with 0-1 anyway in order to calculate almost any statistics on them.

Try this for example:

##### R CODE
# variables
y <- rnorm(100)
xchar <- rep(c("a","b"), 50)
xnum <- rep(c(0,1), 50)

# both linear models give the same result
lm(y~xchar)
lm(y~xnum)
#####

Hope that helps...

Mick
On 2010-11-27, at 3:00 AM, <r-sig-ecology-request at r-project.org> <r-sig-ecology-request at r-project.org> wrote: