I find myself in a disadvantage, I am trying to calculate Mallows' Cp for different linear regressions (each regression has a different number of independent variables), but when I try to use the% package leaps()
sends me an error
Error in
colnames<-
(*tmp*
, value = c (as.character (1: 9), LETTERS) [1: NCOL (x)]): attempt to set 'colnames' on an object with less than two dimensions
I do not know how to correct it. Also, I do not know how to define variable variables X so that software R can calculate the coefficient Cp. I do not have an advanced knowledge of the software, I'm just learning to use the program.
data = read.table('clipboard')
names(data)
y=datos$V1
x1=datos$V2
x2=datos$V3
x3=datos$V4
x4=datos$V5
x5=x1*x2
x6=x1*x3
x7=x1^2
x8=x2^2
x9=x3^2
x10=x4^2
m.general=lm(y~x1+x2+x3+x3+x4+x5+x6+x7+x8+x9+x10)
summary(m.general)
best=regsubsets(y~x1+x2+x3+x3+x4+x5+x6+x7+x8+x9+x10,datos,nbest=3)
summary(best)
m.r1=lm(y~x5,datos)
summary(m.r1)
AIC(m.r1)
press(m.r1)
x=data$V6
y=data$V1
m.r1Cp=leaps(x,y,method=c("Cp","adjr2","rsq"))