Hello
I am in the process of coming up with an amelia() command for my survey
data, starting with a small subset to get a start and learn in the process.
It is about how to decide whether to specify variables as noms or ords.
When I look at my data (mostly ordered factors), I think I should use
the ords specification (see at bottom) and not "noms", but unfortunately
"ords" gives an error message whereas "noms" only gives warnings. --
Thus, my two questions are:
1) Which specification approach A or B is the correct (or better) one?
Or, more generally, should all factor variables be "noms=" and all
ordered factors be "ords="?
2) What do the warnings or the error message mean? What to do about them?
Thanks for having a look at it!
Marcus
t<-md[20:1000,1:12] # subset of full data frame
# First, to give you a feel for the data (output truncated)
t[1:8,1:10] # to get a feel for the data frame
id camp startyr exp.pjs insp.need insp.foss insp.pcss insp.feat
20 30019 free 1990 5 0 0 0 0
21 30020 <NA> NA 1 0 0 0 0
22 30021 free 2005 1 0 0 0 0
23 30022 both 2004 1 0 0 0 0
24 30023 both 2005 1 0 0 0 0
25 30024 both 2000 <NA> 0 0 0 1
26 30025 open 2004 5 0 0 0 1
27 30026 open 1985 30 0 1 0 0
str(t, give.attr=FALSE)
'data.frame':
981 obs. of 12 variables:
$ id : int 30019 30020 30021 30022 30023 30024 30025 30026 40001
$ camp : Factor w/ 3 levels "both","free",..: 2 NA 2 1 1 1 3 3 1
3
$ startyr : int 1990 NA 2005 2004 2005 2000 2004 1985 2002 1999 ...
$ exp.pjs : Ord.factor w/ 6 levels
"1"<"5"<"10"<"20"<..: 2 1 1 1 1 NA
$ insp.need: Ord.factor w/ 2 levels "0"<"1": 1 1 1 1 1 1 1 1 2 2
...
$ insp.foss: Ord.factor w/ 2 levels "0"<"1": 1 1 1 1 1 1 1 2 2 1
...
$ insp.pcss: Ord.factor w/ 2 levels "0"<"1": 1 1 1 1 1 1 1 1 1 1
...
$ insp.feat: Ord.factor w/ 2 levels "0"<"1": 1 1 1 1 1 2 2 1 2 2
...
$ insp.bugr: Ord.factor w/ 2 levels "0"<"1": 1 1 1 1 1 1 1 1 2 2
...
$ insp.insc: Ord.factor w/ 2 levels "0"<"1": 1 1 1 1 1 1 1 2 2 1
...
$ insp.outc: Ord.factor w/ 2 levels "0"<"1": 1 1 1 1 1 1 1 1 2 1
...
$ insp.offr: Ord.factor w/ 2 levels "0"<"1": 1 2 1 1 1 2 1 1 1 1
...
===== A) MI with variant "noms" =====
# specifying indep. variables as "noms"...
works...
t_noms<-amelia(t, p2s=2, m=5, idvars=c("id"),
noms=c("camp","exp.pjs","insp.need","insp.foss","insp.pcss","insp.feat","insp.bugr","insp.insc"))
... but gives warnings (usually 30-50, multiples of
ten it seems):
-- Imputation 5 --
setting up EM chain indicies
1(140) 2(0)
saving and cleaning
Es gab 50 oder mehr Warnungen (Anzeige der ersten 50 mit warnings())
warnings() # with English translation
50: Bedingung hat Länge > 1 und nur das erste Element wird benutzt in:
if (class(x.orig[, i]) == "logical") x.imp[, i] <- as.logical(x.imp[,
50: Condition has length>1 and only the first element is used in:
if (class...
# Plus: I occasionally get this warning (or error message?) in some
# Imputations:
The resulting variance matrix was not invertible. Please check your
data for highly collinear variables.
===== B) MI with variant "ords" =====
# specifying vars as ords throws an error message:
t_ords<-amelia(t, p2s=2, m=5,
idvars=c("id"), noms=c("camp"),
ords=c("exp.pjs","insp.need","insp.foss","insp.pcss","insp.feat","insp.bugr","insp.insc","insp.outc","insp.offr"))
amelia starting
Fehler in if (any(unique(na.omit(data[, i]))%%1 != 0)) { :
Fehlender Wert, wo TRUE/FALSE nötig ist
# Missing value, where TRUE/FALSE needed/expected
Zusätzlich: Warning message:
'%%' is not meaningful for ordered factors in:
Ops.ordered(unique(na.omit(data[, i])), 1)
--
Marcus M. Dapp | PhD student | ETH Zurich |
www.ib.ethz.ch/people/mdapp
Prof. Thomas Bernauer, International Relations |
www.ib.ethz.ch
On the shoulders of giants?
http://science.creativecommons.org
-
Amelia mailing list served by Harvard-MIT Data Center
[Un]Subscribe/View Archive:
http://lists.gking.harvard.edu/?info=amelia