CAPM.jensenAlpha没有使用Ubuntu

时间:2015-10-29 10:05:04

标签: r ubuntu centos rserve

我有相同的程序来安装我的R和我需要的软件包。但我有这种奇怪的行为,当我在R下面运行我的centOS 7脚本时,结果是正确的。但是当我在Ubuntu 14中运行相同的脚本时,我遇到了此错误,其中CAPM.jensenAlpha函数返回NaN。这些是每台计算机RserveUbuntulibrary(xts) library(PerformanceAnalytics) cleanSeries <- function (benchmarkSeries, timeSeries) { commonDates = merge(timeSeries, benchmarkSeries, all = FALSE) allSeriesDates = merge(timeSeries, commonDates[,2]) allSeriesDates[is.na(allSeriesDates)] <- 0 return( xts(allSeriesDates[,2], index(allSeriesDates)) ) } # input timeSeries = xts(inputClass1@values, inputClass1@dates) print('timeSeries') print(timeSeries) benchmarkSeries = xts(inputClass2@values, inputClass2@dates) print('benchmarkSeries') print(benchmarkSeries) riskFreeSeries = xts(inputClass3@values, inputClass3@dates) print('riskFreeSeries') print(riskFreeSeries) # amend dates of series (only dates from timeSeries are used) cleanedBenchmarkSeries = cleanSeries(benchmarkSeries, timeSeries) print('cleanedBenchmarkSeries') print(cleanedBenchmarkSeries) cleanedRiskFreeSeries = cleanSeries(riskFreeSeries, timeSeries) print('cleanedRiskFreeSeries') print(cleanedRiskFreeSeries) jensensAlpha = CAPM.jensenAlpha(timeSeries, cleanedBenchmarkSeries, cleanedRiskFreeSeries, method = "alternative") print('jensensAlpha') print(jensensAlpha) # output setClass("ResultClass", representation(value = "numeric")) traceback() resultClass <- new("ResultClass", value = as.numeric(jensensAlpha)) 的输出。我也粘贴了下面输出的版本。但我的关键点是:同一个脚本如何提供不同的输出?

R脚本

    valter@eniac:centos$ R

R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Rserve)
> Rserve(args = "--vanilla --RS-enable-control --RS-enable-remote");
Starting Rserve:
 /usr/lib/R/bin/R CMD /usr/local/lib/R/site-library/Rserve/libs//Rserve --vanilla --RS-enable-control --RS-enable-remote 


R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Rserv started in daemon mode.
> Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric


Package PerformanceAnalytics (1.4.3541) loaded.
Copyright (c) 2004-2014 Peter Carl and Brian G. Peterson, GPL-2 | GPL-3
http://r-forge.r-project.org/projects/returnanalytics/


Attaching package: ‘PerformanceAnalytics’

The following object is masked from ‘package:graphics’:

    legend

[1] "timeSeries"
                    [,1]
2006-03-29  4.099731e-03
2006-03-30  1.173501e-02
2006-03-31 -2.357880e-03
2006-04-03  9.040080e-03
...

[1] "benchmarkSeries"
                    [,1]
2006-03-29  2.514452e-03
2006-03-30  6.105668e-03
2006-03-31  9.068408e-03
2006-04-03  5.285038e-03
...

[1] "riskFreeSeries"
                   [,1]
2006-03-29 7.594521e-05
2006-03-30 7.663014e-05
2006-03-31 7.709589e-05
2006-04-03 2.314521e-04
...

[1] "cleanedBenchmarkSeries"
           benchmarkSeries
2006-03-29    2.514452e-03
2006-03-30    6.105668e-03
2006-03-31    9.068408e-03
2006-04-03    5.285038e-03
2006-04-04    4.359010e-03
...

[1] "cleanedRiskFreeSeries"
           benchmarkSeries
2006-03-29    7.594521e-05
2006-03-30    7.663014e-05
2006-03-31    7.709589e-05
2006-04-03    2.314521e-04
2006-04-04    7.720548e-05
...

[1] "jensensAlpha"
           benchmarkSeries
2006-03-29      0.03980130
2006-03-30      0.03980089
2006-03-31      0.03980062
2006-04-03      0.03970984
2006-04-04      0.03980056
...

No traceback available 

CentOS(记录器)

vagrant@vagrant-ubuntu-trusty-64:~$ R

R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Rserve)
> Rserve(args = "--vanilla --RS-enable-control --RS-enable-remote");
Starting Rserve:
 /usr/lib/R/bin/R CMD /usr/local/lib/R/site-library/Rserve/libs//Rserve --vanilla --RS-enable-control --RS-enable-remote 


R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Rserv started in daemon mode.
> Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric


Package PerformanceAnalytics (1.4.3541) loaded.
Copyright (c) 2004-2014 Peter Carl and Brian G. Peterson, GPL-2 | GPL-3
http://r-forge.r-project.org/projects/returnanalytics/


Attaching package: ‘PerformanceAnalytics’

The following object is masked from ‘package:graphics’:

    legend

[1] "timeSeries"
                    [,1]
2006-03-29  4.099731e-03
2006-03-30  1.173501e-02
2006-03-31 -2.357880e-03
2006-04-03  9.040080e-03
2006-04-04 -1.693213e-03
...

[1] "benchmarkSeries"
                    [,1]
2006-03-29  2.514452e-03
2006-03-30  6.105668e-03
2006-03-31  9.068408e-03
2006-04-03  5.285038e-03
2006-04-04  4.359010e-03
...

[1] "riskFreeSeries"
                   [,1]
2006-03-29 7.594521e-05
2006-03-30 7.663014e-05
2006-03-31 7.709589e-05
2006-04-03 2.314521e-04
2006-04-04 7.720548e-05
...

[1] "cleanedBenchmarkSeries"
           benchmarkSeries
2006-03-29    2.514452e-03
2006-03-30    6.105668e-03
2006-03-31    9.068408e-03
2006-04-03    5.285038e-03
2006-04-04    4.359010e-03
2006-04-05    3.705145e-03
...

[1] "cleanedRiskFreeSeries"
           benchmarkSeries
2006-03-29    7.594521e-05
2006-03-30    7.663014e-05
2006-03-31    7.709589e-05
2006-04-03    2.314521e-04
2006-04-04    7.720548e-05
...

[1] "jensensAlpha"
           benchmarkSeries
2006-03-29              NA
2006-03-30              NA
2006-03-31              NA
2006-04-03              NA
2006-04-04              NA

No traceback available 

Ubuntu(记录器)

return false

1 个答案:

答案 0 :(得分:0)

只是为了让你知道我的问题发生了什么。 问题是 TIMEZONE 。我不确切知道原因,但R或我们用于计算的某些软件包要求时区相同。

我位于德国(时区CET是+1 UTC),我正在设置我的虚拟机使用UTC,从而解决问题。哦,伙计,我很高兴能解决这个问题(连续3天就可以解决这个问题!)但现在一切都很好!非常感谢我的同事@Ralf提示!

其他相关问题:123。 我希望这可以帮助别人! :)