[R] problem with polr ?
Marc Girondot
marc.girondot at ese.u-psud.fr
Fri Jun 10 22:44:28 CEST 2005
I want to fit a multinomial model with logit link.
For example let this matrix to be analyzed:
male female aborted factor
10 12 1 1.2
14 14 4 1.3
15 12 3 1.4
(this is an example, not the true data which are far more complex...)
I suppose the correct function to analyze these data is polr from MASS library.
The data have been entered in a text file like this:
output factor n
m 1.2 10
f 1.2 12
a 1.2 1
m 1.3 14
f 1.3 14
a 1.3 4
m 1.4 15
f 1.4 12
a 1.4 3
However, after having performed the analysis, it
appears this is not correct as the 3 outputs per
experiment are not linked...
library(MASS)
dt.plr <- polr(output ~ factor, data=dt, weights=n)
> dt.pr1<-predict(dt.plr, , type="probs")
> dt.pr1
a f m
1 0.09987167 0.4578184 0.4423099
2 0.09987167 0.4578184 0.4423099
3 0.09987167 0.4578184 0.4423099
4 0.09437078 0.4477902 0.4578390
5 0.09437078 0.4477902 0.4578390
6 0.09437078 0.4477902 0.4578390
7 0.08914287 0.4374067 0.4734505
8 0.08914287 0.4374067 0.4734505
9 0.08914287 0.4374067 0.4734505
---------------------------Another linked problem
Also, I don't understand what the meaning of the
residual deviance that is displayed.
Let modify the file so that the model can also be
analyzed using binomial model:
output factor n
m 1.2 10
f 1.2 12
a 1.2 0
m 1.3 14
f 1.3 14
a 1.3 0
m 1.4 15
f 1.4 12
a 1.4 0
dt.plr
Call:
polr(formula = output ~ factor, data = dt, weights = n)
Coefficients:
factor
2.034848
Intercepts:
a|f f|m
-16.306511 2.632410
Residual Deviance: 106.2304
AIC: 112.2304
whereas the corresponding scaled deviance for the
binomial model (removing a column) is 1.842e-3...
--
__________________________________________________________
Marc Girondot, Pr
Laboratoire Ecologie, Systématique et Evolution
Equipe de Conservation des Populations et des Communautés
CNRS, ENGREF et Université Paris-Sud 11 , UMR 8079
Bâtiment 362
91405 Orsay Cedex, France
Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1 69
15 56 96 e-mail: marc.girondot at ese.u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot
Fax in US: 1-425-732-6934
More information about the R-help
mailing list