![](/img/trans.png)
[英]Getting confidence intervals for robust regression coefficient (MASS::rlm)
[英]Handling MASS: rlm error while fitting robust regression multiple times using MM-estimator
我有一個具有以下結構的數據框:
W01 0.750000 0.916667 0.642857 1.000000 0.619565
W02 0.880000 0.944444 0.500000 0.991228 0.675439
W03 0.729167 0.900000 0.444444 1.000000 0.611111
W04 0.809524 0.869565 0.500000 1.000000 0.709091
W05 0.625000 0.925926 0.653846 1.000000 0.589286
Variation 1_941119_A/G 1_942335_C/G 1_942451_T/C 1_942934_G/C \
W01 0.967391 0.965909 1 0.130435
W02 0.929825 0.937500 1 0.184211
W03 0.925926 0.880000 1 0.138889
W04 0.918182 0.907407 1 0.200000
W05 0.901786 0.858491 1 0.178571
Variation 1_944296_G/A ... X_155545046_C/T X_155774775_G/T \
W01 0.978261 ... 0.652174 0.641304
W02 0.938596 ... 0.728070 0.736842
W03 0.944444 ... 0.675926 0.685185
W04 0.927273 ... 0.800000 0.690909
W05 0.901786 ... 0.794643 0.705357
Variation Y_5100327_G/T Y_5100614_T/G Y_12786160_G/A Y_12914512_C/A \
W01 0.807692 0.800000 0.730769 0.807692
W02 0.655172 0.653846 0.551724 0.666667
W03 0.880000 0.909091 0.833333 0.916667
W04 0.666667 0.642857 0.580645 0.678571
W05 0.730769 0.720000 0.692308 0.720000
Variation Y_13470103_G/A Y_19705901_A/G Y_20587967_A/C mean_age
W01 0.807692 0.666667 0.333333 56.3
W02 0.678571 0.520000 0.250000 66.3
W03 0.916667 0.764706 0.291667 69.7
W04 0.666667 0.560000 0.322581 71.6
W05 0.703704 0.600000 0.346154 72.5
[5 rows x 67000 columns]
我正在嘗試使用MM-estimator擬合魯棒的回歸,並使用下面的代碼段收集擬合的摘要統計信息(p值和斜率):
> df %>% gather(snp, value, -mean_age) %>%
+ nest(-snp) %>%
+ mutate(model = map(data, ~rlm(mean_age ~ value, data = ., method="MM", psi=psi.bisquare, maxit=50)),
+ summary = map(model, glance)) %>%
+ dplyr::select(-data, -model) %>%
+ unnest(summary) -> linear_regression_results
但是,這會引發眾所周知的rlm奇異錯誤:
Error in rlm.default(x, y, weights, method = method, wt.method = wt.method, :
'x' is singular: singular fits are not implemented in 'rlm'
我想知道是否有關於如何解決此錯誤的建議?
有時是由於變量重復測量而導致此問題。 從上面的數據框1_942451_T/C
可以明顯看出,存在重復的值。 一個簡單而臨時的解決方案是抖動值:
jittered_DF <- data.frame(lapply(df, jitter))
要么
r_DF <- data.frame(lapply(df, rnorm))
如果jitter()
方法僅適用於具有重復值的列,而不適用於整個數據幀,則可能會更加精確。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.