[R] Hypergeometric Function seems to give wrong results

2015-07-06 Thread Carlos Nasher via R-help
Hello R helpers, I need to evaluate the Hypergeometric Function of the 2nd kind (Tricomi confluent hypergeometric function). Therefore I'm using the kummerU function from the fAsianOptions package. It seems to me that kummerU is giving wrong results. Here's an example: library("fAsianOptions") ku

[R] apply function to multiple list arguments

2014-10-14 Thread Carlos Nasher
desired results (res_1, res_2) again in a list. I tried mapply, but I don't get it running. Can anybody help? Thanks and best regards, Carlos -- ----- Carlos Nasher Buchenstr. 12 22299 Hamburg tel:+49 (0)40 67952962 mobi

Re: [R] SOLVED: Count number of consecutive zeros by group

2013-11-11 Thread Carlos Nasher
umber of zeroes not max number of > consecutive zeroes. > > Regards > Petr > > > > -Original Message- > > From: arun [mailto:smartpink...@yahoo.com] > > Sent: Friday, November 01, 2013 2:17 PM > > To: R help > > Cc: PIKAL Petr; Carlos Nas

Re: [R] Count number of consecutive zeros by group

2013-10-31 Thread Carlos Nasher
If I apply your function to my test data: ID <- c(1,1,1,2,2,3,3,3,3) x <- c(1,0,0,0,0,1,1,0,1) data <- data.frame(ID=ID,x=x) rm(ID,x) f2 <- function(x) { max( rle(x == 0)$lengths ) } with(data, tapply(x, ID, f2)) the result is 1 2 3 2 2 2 which is not what I'm aiming for. It should be 1 2 3

[R] Count number of consecutive zeros by group

2013-10-31 Thread Carlos Nasher
er of consecutive zeros? Different approaches are also welcome. Since the real dataframe is quite large, a fast solution is appreciated. Best regards, Carlos -- --------- Carlos Nasher Buchenstr. 12 22299 Hamburg tel:+49 (0)40 679529

Re: [R] [dfoptim] 'Error in fn(ginv(par), ...) : object 'alpha' not found'

2013-09-09 Thread Carlos Nasher
xp(lgamma(r+x)-lgamma(r)+r*(log(alpha_zero)-log(alpha_zero+T))-x*log(alpha_zero+T)+s*(log(beta_zero)-log(beta_zero+T)))+exp(lgamma(r+x)-lgamma(r)+r*log(alpha_zero)+log(s)+s*log(beta_zero)+log(integral$V1)) > f <- -sum(log(L)) > return (f) > } > > > Best > > Simon &

[R] [dfoptim] 'Error in fn(ginv(par), ...) : object 'alpha' not found'

2013-09-03 Thread Carlos Nasher
5, -0.02, -0.02) fit <- nmkb(par=params, fn=Likelihood_cov, lower=c(0.0001, 0.0001, 0.0001, 0.0001, -Inf, -Inf), upper=c(Inf, Inf, Inf, Inf, Inf, Inf), x=data$x, tx=data$tx, T=data$T, IS=IS) ########## Maybe you could give me a h

[R] [optim/bbmle] function returns NA at ... distance from x

2013-08-13 Thread Carlos Nasher
, beta=10)) 'Error in grad.default(objectivefunction, coef) : function returns NA at 1e-040.001013016911639890.0003166929388711890.000935163594829395 distance from x. In addition: Warning message: In optimx(par = c(0.5, 10, 0.7, 10), fn = function (p) : Gradient not computable after method Nelder-Mead' Best regard

[R] Numercial evaluation of intgral with different bounds

2013-08-08 Thread Carlos Nasher
unlist(integral2, use.names=FALSE) But this doesn't work properly. I'd glad if you have any hints how to get this done. Many thanks and best regards, Carlos -- ----- Carlos Nasher Buchenstr. 12 22299 Hamburg tel:

[R] Set a zero at minimum row by group

2012-12-18 Thread Carlos Nasher
Dear R Helpers, I'm struggling with a data preparation problem. I feel that it is a quite easy task but I don't get it done. I hope you can help me with that. I have a data frame looking like this: ID <- c(1,1,1,2,2,3,3,3,3) T <- c(1,2,3,1,4,3,5,6,8) x <- rep(1,9) df <- data.frame(ID,T,x) >df I