t_X <- rbind( c(0.89, 0.46, 0.45, 0.56, 0.41, 0.44, 0.34, 0.74, 0.75, 0.48),
c(0.02, 0.09, 0.16, 0.09, 0.02, 0.17, 0.23, 0.11, 0.01, 0.15),
c(0.01, 0.24, 0.23, 0.09, 0.28, 0.14, 0.20, 0.01, 0.15, 0.06),
c(18.7, 31.3, 30.0, 20.0, 31.5, 22.0, 25.7, 18.7, 27.3, 18.3),
c(26.8, 33.4, 35.1, 25.7, 34.8, 28.0, 31.4, 26.8, 34.6, 22.8),
c(42.1, 45.7, 48.3, 39.3, 46.5, 38.5, 41.1, 37.8, 47.8, 32.8),
c(56.6, 49.3, 53.5, 46.6, 46.7, 46.7, 50.6, 50.6, 55.9, 43.4),
c(70.0, 53.8, 59.2, 56.5, 48.5, 54.1, 53.5, 65.0, 67.9, 49.6),
c(83.2, 55.3, 57.7, 57.8, 51.1, 53.6, 49.3, 72.3, 75.2, 51.1))
X <- as.data.frame(t(t_X))
colnames(X) <- c("c1", "c2", "c3", "A1", "A2", "A3", "A4", "A5", "A6")
X.labels <- X[,1:3]
X.training <- X[,4:9]
I am trying to build linear models of c1, c2, c3 form A1-A6. Unfortunately, I am getting the error:
Error in model.frame.default(formula = X.labels ~ X.training, drop.unused.levels = TRUE) :
invalid type (list) for variable 'X.labels'
when I do
xlm <- lm(X.labels ~ X.training)
Any ideas why?
You need to pass only one depended variable to lm. If you want models for each c you could do:
To get: