[R] Solve an equation including integral

Ravi Varadhan ravi.varadhan at jhu.edu
Fri Jan 8 17:28:52 CET 2016

I think this is what you want:

myroot <- function(t, nu, exi, alpha){
  fun <- function(t, exi, nu) (nu+t^2)^(-(nu+1)/2)*exp(((nu+1)*exi*t)/((nu+t^2)^0.5))
  res <- alpha - integrate(fun, -Inf, t, nu=2, exi=0.5)$value

uniroot(myroot, c(-2, 2), nu=2, exi=0.5, alpha=.05)

Hope this is helpful,

Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
Associate Professor,  Department of Oncology
Division of Biostatistics & Bionformatics
Sidney Kimmel Comprehensive Cancer Center
Johns Hopkins University
550 N. Broadway, Suite 1111-E
Baltimore, MD 21205

	[[alternative HTML version deleted]]

More information about the R-help mailing list