Description Usage Arguments Value Examples
This function takes in an outcome and covariates, and fits a semiparametric regression model with additive functions so that the effect of each covariate is modeled with a spline basis representation
1 2 3 |
Y |
The outcome to be analyzed |
x |
An n by p matrix of covariates |
xnew |
A new n2 by p matrix of covariates at which the outcome will be predicted |
DF |
Degrees of freedom of the splines for each covariate |
lambda1 |
Prior parameter for the slab component of the prior |
lambda0seq |
Sequence of lambda0 values to consider |
a |
First hyperparameter for the beta prior denoting the prior probability of being in the slab |
b |
Second hyperparameter for the beta prior denoting the prior probability of being in the slab |
nFolds |
The number of folds to run cross validation on |
M |
Positive number less than p indicating how often to update theta and sigma. There is no need to change this unless trying to optimize computation time |
error |
The l2 norm difference that constitutes when the algorithm has converged |
forceGroups |
A vector containing the indices of any groups you wish to automatically include in the model and not penalize |
UpdateSigma |
True or False indicating whether to estimate the residual variance |
A list of values containing the predictions at the observed locations, predictions at the new locations xnew, a vector indicating which covariates have nonzero coefficients, an n by p matrix of predicted f(x) values for each covariate, an n2 by p matrix of predicted f(xnew) values for each covariate, and an estimate of the residual variation in the model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Here we generate 200 samples from 100 covariates
n = 200
n2 = 100
G = 100
x = mvtnorm::rmvnorm(n, sigma=diag(G))
xnew = mvtnorm::rmvnorm(n2, sigma=diag(G))
Ynew = 200 + xnew[,1] + xnew[,2] + 0.6*xnew[,2]^2 + rnorm(n2, sd=1)
modSSGLspr = SSGLspr(Y=Y, x=x, xnew = xnew, lambda1=.1, DF=2)
mean((modSSGLspr$predY - Y)^2)
mean((modSSGLspr$predYnew - Ynew)^2)
modSSGLspr$nonzero
plot(xnew[,2], modSSGLspr$fxnew[,2])
points(xnew[,2], xnew[,2] + 0.6*xnew[,2]^2 -
mean(xnew[,2] + 0.6*xnew[,2]^2), col=2)
legend("top", c("Estimated", "Truth"),col=1:2, pch=1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.