Skip to content
Back to formatted view

Raw Message

Message-ID: <46954B32-E577-4167-A795-0F0F0B4ADF2E@me.com>
Date: 2010-08-03T13:34:02Z
From: Sam
Subject: factor / intiger

Dear List

I have a excel spread sheet with 5 columns that contain categorical data. I have recoded them to numbers 

A	B 	C
0	0	0
1	1	1
2	2	2
3	3
4
5

etc

When i read it into R and do str(dataframe) i get -

 $ A       : int  1 1 1 1 1 1 1 1 1 1 ...
 $ B    : int  1 1 1 1 1 1 1 1 1 1 ...
 $ C       : int  0 0 0 0 0 0 0 0 0 0 ...
 $ D    : int  0 0 0 0 0 0 0 0 0 0 ...
 $ E : int  0 0 0 0 0 0 0 0 0 0 ...

I then realised they should probably be factors instead of integers so used as.factor to convert them -

A <- as.factor(A)

Now when i run the GLMM the AIC values are different from when they were integers, i have 2 questions

1. Should i not have converted the categories to numbers in the excel spreadsheet before import.

2. Why are the AIC values different when i use as.factor as opposed to keeping them as integers, and which approach is recommended?

Thanks

Sam