Description Usage Arguments Examples
View source: R/PlottingFunctions.R
This function takes in an object which is a model from the NLint function and plots the bivariate exposure response curve and pointwise posterior standard deviations for exposures j1 and j2, keeping the remaining exposures at quantile_rest and the covariates at their mean
1 2 3 4 5 6 7 8 9 10 11 12 | plotSurface2d(
NLmod,
X,
C,
j1,
j2,
gridLength_j1 = 20,
gridLength_j2 = 20,
minDist = Inf,
quantile_rest = 0.5,
...
)
|
NLmod |
The fitted model |
X |
an n by p matrix of exposures to evaluate. These should be continuous. |
C |
An n by q matrix of additional covariates to adjust for. |
j1 |
The exposure for which we will plot the exposure response function |
j2 |
The second exposure which we will fix at a certain value. This should be a secondary exposure of interest in the sense that we want to see if the exposure response curve of j1 is different at different levels of j2 (i.e interaction) |
gridLength_j1 |
The number of points to evaluate the curve at for the first exposure. More points make for a smoother curve, but also increase the computation time associated with calculating the curve |
gridLength_j2 |
The number of points to evaluate the curve at for the first exposure. More points make for a smoother curve, but also increase the computation time associated with calculating the curve |
minDist |
If the euclidean distance between all observed data points is greater than this number for any point on the plot, we wont' plot the surface there. The default is infinity so that all points on the grid are plotted. |
quantile_rest |
The quantile at which we will fix the remaining exposures |
... |
Plotting parameters to be passed on such as ylim, ylab, main, etc. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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)
par(mfrow=c(1,2), pty='s')
plotSurface2d(NLmod = NLmod, X=X, C=C, j1=4, j2=5,
gridLength_j1=20, gridLength_j2 = 20, quantile_rest = 0.5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.