[R] Uniroot error message with in intergration

jeka12386 jeka12386 at hotmail.co.uk
Fri Jun 22 23:00:24 CEST 2012


Dear all 

I am trying to calculate the value of n using uniroot.  Here is the message
I am having:

<<<
Error in uniroot(integ, lower = 0, upper = 1000, n) : 
  'interval' must be a vector of length 2 >>>

Please  would you be able to  give me an indication on why I am having this
error message.

Many thanks

EXAMPLE BELOW:

## t  =  statistics test  from t -distribution  [-Inf,Inf]
## df == degree of freedom
###p <- p value

diff <- 0.5

y <- function(t,n){

df <- 2*n-2
ncp1 <- sqrt((diff^2*n)/2) 
p <- 1- pt(t,df=df1)
test <- qt((1-p),df=df1,ncp=ncp1)*(1/sqrt(2))
return(test)
}

integ <- function(t,n){
1-integrate(y,lower=0,upper=3.6,n)$value -0.5
}
 
uniroot(integ,lower=0,upper=1000) 


--
View this message in context: http://r.789695.n4.nabble.com/Uniroot-error-message-with-in-intergration-tp4634247.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list