masal: Recursive partitioning based masal

Description Usage Arguments Details Value References Examples

View source: R/masal.R

Description

Fit the regression function based on multivariate adaptive splines.

Usage

1
2
  masal(data, col = NULL, maxterm = 20, maxinteraction = 2,
                varhat = c(1, 1, 1), forced_num = NULL, maxiter = 2)

Arguments

data

a data.frame including one column of ID of the observations, covariates, time, and response.

col

a charater vector indicating each column in the data: c(covariate), i(ID), r(response), t(time). If NULL, column 1 of data should be the ID number, columns 2 to the third last from the end should be the covariates, the second last from the end should be time, and the response should be in the last column. The default is NULL.

maxterm

the maximum number of terms allowed in the model during the forward step. The default is 20.

maxinteraction

the maximum number of interactive predictors allowed in the model. The default is 2.

varhat

a vector of length three indicating whether any of the three random effects should be considered. A value of ‘1’ or ‘0’ indicates whether the corresponding term should be included or not. The default is c(1, 1, 1).

forced_num

the number of the covariates that a user wishes to force into the masal. The default is NULL.

maxiter

the maximum number of iterations between the surface estimation and covariance estimation. The default is 2.

Details

For cross-sectional data, function masal fits a nonparametric surface for a continuous response variable. For longitudinal data, masal provides a surface that depends on time and selected covariates, and their interactions are allowed. The regression surface is based on the multivariate adaptive splines.

The data should include the identification (ID) number that links possibly multiple observations from the same unit of observation, the covariates, the time of each observation, and the response variables. For categorical covariates, dummy variables should be created before input.

Value

fitted

the fitted fixed-effect function f.

masaled.values

the fitted values with the formula obtained by masal.

masaled.residuals

the residuals from masal.

sigma

a vector of 4 containing the estimated parameters related to the random effects.

cov_matrix

the estimated covariance matrix depending on sigma.

regression

an indicator for whether some of the three random effects in the model has been included. A value of ‘1’ means yes and ‘0’ otherwise.

call

the call by which this object is generated.

nsub

the number of subjects contained by input data.

nobs

the number of observations, i.e., the number of rows of data.

ntime

a vector that indicates the number of observations for each subject of data.

Mobs

the maximum number of ntime.

learning.data

the data that are actually used in masal. They are not necessarily the same as original data since some processing may be conducted.

References

Zhang, H. (1997) Multivariate adaptive splines for analysis of longitudinal data.

Zhang, H. and Singer, B. (1999) Recursive partitioning in the health sciences. Springer Verlag.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library("macs")
set.seed(123)
data <- data.frame(ID = sort(rep(1:100, 5)),
                    X1 = runif(500, min = 0, max = 1),
                    X2 = runif(500, min = 0, max = 2),
                    X3 = runif(500, min = 0, max = 4),
                    X4 = rnorm(500, mean = 0, sd = 1),
                    X5 = rnorm(500, mean = 0, sd = 2),
                    X6 = rnorm(500, mean = 0, sd = 3),
                    time = rep(1:5, 100),
                    Y = rnorm(500, mean = 40, sd = 10))
result <- masal(data, col = NULL, maxterm = 20, maxinteraction = 2,
 varhat = c(1, 1, 1), forced_num = NULL, maxiter = 2)
plot(result)
forecast(result)
summary(result)

macs documentation built on Oct. 9, 2019, 5:05 p.m.

Related to masal in macs...