1

我根据遗传信息预测身高。数据是来自每个生物体的数十万个数据点,但简化版本可能是:

    dput(df)
structure(list(ID = c("A", "B", "C", "D", "E"), 
height = c(2, 4, 6, 10, 12), 
gene1 = c(0.2, -0.3, -0.6, 0, -0.8), 
gene2 = c(0.4, -0.2, -0.4, 0.2, -0.6)), 
gene3 = c(-0.1, 0.1, 0.3, 0.5, 0.7)
row.names = c(NA, -5L), class = "data.frame")

我开始对对基因 1 进行逆回归感兴趣,因为我从中获得的残差值给出的结果与使用高度作为响应不同。所以回归是:

model1 <- lm(gene1 ~ height, data=df)

然后我从中获取残差值并在从数据框中删除gene1之后逐步进行(LARS包):

resid <- model1$residuals
resid <- as.data.frame(resid)
Stagewise <- lars(df, resid$resid, type="forward.stagewise", max.steps=2, use.Gram=FALSE)

完成此操作后,我有兴趣拟合模型,以便获得高度值(并运行测试集)。由于我使用的是逐步过程的残差值,因此我不确定如何获得它。

非常感谢您的帮助!

4

0 回答 0