# cdens: Build a conditional density function In truncgof: GoF tests allowing for left truncated data

## Description

For a given distribution function `cdens` builds a conditional density function with respect to a relevant treshold.

## Usage

 `1` ```cdens(distn, H) ```

## Arguments

 `distn` character string naming the distribution function for which the conditional density is to be built `H` a treshold value

## Details

For x >= H the conditional density f* of a density f is given by

f*_theta(x) = f(x|x>=H) = f_theta(x)/(1-F_theta(x)),

with theta the parameters of the distribution, F the cumulative distribution function and H the treshhold value. For x < H, f* disappear.

## Value

The conditional density of the specified density function with arguments `x`, the relevant parameters and the treshold `H` predefined as the value of cdens' argument `H`. `x` can be a numeric value or numeric vector, but must be greater or equal to `H`.

## See Also

density functions, e.g. `dlnorm`, `dgamma`, etc.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```require(MASS) set.seed(123) treshold <- 10 xc <- rlnorm(100, 2, 2) # complete sample xt <- xc[xc >= treshold] # left truncated sample clnorm <- cdens("plnorm", H = treshold) args(clnorm) # mle fitting based on the complete sample start <- list(meanlog = 2, sdlog = 1) fitdistr(xc, dlnorm, start = start) # mle fitting based on the truncated sample fitdistr(xt, clnorm, start = start) # in contrast fitdistr(xt, dlnorm, start = start) ```

### Example output

```Loading required package: MASS

Attaching package: 'truncgof'

The following object is masked from 'package:stats':

ks.test

function (x, meanlog = 0, sdlog = 1, log = FALSE, H = 10)
NULL
meanlog      sdlog
2.1808115   1.8164823
(0.1816482) (0.1284447)
Warning message:
In densfun(x, parm, parm, ...) : NaNs produced
meanlog      sdlog
2.3735856   1.7963580
(1.2009245) (0.5221259)
meanlog      sdlog
3.7621786   1.0954865
(0.1615207) (0.1142094)
Warning messages:
1: In densfun(x, parm, parm, ...) : NaNs produced
2: In densfun(x, parm, parm, ...) : NaNs produced
3: In densfun(x, parm, parm, ...) : NaNs produced
4: In densfun(x, parm, parm, ...) : NaNs produced
5: In densfun(x, parm, parm, ...) : NaNs produced
6: In densfun(x, parm, parm, ...) : NaNs produced
7: In densfun(x, parm, parm, ...) : NaNs produced
```

truncgof documentation built on May 1, 2019, 10:54 p.m.