【问题标题】:Handling MASS: rlm error while fitting robust regression multiple times using MM-estimator处理 MASS:rlm 错误,同时使用 MM 估计器多次拟合稳健回归
【发布时间】:2019-07-08 20:26:35
【问题描述】:

我有一个结构如下的数据框:

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 估计器拟合稳健的回归,并使用下面的 sn-p 收集拟合的汇总统计数据(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' 

我想知道是否有任何关于如何解决此错误的建议?

【问题讨论】:

  • 你搜索过吗?如果是这样,你应该总结你的努力并提供你发现的链接。
  • 我看到了这个 (stackoverflow.com/questions/32906388/…) 和其他建议删除缺失值或使用 unique 方法的线程。似乎都没有帮助!
  • 您没有提供我们可以参与的解决问题的方法。请注意,对类似问题的成功回复有足够的数据可供检查。
  • 我的数据框和我解释的一模一样!
  • 我没有看到任何描述。但是,如果有的话,您认为构建一个可能类似的可能需要多长时间?您为什么要负责任地我们的

标签: r regression linear-regression


【解决方案1】:

此问题有时是由于变量中的重复测量造成的。从上面的数据框中可以清楚地看出,1_942451_T/C 列存在重复值。这个问题的一个简单的ad hoc解决方案是抖动值:

jittered_DF <- data.frame(lapply(df, jitter))

r_DF <- data.frame(lapply(df, rnorm))

如果jitter() 方法只能应用于那些具有重复值的列,而不是整个数据框,也许会更精确。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-01
    • 2019-07-07
    • 2013-07-03
    • 1970-01-01
    • 2016-12-27
    • 2020-05-21
    • 1970-01-01
    • 2022-06-10
    相关资源
    最近更新 更多