InteractionProb: Calculate posterior inclusion probabilities for an...

Description Usage Arguments Value Examples

View source: R/main.R

Description

This function takes a fitted NLint object and can return the posterior probability that any given set of variables are jointly interacting with each other.

Usage

1
InteractionProb(NLmod, Xsub)

Arguments

NLmod

The fitted NLint object

Xsub

The exposures for which you want to evaluate whether there is an interaction

Value

A number indicating the posterior probability that the exposures in Xsub are jointly interacting together. If Xsub is a scalar then the marginal posterior inclusion probability is returned, while if Xsub is a vector of length 2, the two way interaction is returned and so on.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
n = 200
p = 10
pc = 1

sigma = matrix(0.3, p, p)
diag(sigma) = 1
X = rmvnorm(n, mean=rep(0,p), sigma = sigma)

C = matrix(rnorm(n*pc), nrow=n)

TrueH = function(X) {
  return(0.5*(X[,2]*X[,3]) - 0.6*(X[,4]^2 * X[,5]))
}

Y = 5 + C + TrueH(X) + rnorm(n)

NLmod = NLint(Y=Y, X=X, C=C)

## Find 2 way interaction probability between exposure 4 and 5
InteractionProb(NLmod=NLmod, Xsub=c(4,5))

jantonelli111/NLinteraction documentation built on Aug. 7, 2020, 10:02 p.m.