[R] Error due to non-conformable arrays

spime sabya23 at gmail.com
Tue Jul 7 19:30:23 CEST 2009


Hello,

Consider this function for generalized ridge regression:

gre <- function (X,y,D){
	n <- dim(X)[1]
	p <- dim(X)[2]
	intercept <- rep(1, n) 
	X <- cbind(intercept, X)	 
	X2D <- crossprod(X,X)+ D
	Xy <- crossprod(X,y) 
	bth <- qr.solve(X2D, Xy) 
}

# suppose X is an (nxp) design matrix and y is an (nx1) response vector
p <- dim(x)[2]
D<- diag(rep(1.5,p)) 
bt <- gre(X,y,D)

I am getting following error:
Error in crossprod(X, X) + D : non-conformable arrays

But when  i define D within the function 'gre()' then everything is fine.
What wrong i have done?

thanks. 
-- 
View this message in context: http://www.nabble.com/Error-due-to-non-conformable-arrays-tp24377781p24377781.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list