[R] Function -return value

From: livia <yn19832_at_msn.com>
Date: Tue, 19 Jun 2007 08:33:45 -0700 (PDT)

Hi, I am trying to write a function with the following codes and I would like it to return the values for "alpha
beta para parab " seperately. Then I would like to use this funstion for
"variable" with factor "a" and "b". But the result turns out to be a matrix
with element like "Numeric,2" ... I guess they are just the values for
"parab", and we can not even see the two parameters in parab.

parameter <- function(v) {
v1 <- v[v>mean(v)+0.5*sd(v)]
v2 <- v[v<mean(v)-0.5*sd(v)]
alpha=min(v1)
beta=max(v2)
para <- fitgpd(v1,alpha, method="pwmu")$param parab <- fitgpd((-v2), (-beta), method="pwmu")$param v1.fit <- qgpd(ppoints(v1, a=0.5), alpha, para[1], para[2]) v2.fit <- qgpd(ppoints((-v2), a=0.5), (-beta), para[1], para[2]) alpha
beta
para
parab

}

tapply(variable, list(a, b),parameter)

I would be grateful if anyone can give me some advice. Many thanks

-- 
View this message in context: http://www.nabble.com/Function--return-value-tf3947134.html#a11197159
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 19 Jun 2007 - 15:52:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Jun 2007 - 17:32:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.