last day (21 days later) » 

6:51 AM
3
A: Weibull distribution parameters k and c

COOLSerdashBecause @zaynah posted in the comments that the data are thought to follow a Weibull distribution, I'm gonna provide a short tutorial on how to estimate the parameters of such a distribution using MLE (Maximum likelihood estimation). Download and install R, it's free Optional: Download and inst...

 
@gung Thanks. I'm not aware that qqPlot from car calculates the MLE parameters automatically. If I generate a random variable with a weibull distribution (rweibull) and use the command qqPlot(rw, distribution="weibull") I get an error message saying that must provide the parameters shape and scale to qqPlot. Am I missing something?
 
hi, i found that after i import mydata into R, when i do the command,fitdistr(mydata, densfun="weibull") it says error messgae that "mydata" not found.. in fact my data hs been imported into R. any answer would be welcome.
 
@zaynah Could you please edit your answer and post your code that you use to import the data. Please add the error message too. Could you import the data without errors? Did you check if the data was imported correctly?
 
i import successfully my data..:read.table("C:/Users/Zaynah/Desktop/mydata.csv"), then i got my data. i mean i saw the full data.. then i use the function > fitdistr(mydata, distribution="weibull")
then the error was found:"Error in fitdistr(mydata, distribution = "weibull") : object 'mydata' not found"
 
@zaynah That's because mydata refers to the whole dataset. What is your data inside the dataset called? If it is called wind.speed, for example, you have to type mydata$wind.speed to access the variable inside your dataset. Just replace wind.speed with your actual name.
 
6:51 AM
but @COOLSerdash there is no name at all.. like you told me, i had only insert the numbers.. so mydata has only rows n columns of numbers..:(
 
@zaynah Please post your R-output in your question (click the edit button below your question). In any case, mydata should have exactly 1 column and n rows (n = your sample size). This column has a name. Type str(mydata) to get it. Use this name then in this way: fitdistr(mydata$myname, distribution="weibull").
 
read.table("C:/Users/Zaynah/Desktop/mydata.csv")
V1
1 5.28,5.28,4.75,3.69,3.69,5.28,5.81,4.22,5.28,5.28,4.22,3.69
2 2.64,4.75,3.69,4.22,3.69,3.69,5.28,5.28,4.75,4.22,4.22,4.22
3 3.17,3.69,3.69,3.69,4.75,4.75,5.28,5.81,4.22,4.75,4.22,4.22
4 4.22,3.69,3.17,4.22,2.64,3.69,4.22,4.75,4.75,4.22,4.22,3.69
5 3.69,3.69,5.28,4.75,4.22,5.23,5.12,5.81,5.81,5.81,4.43,4.43
ps: the edit button is not working...when i do "str(mydata)"
Error in str(mydata) : object 'mydata' not found
 
You need to assign your data to a name. Type "mydata <- read.table ..."
 
yes i did the command. nothing happen, mydata <- read.table..nothing happen then i did,
> str(mydata)
i got the follwing message...:"function (file, header = FALSE, sep = "", quote = "\"'", dec = ".", row.names, col.names, as.is = !stringsAsFactors, na.strings = "NA", colClasses = NA, nrows = -1, skip = 0,
check.names = TRUE, fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip = TRUE, comment.char = "#", allowEscapes = FALSE, flush = FALSE, stringsAsFactors = default.stringsAsFactors(),
 
I think you need to use the option header = TRUE if you have column names (variable names in your csv-file): "mydata <- read.table("C:/Users/Zaynah/Desktop/mydata.csv", header=TRUE)"
And how is your file delimited? By tab? Then you also have to specify that in "read.table" by typing the option "sep="\t""
 
6:56 AM
mydata is in excel, CSV
by coma
 
And is your first row in excel the name of the variable?
Or does it contain ONLY the numbers and no text whatsoever?
 
5.28 5.28 4.75 3.69 3.69 5.28 5.81 4.22 5.28 5.28 4.22 3.69
2.64 4.75 3.69 4.22 3.69 3.69 5.28 5.28 4.75 4.22 4.22 4.22
3.17 3.69 3.69 3.69 4.75 4.75 5.28 5.81 4.22 4.75 4.22 4.22
4.22 3.69 3.17 4.22 2.64 3.69 4.22 4.75 4.75 4.22 4.22 3.69
3.69 3.69 5.28 4.75 4.22 5.23 5.12 5.81 5.81 5.81 4.43 4.43
when u todl me that names are nt important.. so i deletd the names
orgininally it was liek this JAN FEB MAR APR MAY JUNE JULY AUG SEPT OCT NOV DEC
2008 5.28 5.28 4.75 3.69 3.69 5.28 5.81 4.22 5.28 5.28 4.22 3.69
2009 2.64 4.75 3.69 4.22 3.69 3.69 5.28 5.28 4.75 4.22 4.22 4.22
2010 3.17 3.69 3.69 3.69 4.75 4.75 5.28 5.81 4.22 4.75 4.22 4.22
2011 4.22 3.69 3.17 4.22 2.64 3.69 4.22 4.75 4.75 4.22 4.22 3.69
2012 3.69 3.69 5.28 4.75 4.22 5.23 5.12 5.81 5.81 5.81 4.43 4.43
mean 3.80 4.22 4.12 4.12 3.80 4.53 5.14 5.17 4.96 4.86 4.26 4.05
 
Yeah, that's okay. And are they - in Excel - in 1 column (the first)?
 
JAN FEB MAR APR MAY JUNE JULY AUG SEPT OCT NOV DEC
2008 5.28 5.28 4.75 3.69 3.69 5.28 5.81 4.22 5.28 5.28 4.22 3.69
2009 2.64 4.75 3.69 4.22 3.69 3.69 5.28 5.28 4.75 4.22 4.22 4.22
2010 3.17 3.69 3.69 3.69 4.75 4.75 5.28 5.81 4.22 4.75 4.22 4.22
2011 4.22 3.69 3.17 4.22 2.64 3.69 4.22 4.75 4.75 4.22 4.22 3.69
2012 3.69 3.69 5.28 4.75 4.22 5.23 5.12 5.81 5.81 5.81 4.43 4.43
mean 3.80 4.22 4.12 4.12 3.80 4.53 5.14 5.17 4.96 4.86 4.26 4.05
u want me to put them all in 1 column?
thy are a posted above minus the years and months name..:(
 
Do you want to calculate one k and c for all data?
 
7:01 AM
i want to calculate the k and c for the experimental data first
i am honesly lost.
 
Me too.
 
let me start
my aim is to compare the k and c experimental
with the k and c from MlE
 
Right.
And you want to estimate the k and c from your data?
 
yess
those data are mt experimental ones.
measure for a period f 5 years
monthly mean speed data.
 
Yeah yeah, I got that.
Again: You want to compare ONE k and c?
For all 5 years?
 
7:03 AM
can i do it yearly?
 
You could also do it per year, yes. Then you'd have 5 k's and c's.
 
yes but how would i do the comparison then?
ie from MLE.?
 
With what do you want to compare it?
 
graph of probability distribution
agains wind speed
with observed data adn MLE method data
 
And what is the data above? The observed data? And what do you mean by MLE method data?
MLE is a method to estimate the parameters.
 
7:08 AM
above s experimental dta
i wud have to use MLE method to estimate the k and c
 
rigth?
 
Yes, that's what we're trying to do.
 
yess
from research papers i found that they compared the observed data with the Weibull distribution on a graph of probabiliy density distribution against monthly mean speed
 
The first thing is to correctly format your data file in excel. Please do it like that: The first column contains all wind speeds, from all years and all months. The second column contains the year and the third column contains the months.
 
7:10 AM
this is what i am actually trying to do
 
Do you have a link to such a graph?
 
yes of coruse
cani sent it to u?
 
yes here
 
which graph?
 
7:17 AM
fig 6
 
Okay.
Wait a second.
 
yes yess i am going to send you a secodn link.
fig 10
this is another comparison done with observed and MLE.
 
Just a second.
Thanks
 
Please download these two files. One is the data file and one is the R-Script.
 
7:32 AM
done
 
Good, open windspeed.R with R.
 
done
 
Good! Now you have to change the path to your file.
 
woaww you made a program?
 
After you updated your path, try to run the program (not the whole file), just until the first "legend"
 
7:35 AM
yes am doing it
 
Okay.
This should produce the comparison plot similar to those you gave the link.
 
yess
its samee
but i run till
legent
and i got the graph
of theroretical
 
Okay.
So that should be it.
 
yess now i run more part
and i found
i mean the 2 graphs.
this is very very perfect
can u please tell me how you did this?
 
The lower part fits different curves for each year.
 
7:40 AM
yeah this i saw..
 
I think you see inside the R-Script how I did it. I used fitdistr to calculate the MLE estimate of the shape and scale and then plottet the Weibull density with these parameters (blue curve). Then I've added the density of your data.
 
how wud i knwo whch year for which curve?
 
Add this at the bottom: legend("topright", legend=as.character(2008:2012), lwd=rep(2, 5), col=rainbow(5), bty="n")
Just re-download the script. I've added some things: wuala.com/coolserdash/Share/?key=wU3zab5E0v9v
Wait
 
yes yes u added colourss
to each linee
 
Okay, now download it again. I have made it more clear.
I have to go now.
Bye :)
 
7:49 AM
hey
thanks
 
Now each year is plottet separately.
 
1 more thing, does the softrware know
the difernecr bet the theoryand experimental?
 
What do you mean by "does the software know"?
 
i mean you directly put the experiment and theoretical graph.
u used some comand
so the software di this directly.
 
Yup.
x <- seq(0, 10, length.out=100)
hx <- dweibull(x, shape=6.3715695, scale=4.7438316)
 
7:51 AM
i have neve heard of R.
the input values for shape n sclaee
were done by u?
 
This creates the theoretical Weibull density for wind speeds from 0 -10
Yeah, the scale and shape are those that we've estimated by "fitdistr" from your observed data.
 
i wil study this deeply
thnaks a lot
dear Coolserdas
 
:) No problem.
Bye
 
byee..
:)
 

  last day (21 days later) »