On Feb 15, 2010, at 4:35 PM, Jay wrote:
> Hello,
>
> silly question I suppose, but somehow I can't manage to extract the
> probabilities from a glm.predict() result:
>
>> str(res)
> Named num [1:9] 0.00814 0.01877 0.025 0.02941 0.03563 ...
> - attr(*, "names")= chr [1:9] "1" "2"
"3" "4" ...
>
> I got from:
>
> # A Gamma example, from McCullagh & Nelder (1989, pp. 300-2)
> clotting <- data.frame(
> u = c(5,10,15,20,30,40,60,80,100),
> lot1 = c(118,58,42,35,27,25,21,19,18),
> lot2 = c(69,35,26,21,18,16,13,12,12))
> model <- glm(lot1 ~ log(u), data=clotting, family=Gamma)
> res <- predict(model, clotting)
>
> I want to transfer the probabilities "0.00814 0.01877 0.025 0.02941
> 0.03563 ..." to a separate vector, how do I do this?
It is already a separate vector. If you want those values without its
names, then the unname function is available:
> ures<-unname(res)
> ures
[1] 0.008139409 0.018774446 0.024995544 0.029409483 0.035630581
0.040044520 0.046265617
[8] 0.050679556 0.054103274
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT