predict.rncReg: make predictions from a "rncReg" object.

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/Rfunc.R

Description

The generic prediction function that makes predictions according an "rncReg" object, which is a regression model fitted with network cohesion.

Usage

1
2
## S3 method for class 'rncReg'
predict(object,full.X=NULL,full.A,...)

Arguments

object

An object returned by the function rncreg.

full.X

A matrix with first n rows being the original training covariates and the last m rows being the new test covariates. If not provided, covariates will not be used in prediction.

full.A

An adjacency matrix of the complete network with both training and test samples. The first n vertices are representing the training samples (in the original order) and the last m vertices are reprenting the test samples.

...

further arguments passed to or from other methods.

Details

The function first predicts individual effects on test sample by minimizing network cohesion penalty and then incorporates the covariate effects. For full details, please check the reference paper. The predicted test sample individual effects will be returned, as well as the corresponding linear terms. For linear regression model, the predicted response y is also given, which is exactly the same as the linear term. For logistic regression, the predicted probability is also given.

Value

A list with following slots:

terms

the linear term in the model.

alpha

the predicted individual effects.

y

the predicted responses in linear model.

p

the predicted probabilities in logistic regression.

model

the model used in prediction. This is the same as in object.

Author(s)

Tianxi Li, Elizaveta Levina, Ji Zhu
Maintainer: Tianxi Li tianxili@umich.edu

References

Tianxi Li, Elizaveta Levina and Ji Zhu. (2016) Regression with network cohesion, http://arxiv.org/pdf/1602.01192v1.pdf

See Also

rncreg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
set.seed(100)

A <- matrix(0,200,200)
A[1:100,1:100] <- 1
A[101:200,101:200] <- 1
diag(A) <- 0

alpha <- c(rep(1,100),rep(-1,100)) + rnorm(200)*0.5
A <- A[c(1:50,101:150,51:100,151:200),c(1:50,101:150,51:100,151:200)]
alpha <- alpha[c(1:50,101:150,51:100,151:200)]

beta <- rnorm(2)

X <- matrix(rnorm(400),ncol=2)

Y <- X

A1 <- A[1:100,1:100]
X1 <- X[1:100,]
Y1 <- matrix(Y[1:100],ncol=1)


## If one wants to regularize the Laplacian by 
## using gamma > 0 in rncreg, we suggest use 
## centered data.
#mean.x <- colMeans(X1)
#mean.y <- mean(Y1)
#Y1 <- Y1-mean.y
#X1 <- t(t(X1)-mean.x)
#Y <- Y-mean.y
#X <- t(t(X)-mean.x)



m <- rncreg(A=A1,X=X1,Y=Y1,model="linear",lambda=10,gamma=0,cv=5)

p <- predict(m,full.A=A,full.X=X)
  

netcoh documentation built on May 2, 2019, 8:19 a.m.