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 exposure response curve and pointwise 95 band for exposure j1, while fixing exposure j2 at quantile_j2, the remaining exposures at quantile_rest, and the covariates at their mean
1 2 3 4 5 6 7 8 9 10 11 | plotSurface1d(
NLmod,
X,
C,
j1,
j2,
gridLength = 100,
quantile_j2,
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 |
The number of points to evaluate the curve at. More points make for a smoother curve, but also increase the computation time associated with calculating the curve |
quantile_j2 |
The quantile at which we will fix exposure j2 |
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 22 23 | 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')
plotSurface1d(NLmod = NLmod, X=X, C=C, j1=4, j2=5,
gridLength=30, quantile_j2=0.2, quantile_rest = 0.5)
plotSurface1d(NLmod = NLmod, X=X, C=C, j1=4, j2=5,
gridLength=30, quantile_j2=0.8, quantile_rest = 0.5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.