Let's say I have a data matrix d
pc = prcomp(d)# pc1 and pc2 are the principal components pc1 = pc$rotation[,1] pc2 = pc$rotation[,2]Then this should fit the linear regression model right?
r = lm(y ~ pc1+pc2)But then I get this error :
Errormodel.frame.default(formula = y ~ pc1+pc2, drop.unused.levels = TRUE) : unequal dimensions('pc1')I guess there a packages out there who do this automatically, but this should work too?


雷达卡



京公网安备 11010802022788号







