[R] binomial glm???

Gerard M. Keogh GMKeogh at justice.ie
Thu Nov 20 15:40:06 CET 2008


Hi everyone,

newbee query!

I've installed R 2.8.0 and tried to run this simple glm -
      x is no of cars in a given year, y is the number voted in an election
that year while n is the population 18+:


       votes <- data.frame(x = c(0.62,0.77,0.71,0.74,0.77,0.86,1.13,1.44),
      +                           y=c(502,542,711,653,771,806,934,1123), n=
      c(1617,1734,1680,1793,1678,1751,1807,1879))
      > votes$YM <- cbind(votes$y, votes$n - votes$y)
      > fml <- glm(YM ~ x, family = binomial, data = votes)
      > summary(fml)

and got the following which seem really wrong!


      Coefficients:
                  Estimate Std. Error z value Pr(>|z|)
      (Intercept) -1.43498    0.06233  -23.02   <2e-16 ***
      x            1.30739    0.06705   19.50   <2e-16 ***


      > dfr = votes
      > prd.mdl <- predict(fml,newdata=dfr)
      > prd.mdl
                1           2           3           4           5
      6           7           8
      -0.62439978 -0.42829203 -0.50673513 -0.46751358 -0.42829203
      -0.31062738  0.04236657  0.44765592


      > predict(fml, type="response")
              1         2         3         4         5         6         7
      8
      0.3487815 0.3945343 0.3759592 0.3852049 0.3945343 0.4229616 0.5105901
      0.6100818

the original proportions are
      |------+------+------+------+------+------+-------+------|
      |  0.76|  0.76|  0.70|  0.73|  0.69|  0.68|   0.66|  0.63|
      |------+------+------+------+------+------+-------+------|



and I would expect intercept to be about -0.14 and beta = 0.83?

Am I missing something obvious? Any help or suggestions appreciated!

Thanks
Gerard



**********************************************************************************
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.  It is the policy of the Department of Justice, Equality and Law Reform and the Agencies and Offices using its IT services to disallow the sending of offensive material.
Should you consider that the material contained in this message is offensive you should contact the sender immediately and also mailminder[at]justice.ie.

Is le haghaidh an duine nó an eintitis ar a bhfuil sí dírithe, agus le haghaidh an duine nó an eintitis sin amháin, a bheartaítear an fhaisnéis a tarchuireadh agus féadfaidh sé go bhfuil ábhar faoi rún agus/nó faoi phribhléid inti. Toirmisctear aon athbhreithniú, atarchur nó leathadh a dhéanamh ar an bhfaisnéis seo, aon úsáid eile a bhaint aisti nó aon ghníomh a dhéanamh ar a hiontaoibh, ag daoine nó ag eintitis seachas an faighteoir beartaithe. Má fuair tú é seo trí dhearmad, téigh i dteagmháil leis an seoltóir, le do thoil, agus scrios an t-ábhar as aon ríomhaire. Is é beartas na Roinne Dlí agus Cirt, Comhionannais agus Athchóirithe Dlí, agus na nOifígí agus na nGníomhaireachtaí a úsáideann seirbhísí TF na Roinne, seoladh ábhair cholúil a dhícheadú.
Más rud é go measann tú gur ábhar colúil atá san ábhar atá sa teachtaireacht seo is ceart duit dul i dteagmháil leis an seoltóir láithreach agus le mailminder[ag]justice.ie chomh maith. 
***********************************************************************************





More information about the R-help mailing list