简体   繁体   English

如何提取 p 值

[英]How to extract p-values

I've been trying for a while to regress between the first observation and the rest of the 199 observations of my data set.我一直在尝试在第一次观察和我的数据集的 199 次观察中的 rest 之间回归。 I used the lapply function and the regression result is stored as a list in the environment.我使用了 lapply function 并将回归结果作为列表存储在环境中。 My aim is to get only the list of p_values as a data frame and determine how many observations are less than 0.05.我的目标是仅获取 p_values 列表作为数据框,并确定有多少观察值小于 0.05。 Any help would be appreciated!任何帮助,将不胜感激!

## Here are the code I am using right now.
myre1 <- apply(2:ncol(muscle), function(x) lm(muscle[,1] ~ muscle[,x], data = muscle))
myre2 <- lapply(muscle[,-1], function(x) lm(muscle$GIR ~ x))

## To extract the coefficient
myre3 <- lapply(2:ncol(muscle), function(x) coefficients(lm(muscle[,1] ~ muscle[,x], data = muscle)))
myre4 <- lapply(muscle[,-1], function(x) coefficients(lm(muscle$GIR ~ x)))

Try this.尝试这个。 You'll get the coefficients along with the p.values您将获得系数以及 p.values

sum1 <- lapply(mre1, function(x) summary(x)$coefficients)
sum2 <- lapply(mre2, function(x) summary(x)$coefficients)

You may have to convert the sum1 and sum2 to data frame.您可能必须将 sum1 和 sum2 转换为数据框。

Edit:编辑:

To extract the p values alone单独提取 p 值

sum1 <- lapply(mre1, function(x) summary(x)$coefficients[10:12])
sum2 <- lapply(mre2, function(x) summary(x)$coefficients[7:8])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM