[R] Questions of non-conformable arrays
arun
smartpink111 at yahoo.com
Sat Sep 7 19:24:46 CEST 2013
Hi,
sini<- sin(i)
is.vector(sini)
#[1] TRUE
lni<- log(i)
is.vector(lni)
#[1] TRUE
x<-cbind(int=1,sini,lni)
is.matrix(x)
#[1] TRUE
t(x)*x
#Error in t(x) * x : non-conformable arrays
t(x)%*%x
# int sini lni
#int 20.0000000 0.9982219 42.3356165
#sini 0.9982219 10.2971266 -0.1138875
#lni 42.3356165 -0.1138875 102.1647590
xxi<-solve(t(x)%*%x)
xxi
# int sini lni
#int 0.42542540 -0.04319182 -0.17633836
#sini -0.04319182 0.10150077 0.01801122
#lni -0.17633836 0.01801122 0.08288028
A.K.
Dear R-help,
I have new learner of R, I try to get an inverse matrix of (X'X), however it returen that my t(x)*x is non-conformable.
I try to figure out my mistake in code, However I failed.
This is my code, thank you for your help.
> i<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
> sini<-as.vector(sin(i))
> lni<-as.vector(log(i))
> x<-as.matrix(cbind(int=1,sini,lni))
> xxi<-solve(t(x)*x)
Error in t(x) * x : non-conformable arrays
More information about the R-help
mailing list