# [R] integration

From: Derya Çalışkan <deryacal_at_yahoo.com>
Date: Mon, 17 Nov 2008 09:58:13 -0800 (PST)

Hello;
I have a function with 3 variables. I would like to take integration with respect to just one variable. How can I write this function? You can find my function above. ( I am trying to find \int_ZL^ZU rho.bisquare(rho*z+u*sqrt(1-rho^2)*dnorm(u)du.Integrand has three variables, I know the value of k and alpha, I am trying to obtain term2 function with variable z.  I want to take integral with respect to u. )

rho.bisquare <- function(x,k = k){

i1 <- abs(x)<=k
i2 <- i1==F
out <- (x^2/2)*(1-x^2/k^2 + x^4/(3*k^4))*i1 + k^2/6*i2 out
}

term2<-function(z,k=k,alpha=alpha,rho){
integrand <-function(u){
A <-rho*z+u*sqrt(1-rho^2)
out<-rho.bisquare(A/sqrt(3/2),k = k)*dnorm(u)  out}

ZU <-(sqrt(3/2)*k-rho*z)/sqrt(1-rho^2)
ZL <-(-sqrt(3/2)*k-rho*z)/sqrt(1-rho^2)
out <-integrate(integrand,lower=ZL,upper=ZU)\$value out}

Derya


[[alternative HTML version deleted]]

______________________________________________

R-help_at_r-project.org 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 Mon 17 Nov 2008 - 19:20:41 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 Mon 17 Nov 2008 - 19:31:27 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.