[R] fitted() and loglm()
Michal Bojanowski
bojaniss at poczta.onet.pl
Mon Mar 31 02:08:11 CEST 2003
Hello,
I encountered some difficulities using loglm() from MASS package. I
had to fit several (about 20) models to the same dataset and than
compare the fitted values. Each time a call to loglm() looks like
loglm(freq ~ x + y + y*z , data=d)
where d is a data.frame containing a bunch of factors x, y, z ...
as well as a vector of frequencies (freq).
For each created model object somewhere later I used fitted() to
obtain fitted values. The result returned was always an array.
Unfortunately for different models its structure (i.e. dim attribute)
is different (probably because of different ordering of the factors in
the model formulas). That makes any calculations on those arrays very
tedious.
Actually I would expect fitted(loglm(freq ~ x)) to return a vector and
fitted(loglm(~ x)) to return an array. Just to preserve the structure
of entered observed frequencies. Correct me if I'm wrong.
Is there a good remedy for the problem above apart from comparing array
structures ,,by hand'' and than using aperm() to make all of them
comformable?
I would be very gratefull for some hints. Thank you in advance for
your time.
Michał
~,~`~,~`~,~`~,~`~,~`~,~
Michał Bojanowski
bojaniss at poczta.onet.pl
More information about the R-help
mailing list