首页 文章

从许多线性模型创建自定义结果表[重复]

提问于
浏览
-1

这个问题与以下内容完全相同:

我在一个分析实验室工作,生成大量数据 . 我们进行模型拟合,并对模型系数(截距,a,b),r_squared和残差标准误差感兴趣 . 最多70个因变量(响应)的数量相当大 . 我想从mylms生成一个表,其中行是响应a到f和列所提到的模型参数 .

我无法使我在网上找到的解决方案适应我的情况:

解决方案的一部分肯定是汇总(mylms)存储参数的地方 .

以下是我想要找到解决方案的简化示例:

#To generate a dataset
x <- c(1:30)
x2 <- x*x
a <- x2
b <- jitter(a, factor=10)
c <- jitter(b, factor=30)
d <- jitter(c, factor=40)
e <- jitter(d, factor=50)
f <- jitter(e, factor=60)
z <- cbind(a,b,c,d,e,f)

# The matrix y are the responses of x
y <- as.matrix(z)

# Define the weights for the regression
w <- 1/x

# create linear models
mylms <- lm(y~x+x2, weights=w)

1 回答

  • 0

    你可以这样做:

    mylms$residuals
    

    或者获得残差的范围,例如:

    apply(mylms$residuals,2,range)
    

    或者获取分位数例如:

    apply(mylms$residuals,2,quantile,seq(0.1,0.9,by=0.1))
    

相关问题