I have a contingency table with a 0/1 variable (fwr) that flags a particular condition, a weight variable (cnt) and other variables (e.g. zz) characterizing that observation of the table. I am trying to use GLM. By converting the variables to factors and running the following regression: fwr1<-factor(fwr) zz1<-factor(zz1) res1<-glm(fwr1 ~ zz1,weights=cnt) Is that appropriate? Paul M. Jacobson Jacobson Consulting Inc. 80 Front Street East, Suite 720 Toronto, ON, M5E 1T4 Voice: +1(416)868-1141 Farm: +1(519)463-6061/6224 Fax: +1(416)868-1131 E-mail: pmj at jciconsult.com Web: http://www.jciconsult.com/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
GLM Contingency table regressions
2 messages · Paul M. Jacobson, Martin Maechler
1 day later
"PaulMJ" == Paul M Jacobson <pmj at jciconsult.com>
on Sat, 10 Aug 2002 15:02:55 -0400 writes:
PaulMJ> I have a contingency table with a 0/1 variable (fwr)
PaulMJ> that flags a particular condition, a weight variable
PaulMJ> (cnt) and other variables (e.g. zz) characterizing
PaulMJ> that observation of the table. I am trying to use
PaulMJ> GLM. By converting the variables to factors and
PaulMJ> running the following regression:
PaulMJ> fwr1<-factor(fwr)
PaulMJ> zz1<-factor(zz1)
PaulMJ> res1<-glm(fwr1 ~ zz1,weights=cnt)
(spaces around "<-" would improve readibility}
PaulMJ> Is that appropriate?
not quite.
Assuming that you really want to predict (a function of) the
probability P[ fwr = 1 | zz1 ]
you need at least to add
family = binomial
to your glm() arguments.
The thing you did above was least-squares regression with a 0/1 variable
which is probably not what you wanted.
Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._