cv.predict {cvDSA}R Documentation

Model Predictions

Description

'cv.predict' is used to calculate the predicted values of the given model for the covariate 'w'.

Usage

cv.predict(w, model, family='gaussian')

Arguments

w covariates matrix.
model a list description of the model, e.g., model=list(formula=, coef= ). $formula can be in two formats: a list of integer arrays or a character string. Please see Examples for detail.
family a description of the error distribution. Availible choices are 'gaussian' and 'binomial'.

Value

Note

See Also

cvMSM, cvGLM, cvDCY, check.ETA, create.obs.data

Examples

# Example 1. 
n<-2000;
w1<-runif(n); w2<-runif(n); w3<-runif(n); w4<-runif(n);
w<-cbind(w1,w2,w3,w4);

# Let E(Y|W)=-1+w1+w2+w1*w3;

model <- list(formula=list(c(1,0,0,0),c(0,1,0,0),c(1,0,1,0)), coef=c(-1, 1, 1, 1));
y.hat <- cv.predict(w, model)

# Or
model <- list(formula="w1+w2+w1:w3", coef=c(-1, 1, 1, 1));
y.hat <- cv.predict(w, model)

# Example 2.
# Let g(A|W) = logit^(-1) (-1 + w1 - w2 + w1*w3)
p.vec <- diag(4)
model.aw <- list(formula = list(p.vec[1,], p.vec[2,], p.vec[1,]+p.vec[3,]), 
                 coef = c(-1, 1, -5, 1))
y.hat <- cv.predict(w, model.aw, 'binomial')
# Or
model.aw <- list(formula = "w1+w2+w1:w3", coef = c(-1, 1, -5, 1))
y.hat <- cv.predict(w, model.aw, 'binomial')


[Package cvDSA version 0.5-3 Index]