[R] Basic R question
arun
smartpink111 at yahoo.com
Tue May 14 00:34:49 CEST 2013
Hi,
Try:
integrate(Pareto,lower=0,upper=(MM-1)+0.5,x0=x0,alpha2=alpha2)
#170.5065 with absolute error < 0.016
A.K.
For a homework assignment I'm constructing a simple code. R keeps returning that a x0 is missing in evaluating p2.
I can't figure out why.
lab1 <- 50; mu <- 1; sigma <- 1
alpha1 <- 1 ; beta1 <- 1
lab2 <- 3; mu <- 5; sigma <- 5
alpha2 <- (1+sqrt(2)); x0 <- (10- 5* sqrt(2))
ES1 <- lab1 * alpha1/beta1; VarS1 <- lab1 * alpha1/(beta1^2)
ES2 <- lab2 * alpha2*x0/(alpha2-1); VarS2 <- lab2 * alpha2*x0^2/((alpha2-1)^2*(alpha2-2))
MM <- trunc(ES1 + ES2 + 10*sqrt(VarS1 + VarS2))
p1 <- pgamma((0:(MM-1)+0.5), alpha1, beta1) ##cdf
p1 <- c(p1,1) - c(0,p1) ## pdf
Pareto <- function (x, alpha2, x0) ifelse(x<x0 , 0, 1 - (x0/x)^alpha2)
p2 <- integrate(Pareto, lower = 0, upper = (MM-1)+0.5) ##cdf
p2 <- c(p2,1) - c(0,p2) ## pdf
Many thanks in advance!
Regards, Vincent
More information about the R-help
mailing list