2017年5月26日金曜日

PGP and/or GPG


use gpg or gpg2 or gpg1 according to the environment.

Encrypt Files

$ gpg -r Euron -ea filename.txt # use public key and output ascii. use this option.

        or

$ gpg -c filename.txt # use symmetric and output binary

       or

$ gpg -ca filename.txt # use symmetric and output ascii

Manage Keys

export public  key.

$  gpg2 --output  <key_file_name> --armor  --export Euron

export secret key.

$  gpg2 --output  <key_file_name> --armor  --export-secret-keys  Euron

import

$ gpg2 --import  <key_file_name>

2017年5月25日木曜日

3 Value Stocks for Retirement

With the market at an all-time high, eight full years into what's been one of the longest bull markets in history, having a few value stocks in one's portfolio might just be more important than ever -- particularly for retirees. More specifically, Archer Daniels Midland (NYSE:ADM), Philips 66 (NYSE:PSX), and Warren Buffett's Berkshire Hathaway (NYSE:BRK-A) (NYSE:BRK-B) appear to be interesting choices.

Three of our Fools break down the details on these great picks to get retirees -- or any investor digging for value in today's sky-high stock market -- started today.

A stock price chart going up through time, superimposed over a digital stock price board
IMAGE SOURCE: GETTY IMAGES.

Turning agricultural products into gold
Sean O'Reilly (Archer Daniels Midland): My pick for the ideal value stock as part of a retirement portfolio, Archer Daniels Midland, has a great deal to offer any Foolish investor. It boasts a forward P/E ratio of just 15, and earnings per share are expected to grow to $3.37 on average by fiscal 2020, according to analysts polled by S&P Global Market Intelligence. The company is a bastion of value in a world where the forward P/E ratio of the S&P 500 index is 24.

Founded in 1898 as a milling company in Minneapolis, Archer Daniels Midland is an agricultural-products powerhouse. Today, it's a modern commodity operator, offering everything from oilseeds, corn, and rice for food manufacturing to ingredients for animal feed and cotton pulp for paper manufacturing. The company made a big move with its $3 billion acquisition of German natural-ingredients company Wild Flavors in 2014, pushing itself further into the increasingly important business of natural flavors, proteins, and health products.

The company is a prime example of sound financial management and execution. It generated $957 million of free cash flow in the 12 months ended March 31, up significantly from $593 million in fiscal 2016. In the company's Q1 earnings press release, CEO Juan Luciano touched on the reason for the improvement:

We are continuing to execute the long-term strategic plan that we launched in 2012, and we are seeing the results. We have strengthened our core, improving our cost positions and implementing measures to improve results where necessary. Our operational-excellence initiatives have delivered significant savings and efficiencies. And we continue to grow strategically by expanding into new geographies and increasing our capabilities in food, beverage, and feed. Those actions contributed to the improved results we saw in the first quarter despite muted margin environments in some businesses. The continued momentum in the execution of our plan gives us confidence that we will deliver sustainable value creation.
This is a rock-solid business sporting a low valuation compared with the rest of the market, all while it generates plenty of cash to do things like expand the business and maintain its healthy 3% dividend yield. For retired value investors, there's a lot to love.

A cheap dividend growth stock hiding in plain sight
Jason Hall (Phillips 66): Shares of Phillips 66 are trading a little above one-year lows, down more than 10% since the start of the year. At the same time, the company has seen its earnings fall sharply over the past couple of years, as refining margins have been squeezed by falling crude prices around the world. This situation has the company trading at more than 24 times the past year's earnings, a number that's not cheap by any stretch of the imagination.

But now's a bad time to evaluate Phillips 66 based on last year's earnings -- especially after the results the company posted to start the year. Not only was this a solid quarter for the company's refining business, which reported a near tripling of its profits year over year, but the midstream and chemicals segments also reported profit growth on both a GAAP and adjusted basis. All told, quarterly profit increased 40% year over year, and 267% sequentially. With the growth of its midstream and chemicals segments combining with an expected bounce-back in refinings, full-year profits are on track to come in well above last year's levels, and that makes Phillips 66 cheap, trading at 12 times projected 2017 earnings.

Furthermore, the company's management is relentlessly focused on using cash flow growth to fund regular dividend increases. The company just announced an 11% dividend raise, putting the yield at 3.6% at recent prices. Since 2012, the company has increased its dividend 350%.

Put it all together, and Phillips 66 is a dividend growth stock at a bargain price. That's ideal for retirement investors.

Trust the best in the world to help you beat the market
Steve Symington (Berkshire Hathaway): Normally I favor dividend-paying stocks for retired investors, so it might be a surprise that I'm arguing for Berkshire Hathaway as a compelling buy. As fellow Fool Matthew Frankel pointed out recently, though renowned value investor and Berkshire CEO Warren Buffett loves to pack his company's enviable portfolio full of generous dividend payers, he has famously shunned the prospect of his company paying a dividend. Instead, Buffett has consistently demonstrated his unrivaled ability to compound shareholder value by reinvesting in Berkshire's existing businesses, acquiring new businesses, or buying back Berkshire Hathaway shares. On the latter, Buffett has historically preferred to buy back shares only if Berkshire Hathaway stock falls below 1.2 times book value -- an exceedingly attractive price for a business of this caliber.

But at Berkshire's recent annual shareholder meeting, Buffett surprised investors by hinting that the company may consider initiating a dividend if it can't find a better way to put some of its roughly $80 billion in cash, cash equivalents, and Treasury bills to work. In addition, Berkshire is looking at whether to raise its acceptable buyback floor to a slightly higher but still attractive level. Either way, trying to find the best way to put all of Berkshire Hathaway's money to work is an enviable problem to have. And with Berkshire Hathaway stock currently trading at a reasonable 1.37 times book value as of this writing, I think retired investors would do well to pick up shares and trust Warren Buffett to extend his market-beating ways. 

2017年5月17日水曜日

2017MAY17 S&P500 forecast.




> as.xts(forecast(auto.arima(UC),h=10)$mean[1:10],as.Date(as.yearmon(seq(mondate(index(last(UC)))+1,by=1,length.out=10))))[(3-month(index(last(UC))) %% 3) + c(1,4,7)]  #arimaUC
               [,1]
2017-07-01 1070.704
2017-10-01 1067.531
2018-01-01 1065.085
> as.xts(forecast(auto.arima(PA),h=10)$mean[1:10],as.Date(as.yearmon(seq(mondate(index(last(PA)))+1,by=1,length.out=10))))[(3-month(index(last(PA))) %% 3) + c(1,4,7)]
               [,1]
2017-07-01 146533.6
2017-10-01 146980.6
2018-01-01 147405.9
> my_sp5(last(GDP) * 1.05**(2/4),146533.6,1070)
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
                GDP
2017-01-01 2471.923
> my_sp5(last(GDP) * 1.05**(3/4),146980.6,1067.531)
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
                GDP
2017-01-01 2557.749
> my_sp5(last(GDP) * 1.05**(4/4),147405.9,1065.085)
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
                GDP
2017-01-01 2642.108
> last(UC)
           UNDCONTSA
2017-04-01      1074
> kikan
[1] "1992-01-01::2017-03-31"

Please see below. The result is not same the previous post even with completely same parameters. This is caused by UNDCONSTA before April is also revised at this time and it has an impact on the underlying economic model.

> my_sp5(19767.59,147405.9,1117.029)
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
[1] 2537.074

2017年5月9日火曜日

2017MAY09 S&P500 Forecast



With the assumption that nominal GDP annual growth rate is 4.0%. Other data are calculated by auto regression.



> my_sp5(19383.72,146533.6,1102.529)    #2017Q3
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
[1] 2413.117
> my_sp5(19574.71,146980.6,1110.716)   #2017Q4
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
[1] 2476.287
> my_sp5(19767.59,147405.9,1117.029)   #2018Q1
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
[1] 2540.103


> as.xts(forecast(auto.arima(PA),h=10)$mean[1:10],as.Date(as.yearmon(seq(mondate(index(last(PA)))+1,by=1,length.out=10))))[(3-month(index(last(PA))) %% 3) + c(1,4,7)]
               [,1]
2017-07-01 146533.6
2017-10-01 146980.6
2018-01-01 147405.9
> as.xts(forecast(auto.arima(UC),h=10)$mean[1:10],as.Date(as.yearmon(seq(mondate(index(last(UC)))+1,by=1,length.out=10))))[(3-month(index(last(UC))) %% 3) + c(1,4,7)]
               [,1]
2017-07-01 1102.529
2017-10-01 1110.716
2018-01-01 1117.029

> as.numeric(last(GDP))*(1.04**(c(1,2,3,4)/c(4)))
[1] 19194.59 19383.72 19574.71 19767.59

2017年4月26日水曜日

Data - GDP, PAYEMS and UNDCONTSA for 2017Q3 and Q4.


> last(GDP)
               GDP
2016-10-01 18869.4
> last(GDP) *  1.024^(3/4)
                GDP
2017-07-01 19208.04
> last(GDP) *  1.024^(4/4)
                GDP
2017-10-01 19322.27
> as.xts(forecast(auto.arima(PA),h=10)$mean[1:10],as.Date(as.yearmon(seq(mondate(index(last(PA)))+1,by=1,length.out=10))))[(3-month(index(last(PA))) %% 3) + c(1,4,7)]
               [,1]
2017-07-01 146452.6
2017-10-01 146868.5
2018-01-01 147271.4
> as.xts(forecast(auto.arima(UC),h=10)$mean[1:10],as.Date(as.yearmon(seq(mondate(index(last(UC)))+1,by=1,length.out=10))))[(3-month(index(last(PA))) %% 3) + c(1,4,7)]
               [,1]
2017-07-01 1102.529
2017-10-01 1110.716
2018-01-01 1117.029

> my_sp5(19208.04,146452.6,1102.529)
[1] "m_m params! to.quarter w/ GDPC96"
[1] 1928.808
[1] "m_m params! apply.quarter w/ GDPC96"
[1] 1892.213
[1] "m_m params! apply.quarter - UC w/ GDPC96"
[1] 2067.087
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
[1] 2406.39

> my_sp5(19322.27,146868.5,1110.716)
[1] "m_m params! to.quarter w/ GDPC96"
[1] 1955.476
[1] "m_m params! apply.quarter w/ GDPC96"
[1] 1915.963
[1] "m_m params! apply.quarter - UC w/ GDPC96"
[1] 2104.267
[1] "m_m params! apply.quarter - UC w/ nominal GDP"
[1] 2465.982

the list of library for R 3.3


パッケージ (ライブラリ ‘/Users/<User_Name>/Library/R/3.3/library’ 中): 

assertthat                                               Easy pre and post assertions.
car                                                      Companion to Applied Regression
caret                                                    Classification and Regression Training
colorspace                                               Color Space Manipulation
DBI                                                      R Database Interface
dichromat                                                Color Schemes for Dichromats
digest                                                   Create Compact Hash Digests of R Objects
foreach                                                  Provides Foreach Looping Construct for R
forecast                                                 Forecasting Functions for Time Series and Linear Models
fracdiff                                                 Fractionally differenced ARIMA aka ARFIMA(p,d,q) models
ggplot2                                                  Create Elegant Data Visualisations Using the Grammar of Graphics
gtable                                                   Arrange 'Grobs' in Tables
iterators                                                Provides Iterator Construct for R
labeling                                                 Axis Labeling
lazyeval                                                 Lazy (Non-Standard) Evaluation
lme4                                                     Linear Mixed-Effects Models using 'Eigen' and S4
lmtest                                                   Testing Linear Regression Models
magrittr                                                 A Forward-Pipe Operator for R
MatrixModels                                             Modelling with Sparse And Dense Matrices
minqa                                                    Derivative-free optimization algorithms by quadratic approximation
ModelMetrics                                             Rapid Calculation of Model Metrics
mondate                                                  Keep track of dates in terms of months
munsell                                                  Utilities for Using Munsell Colours
nloptr                                                   R interface to NLopt
pbkrtest                                                 Parametric Bootstrap and Kenward Roger Based Methods for Mixed Model Comparison
plyr                                                     Tools for Splitting, Applying and Combining Data
quadprog                                                 Functions to solve Quadratic Programming Problems.
quantmod                                                 Quantitative Financial Modelling Framework
quantreg                                                 Quantile Regression
RColorBrewer                                             ColorBrewer Palettes
Rcpp                                                     Seamless R and C++ Integration
RcppArmadillo                                            'Rcpp' Integration for the 'Armadillo' Templated Linear Algebra Library
RcppEigen                                                'Rcpp' Integration for the 'Eigen' Templated Linear Algebra Library
reshape2                                                 Flexibly Reshape Data: A Reboot of the Reshape Package
RMySQL                                                   Database Interface and 'MySQL' Driver for R
sandwich                                                 Robust Covariance Matrix Estimators
scales                                                   Scale Functions for Visualization
SparseM                                                  Sparse Linear Algebra
stringi                                                  Character String Processing Facilities
stringr                                                  Simple, Consistent Wrappers for Common String Operations
strucchange                                              Testing, Monitoring, and Dating Structural Changes
tibble                                                   Simple Data Frames
timeDate                                                 Rmetrics - Chronological and Calendar Objects
tseries                                                  Time Series Analysis and Computational Finance
TTR                                                      Technical Trading Rules
urca                                                     Unit Root and Cointegration Tests for Time Series Data
vars                                                     VAR Modelling
xts                                                      eXtensible Time Series
zoo                                                      S3 Infrastructure for Regular and Irregular Time Series (Z's Ordered Observations)
 
 パッケージ (ライブラリ ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library’ 中): 

base                                                     The R Base Package
boot                                                     Bootstrap Functions (Originally by Angelo Canty for S)
class                                                    Functions for Classification
cluster                                                  "Finding Groups in Data": Cluster Analysis Extended Rousseeuw et al.
codetools                                                Code Analysis Tools for R
compiler                                                 The R Compiler Package
datasets                                                 The R Datasets Package
foreign                                                  Read Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, Weka, dBase, ...
graphics                                                 The R Graphics Package
grDevices                                                The R Graphics Devices and Support for Colours and Fonts
grid                                                     The Grid Graphics Package
KernSmooth                                               Functions for Kernel Smoothing Supporting Wand & Jones (1995)
lattice                                                  Trellis Graphics for R
MASS                                                     Support Functions and Datasets for Venables and Ripley's MASS
Matrix                                                   Sparse and Dense Matrix Classes and Methods
methods                                                  Formal Methods and Classes
mgcv                                                     Mixed GAM Computation Vehicle with GCV/AIC/REML Smoothness Estimation
nlme                                                     Linear and Nonlinear Mixed Effects Models
nnet                                                     Feed-Forward Neural Networks and Multinomial Log-Linear Models
parallel                                                 Support for Parallel computation in R
rpart                                                    Recursive Partitioning and Regression Trees
spatial                                                  Functions for Kriging and Point Pattern Analysis
splines                                                  Regression Spline Functions and Classes
stats                                                    The R Stats Package
stats4                                                   Statistical Functions using S4 Classes
survival                                                 Survival Analysis
tcltk                                                    Tcl/Tk Interface
tools                                                    Tools for Package Development
utils                                                    The R Utils Package

2017年3月24日金曜日

Calculate the first and the last day of any designated month.

Below will pick up the start and the end of next month where PA data ends.


as.Date(as.yearmon(mondate(index(last(PA)))+1))
[1] "2017-03-01"
as.Date(as.yearmon(mondate(index(last(PA)))+2))-1
[1] "2017-03-31"


thus the combination of them will output as below.


as.xts(forecast(auto.arima(PA),h=10)$mean[1:10],as.Date(seq(mondate(index(last(PA)))+1,by=1,length.out=10)))

               [,1]
2017-03-02 145989.9
2017-04-02 146182.0
      <SKIP>
2017-11-02 147361.8

2017-12-02 147513.5


pick up the first day and the last day of the month which is exactly 36 months after any given date.

> as.Date(as.yearmon((mondate(Sys.Date())+36)))
[1] "2020-03-01"


> as.Date(as.yearmon((mondate(Sys.Date())+36)))-1
[1] "2020-02-29"
>

do the same thing by ISOdate, however it's much more redundant.

> as.Date(ISOdate(yea(mondarte(.())SysDate+36),month(mondate(Sys.Date())+36),1))-1
[1] "2020-02-29"

2017年3月23日木曜日

mondate and Calculate date by months

mondate and Calculate date by months

When you have to generate date sequence from 2017 march and other 9 following months, you can do as below.

seq(as.Date("2017-03-01"),as.Date("2017-12-01"),by="months")

If you like to do it in an arithmetic way. use mondate. you also need as.Date to make the generated sequence to use as as.xts argument.

as.Date(seq(mondate("2017-03-01"), by=1, length.out=10)))

below will create xts format data with forecast by auto regression of PAYEMS from 2017 MAR. to DEC. Don't forget to put [1:10] at the end of the first argument.

as.xts(forecast(auto.arima(PA),h=10)$mean[1:10],as.Date(seq(mondate("2017-03-01"), by=1, length.out=10)))

see below for output.

[,1]
2017-03-01 145989.9
2017-04-01 146182.0
<SKIP>
2017-11-01 147361.8
2017-12-01 147513.5


Without index number [1:10], it will end as an error like below.

> as.xts(forecast(auto.arima(PA),h=10)$mean,as.Date(seq(mondate("2017-03-01"), by=1, length.out=10)))
Error in do.call(paste("as", dateFormat, sep = "."), list(as.numeric(time(x)),  :
  'what' must be a function or character string