0

I have a Df, the first column is phenotypic data and from the second to the last column is markers data. The rows are lines name.

pheno <- c(1450, 1700, 1300, 1333, 1545, 1755, 1100)
M1 <- c(0,2,0,0,0,0,2)
M2 <- c(2,2,2,2,0,0,2)
M3 <- c(0,0,0,0,0,2,0)
M4 <- c(0,0,2,2,2,2,0)
dd <- data.frame(pheno, M1, M2, M3, M4)

I want to run lm, so my code is:

fit <- lm(dd$pheno ~ ., data = dd) 

I think that this code computes a regression of pheno over all other columns, but the coefficients for M1(and all other columns) are not the same when running a regression individually for each column

fit2 <- lm(dd$pheno ~ dd$M1, data = dd)

Any idea of what i could be doing wrong? Thanks in advance

  • The coefficients should **NOT** be the same as you add and subtract terms from the model @Maximiliano Verocai you're not doing anything "wrong" other than perhaps a little extra work since you can type `fit <- lm(pheno ~ ., data = dd) ` – Chuck P Jun 16 '20 at 19:55
  • @BenBolker I dupe tagged with a post. Please edit if you find a better one. thanks – akrun Jun 16 '20 at 20:01
  • But the operation in both cases are the same, the only difference is that with fit all is done at a time and with fit2 I run lm one at a time. – Maximiliano Verocai Jun 16 '20 at 20:03

0 Answers0