[R] Function -return value

livia yn19832 at msn.com
Tue Jun 19 17:33:45 CEST 2007


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.



More information about the R-help mailing list