makessa {bigsplines} | R Documentation |
Makes Objects to Fit Smoothing Spline ANOVA Models
Description
This function creates a list containing the necessary information to fit a smoothing spline anova model (see bigssa
).
Usage
makessa(formula,data=NULL,type=NULL,nknots=NULL,rparm=NA,
lambdas=NULL,skip.iter=TRUE,se.fit=FALSE,rseed=1234,
gcvopts=NULL,knotcheck=TRUE,gammas=NULL,weights=NULL,
random=NULL,remlalg=c("FS","NR","EM","none"),remliter=500,
remltol=10^-4,remltau=NULL)
Arguments
formula |
An object of class " |
data |
Optional data frame, list, or environment containing the variables in |
type |
List of smoothing spline types for predictors in |
nknots |
Two possible options: (a) scalar giving total number of random knots to sample, or (b) vector indexing which rows of |
rparm |
List of rounding parameters for each predictor. See Details. |
lambdas |
Vector of global smoothing parameters to try. Default uses |
skip.iter |
Logical indicating whether to skip the iterative smoothing parameter update. Using |
se.fit |
Logical indicating if the standard errors of the fitted values should be estimated. |
rseed |
Random seed for knot sampling. Input is ignored if |
gcvopts |
Control parameters for optimization. List with 3 elements: (a) |
knotcheck |
If |
gammas |
List of initial smoothing parameters for each predictor. See Details. |
weights |
Vector of positive weights for fitting (default is vector of ones). |
random |
Adds random effects to model (see Random Effects section). |
remlalg |
REML algorithm for estimating variance components (see Random Effects section). Input is ignored if |
remliter |
Maximum number of iterations for REML estimation of variance components. Input is ignored if |
remltol |
Convergence tolerance for REML estimation of variance components. Input is ignored if |
remltau |
Initial estimate of variance parameters for REML estimation of variance components. Input is ignored if |
Details
See bigssa
and below example for more details.
Value
An object of class "makessa", which can be input to bigssa
.
Warning
When inputting a "makessa" class object into bigssa
, the formula input to bigssa
must be a nested version of the original formula input to makessa
. In other words, you cannot add any new effects after a "makessa" object has been created, but you can drop (remove) effects from the model.
Author(s)
Nathaniel E. Helwig <helwig@umn.edu>
References
Gu, C. (2013). Smoothing spline ANOVA models, 2nd edition. New York: Springer.
Helwig, N. E. (2013). Fast and stable smoothing spline analysis of variance models for large samples with applications to electroencephalography data analysis. Unpublished doctoral dissertation. University of Illinois at Urbana-Champaign.
Helwig, N. E. (2016). Efficient estimation of variance components in nonparametric mixed-effects models with large samples. Statistics and Computing, 26, 1319-1336.
Helwig, N. E. (2017). Regression with ordered predictors via ordinal smoothing splines. Frontiers in Applied Mathematics and Statistics, 3(15), 1-13.
Helwig, N. E. and Ma, P. (2015). Fast and stable multiple smoothing parameter selection in smoothing spline analysis of variance models with large samples. Journal of Computational and Graphical Statistics, 24, 715-732.
Helwig, N. E. and Ma, P. (2016). Smoothing spline ANOVA for super-large samples: Scalable computation via rounding parameters. Statistics and Its Interface, 9, 433-444.
Examples
########## EXAMPLE ##########
# function with two continuous predictors
set.seed(773)
myfun <- function(x1v,x2v){
sin(2*pi*x1v) + log(x2v+.1) + cos(pi*(x1v-x2v))
}
x1v <- runif(500)
x2v <- runif(500)
y <- myfun(x1v,x2v) + rnorm(500)
# fit 2 possible models (create information 2 separate times)
system.time({
intmod <- bigssa(y~x1v*x2v,type=list(x1v="cub",x2v="cub"),nknots=50)
addmod <- bigssa(y~x1v+x2v,type=list(x1v="cub",x2v="cub"),nknots=50)
})
# fit 2 possible models (create information 1 time)
system.time({
makemod <- makessa(y~x1v*x2v,type=list(x1v="cub",x2v="cub"),nknots=50)
int2mod <- bigssa(y~x1v*x2v,makemod)
add2mod <- bigssa(y~x1v+x2v,makemod)
})
# check difference (no difference)
crossprod( intmod$fitted.values - int2mod$fitted.values )
crossprod( addmod$fitted.values - add2mod$fitted.values )