Skip to content
Back to formatted view

Raw Message

Message-ID: <CAGsroM2O5yKg3Jyd+2Fs_+UX2F1yiviL2GSAmjGrzRSyoJeKCw@mail.gmail.com>
Date: 2016-05-21T19:00:31Z
From: george brida
Subject: Matrix multiplications

Dear R users:

I have written the following lines :

>x=c(10,11,12,13,14,17,15,16,10,11,41,25,26,14,12,14,15,20,14,22)
> x=matrix(x,ncol=2)
> a=matrix(1,nrow(x),1)
> X=cbind(a,x)
>y=c(12.00, 11.00, 13.00, 12.50, 14.00, 18.50, 15.00, 12.50, 13.75, 15.00)

>b=solve(t(X)%*% X)%*% t(X)%*% y

when I wrote the following line
>(t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X)))*solve(t(X)%*% X)
I have obtained an error message, I don't know why namely (t(y-X %*%
b)%*%(y-X %*% b)/(length(y)-ncol(X))) is a scalar:
> (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X)))
         [,1]
[1,] 3.620354


Can you please help me.

Thank you

George

	[[alternative HTML version deleted]]