I think that is because X in your function has (n + 1) columns and D with
only n coluimns:

matrix(1:9, ncol = 3) + matrix(1:8, ncol = 2)

On Tue, Jul 7, 2009 at 2:30 PM, spime <saby...@gmail.com> wrote:

>
> 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.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to