I am trying to fit my data with a Weibull density functions. eventually, I want to smooth my observations for the entire year so that I can create a smooth GPP (my observation)- DOY (day of the year) curve.
The data is detached at the end of my question.And here's the point plot for my data Point plot
The formula is quite complex here's the formula, P(t) stands for my observations
somehow I managed to build a nonlinear model for my data using code below,
library(nls2)
library(dplyr)
require(minpack.lm)
#I store my data in data.frame d
#define weibull function
weibull_function<-function(a,b,k,x0,y0,t){
y=
ifelse(t>(x0-b*(k-1)/k),
y0+a*((k-1)/k)^((1-k)/k)*abs((t-x0)/b+((k-1)/k)^(1/k))^(k-1)*exp(1)^(-abs((t-x0)/b+((k-1)/k)^(1/k))^k+(k-1)/k),
y0
)
return(y)
}
#data fitting
lm1<-nlsLM(y~weibull_function(a,b,k,x0,y0,t),data=d,start=list(a=0,b=10,k=2,x0=1,y0=0)
#plot predict values
plot(d$x,predict(lm1,d))
But the predicted values can not actually fit my data, as u see in the plot fitted data
I had go through quite a lot of answers on StackOverflow,
and aware that the bias may relate to the start values I use.
So I changed some of the values for the start value, and here's what surprised me.
As I go through different combinations of start values for my a,b,k,x0 and y0, the nls function generated quite an amount of different models, which use different values,
however, none of them seems to really fit my data.
Now I am quite confused about which strat values I should use and how can I make sure that the model (suppose I eventually find ONE fits my data) is better than any other nls Weibull models (since it is impossible to go through all combinations of start values?
Thank u
t y
1 1 0.0000000
2 2 0.0000000
3 3 0.0000000
4 4 0.0000000
5 5 0.0707867
6 6 0.1712200
7 7 0.4918100
8 8 0.7889240
9 9 0.5143970
10 10 0.7365840
11 11 0.8226880
12 12 0.8913360
13 13 1.9113300
14 14 1.9021600
15 15 2.5347900
16 16 2.9011300
17 17 2.4049000
18 18 0.7344520
19 19 0.1427200
20 20 0.0541768
21 21 0.0000000
22 22 0.0000000
23 23 0.1926340
24 24 0.5145610
25 25 0.8064800
26 26 0.8090040
27 27 2.1381500
28 28 1.8712600
29 29 0.9658490
30 30 0.2964860
31 31 1.2073700
32 32 2.5077900
33 33 3.4101900
34 34 2.8787600
35 35 3.6792400
36 36 2.9349200
37 37 2.6029300
38 38 1.9863700
39 39 1.2938900
40 40 0.4992630
41 41 0.6379650
42 42 0.4024000
43 43 0.1084260
44 44 0.1374730
45 45 0.2230510
46 46 0.1501440
47 47 0.4220550
48 48 0.7916190
49 49 0.6582870
50 50 1.2428100
51 51 1.0643000
52 52 0.4634650
53 53 0.4777060
54 54 0.2625760
55 55 0.3416690
56 56 2.0303200
57 57 1.1497000
58 58 1.4016800
59 59 0.7974760
60 60 1.6967400
61 61 1.5555500
62 62 1.3034300
63 63 2.9090000
64 64 2.0858800
65 65 0.8658620
66 66 3.3597300
67 67 1.0571400
68 68 4.4057700
69 69 3.0252900
70 70 1.2971200
71 71 3.9716500
72 72 3.1547100
73 73 1.6375300
74 74 3.0920600
75 75 4.3314800
76 76 3.6577800
77 77 3.0225800
78 78 3.4114200
79 79 4.1715900
80 80 3.5697300
81 81 3.8911100
82 82 4.4364500
83 83 4.9133700
84 84 5.2404200
85 85 5.7771400
86 86 6.7429000
87 87 6.9022200
88 88 7.4436900
89 89 4.3942800
90 90 0.8826800
91 91 1.4101000
92 92 2.2473800
93 93 2.9795900
94 94 3.9610900
95 95 2.8689700
96 96 2.3157700
97 97 4.2013700
98 98 2.4536200
99 99 2.3285200
100 100 1.6641800
101 101 1.8391400
102 102 3.7247200
103 103 4.4881200
104 104 5.4677000
105 105 7.1896600
106 106 4.5204400
107 107 5.8330400
108 108 3.3793700
109 109 3.8234600
110 110 3.9182200
111 111 3.1710000
112 112 2.9232900
113 113 4.2434700
114 114 4.7464600
115 115 4.6802300
116 116 5.1251200
117 117 6.4484500
118 118 5.6865200
119 119 4.1672000
120 120 4.9955900
121 121 6.9491800
122 122 5.7618500
123 123 2.4349800
124 124 3.7315500
125 125 8.3070800
126 126 4.3468400
127 127 8.4310100
128 128 9.7953500
129 129 5.1387300
130 130 5.6159800
131 131 4.9249800
132 132 5.2035200
133 133 7.3140900
134 134 8.5128400
135 135 8.8445500
136 136 6.4021100
137 137 8.5730400
138 138 9.0752800
139 139 6.9884600
140 140 10.0649000
141 141 10.9208000
142 142 10.4544000
143 143 14.0787000
144 144 12.6344000
145 145 11.9214000
146 146 15.1133000
147 147 15.3369000
148 148 15.4777000
149 149 16.0808000
150 150 15.8116000
151 151 15.3791000
152 152 10.9130000
153 153 11.8881000
154 154 12.5383000
155 155 2.9121600
156 156 4.8731600
157 157 11.6981000
158 158 6.8281600
159 159 8.1552300
160 160 11.3900000
161 161 10.4996000
162 162 9.9490400
163 163 7.3252500
164 164 11.6759000
165 165 10.3756000
166 166 17.2289000
167 167 6.7320000
168 168 13.6835000
169 169 15.4414000
170 170 12.7428000
171 171 13.5159000
172 172 13.8205000
173 173 9.9679200
174 174 11.4347000
175 175 11.8706000
176 176 6.5545700
177 177 13.6308000
178 178 15.3185000
179 179 9.1710900
180 180 13.5977000
181 181 11.2282000
182 182 11.7510000
183 183 11.4871000
184 184 10.4018000
185 185 10.8641000
186 186 9.2063100
187 187 11.3159000
188 188 10.6050000
189 189 12.6539000
190 190 9.2266000
191 191 8.5330400
192 192 9.2949000
193 193 8.2153200
194 194 10.7958000
195 195 7.4245200
196 196 7.2358800
197 197 9.3145700
198 198 8.3644700
199 199 8.4106900
200 200 13.7398000
201 201 12.8421000
202 202 9.3427900
203 203 11.5155000
204 204 12.1537000
205 205 11.3195000
206 206 10.8288000
207 207 11.1031000
208 208 12.6185000
209 209 10.4288000
210 210 8.7446600
211 211 13.1651000
212 212 12.4868000
213 213 7.0671500
214 214 10.6482000
215 215 10.5971000
216 216 11.2978000
217 217 12.0698000
218 218 11.9749000
219 219 11.3467000
220 220 12.7263000
221 221 8.9283400
222 222 9.7184300
223 223 10.2274000
224 224 11.9933000
225 225 12.6712000
226 226 11.4917000
227 227 11.5164000
228 228 11.1688000
229 229 12.1940000
230 230 12.2719000
231 231 12.6843000
232 232 12.0033000
233 233 10.4394000
234 234 10.0225000
235 235 9.3543900
236 236 9.5651400
237 237 8.0770500
238 238 8.2516400
239 239 6.7008700
240 240 10.2780000
241 241 8.4796000
242 242 9.8009400
243 243 8.6459500
244 244 7.7860100
245 245 9.7695600
246 246 8.4967000
247 247 8.2067600
248 248 8.2361900
249 249 7.3512700
250 250 6.2018700
251 251 7.1628900
252 252 7.0082400
253 253 6.9478600
254 254 6.8310100
255 255 4.1930200
256 256 7.1842600
257 257 7.2565500
258 258 3.7791600
259 259 6.7925900
260 260 10.1900000
261 261 7.4041900
262 262 8.6597800
263 263 9.5826000
264 264 8.3029000
265 265 7.2548300
266 266 8.7421600
267 267 4.3173600
268 268 5.5106100
269 269 6.4128400
270 270 5.4460700
271 271 5.8495000
272 272 6.1458700
273 273 6.7045200
274 274 7.3160100
275 275 6.4701900
276 276 4.5038000
277 277 2.7967300
278 278 4.6101100
279 279 3.1605100
280 280 3.4307200
281 281 5.7120700
282 282 4.8887400
283 283 5.2968700
284 284 5.8722500
285 285 6.0290200
286 286 3.8281000
287 287 1.4922500
288 288 4.3007900
289 289 4.7463100
290 290 3.6876100
291 291 3.1633900
292 292 2.5615100
293 293 4.0825100
294 294 2.8859400
295 295 3.1885900
296 296 5.4614400
297 297 4.9645100
298 298 4.4726700
299 299 1.3583300
300 300 1.6828900
301 301 3.0714600
302 302 3.4279900
303 303 1.2706300
304 304 2.2885800
305 305 4.0884900
306 306 1.4124700
307 307 3.6298100
308 308 2.7364700
309 309 2.8791000
310 310 2.6254400
311 311 3.5437700
312 312 1.8247300
313 313 1.6026100
314 314 2.0445300
315 315 1.2098200
316 316 2.9734400
317 317 1.7955200
318 318 1.6497700
319 319 3.7585900
320 320 2.1699300
321 321 1.9716500
322 322 1.0365200
323 323 1.0400600
324 324 1.2130500
325 325 2.7250800
326 326 1.6329600
327 327 3.0840200
328 328 0.7717740
329 329 0.8716610
330 330 1.6803600
331 331 1.3165100
332 332 0.8895280
333 333 1.1678900
334 334 1.3315100
335 335 1.3054600
336 336 0.8515050
337 337 0.4578000
338 338 0.0516099
339 339 0.1484510
340 340 0.2275460
341 341 0.8208840
342 342 0.7448860
343 343 2.3841900
344 344 0.2445460
345 345 0.7701040
346 346 1.9149200
347 347 1.4889100
348 348 0.8986610
349 349 0.3705810
350 350 0.4623590
351 351 0.2586430
352 352 0.1939820
353 353 0.1817090
354 354 0.1586170
355 355 0.0517517
356 356 0.0291422
357 357 0.0269378
358 358 0.0960937
359 359 0.4633600
360 360 0.5766720
361 361 0.8399390
362 362 0.6647790
363 363 0.7475380
364 364 1.6569600
365 365 1.8504600
366 366 1.3835600