Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

R: What exactly are starting values in glm and how to specify?

I tried to fit the following glm in R:

        date_st period plot  rain    flow      api
1      5M29      1    A  16.0  0.7000   2.5000
2       6M4      1    A   9.5  0.2000  18.5000
3      6M12      1    A  18.5  0.8000  12.5000
4      6M16      1    A  10.0  0.2000  31.0000
5      6M21      1    A  24.0  1.0000  35.5000
6      6M22      1    A  65.5  3.2000  60.0000
7      6M24      1    A  18.5  0.6000 122.5000
8      6M27      1    A  23.0  1.0000 129.5000
9      6M29      1    A  13.0  0.5000 143.0000
10      7M9      1    A  52.0  2.3000  44.0000
11     7M13      1    A  37.0  1.4000  62.5000
12     7M26      1    A  39.5  2.8000   0.0001
13      8M1      1    A  72.5  4.0000  40.0000
14      8M2      1    A  20.0  1.1000 112.0000
15     8M23      1    A   8.5  0.4000   4.0000
16     8M24      1    A   8.5  0.3000  13.0000
17     8M29      1    A   9.5  0.1000  36.5000
18    10M17      1    A  41.0  1.1000  27.0000
19    10M26      1    A  13.0  0.4000  44.5000
20    10M28      1    A  19.5  0.4000  58.0000
21     3M21      2    A  31.0  0.6000   0.0001
22     3M26      2    A  27.0  0.4000  31.0000
23      4M6      2    A  40.0  0.7000  39.5000
24      4M8      2    A  20.0  0.4000  55.0000
25     4M11      2    A  26.0  0.5000  75.0000
26     4M17      2    A  63.5  1.3000  92.0000
27     4M26      2    A  15.5  0.2000  68.0000
28     5M13      2    A  14.5  0.2000  15.0000
29     5M24      2    A  15.0  0.2000  14.5000
30     6M21      2    A  31.5  0.7000   0.0001
31     6M30      2    A  75.0  1.4000  48.0000
32      7M4      2    A  91.5  1.6000  96.0000
33     7M10      2    A   9.0  0.1000 176.5000
34     7M12      2    A  66.5  1.2000 107.0000
35     7M17      2    A  19.5  0.2000  83.5000
36      8M7      2    A 102.0  3.6000  19.0000
37     8M10      2    A  36.0  0.8000 104.0000
38     8M11      2    A  29.5  0.6000 138.0000
39     8M18      2    A  44.5  0.5000 191.5000
40     9M11      2    A  27.5  0.3000  26.0000
41     9M16      2    A  29.0  0.3000  53.5000
42     10M2      2    A  29.5  0.4000  13.0000
43     10M6      2    A  35.0  0.4000  41.5000
44    10M13      2    A  23.0  0.4000  66.0000
45    10M15      2    A  57.0  0.7000  58.0000
46    10M21      2    A 133.5  2.3000 100.5000
47    10M28      2    A  68.0  0.9000 190.0000
48    12M24      2    A  26.5  0.7000   0.0001
49      3M1      2    A  21.5  0.3000   0.5000
50      3M5      2    A  33.5  1.1000  22.0000
51      3M8      2    A  64.0  1.2000  55.5000
52     3M19      2    A  58.5  0.8000  77.0000
53     4M14      2    A  50.0  0.8000  10.0000
54     4M17      2    A  48.0  0.6000  60.0000
55     4M24      2    A  95.0  1.7000  98.0000
56      5M2      2    A  25.5  0.3000  95.0000
57      5M6      2    A  78.5  1.0000  86.5000
58     5M13      2    A  79.0  1.1000 104.0000
59     5M31      2    A  37.5  0.5000  17.5000
60      6M8      2    A  29.5  0.3000  72.0000
61   4M9M18      3    A  54.0  0.9000  45.0000
62   9M9M18      3    A  52.5  0.9000  97.0000
63   9M9M18      3    A  23.0  0.2000 149.5000
64  14M9M18      3    A  47.5  0.5000 157.0000
65  20M9M18      3    A  31.0  0.2000 105.0000
66  26M9M18      3    A  44.5  0.2000  89.0000
67  29M9M18      3    A  27.5  0.1000 119.0000
68  30M9M18      3    A  46.5  0.4000 162.0000
69  6M11M18      3    A  23.0  0.3000  32.0000
70  28M2M18      3    A  23.0  0.2000  40.0000
71  10M3M18      3    A  39.5  0.4000  47.0000
72  10M4M18      3    A  23.5  0.2000  26.0000
73  14M4M18      3    A  25.0  0.2000  29.5000
74  29M4M18      3    A  29.0  0.3000  16.5000
75  20M5M19      3    A  72.0  1.2000   9.0000
76  28M5M19      3    A  35.5  0.1000  75.0000
77   7M6M19      3    A  49.0  0.6000  36.5000
78  27M6M19      3    A  35.0  0.2000   6.0000
79  29M6M19      3    A  64.5  0.5000  40.5000
80   3M7M19      3    A  29.0  0.1000 113.0000
81  11M7M19      3    A  32.5  0.1000 108.0000
82  14M7M19      3    A  21.5  0.1000  84.0000
83  18M7M19      3    A  38.5  0.1000  88.0000
84  22M7M19      3    A  31.0  0.1000 128.5000
85  26M7M19      3    A  59.5  0.2000 111.0000
86     5M29      1    B  16.0  0.4000   2.5000
87      6M4      1    B   9.5  0.1000  18.5000
88     6M12      1    B  18.5  0.5000  12.5000
89     6M16      1    B  10.0  0.1000  31.0000
90     6M21      1    B  24.0  0.6000  35.5000
91     6M22      1    B  65.5  2.1000  60.0000
92     6M24      1    B  18.5  0.3000 122.5000
93     6M27      1    B  23.0  0.5000 129.5000
94     6M29      1    B  13.0  0.2000 143.0000
95      7M9      1    B  52.0  1.5000  44.0000
96     7M13      1    B  37.0  0.7000  62.5000
97     7M26      1    B  39.5  1.7000   0.0001
98      8M1      1    B  72.5  2.4000  40.0000
99      8M2      1    B  20.0  0.5000 112.0000
100    8M23      1    B   8.5  0.2000   4.0000
101    8M24      1    B   8.5  0.1000  13.0000
102    8M29      1    B   9.5  0.1000  36.5000
103   10M17      1    B  41.0  0.2000  27.0000
104   10M26      1    B  13.0  0.1000  44.5000
105   10M28      1    B  19.5  0.1000  58.0000
106    3M21      2    B  31.0  6.0000   0.0001
107    3M26      2    B  27.0  1.5000  31.0000
108     4M6      2    B  40.0  2.8000  39.5000
109     4M8      2    B  20.0  0.6000  55.0000
110    4M11      2    B  26.0  0.4000  75.0000
111    4M17      2    B  63.5  1.1000  92.0000
112    4M26      2    B  15.5  0.9000  68.0000
113    5M13      2    B  14.5  0.2000  15.0000
114    5M24      2    B  15.0  0.3000  14.5000
115    6M21      2    B  31.5  4.7000   0.0001
116    6M30      2    B  75.0  1.4000  48.0000
117     7M4      2    B  91.5  1.9000  96.0000
118    7M10      2    B   9.0  0.2000 176.5000
119    7M12      2    B  66.5  2.1000 107.0000
120    7M17      2    B  19.5  0.3000  83.5000
121     8M7      2    B 102.0 14.8000  19.0000
122    8M10      2    B  36.0  2.0000 104.0000
123    8M11      2    B  29.5  1.3000 138.0000
124    8M18      2    B  44.5  0.7000 191.5000
125    9M11      2    B  27.5  1.9000  26.0000
126    9M16      2    B  29.0  1.5000  53.5000
127    10M2      2    B  29.5  3.7000  13.0000
128    10M6      2    B  35.0  2.9000  41.5000
129   10M13      2    B  23.0  1.5000  66.0000
130   10M15      2    B  57.0  2.8000  58.0000
131   10M21      2    B 133.5  3.4000 100.5000
132   10M28      2    B  68.0  1.1000 190.0000
133   12M24      2    B  26.5  4.4000   0.0001
134     3M1      2    B  21.5  1.4000   0.5000
135     3M5      2    B  33.5  0.4000  22.0000
136     3M8      2    B  64.0  1.1000  55.5000
137    3M19      2    B  58.5  0.8000  77.0000
138    4M14      2    B  50.0  2.8000  10.0000
139    4M17      2    B  48.0  1.9000  60.0000
140    4M24      2    B  95.0  3.9000  98.0000
141     5M2      2    B  25.5  0.5000  95.0000
142     5M6      2    B  78.5  1.0000  86.5000
143    5M13      2    B  79.0  0.8000 104.0000
144    5M31      2    B  37.5  0.1000  17.5000
145     6M8      2    B  29.5  0.0001  72.0000
146  4M9M18      3    B  54.0 11.2000  45.0000
147  9M9M18      3    B  52.5  3.1000  97.0000
148  9M9M18      3    B  23.0  3.7000 149.5000
149 14M9M18      3    B  47.5  3.5000 157.0000
150 20M9M18      3    B  31.0  6.0000 105.0000
151 26M9M18      3    B  44.5  3.1000  89.0000
152 29M9M18      3    B  27.5  1.5000 119.0000
153 30M9M18      3    B  46.5  3.0000 162.0000
154 6M11M18      3    B  23.0  5.7000  32.0000
155 28M2M18      3    B  23.0  3.4000  40.0000
156 10M3M18      3    B  39.5  3.0000  47.0000
157 10M4M18      3    B  23.5  2.6000  26.0000
158 14M4M18      3    B  25.0  1.6000  29.5000
159 29M4M18      3    B  29.0  1.5000  16.5000
160 20M5M19      3    B  72.0 10.9000   9.0000
161 28M5M19      3    B  35.5  1.3000  75.0000
162  7M6M19      3    B  49.0  6.0000  36.5000
163 27M6M19      3    B  35.0  4.2000   6.0000
164 29M6M19      3    B  64.5  2.3000  40.5000
165  3M7M19      3    B  29.0  0.1000 113.0000
166 11M7M19      3    B  32.5  0.6000 108.0000
167 14M7M19      3    B  21.5  0.2000  84.0000
168 18M7M19      3    B  38.5  0.4000  88.0000
169 22M7M19      3    B  31.0  0.4000 128.5000
170 26M7M19      3    B  59.5  1.5000 111.0000
library(glm2)
r.all.2 <- glm2(flow~period+(rain*api) - 1,  family=Gamma(link='identity'),  data=d)
summary(r.all.2)

but got this warning:

Error: no valid set of coefficients has been found: please supply starting values
In addition: Warning message:
In log(ifelse(y == 0, 1, y/mu)) : NaNs produced
  1. I know this have been asked several times and answered, but what exactly are starting values? In a fitted line, what does it correspond to?

  2. How to specify starting values? For my case, only start=c(1,1,1,1) worked but not start=c(b0,b1), start=c(0,0), and start=NULL

  3. Why did I get this warning? I do not have any 0 or NA values in my data.

Thank you.

question from:https://stackoverflow.com/questions/65831659/r-what-exactly-are-starting-values-in-glm-and-how-to-specify

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...