kmmoon100
2013-Oct-28 12:07 UTC
[R] Optimization failed in fitdistr (Weibull distribution)
Hello everyone,
This is Kangmin.
I am trying to produce shape and scale of my wind data. My data is based on
wind speed frequency with 1km/hr increment. data is described below.
Windspeed (km/h) Frequency
1 351
2 147
3 317
4 378
5 527
6 667
7 865
8 970
9 987
10 907
11 905
12 642
13 1000
14 983
15 847
16 842
17 757
18 698
19 632
20 626
21 599
22 529
23 325
24 391
25 356
26 267
27 230
28 223
29 190
30 142
31 124
32 104
33 97
34 37
35 62
36 46
37 42
38 24
39 9
40 13
41 9
42 5
43 2
R codes to calculate shape and scale are described below:
Pine.windfrequency.4weeks<-read.table("C:/Users/kmoon/Documents/Pine_frequency_4weeks.csv",header=TRUE,sep=",")
fitdistr(Pine.windfrequency.4weeks$Frequency, densfun="weibull")
I have got an error message when I was using 'fitdistr' function
"Error in fitdistr(Pine.windfrequency.4weeks$Frequency, densfun =
"weibull")
:
optimization failed"
Please help me calculating shape and scale of weibull distribution.
And please understand that I am not an user familiar with R program but I am
really trying to make my analysis work on R!
Thank you!!!
Kangmin.
--
View this message in context:
http://r.789695.n4.nabble.com/Optimization-failed-in-fitdistr-Weibull-distribution-tp4679167.html
Sent from the R help mailing list archive at Nabble.com.
Rui Barradas
2013-Oct-28 15:07 UTC
[R] Optimization failed in fitdistr (Weibull distribution)
Hello, I can't reproduce your error: windfreq <- c(1351L, 2147L, 3317L, 4378L, 5527L, 6667L, 7865L, 8970L, 9987L, 10907L, 11905L, 12642L, 131000L, 14983L, 15847L, 16842L, 17757L, 18698L, 19632L, 20626L, 21599L, 22529L, 23325L, 24391L, 25356L, 26267L, 27230L, 28223L, 29190L, 30142L, 31124L, 32104L, 3397L, 3437L, 3562L, 3646L, 3742L, 3824L, 399L, 4013L, 419L, 425L, 432L library(MASS) fitdistr(windfreq, "weibull") Hope this helps, Rui Barradas Em 28-10-2013 12:07, kmmoon100 escreveu:> Hello everyone, > > This is Kangmin. > > I am trying to produce shape and scale of my wind data. My data is based on > wind speed frequency with 1km/hr increment. data is described below. > > Windspeed (km/h) Frequency > 1 351 > 2 147 > 3 317 > 4 378 > 5 527 > 6 667 > 7 865 > 8 970 > 9 987 > 10 907 > 11 905 > 12 642 > 13 1000 > 14 983 > 15 847 > 16 842 > 17 757 > 18 698 > 19 632 > 20 626 > 21 599 > 22 529 > 23 325 > 24 391 > 25 356 > 26 267 > 27 230 > 28 223 > 29 190 > 30 142 > 31 124 > 32 104 > 33 97 > 34 37 > 35 62 > 36 46 > 37 42 > 38 24 > 39 9 > 40 13 > 41 9 > 42 5 > 43 2 > > R codes to calculate shape and scale are described below: > > Pine.windfrequency.4weeks<-read.table("C:/Users/kmoon/Documents/Pine_frequency_4weeks.csv",header=TRUE,sep=",") > fitdistr(Pine.windfrequency.4weeks$Frequency, densfun="weibull") > > I have got an error message when I was using 'fitdistr' function > > "Error in fitdistr(Pine.windfrequency.4weeks$Frequency, densfun = "weibull") > : > optimization failed" > > Please help me calculating shape and scale of weibull distribution. > > And please understand that I am not an user familiar with R program but I am > really trying to make my analysis work on R! > > Thank you!!! > > Kangmin. > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Optimization-failed-in-fitdistr-Weibull-distribution-tp4679167.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org 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. >
peter dalgaard
2013-Oct-29 06:44 UTC
[R] Optimization failed in fitdistr (Weibull distribution)
On 28 Oct 2013, at 13:07 , kmmoon100 <k.moon at student.unimelb.edu.au> wrote:> Hello everyone, > > This is Kangmin. > > I am trying to produce shape and scale of my wind data. My data is based on > wind speed frequency with 1km/hr increment. data is described below. > > Windspeed (km/h) Frequency > 1 351 > 2 147 > 3 317 > 4 378 > 5 527 > 6 667 > 7 865 > 8 970 > 9 987 > 10 907 > 11 905 > 12 642 > 13 1000 > 14 983 > 15 847 > 16 842 > 17 757 > 18 698 > 19 632 > 20 626 > 21 599 > 22 529 > 23 325 > 24 391 > 25 356 > 26 267 > 27 230 > 28 223 > 29 190 > 30 142 > 31 124 > 32 104 > 33 97 > 34 37 > 35 62 > 36 46 > 37 42 > 38 24 > 39 9 > 40 13 > 41 9 > 42 5 > 43 2 > > R codes to calculate shape and scale are described below: > > Pine.windfrequency.4weeks<-read.table("C:/Users/kmoon/Documents/Pine_frequency_4weeks.csv",header=TRUE,sep=",") > fitdistr(Pine.windfrequency.4weeks$Frequency, densfun="weibull") > > I have got an error message when I was using 'fitdistr' function > > "Error in fitdistr(Pine.windfrequency.4weeks$Frequency, densfun = "weibull") > : > optimization failed" > > Please help me calculating shape and scale of weibull distribution. > > And please understand that I am not an user familiar with R program but I am > really trying to make my analysis work on R!There really is no substitute for knowledge and understanding! Did it not occur to you that the Windspeed column needs to enter into your analysis? I suppose you wanted the following:> tt<-read.delim("/tmp/foo") > summary(tt)Windspeed..km.h. Frequency Min. : 1.0 Min. : 2.0 1st Qu.:11.5 1st Qu.: 100.5 Median :22.0 Median : 351.0 Mean :22.0 Mean : 415.7 3rd Qu.:32.5 3rd Qu.: 682.5 Max. :43.0 Max. :1000.0> x <- rep(tt$Windspeed..km.h., tt$Frequency) > library(MASS) > fitdistr(x, densfun="weibull")shape scale 1.99900495 16.43640142 ( 0.01174133) ( 0.06468371) Warning messages: 1: In densfun(x, parm[1], parm[2], ...) : NaNs produced 2: In densfun(x, parm[1], parm[2], ...) : NaNs produced 3: In densfun(x, parm[1], parm[2], ...) : NaNs produced 4: In densfun(x, parm[1], parm[2], ...)> > Thank you!!! > > Kangmin. > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Optimization-failed-in-fitdistr-Weibull-distribution-tp4679167.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org 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.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com