[R] (no subject)
Leaf Sun
leaflovesun at yahoo.ca
Thu Jul 20 22:25:05 CEST 2006
@yahoo.ca>
Subject: Re: [R] Weibull distribution
Message-ID: <200607201425040019536 at yahoo.ca>
X-mailer: Foxmail 6, 3, 103, 21 [cn]
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="=====003_Dragon527446281311_====="
This is a multi-part message in MIME format.
--=====003_Dragon527446281311_=====
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: 7bit
Hi William,
Thanks a lot for your response. I checked the package and found that what I want to solve was the opposite, that is, from mean and sd to parameters shape and scale. Could anyone give some hints please? Any suggestion would be appreciated!
Leaf
----- Original Message -----
From: William Asquith, wasquith at austin.rr.com
Sent: 2006-07-17, 16:18:31
To: Leaf Sun, leaflovesun at yahoo.ca
Subject: Re: [R] Weibull distribution
Do not have answer per se, but if you are seeking some comparisons--
try three parameter Weibull as implemented by the lmomco package.
William
On Jul 17, 2006, at 1:18 PM, Leaf Sun wrote:
> Hi all,
>
> By its definition, the mean and variance of two-par. Weibull
> distribution are:
>
>
>
>
>
> (www.wikipedia.org)
>
>
> I was wondering, if given mean and sd. could we parameterize the
> distribution? I tried this in R.
>
> gamma.fun <- function(mu,sd,start=100)
> {
> f.fn <- function(alpha) sd^2-mu^2/(gamma(1+1/alpha))^2*(gamma(1+2/
> alpha)-(gamma(1+1/alpha))^2)
> alpha <- optim(start, f.fn,method='BFGS')
> beta <- mu/gamma(1+1/alpha$par)
> return(list=c(a=alpha$par,b=beta));
> }
>
>
> But the problems come up here:
>
> 1) the return values of a and b are only related to the input
> mean, and nothing to do with the sd. For instance, when I apply a
> mean mu = 3 whatever I use sd=2, sd=4, the function returned the
> same scale and shape values.
>
> > gamma.fun(3,4,10);
> a b
> 5.112554 3.263178
>
> > gamma.fun(3,2,10);
> a b
> 5.112554 3.263178
>
> 2) the start value determines the results: if I apply mean = 3, and
> sd=2, with a start of 10, it would return alpha close to 10, if I
> use a start = 100, it would return alpha close to 100.
>
> > gamma.fun(3,2,10);
> a b
> 5.112554 3.263178
>
> > gamma.fun(3,2,100);
> a b
> 99.999971 3.017120
>
> Since I am not a statistician, I guess there must be some
> theoretical reasons wrong with this question. So I am looking
> forward to some correction and advice to solve these. Thanks a lot
> in advance!
>
> Leaf
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
--=====003_Dragon527446281311_=====
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
<BODY>
<DIV>Hi William,</DIV>
<DIV> </DIV>
<DIV>Thanks a lot for your response. I checked the package and found that what I
want to solve was the opposite, that is, from mean and sd to parameters shape
and scale. Could anyone give some hints please? Any suggestion would be
appreciated!</DIV>
<DIV><BR>Leaf</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>----- Original Message -----</DIV>
<DIV> </DIV>
<DIV><FONT size=2><FONT face=Tahoma><STRONG>From:</STRONG> William
Asquith, <A
href="mailto:wasquith at austin.rr.com">wasquith at austin.rr.com</A><BR><B>Sent:</B>
2006-07-17, 16:18:31<BR><B>To:</B> Leaf Sun, <A
href="mailto:leaflovesun at yahoo.ca">leaflovesun at yahoo.ca</A><BR><B>Subject:</B>
Re: [R] Weibull distribution</FONT></FONT></DIV>
<DIV> </DIV>
<DIV>
<TABLE width="100%">
<TBODY>
<TR>
<TD width="100%">
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>Do not have answer per se, but
if you are seeking some
comparisons-- </DIV>
<DIV>try three parameter Weibull as
implemented by the lmomco package.</DIV>
<DIV> </DIV>
<DIV>William</DIV>
<DIV>On Jul 17, 2006, at 1:18 PM,
Leaf Sun wrote:</DIV>
<DIV> </DIV>
<DIV>> Hi all,</DIV>
<DIV>></DIV>
<DIV>> By its definition, the mean
and variance of two-par. Weibull
</DIV>
<DIV>> distribution are:</DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>> (www.wikipedia.org)</DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>> I was wondering, if given
mean and sd. could we parameterize
the </DIV>
<DIV>> distribution? I tried this in
R.</DIV>
<DIV>></DIV>
<DIV>> gamma.fun <-
function(mu,sd,start=100)</DIV>
<DIV>> {</DIV>
<DIV>> f.fn <- function(alpha)
sd^2-mu^2/(gamma(1+1/alpha))^2*(gamma(1+2/ </DIV>
<DIV>> alpha)-(gamma(1+1/alpha))^2)</DIV>
<DIV>> alpha <- optim(start,
f.fn,method='BFGS')</DIV>
<DIV>> beta <- mu/gamma(1+1/alpha$par)</DIV>
<DIV>> return(list=c(a=alpha$par,b=beta));</DIV>
<DIV>> }</DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>> But the problems come up
here:</DIV>
<DIV>></DIV>
<DIV>> 1) the return values of
a and b are only related to
the input </DIV>
<DIV>> mean, and nothing to do
with the sd. For instance, when
I apply a </DIV>
<DIV>> mean mu = 3 whatever I
use sd=2, sd=4, the function
returned the </DIV>
<DIV>> same scale and shape
values.</DIV>
<DIV>></DIV>
<DIV>> > gamma.fun(3,4,10);</DIV>
<DIV>> a
b</DIV>
<DIV>> 5.112554 3.263178</DIV>
<DIV>></DIV>
<DIV>> > gamma.fun(3,2,10);</DIV>
<DIV>> a
b</DIV>
<DIV>> 5.112554 3.263178</DIV>
<DIV>></DIV>
<DIV>> 2) the start value determines
the results: if I apply mean =
3, and </DIV>
<DIV>> sd=2, with a start of 10,
it would return alpha close to
10, if I </DIV>
<DIV>> use a start = 100, it
would return alpha close to
100.</DIV>
<DIV>></DIV>
<DIV>> > gamma.fun(3,2,10);</DIV>
<DIV>> a
b</DIV>
<DIV>> 5.112554 3.263178</DIV>
<DIV>></DIV>
<DIV>> > gamma.fun(3,2,100);</DIV>
<DIV>>
a
b</DIV>
<DIV>> 99.999971 3.017120</DIV>
<DIV>></DIV>
<DIV>> Since I am not a
statistician, I guess there must be
some </DIV>
<DIV>> theoretical reasons wrong with
this question. So I am looking
</DIV>
<DIV>> forward to some correction and
advice to solve these. Thanks a
lot </DIV>
<DIV>> in advance!</DIV>
<DIV>></DIV>
<DIV>> Leaf</DIV>
<DIV>></DIV>
<DIV>> [[alternative HTML version
deleted]]</DIV>
<DIV>></DIV>
<DIV>> ______________________________________________</DIV>
<DIV>> R-help at stat.math.ethz.ch mailing list</DIV>
<DIV>> https://stat.ethz.ch/mailman/listinfo/r-help</DIV>
<DIV>> PLEASE do read the posting
guide! <A
href="http://www.R-project.org/posting-">http://www.R-project.org/posting-</A>
</DIV>
<DIV>> guide.html</DIV>
<DIV> </DIV></BLOCKQUOTE></TD></TR></TBODY></TABLE></DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>
--=====003_Dragon527446281311_=====--
More information about the R-help
mailing list