1
$\begingroup$

Say I have a continuous variable $C \sim N(0, 1)$, which was observed in a few points:

obsC <- seq(-1.5, 1.5, by = 1)

I also have a discrete variable $D \in \{0; 1\}$ as well as all the values for $\Pr(D = d | C = c)$:

DcondC <- matrix(c(.1, .2, .3, .4, .9, .8, .7, .6),
                 nrow = length(obsC), ncol = 2,
                 dimnames = list("C" = obsC, "D" = 0:1))
DcondC
      D
C        0   1
  -1.5 0.1 0.9
  -0.5 0.2 0.8
  0.5  0.3 0.7
  1.5  0.4 0.6

My goal is to get to $\Pr(D = d)$.

In order to achieve this, my approach has begun with calculating the mixed joint density, defined as

$$ f_{C, D}(c, d) = \Pr(D = d | C = c) f_C(c). $$

I believe the code below correcly calculates these values:

mixedJointDens <- DcondC  # just to create the matrix
for (row in 1:nrow(DcondC)) {
  mixedJointDens[row, ] <- DcondC[row, ] * dnorm(obsC[row])
}
mixedJointDens
      D
C               0          1
  -1.5 0.01295176 0.11656584
  -0.5 0.07041307 0.28165226
  0.5  0.10561960 0.24644573
  1.5  0.05180704 0.07771056

The densities above sum to less than 1, but I think this is either because this is not a proper PDF or because I am missing a chunk of the support for $C$. Anyway, apparently I need to recover the joint CDF by calculating

$$ F_{C, D}(c, d) = \sum_{t \leq d} \int_{s = -\infty}^c f_{C, D}(s, t)ds, $$

which I can't understand how to do, either algebraically or numerically. After that, I'll need to figure out a way to integrate out $C$ so I can end up with $F_D(d)$ and, by subtraction, $\Pr(D = d)$.

I've been trying to solve this problem for a couple of days now, and as my brain cells start giving up I can't help but think I am either over complicating this or missing something obvious. Am I on the correct path? Is there a better approach to getting to $\Pr(D = d)$ when one knows $\Pr(D = d | C = c)$ and $f_C(c)$?

$\endgroup$
3
  • $\begingroup$ If you only happen to know $P(D=1|C=c)$ at the four observed values of $c$, there is no way you can find $P(D=1)=\int_{-\infty}^\infty P(D=1|C=c)f_C(c)dc$ without making more assumptions. You need to know $P(D=1|C=c)$ for all possible values of $c$. $\endgroup$ Commented Aug 12, 2017 at 12:07
  • $\begingroup$ @JarleTufto, I see. In my actual case, I have an exact function to calculate $P(D = d|C = c)$ for any $d$ and $c$. $\endgroup$ Commented Aug 12, 2017 at 14:54
  • 1
    $\begingroup$ Maybe you have already solved this but if $P(D=1|C=c)$ is a known function, all you have to to is to compute the integral in my first comment, either analytically or numerically (using say the integrate function in R). I also don't see how sample values of $C$ are relevant if you know that $C\sim N(0,1)$. $\endgroup$ Commented Aug 12, 2017 at 22:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.