inst/unitTests/runitmomentsLogitnorm.R

#TODO

.setUp <-function () {
}

.tearDown <- function () {
}

test.1 <- function(){
  set.seed(0815)
  theta0 <- c(mu=1.5, sigma=0.8)
	#plot the true and the rediscovered distributions
	xGrid = seq(0,1, length.out=81)[-c(1,81)]
	dx <- dlogitnorm(xGrid, mu=theta0[1], sigma=theta0[2])
	plot( dx~xGrid, type="l")
	
	moments <- momentsLogitnorm(mu=theta0[1], sigma=theta0[2] )
	#check by monte carlo integration
	z <- rlogitnorm(1e6, mu=theta0[1], sigma=theta0[2]);	var(z)
	checkEqualsNumeric( mean(z), moments["mean"], tolerance=1e-3)
	checkEqualsNumeric( var(z), moments["var"], tolerance=1e-2)
}

test.momentsLogitnorm41 <- function(){
	(res <- momentsLogitnorm(4,1))
	checkEqualsNumeric( c(0.97189602, 0.00101663), res)
}

test.momentsLogitnorm501 <- function(){
  set.seed(0815)
  (res <- momentsLogitnorm(5,0.1))
	checkEqualsNumeric( c(9.932743e-01, 4.484069e-07), res, tolerance=1e-7)
}

Try the logitnorm package in your browser

Any scripts or data that you put into this service are public.

logitnorm documentation built on Jan. 7, 2021, 9:09 a.m.