[R] gamma distribution don't allow negative value in GLMs?

From: zhijie zhang <epistat_at_gmail.com>
Date: Sun 15 Oct 2006 - 11:10:25 GMT


Dear friends,
 when i use glm() to fit my data, i use glm(formula = snail ~ vegtype + mhveg + humidity + elevation + soiltem, *family = Gamma(link = inverse),* data =a,))
It shows: error in eval(expr, envir, enclos) : *gamma distribution don't allow negative value*.

But i use
result<-glm(formula = snail ~ vegtype + mhveg + humidity + elevation + soiltem, family = poisson, data =a) #this works  In fact , there isn't any negative value in my dataset, who can tell me the reason?
Thanks very much!
 I copy my data here so you can check it:

      vegtype mhveg humidity soiltem elevation snail
1         diluo  35.0 0.279851    21.1       low   162
2         diluo  25.0 0.316092    23.1       low   113
3         yuhao  35.0 0.297238    21.7       low   105
4   huanghuacai   1.5 0.310687    23.1       low     5
5   huanghuacai   2.0 0.267868    28.3       low     1
6         yuhao  25.0 0.290135    21.9       low    10
7   huanghuacai   1.0 0.285207    27.7       low     6
8   huanghuacai   2.0 0.252973    28.3       low     1
9   huanghuacai   1.5 0.270000    28.1       low     1
10  huanghuacai   2.5 0.300000    29.1       low     1
11  huanghuacai   2.0 0.296154    29.1       low     0
12  huanghuacai   2.0 0.302874    27.5       low     3
13  huanghuacai   1.5 0.301499    28.9       low     0
14  huanghuacai   3.0 0.291513    30.3       low     1
15  huanghuacai   1.0 0.273438    31.1       low     3
16  huanghuacai   1.5 0.290116    27.9       low    19
17  huanghuacai   2.5 0.198932    31.9       low     0
18  huanghuacai   2.0 0.390000    30.5      high     4
19  huanghuacai   2.5 0.282595    30.7      high     0
20  huanghuacai   1.0 0.266097    24.7      high    14
21        yuhao  30.0 0.240516    26.9      high    51
22        yuhao  35.0 0.227541    26.7      high    84
23        yuhao  20.0 0.252833    28.3       low    30
24        diluo  40.0 0.303030    27.9       low    91
25        hucao  80.0 0.303867    24.5       low   114
26        diluo  25.0 0.334948    26.7       low   115
27        hucao  60.0 0.306897    26.5       low    23
28        hucao  75.0 0.314465    25.7       low    43
29        yuhao  30.0 0.251783    26.1       low    77
30        diluo  10.0 0.277778    26.1       low    62
31        yuhao  25.0 0.291716    26.1       low    78
32        hucao  90.0 0.288800    24.5       low    35
33        diluo  25.0 0.337830    26.3      high    75
34        yuhao  13.0 0.296599    27.7      high    23
35        hucao  70.0 0.279498    26.3      high   116
36        diluo   3.0 0.281481    28.1      high    25
37        hucao  70.0 0.296000    23.7      high    83
38        diluo  10.0 0.272662    27.7       low    56
39        hucao  70.0 0.289796    25.3      high   112
40        diluo   5.0 0.339716    27.9      high    84
41        yuhao  35.0 0.231427    24.9      high    88
42        hucao  80.0 0.273810    24.1      high   134
43        yuhao  40.0 0.272789    25.1      high    53
44        yuhao  45.0 0.226036    25.1      high    88
45        yuhao  55.0 0.285495    23.9      high    76
46        hucao  80.0 0.252185    23.9      high   106
47        diluo  15.0 0.289933    24.5      high   194
48        hucao  95.0 0.261756    23.1      high    35
49        hucao  55.0 0.239819    24.7      high    21
50        hucao  75.0 0.254307    23.9      high    41
51  huanghuacai   1.0 0.286432    23.7       low    18
52  huanghuacai   2.0 0.301342    23.1       low     2
53  huanghuacai   2.0 0.369565    23.3       low     5
54  huanghuacai   1.5 0.245833    24.3       low     4
55  huanghuacai   1.0 0.315679    24.1       low     4
56  huanghuacai   2.5 0.296124    23.7       low     4
57  huanghuacai   2.0 0.312667    25.7       low     3
58  huanghuacai   3.0 0.300870    25.7       low     0
59  huanghuacai   2.0 0.303743    26.5       low     2
60  huanghuacai   1.0 0.269799    25.3       low     7
61        hucao  75.0 0.281250    22.5       low    14
62        yuhao  35.0 0.350350    23.3       low    63
63        hucao  65.0 0.304545    22.7       low    17
64        diluo   7.0 0.310056    24.9       low    45
65        hucao  80.0 0.288000    22.9       low    27
66        hucao  80.0 0.284211    22.7       low    46
67        diluo  25.0 0.281379    23.5       low   161
68        hucao  80.0 0.290533    23.3       low   117
69        yuhao  27.0 0.316568    24.1       low   106
70        yuhao  28.0 0.285156    25.1       low    82
71        yuhao  30.0 0.266667    24.5       low    55
72        hucao  85.0 0.290345    23.9       low    54
73        yuhao  35.0 0.315789    24.1       low    81
74        diluo  15.0 0.286598    28.3       low   102
75        yuhao  45.0 0.314211    24.1       low    85
76        yuhao  25.0 0.268794    25.1       low    63
77        hucao  80.0 0.275691    23.9       low    59
78        hucao 100.0 0.316614    24.1       low    46
79        yuhao  40.0 0.336683    25.5       low    70
80        diluo  20.0 0.270874    26.1      high   167
81        yuhao  50.0 0.271483    24.3      high   125
82        hucao  80.0 0.238095    25.1      high   200
83        yuhao  30.0 0.241202    26.7       low   122
85        diluo  35.0 0.244531    28.1      high   186
86        yuhao  55.0 0.274038    24.9       low   208
87        hucao  80.0 0.303488    25.7       low    87
88        hucao  85.0 0.278846    25.3       low    25
89        diluo   5.0 0.270330    28.3      high    18
90        yuhao  35.0 0.296296    24.7      high    21
91        diluo   1.0 0.274306    27.9       low    23
92        diluo   3.0 0.262673    29.5       low     0
93        diluo   8.0 0.268750    27.7      high    21
94        hucao  70.0 0.265734    26.1      high     2
95        hucao  85.0 0.275373    24.3       low     6
96        diluo  10.0 0.284091    27.1       low     2
97        hucao  85.0 0.268229    25.3       low     0
98        hucao  90.0 0.293056    23.9       low     0
99        yuhao  35.0 0.277483    24.7       low     3
100       hucao  95.0 0.286822    24.3      high     1
101       hucao  88.0 0.285946    23.9      high     5
102       yuhao  35.0 0.268313    24.5       low     1
103       yuhao  25.0 0.285714    24.3      high     0
104       yuhao  25.0 0.294675    24.5      high     2
105       yuhao  38.0 0.275385    23.5      high     6
106       hucao  92.0 0.302415    23.3       low    15
107       hucao  83.0 0.276190    23.9       low     5
108       yuhao  55.0 0.285068    24.1       low    20
109       hucao  80.0 0.276552    23.5       low     5
110       hucao  95.0 0.281818    23.9       low     0
111       hucao 105.0 0.270293    23.1       low    13
112       hucao  95.0 0.291209    20.1       low    23
113       hucao  90.0 0.273196    20.9       low    48
114       yuhao  27.0 0.261986    20.5       low    49
115       yuhao  40.0 0.265187    20.5       low     9
116       yuhao  27.0 0.307143    20.9       low    27
117       yuhao  33.0 0.293194    20.7       low    34
118       yuhao  25.0 0.211399    20.9       low    38
119       yuhao  20.0 0.277372    21.7       low    30
120       hucao  95.0 0.346224    20.5       low    88
121       hucao  90.0 0.330380    21.3       low    91
122       yuhao  23.0 0.337884    23.3       low    70
123       hucao  80.0 0.322488    22.3       low   103
124       hucao  80.0 0.300000    22.1       low    51
125       hucao 100.0 0.326241    21.7       low    82
126       hucao  95.0 0.298571    21.9       low   104
127       hucao  95.0 0.296029    21.7       low    39
128       hucao  85.0 0.260082    21.7       low    73
129       hucao  93.0 0.304167    21.9       low   103
130       hucao  90.0 0.289941    22.3       low    65
131       hucao  85.0 0.339189    22.7       low   112
132       yuhao  30.0 0.314103    23.3       low    32
133       yuhao  28.0 0.293464    23.5       low    29
134       yuhao  45.0 0.310256    23.3       low    92
135       yuhao  42.0 0.375573    23.1       low    49
136       hucao  90.0 0.313846    23.1       low    47
137       yuhao  25.0 0.303601    23.9       low    54
138       hucao  85.0 0.339394    23.3       low    64
139       hucao  90.0 0.285934    23.1       low    68
140       yuhao  27.0 0.327915    23.9       low    62
141       hucao  85.0 0.372679    23.9       low    94
142       hucao  85.0 0.350147    22.5       low   174
143       yuhao  35.0 0.278014    23.7       low    38
144       hucao 100.0 0.327273    22.9       low   105
145       hucao  68.0 0.309286    24.9       low   105
146       hucao  85.0 0.279503    24.3      high    60
147       hucao  95.0 0.310870    23.3      high    42
148       hucao  95.0 0.309353    24.3      high    64
149       hucao  92.0 0.280745    23.5       low    37
150       yuhao  25.0 0.300355    24.3      high   107
151       yuhao  40.0 0.307692    24.7      high    86
152       hucao  40.0 0.273292    25.3      high    72
153       hucao  53.0 0.305096    24.7      high   109
154       hucao  50.0 0.306288    24.7      high    76
155       hucao  95.0 0.312268    22.3       low    60
156       hucao  90.0 0.301170    22.7       low    62
157       yuhao  38.0 0.305109    22.9       low    68
158       hucao  25.0 0.300719    25.3       low    21
159       hucao  80.0 0.252149    23.1       low    50
160       hucao  90.0 0.290306    23.3       low    63
161       hucao  33.0 0.293772    25.1       low    63

-- 
With Kind Regards,

oooO:::::::::
(..):::::::::

:\.(:::Oooo::
::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [***********************************************************************] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 epistat@gmail.com Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***********************************************************************] oooO::::::::: (..):::::::::
:\.(:::Oooo::
::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Received on Sun Oct 15 21:18:42 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 15 Oct 2006 - 13:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.