Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/pred.response.R
Let x\in R^p denote the values of the p predictors. This function computes \widehat E(Y|X=x) using equation (8.1) of Cook, Forzani, and Rothman (2012).
1 | pred.response(fit, newx=NULL)
|
fit |
The object returned by |
newx |
A matrix with N rows and p columns where each row is an instance of x described above.
If this argument is unspecified, then the fitted values are returned, i.e,
|
See Cook, Forzani, and Rothman (2012) for more information.
A vector of response prediction with nrow(newx)
entries.
Adam J. Rothman
Cook, R. D., Forzani, L., and Rothman, A. J. (2012). Estimating sufficient reductions of the predictors in abundant high-dimensional regressions. Annals of Statistics 40(1), 353-384.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | set.seed(1)
n=25
p=50
d=1
true.G = matrix(rnorm(p*d), nrow=p, ncol=d)
y=rnorm(n)
fy = y
E=matrix(rnorm(n*p), nrow=n, ncol=p)
X=fy%*%t(true.G) + E
fit=fit.pfc(X=X, r=4, d=d, y=y, weight.type="diag")
fitted.values=pred.response(fit)
mean((y-fitted.values)^2)
plot(fitted.values, y)
n.new=100
y.new=rnorm(n.new)
fy.new=y.new
E.new=matrix(rnorm(n.new*p), nrow=n.new, ncol=p)
X.new = fy.new%*%t(true.G) + E.new
mean((y.new - pred.response(fit, newx=X.new))^2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.