简体   繁体   English

计算R错误中的SVD:缺失值或无限值

[英]Calculate SVD in R error: missing or infinite values

I have a similar problem with svd(XTR) 我有一个与svd(XTR) 类似的问题

the data is like: 数据如下:

1     0.3045  0.1448  -0.0714 -0.038  -0.0838 -0.1433 -0.1071 -0.1988 -0.1076 -0.0313 -0.157  -0.1032 -0.137  -0.0802 0.1244  0.0701  0.0457  -0.0634 0.0401 0.1643  0.3056  0.3956  0.4533  0.1557
0.3045  0.9999  0.3197  0.1328  0.093   -0.0846 -0.132  0.0046  -0.004  -0.0197 -0.1469 -0.1143 -0.2016 -0.1    -0.0316 0.0044  -0.0589 -0.0589 0.0277  0.0314  0.078   0.0104  0.0692  0.1858  0.0217
0.1448  0.3197  1       0.3487  0.2811  0.0786  -0.1421 -0.1326 -0.2056 -0.1109 0.0385  -0.1993 -0.1975 -0.1858 -0.1546 -0.0297 -0.0629 -0.0997 -0.0624 -0.0583 0.0316  0.0594  0.0941  0.0813  -0.1211
-0.0714 0.1328  0.3487  1       0.6033  0.2866  -0.246  -0.1201 -0.1975 -0.0929 -0.1071 -0.212  -0.3018 -0.3432 -0.2562 0.0277  -0.1363 -0.2218 -0.1443 -0.0322 -0.012  0.1741  -0.0725 -0.0528 -0.0937
-0.038  0.093   0.2811  0.6033  1       0.4613  0.016   0.0655  -0.1094 0.0026  -0.1152 -0.1692 -0.2047 -0.2508 -0.319  -0.0528 -0.1839 -0.2758 -0.2657 -0.1136 -0.0699 0.1433  -0.0136 -0.0409 -0.1538
-0.0838 -0.0846 0.0786  0.2866  0.4613  0.9999  0.2615  0.2449  0.1471  0.0042  -0.1496 -0.2025 -0.1669 -0.142  -0.1746 -0.1984 -0.2197 -0.2631 -0.2675 -0.1999 -0.1315 0.0469  0.0003  -0.1113 -0.1217
-0.1433 -0.132  -0.1421 -0.246  0.016   0.2615  1       0.3979  0.3108  0.1622 -0.0539 0.0231  0.1801  0.2129  0.1331  -0.1325 -0.0669 -0.0922 -0.1236 -0.1463 -0.1452 -0.2422 -0.0768 -0.1457 0.036
-0.1071 0.0046  -0.1326 -0.1201 0.0655  0.2449  0.3979  1       0.4244  0.3821 0.119   -0.0666 0.0163  0.0963  -0.0078 -0.1202 -0.204  -0.2257 -0.2569 -0.2334 -0.234  -0.2004 -0.138  -0.0735 -0.1442
-0.1988 -0.004  -0.2056 -0.1975 -0.1094 0.1471  0.3108  0.4244  0.9999  0.5459 0.0498  -0.052  0.0987  0.186   0.2576  -0.052  -0.1921 -0.2222 -0.1792 -0.0154 -0.058  -0.1868 -0.2232 -0.3118 0.0186
-0.1076 -0.0197 -0.1109 -0.0929 0.0026  0.0042  0.1622  0.3821  0.5459  0.9999 0.2416  0.0183  0.063   0.0252  0.186   0.0519  -0.1943 -0.2241 -0.2635 -0.0498 -0.0799 -0.0553 -0.1567 -0.2281 -0.0263
-0.0313 -0.1469 0.0385  -0.1071 -0.1152 -0.1496 -0.0539 0.119   0.0498  0.2416 1       0.2601  0.1625  -0.0091 -0.0633 0.0355  0.0397  -0.0288 -0.0768 -0.2144 -0.2581 0.1062  0.0469  -0.0608 -0.0578
-0.157  -0.1143 -0.1993 -0.212  -0.1692 -0.2025 0.0231  -0.0666 -0.052  0.0183 0.2601  0.9999  0.3685  0.3059  0.1269  -0.0302 0.1417  0.1678  0.2219  -0.0392 -0.2391 -0.2504 -0.2743 -0.1827 -0.0496
-0.1032 -0.2016 -0.1975 -0.3018 -0.2047 -0.1669 0.1801  0.0163  0.0987  0.063 0.1625  0.3685  1       0.6136  0.2301  -0.1158 0.0366  0.0965  0.1334  -0.0449 -0.1923 -0.2321 -0.1848 -0.1109 0.1007
-0.137  -0.1    -0.1858 -0.3432 -0.2508 -0.142  0.2129  0.0963  0.186   0.0252 -0.0091 0.3059  0.6136  1       0.4078  -0.0615 0.0607  0.1223  0.1379  0.0072 -0.1377 -0.3633 -0.2905 -0.1867 0.0277
-0.0802 -0.0316 -0.1546 -0.2562 -0.319  -0.1746 0.1331  -0.0078 0.2576  0.186 -0.0633 0.1269  0.2301  0.4078  1       0.0521  -0.0345 0.0444  0.0778  0.0925 0.0596  -0.2551 -0.1499 -0.2211 0.244
0.1244  0.0044  -0.0297 0.0277  -0.0528 -0.1984 -0.1325 -0.1202 -0.052  0.0519 0.0355  -0.0302 -0.1158 -0.0615 0.0521  1       0.295   0.2421  -0.06   0.0921 0.243   0.0953  0.0886  0.0518  -0.0032
0.0701  -0.0589 -0.0629 -0.1363 -0.1839 -0.2197 -0.0669 -0.204  -0.1921 -0.1943 0.0397  0.1417  0.0366  0.0607  -0.0345 0.295   0.9999  0.4832  0.2772  0.0012 0.1198  0.0411  0.1213  0.1409  0.0368
0.0457  -0.0589 -0.0997 -0.2218 -0.2758 -0.2631 -0.0922 -0.2257 -0.2222 -0.2241 -0.0288 0.1678  0.0965  0.1223  0.0444  0.2421  0.4832  1       0.2632  0.0576 0.0965  -0.0043 0.0818  0.102   0.0915
-0.0634 0.0277  -0.0624 -0.1443 -0.2657 -0.2675 -0.1236 -0.2569 -0.1792 -0.2635 -0.0768 0.2219  0.1334  0.1379  0.0778  -0.06   0.2772  0.2632  1       0.2036 -0.0452 -0.142  -0.0696 -0.0367 0.3039
0.0401  0.0314  -0.0583 -0.0322 -0.1136 -0.1999 -0.1463 -0.2334 -0.0154 -0.0498 -0.2144 -0.0392 -0.0449 0.0072  0.0925  0.0921  0.0012  0.0576  0.2036  0.9999 0.2198  0.1268  0.0294  0.0261  0.3231
0.1643  0.078   0.0316  -0.012  -0.0699 -0.1315 -0.1452 -0.234  -0.058  -0.0799 -0.2581 -0.2391 -0.1923 -0.1377 0.0596  0.243   0.1198  0.0965  -0.0452 0.2198 1       0.2667  0.2833  0.2467  0.0288
0.3056  0.0104  0.0594  0.1741  0.1433  0.0469  -0.2422 -0.2004 -0.1868 -0.0553 0.1062  -0.2504 -0.2321 -0.3633 -0.2551 0.0953  0.0411  -0.0043 -0.142  0.1268 0.2667  1       0.4872  0.3134  0.1663
0.3956  0.0692  0.0941  -0.0725 -0.0136 0.0003  -0.0768 -0.138  -0.2232 -0.1567 0.0469  -0.2743 -0.1848 -0.2905 -0.1499 0.0886  0.1213  0.0818  -0.0696 0.0294 0.2833  0.4872  0.9999  0.4208  0.1317
0.4533  0.1858  0.0813  -0.0528 -0.0409 -0.1113 -0.1457 -0.0735 -0.3118 -0.2281 -0.0608 -0.1827 -0.1109 -0.1867 -0.2211 0.0518  0.1409  0.102   -0.0367 0.0261 0.2467  0.3134  0.4208  1       0.0592
0.1557  0.0217  -0.1211 -0.0937 -0.1538 -0.1217 0.036   -0.1442 0.0186  -0.0263 -0.0578 -0.0496 0.1007  0.0277  0.244   -0.0032 0.0368  0.0915  0.3039  0.3231 0.0288  0.1663  0.1317  0.0592  0.9999

when applying svd I get: 申请svd时,我得到:

> s = svd(XTR)
> 
> Error in svd(XTR) : infinite or missing values in 'x'

following the answer int that post, they suggest doing: 按照该帖子的答案,他们建议:

> which(!is.finite(XTR))
V1 
 1 

Butwhat does V1 1 is supposed to mean??? 但是V1 1应该是什么意思?

Quoting the accepted answer your linked to: 引用您链接到的已接受答案:

This indicates that the second and third values are considered to be not finite. 这表明第二和第三值被认为不是有限的。

In your case, you seem to have a data frame rather than a matrix , so is.finite will be applied to columns, rather than elements and isn't going to tell you what you want to know. 在你的情况下,你似乎有一个数据框而不是一个矩阵 ,所以is.finite将应用于列,而不是元素,并不会告诉你你想知道什么。

Try: 尝试:

which(!is.finite(as.matrix(XTR)))

I suppose I should add that I have a sneaking suspicion that your data isn't stored the way you think it is. 我想我应该补充一点,我怀疑你的数据没有以你认为的方式存储。 The fact that which kicked back a result for only one column, V1 , seems to hint that XTR is actually a list of length one. 这样的事实which踢来踢去的结果只有一列, V1 ,似乎暗示XTR实际上是一个长的名单。 Are you sure that your matrix isn't actually the first element in the list called XTR ? 你确定你的矩阵实际上不是名为XTR列表中的第一个元素吗?

暂无
暂无

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

相关问题 R - svd()函数 - 'x'中的无限或缺失值 - R - svd() function - infinite or missing values in 'x' R 中的 PCA:svd(x,nu=0,nv=k)中的错误:“x”中的值无限或缺失 - PCA in R: Error in svd(x, nu=0, nv=k) : Infinite or missing values in 'x' R MASS软件包中的lm.ridge()说“ svd(X)中的错误:'x'中的值无穷或缺失” - lm.ridge() in R MASS package saying “Error in svd(X) : infinite or missing values in 'x'” R:采样:校准函数:svd(X)中的错误:“ x”中的值无穷或缺失 - R: Sampling: Calib function: Error in svd(X) : infinite or missing values in 'x' R中缺少值的SVD - SVD with missing values in R R Mclust - 获取svd错误'无限或缺失价值' - R Mclust - getting svd error 'infinite or missing value' svd(x, nu = 0, nv = k) 中的错误:“x”中的值无限或缺失。 矩阵中没有 NA 或 Inf 值 - Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x'. There are no NA or Inf values in matrix svd(x,nu = 0)中的错误:'x'中的值无限或缺失(检查是否存在负值) - Error in svd(x, nu = 0) : infinite or missing values in 'x' (checked no negative values exist) svd(X)中的错误:'x'中的值无穷或缺失。 在GAS中使用BacktestVaR时 - Error in svd(X) : infinite or missing values in 'x' . when using BacktestVaR in GAS 使用SVD计算R中的协方差矩阵时出错 - Error using SVD to calculate a covariance matrix in R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM