Re: [R] "prob" package alternative

2017-11-02 Thread Tiby Kantrowitz
That worked. Thank you, especially for that last one!

So, for others who might encounter this same situation:

1. Install RTools from here:
https://cran.r-project.org/bin/windows/Rtools/Rtools34.exe
Trying to install Rtools from inside RStudio will result in an "it's not
available for 3.4.2"  message.

2. Install the following dependencies: timeDate, timeSeries, fBasics,
fOptions

3. Download fAsianOptions from here:
https://cran.r-project.org/src/contrib/Archive/fAsianOptions/fAsianOptions_3010.79.tar.gz
and prob from here:
https://cran.r-project.org/src/contrib/Archive/prob/prob_1.0-0.tar.gz

4. Unzip each into its own directory.

5. Use this to install each, as appropriate:
install.packages("~/Downloads/fAsianOptions",
dependencies=TRUE, repos=NULL, type = "source")





On Thu, Nov 2, 2017 at 7:02 PM, David Winsemius 
wrote:

>
> > On Nov 2, 2017, at 3:46 PM, Tiby Kantrowitz  wrote:
> >
> > Thanks. I found that, and installed it and got the same message. Here:
> >
> > RTools version 3.4
> >
> > install.packages("fAsianOptions_3010.tar.gz",
>
> I don't see a path to that file's location.
>
> The expansion from pkg_version.tar.gz might be automatic, but I do
> generally expand such file into its own directory and then drag that
> directory icon into the console so my command would look like:
>
> install.packages("~/Downloads/fAsianOptions", dependencies=TRUE,
> repos=NULL, type = "source")
>
>
> I suggest you learn to post in plain text since your HTML postings are
> loosing their carriage returns.
>
> --
> David
>
>
>
>
> > dependencies=TRUE, repos=NULL, type = "source")
> > Installing package into ‘C:/Users/Tlk7/Documents/R/win-library/3.4’ (as
> ‘lib’ is unspecified) Warning: invalid package 'fAsianOptions_3010.tar.gz'
> Error: ERROR: no packages specified Warning in install.packages : running
> command '"C:/PROGRA~1/R/R-34~1.2/bin/x64/R" CMD INSTALL -l
> "C:\Users\Tlk7\Documents\R\win-library\3.4" "fAsianOptions_3010.tar.gz"'
> had status 1 Warning in install.packages : installation of package
> ‘fAsianOptions_3010.tar.gz’ had non-zero exit status
> >
> > On Thu, Nov 2, 2017 at 6:06 PM, David Winsemius 
> wrote:
> >
> > > On Nov 2, 2017, at 2:14 PM, Tiby Kantrowitz 
> wrote:
> > >
> > > Rtools is not available for the current version of R.
> >
> > Really? If true, I'm surprised and not able to help. I do see an
> Rtools34.exe at https://cran.r-project.org/bin/windows/Rtools/
> > --
> > David.
> >
> > >
> > > What I'm looking for is an alternative package or how others have
> managed to create workarounds.
> > >
> > > On Thu, Nov 2, 2017 at 4:25 PM, David Winsemius <
> dwinsem...@comcast.net> wrote:
> > >
> > > > On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz 
> wrote:
> > > >
> > > > Yes, that is exactly what I was doing two days ago.
> > > >
> > > > Warning in install.packages :
> > > >   installation of package ‘fAsianOptions_3010.79.tar.gz’ had
> non-zero exit status
> > > >
> > > > Which is what a reading of the explanation for why "prob" was
> retired leads one to expect. Do you have some other suggestion about how to
> get it to work? I notice you're not using Windows which might have a
> relationship to why it is working for you.
> > >
> > >
> > > I explained what you needed to do if you were on Windows. You do need
> to read the explanation more closely, identify the parts you don't
> understand (in all likelihood the point I made about needing the proper
> development tools for Windows) _and_ read:
> > >
> > > https://cran.r-project.org/doc/manuals/r-release/R-admin.
> html#Installing-packages
> > >
> > > If you have trouble understanding or getting success after thoroughly
> reading these directions, you need to explain what you have done
> (preserving the order of all operations) and post a complete transcript of
> all commands and complete error messages.
> > >
> > >
> > >
> > > --
> > > David.
> > > > Otherwise, do you know of some other package that could be used
> instead of prob?
> > > >
> > > > On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius <
> dwinsem...@comcast.net> wrote:
> > > >
> > > > > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz 
> wrote:
> > > > >
> > > > > Yes. That's the version I've been discussing that has non-zero
> exit status. That situation is why CRAN retired the prob package. It's
> possible you installed that library earlier in development and it's been
> "carried" along. It no longer installs, now.
> > > > >
> > > > > The problems with all of this seem to have started this month
> according to the conversations. However, no one has mentioned any solutions
> or workarounds except the one mentioned in passing (2.9).
> > > >
> > > > Not true. Not even close to being true. I explained it all on the SO
> question page that you posted 2 days ago.
> > > >
> > > > --
> > > >
> > > > David.
> > > > >
> > > > > Is there some other package that does something similar to prob
> that can be used instead?
> > > > >
> > > > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius <
> d

Re: [R] "prob" package alternative

2017-11-02 Thread David Winsemius

> On Nov 2, 2017, at 3:46 PM, Tiby Kantrowitz  wrote:
> 
> Thanks. I found that, and installed it and got the same message. Here:
> 
> RTools version 3.4 
> 
> install.packages("fAsianOptions_3010.tar.gz",

I don't see a path to that file's location.

The expansion from pkg_version.tar.gz might be automatic, but I do generally 
expand such file into its own directory and then drag that directory icon into 
the console so my command would look like:

install.packages("~/Downloads/fAsianOptions", dependencies=TRUE, repos=NULL, 
type = "source") 


I suggest you learn to post in plain text since your HTML postings are loosing 
their carriage returns.

-- 
David




> dependencies=TRUE, repos=NULL, type = "source") 
> Installing package into ‘C:/Users/Tlk7/Documents/R/win-library/3.4’ (as ‘lib’ 
> is unspecified) Warning: invalid package 'fAsianOptions_3010.tar.gz' Error: 
> ERROR: no packages specified Warning in install.packages : running command 
> '"C:/PROGRA~1/R/R-34~1.2/bin/x64/R" CMD INSTALL -l 
> "C:\Users\Tlk7\Documents\R\win-library\3.4" "fAsianOptions_3010.tar.gz"' had 
> status 1 Warning in install.packages : installation of package 
> ‘fAsianOptions_3010.tar.gz’ had non-zero exit status
> 
> On Thu, Nov 2, 2017 at 6:06 PM, David Winsemius  
> wrote:
> 
> > On Nov 2, 2017, at 2:14 PM, Tiby Kantrowitz  wrote:
> >
> > Rtools is not available for the current version of R.
> 
> Really? If true, I'm surprised and not able to help. I do see an Rtools34.exe 
> at https://cran.r-project.org/bin/windows/Rtools/
> --
> David.
> 
> >
> > What I'm looking for is an alternative package or how others have managed 
> > to create workarounds.
> >
> > On Thu, Nov 2, 2017 at 4:25 PM, David Winsemius  
> > wrote:
> >
> > > On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz  wrote:
> > >
> > > Yes, that is exactly what I was doing two days ago.
> > >
> > > Warning in install.packages :
> > >   installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero 
> > > exit status
> > >
> > > Which is what a reading of the explanation for why "prob" was retired 
> > > leads one to expect. Do you have some other suggestion about how to get 
> > > it to work? I notice you're not using Windows which might have a 
> > > relationship to why it is working for you.
> >
> >
> > I explained what you needed to do if you were on Windows. You do need to 
> > read the explanation more closely, identify the parts you don't understand 
> > (in all likelihood the point I made about needing the proper development 
> > tools for Windows) _and_ read:
> >
> > https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Installing-packages
> >
> > If you have trouble understanding or getting success after thoroughly 
> > reading these directions, you need to explain what you have done 
> > (preserving the order of all operations) and post a complete transcript of 
> > all commands and complete error messages.
> >
> >
> >
> > --
> > David.
> > > Otherwise, do you know of some other package that could be used instead 
> > > of prob?
> > >
> > > On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius  
> > > wrote:
> > >
> > > > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz  wrote:
> > > >
> > > > Yes. That's the version I've been discussing that has non-zero exit 
> > > > status. That situation is why CRAN retired the prob package. It's 
> > > > possible you installed that library earlier in development and it's 
> > > > been "carried" along. It no longer installs, now.
> > > >
> > > > The problems with all of this seem to have started this month according 
> > > > to the conversations. However, no one has mentioned any solutions or 
> > > > workarounds except the one mentioned in passing (2.9).
> > >
> > > Not true. Not even close to being true. I explained it all on the SO 
> > > question page that you posted 2 days ago.
> > >
> > > --
> > >
> > > David.
> > > >
> > > > Is there some other package that does something similar to prob that 
> > > > can be used instead?
> > > >
> > > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius 
> > > >  wrote:
> > > >
> > > > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz  
> > > > > wrote:
> > > > >
> > > > > The issue is fAsianOptions. Is there a version that works with the 
> > > > > latest version of R? If not, which version of it works with which 
> > > > > version of R and where can it be found? I tried several at the 
> > > > > archive already.
> > > >
> > > > sessionInfo()
> > > > R version 3.4.2 Patched (2017-10-04 r73465)
> > > > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> > > > Running under: OS X El Capitan 10.11.6
> > > >
> > > > >
> > > >
> > > >
> > > > packageDescription("fAsianOptions")
> > > > Package: fAsianOptions
> > > > Version: 3010.79
> > > > Revision: 5522
> > > > Date: 2013-06-23
> > > > Title: EBM and Asian Option Valuation
> > > > Author: Diethelm Wuertz and many others, see the SOURCE file
> > > > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
> > > > Suggests: RUnit
> >

Re: [R] "prob" package alternative

2017-11-02 Thread Tiby Kantrowitz
Thanks. I found that, and installed it and got the same message. Here:

RTools version 3.4

install.packages("fAsianOptions_3010.tar.gz", dependencies=TRUE,
repos=NULL, type = "source")
Installing package into ‘C:/Users/Tlk7/Documents/R/win-library/3.4’ (as
‘lib’ is unspecified) Warning: invalid package 'fAsianOptions_3010.tar.gz'
Error: ERROR: no packages specified Warning in install.packages : running
command '"C:/PROGRA~1/R/R-34~1.2/bin/x64/R" CMD INSTALL -l
"C:\Users\Tlk7\Documents\R\win-library\3.4" "fAsianOptions_3010.tar.gz"'
had status 1 Warning in install.packages : installation of package
‘fAsianOptions_3010.tar.gz’ had non-zero exit status

On Thu, Nov 2, 2017 at 6:06 PM, David Winsemius 
wrote:

>
> > On Nov 2, 2017, at 2:14 PM, Tiby Kantrowitz  wrote:
> >
> > Rtools is not available for the current version of R.
>
> Really? If true, I'm surprised and not able to help. I do see an
> Rtools34.exe at https://cran.r-project.org/bin/windows/Rtools/
> --
> David.
>
> >
> > What I'm looking for is an alternative package or how others have
> managed to create workarounds.
> >
> > On Thu, Nov 2, 2017 at 4:25 PM, David Winsemius 
> wrote:
> >
> > > On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz 
> wrote:
> > >
> > > Yes, that is exactly what I was doing two days ago.
> > >
> > > Warning in install.packages :
> > >   installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero
> exit status
> > >
> > > Which is what a reading of the explanation for why "prob" was retired
> leads one to expect. Do you have some other suggestion about how to get it
> to work? I notice you're not using Windows which might have a relationship
> to why it is working for you.
> >
> >
> > I explained what you needed to do if you were on Windows. You do need to
> read the explanation more closely, identify the parts you don't understand
> (in all likelihood the point I made about needing the proper development
> tools for Windows) _and_ read:
> >
> > https://cran.r-project.org/doc/manuals/r-release/R-admin.
> html#Installing-packages
> >
> > If you have trouble understanding or getting success after thoroughly
> reading these directions, you need to explain what you have done
> (preserving the order of all operations) and post a complete transcript of
> all commands and complete error messages.
> >
> >
> >
> > --
> > David.
> > > Otherwise, do you know of some other package that could be used
> instead of prob?
> > >
> > > On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius <
> dwinsem...@comcast.net> wrote:
> > >
> > > > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz 
> wrote:
> > > >
> > > > Yes. That's the version I've been discussing that has non-zero exit
> status. That situation is why CRAN retired the prob package. It's possible
> you installed that library earlier in development and it's been "carried"
> along. It no longer installs, now.
> > > >
> > > > The problems with all of this seem to have started this month
> according to the conversations. However, no one has mentioned any solutions
> or workarounds except the one mentioned in passing (2.9).
> > >
> > > Not true. Not even close to being true. I explained it all on the SO
> question page that you posted 2 days ago.
> > >
> > > --
> > >
> > > David.
> > > >
> > > > Is there some other package that does something similar to prob that
> can be used instead?
> > > >
> > > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius <
> dwinsem...@comcast.net> wrote:
> > > >
> > > > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz 
> wrote:
> > > > >
> > > > > The issue is fAsianOptions. Is there a version that works with the
> latest version of R? If not, which version of it works with which version
> of R and where can it be found? I tried several at the archive already.
> > > >
> > > > sessionInfo()
> > > > R version 3.4.2 Patched (2017-10-04 r73465)
> > > > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> > > > Running under: OS X El Capitan 10.11.6
> > > >
> > > > >
> > > >
> > > >
> > > > packageDescription("fAsianOptions")
> > > > Package: fAsianOptions
> > > > Version: 3010.79
> > > > Revision: 5522
> > > > Date: 2013-06-23
> > > > Title: EBM and Asian Option Valuation
> > > > Author: Diethelm Wuertz and many others, see the SOURCE file
> > > > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
> > > > Suggests: RUnit
> > > > Maintainer: Yohan Chalabi 
> > > > Description: Environment for teaching "Financial Engineering and
> Computational Finance"
> > > > Note: Several parts are still preliminary and may be changed in the
> future. this
> > > >   typically includes function and argument names, as well as
> defaults for
> > > >   arguments and return values.
> > > > LazyData: yes
> > > > License: GPL (>= 2)
> > > > URL: http://www.rmetrics.org
> > > > Packaged: 2013-06-23 18:22:14 UTC; yohan
> > > > NeedsCompilation: yes
> > > > Repository: CRAN
> > > > Date/Publication: 2013-06-24 01:53:27
> > > > Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-

Re: [R] "prob" package alternative

2017-11-02 Thread David Winsemius

> On Nov 2, 2017, at 2:14 PM, Tiby Kantrowitz  wrote:
> 
> Rtools is not available for the current version of R.

Really? If true, I'm surprised and not able to help. I do see an Rtools34.exe 
at https://cran.r-project.org/bin/windows/Rtools/
-- 
David.

> 
> What I'm looking for is an alternative package or how others have managed to 
> create workarounds.
> 
> On Thu, Nov 2, 2017 at 4:25 PM, David Winsemius  
> wrote:
> 
> > On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz  wrote:
> >
> > Yes, that is exactly what I was doing two days ago.
> >
> > Warning in install.packages :
> >   installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero exit 
> > status
> >
> > Which is what a reading of the explanation for why "prob" was retired leads 
> > one to expect. Do you have some other suggestion about how to get it to 
> > work? I notice you're not using Windows which might have a relationship to 
> > why it is working for you.
> 
> 
> I explained what you needed to do if you were on Windows. You do need to read 
> the explanation more closely, identify the parts you don't understand (in all 
> likelihood the point I made about needing the proper development tools for 
> Windows) _and_ read:
> 
> https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Installing-packages
> 
> If you have trouble understanding or getting success after thoroughly reading 
> these directions, you need to explain what you have done (preserving the 
> order of all operations) and post a complete transcript of all commands and 
> complete error messages.
> 
> 
> 
> --
> David.
> > Otherwise, do you know of some other package that could be used instead of 
> > prob?
> >
> > On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius  
> > wrote:
> >
> > > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz  wrote:
> > >
> > > Yes. That's the version I've been discussing that has non-zero exit 
> > > status. That situation is why CRAN retired the prob package. It's 
> > > possible you installed that library earlier in development and it's been 
> > > "carried" along. It no longer installs, now.
> > >
> > > The problems with all of this seem to have started this month according 
> > > to the conversations. However, no one has mentioned any solutions or 
> > > workarounds except the one mentioned in passing (2.9).
> >
> > Not true. Not even close to being true. I explained it all on the SO 
> > question page that you posted 2 days ago.
> >
> > --
> >
> > David.
> > >
> > > Is there some other package that does something similar to prob that can 
> > > be used instead?
> > >
> > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius  
> > > wrote:
> > >
> > > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz  wrote:
> > > >
> > > > The issue is fAsianOptions. Is there a version that works with the 
> > > > latest version of R? If not, which version of it works with which 
> > > > version of R and where can it be found? I tried several at the archive 
> > > > already.
> > >
> > > sessionInfo()
> > > R version 3.4.2 Patched (2017-10-04 r73465)
> > > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> > > Running under: OS X El Capitan 10.11.6
> > >
> > > >
> > >
> > >
> > > packageDescription("fAsianOptions")
> > > Package: fAsianOptions
> > > Version: 3010.79
> > > Revision: 5522
> > > Date: 2013-06-23
> > > Title: EBM and Asian Option Valuation
> > > Author: Diethelm Wuertz and many others, see the SOURCE file
> > > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
> > > Suggests: RUnit
> > > Maintainer: Yohan Chalabi 
> > > Description: Environment for teaching "Financial Engineering and 
> > > Computational Finance"
> > > Note: Several parts are still preliminary and may be changed in the 
> > > future. this
> > >   typically includes function and argument names, as well as 
> > > defaults for
> > >   arguments and return values.
> > > LazyData: yes
> > > License: GPL (>= 2)
> > > URL: http://www.rmetrics.org
> > > Packaged: 2013-06-23 18:22:14 UTC; yohan
> > > NeedsCompilation: yes
> > > Repository: CRAN
> > > Date/Publication: 2013-06-24 01:53:27
> > > Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix
> > >
> > >
> > >
> > > > Alternatively, is there another package that behaves similarly to prob?
> > > >
> > > >
> > > >
> > > > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius 
> > > >  wrote:
> > > >
> > > > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz  
> > > > > wrote:
> > > > >
> > > > > The prob package has been archived because it depends upon some other
> > > > > packages which have issues.
> > > > >
> > > > > However, such projects as Introduction to Probability and Statistics 
> > > > > in R
> > > > > depend upon it for learning. There are a few other resources that 
> > > > > also use
> > > > > it.
> > > > >
> > > > > Does anyone know of any workarounds?
> > > > >
> > > > > Someone at stack exchange mentioned using R 2.9.
> > > >
> > > > I'm not sure I would trust that person. They seem a 

Re: [R] "prob" package alternative

2017-11-02 Thread Tiby Kantrowitz
Rtools is not available for the current version of R.

What I'm looking for is an alternative package or how others have managed
to create workarounds.

On Thu, Nov 2, 2017 at 4:25 PM, David Winsemius 
wrote:

>
> > On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz  wrote:
> >
> > Yes, that is exactly what I was doing two days ago.
> >
> > Warning in install.packages :
> >   installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero
> exit status
> >
> > Which is what a reading of the explanation for why "prob" was retired
> leads one to expect. Do you have some other suggestion about how to get it
> to work? I notice you're not using Windows which might have a relationship
> to why it is working for you.
>
>
> I explained what you needed to do if you were on Windows. You do need to
> read the explanation more closely, identify the parts you don't understand
> (in all likelihood the point I made about needing the proper development
> tools for Windows) _and_ read:
>
> https://cran.r-project.org/doc/manuals/r-release/R-admin.
> html#Installing-packages
>
> If you have trouble understanding or getting success after thoroughly
> reading these directions, you need to explain what you have done
> (preserving the order of all operations) and post a complete transcript of
> all commands and complete error messages.
>
>
>
> --
> David.
> > Otherwise, do you know of some other package that could be used instead
> of prob?
> >
> > On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius 
> wrote:
> >
> > > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz 
> wrote:
> > >
> > > Yes. That's the version I've been discussing that has non-zero exit
> status. That situation is why CRAN retired the prob package. It's possible
> you installed that library earlier in development and it's been "carried"
> along. It no longer installs, now.
> > >
> > > The problems with all of this seem to have started this month
> according to the conversations. However, no one has mentioned any solutions
> or workarounds except the one mentioned in passing (2.9).
> >
> > Not true. Not even close to being true. I explained it all on the SO
> question page that you posted 2 days ago.
> >
> > --
> >
> > David.
> > >
> > > Is there some other package that does something similar to prob that
> can be used instead?
> > >
> > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius <
> dwinsem...@comcast.net> wrote:
> > >
> > > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz 
> wrote:
> > > >
> > > > The issue is fAsianOptions. Is there a version that works with the
> latest version of R? If not, which version of it works with which version
> of R and where can it be found? I tried several at the archive already.
> > >
> > > sessionInfo()
> > > R version 3.4.2 Patched (2017-10-04 r73465)
> > > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> > > Running under: OS X El Capitan 10.11.6
> > >
> > > >
> > >
> > >
> > > packageDescription("fAsianOptions")
> > > Package: fAsianOptions
> > > Version: 3010.79
> > > Revision: 5522
> > > Date: 2013-06-23
> > > Title: EBM and Asian Option Valuation
> > > Author: Diethelm Wuertz and many others, see the SOURCE file
> > > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
> > > Suggests: RUnit
> > > Maintainer: Yohan Chalabi 
> > > Description: Environment for teaching "Financial Engineering and
> Computational Finance"
> > > Note: Several parts are still preliminary and may be changed in the
> future. this
> > >   typically includes function and argument names, as well as
> defaults for
> > >   arguments and return values.
> > > LazyData: yes
> > > License: GPL (>= 2)
> > > URL: http://www.rmetrics.org
> > > Packaged: 2013-06-23 18:22:14 UTC; yohan
> > > NeedsCompilation: yes
> > > Repository: CRAN
> > > Date/Publication: 2013-06-24 01:53:27
> > > Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC;
> unix
> > >
> > >
> > >
> > > > Alternatively, is there another package that behaves similarly to
> prob?
> > > >
> > > >
> > > >
> > > > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius <
> dwinsem...@comcast.net> wrote:
> > > >
> > > > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz 
> wrote:
> > > > >
> > > > > The prob package has been archived because it depends upon some
> other
> > > > > packages which have issues.
> > > > >
> > > > > However, such projects as Introduction to Probability and
> Statistics in R
> > > > > depend upon it for learning. There are a few other resources that
> also use
> > > > > it.
> > > > >
> > > > > Does anyone know of any workarounds?
> > > > >
> > > > > Someone at stack exchange mentioned using R 2.9.
> > > >
> > > > I'm not sure I would trust that person. They seem a bit uninformed.
> > > >
> > > > > However, that broke my
> > > > > RStudio (WSOD) and the dependent packages still wouldn't install,
> anyway.
> > > >
> > > > The latest version of pkg-prob at the Archive directory of CRAN
> indicates that it was last updated within this year. The DESCRIPTION 

Re: [R] repeat a function

2017-11-02 Thread Eric.Pueyo
Hi Petr, 

Many thanks for your response.

Basically I want to create a probability matrix to be used in a trinomial tree 
going forward. This is the reason why I thought to build the matrix around 0 
would be much more efficient. I need to loop through because the probabilities 
will depend on my node and is not always the same per row (e.g. if N> jmax, 
jmax being defined in another function)
I found a workaround. Please see below. 
Thereafter I want to optimize this function. Hopefully it works.

Many thanks,
Eric

HWMProb <- function(N) {
  ProbUP<- function( a, j, dt) 1 / 6 + ((j ^ 2 * Mfactor(a, dt) ^ 2 + j * 
Mfactor(a, dt)) / 2)  # Probability X going up
  ProbMID<- function(a, j, dt) 2 / 3 - (j ^ 2 * Mfactor(a, dt) ^ 2) 
 Probability X going middle
  ProbDWN<-function( a, j, dt) 1 / 6 + ((j ^ 2 * Mfactor(a, dt) ^ 2 - j * 
Mfactor(a, dt)) / 2)  ###  Probability X going down
  TOPProbUP<- function( a, j, dt) 7 / 6 + (j ^ 2 * Mfactor(a, dt) ^ 2 + 3 * j * 
Mfactor(a, dt)) / 2 ### Top branch probability going up
  TOPProbMID<- function(a, j, dt) -1 / 3 - j ^ 2 * Mfactor(a, dt) ^ 2 - 2 * j * 
Mfactor(a, dt)  ### Top branch probability going MID
  TOPProbDWN<- function( a, j, dt) 1 / 6 + (j ^ 2 * Mfactor(a, dt) ^ 2 + j * 
Mfactor(a, dt)) / 2### Top branch probability going DOWN
  BTTMProbUP<- function( a, j, dt) 1 / 6 + (j ^ 2 * Mfactor(a, dt) ^ 2 - j * 
Mfactor(a, dt)) / 2### Bottom branch probability going u
  BTTMProbMID<- function( a, j, dt) -1 / 3 - j ^ 2 * Mfactor(a, dt) ^ 2 + 2 * j 
* Mfactor(a, dt)### Bottom branch probability going MID
  BTTMProbDWN<- function( a, j, dt) 7 / 6 + (j ^ 2 * Mfactor(a, dt) ^ 2 - 3 * j 
* Mfactor(a, dt)) / 2   ### Bottom branch probability going DOWN

if (N>jmax) N=jmax

for (j in 0:N) {
  if (j==0) {
prb["0","1"] <<- ProbUP(a,j,dt)
prb["0","0"] <<- ProbMID(a,j,dt)
prb["0","-1"] <<- ProbDWN(a,j,dt)
  }
  else {
if (j==jmax) {
  prb[paste(j,sep = ""),"1"] <<- TOPProbUP(a,j,dt)
  prb[paste(j,sep = ""),"0"] <<- TOPProbMID(a,j,dt)
  prb[paste(j,sep = ""),"-1"] <<- TOPProbDWN(a,j,dt)
  prb[paste(-j,sep = ""),"1"] <<- BTTMProbUP(a,-j,dt)
  prb[paste(-j,sep = ""),"0"] <<- BTTMProbMID(a,-j,dt)
  prb[paste(-j,sep = ""),"-1"] <<- BTTMProbDWN(a,-j,dt)
}
else {
  prb[paste(j,sep = ""),"1"] <<- ProbUP(a,j,dt)
  prb[paste(j,sep = ""),"0"] <<- ProbMID(a,j,dt)
  prb[paste(j,sep = ""),"-1"] <<- ProbDWN(a,j,dt)
  prb[paste(-j,sep = ""),"1"] <<- ProbUP(a,-j,dt)
  prb[paste(-j,sep = ""),"0"] <<- ProbMID(a,-j,dt)
  prb[paste(-j,sep = ""),"-1"] <<- ProbDWN(a,-j,dt)
} # Close 2nd IF
  } # Close 1st IF
} #end for
}


-Original Message-
From: PIKAL Petr [mailto:petr.pi...@precheza.cz] 
Sent: 02 November 2017 15:56
To: Eric Pueyo; r-help@r-project.org
Subject: RE: [R] repeat a function

Hi Eric

I did not see any answer and frankly speaking I cannot provide you with canned 
help.

AFAIK if a function is defined within another function (which is your case) it 
cannot be called directly so it is necessary to define it in global environment.

>  fff <- function(x) {
+  myf <- function(a) a+2
+  myf(x)^2}
>
> fff(5)
[1] 49
> myf(5)
Error in myf(5) : could not find function "myf"
>

Your function set is quite complicated but I wonder why would it be necessary 
to use for cycle for what seems to be simple table. Everything seems quite 
deterministic.

Basically you have combination of rows (-2,-1,0,1,2) and columns -1,-,1.
expand.grid(u=-2:2, v=-1:1)
for each row you can than use one function with parameters u, v and a and dt.
After you calculate vector of results, you can easily transform it to matrix by 
setting dim argument to it.

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of 
> eric.pu...@avivainvestors.com
> Sent: Wednesday, November 1, 2017 1:31 PM
> To: r-help@r-project.org
> Subject: [R] repeat a function
>
> I want to populate the matrix prb through the function HWMProb <- 
> function
> (a,j,dt) that encapsulates different functions (please see code 
> below), using j=
> 0:2 for each j.
>
> It only populates prb if I specify each function independently in the 
> global environment and then run the loop with the iF statement, as per below.
> for (j in 0:2) {
>   if (j==0) {
> prb["0","1"] <- ProbUP(a,j,dt)
> prb["0","0"] <- ProbMID(a,j,dt)
> prb["0","-1"] <- ProbDWN(a,j,dt)
>   }
>   else {
> if (j==jmax) {
>   prb[paste(j,sep = ""),"1"] <- TOPProbUP(a,j,dt)
>   prb[paste(j,sep = ""),"0"] <- TOPProbMID(a,j,dt)
>   prb[paste(j,sep = ""),"-1"] <- TOPProbDWN(a,j,dt)
>   prb[paste(-j,sep = ""),"1"] <- BTTMProbUP(a,-j,dt)
>   prb[paste(-j,sep = ""),"0"] <- BTTMProbMID(a,-j,dt)
>   prb[paste(-j,sep = ""),"-1"] <- BTTMProbDWN(a,-j,dt)
> }
> else {
>   prb[paste(j,sep =

Re: [R] "prob" package alternative

2017-11-02 Thread David Winsemius

> On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz  wrote:
> 
> Yes, that is exactly what I was doing two days ago.
> 
> Warning in install.packages :
>   installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero exit 
> status
> 
> Which is what a reading of the explanation for why "prob" was retired leads 
> one to expect. Do you have some other suggestion about how to get it to work? 
> I notice you're not using Windows which might have a relationship to why it 
> is working for you.


I explained what you needed to do if you were on Windows. You do need to read 
the explanation more closely, identify the parts you don't understand (in all 
likelihood the point I made about needing the proper development tools for 
Windows) _and_ read:

https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Installing-packages

If you have trouble understanding or getting success after thoroughly reading 
these directions, you need to explain what you have done (preserving the order 
of all operations) and post a complete transcript of all commands and complete 
error messages.



-- 
David.
> Otherwise, do you know of some other package that could be used instead of 
> prob?
> 
> On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius  
> wrote:
> 
> > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz  wrote:
> >
> > Yes. That's the version I've been discussing that has non-zero exit status. 
> > That situation is why CRAN retired the prob package. It's possible you 
> > installed that library earlier in development and it's been "carried" 
> > along. It no longer installs, now.
> >
> > The problems with all of this seem to have started this month according to 
> > the conversations. However, no one has mentioned any solutions or 
> > workarounds except the one mentioned in passing (2.9).
> 
> Not true. Not even close to being true. I explained it all on the SO question 
> page that you posted 2 days ago.
> 
> --
> 
> David.
> >
> > Is there some other package that does something similar to prob that can be 
> > used instead?
> >
> > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius  
> > wrote:
> >
> > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz  wrote:
> > >
> > > The issue is fAsianOptions. Is there a version that works with the latest 
> > > version of R? If not, which version of it works with which version of R 
> > > and where can it be found? I tried several at the archive already.
> >
> > sessionInfo()
> > R version 3.4.2 Patched (2017-10-04 r73465)
> > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> > Running under: OS X El Capitan 10.11.6
> >
> > >
> >
> >
> > packageDescription("fAsianOptions")
> > Package: fAsianOptions
> > Version: 3010.79
> > Revision: 5522
> > Date: 2013-06-23
> > Title: EBM and Asian Option Valuation
> > Author: Diethelm Wuertz and many others, see the SOURCE file
> > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
> > Suggests: RUnit
> > Maintainer: Yohan Chalabi 
> > Description: Environment for teaching "Financial Engineering and 
> > Computational Finance"
> > Note: Several parts are still preliminary and may be changed in the future. 
> > this
> >   typically includes function and argument names, as well as 
> > defaults for
> >   arguments and return values.
> > LazyData: yes
> > License: GPL (>= 2)
> > URL: http://www.rmetrics.org
> > Packaged: 2013-06-23 18:22:14 UTC; yohan
> > NeedsCompilation: yes
> > Repository: CRAN
> > Date/Publication: 2013-06-24 01:53:27
> > Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix
> >
> >
> >
> > > Alternatively, is there another package that behaves similarly to prob?
> > >
> > >
> > >
> > > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius  
> > > wrote:
> > >
> > > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz  wrote:
> > > >
> > > > The prob package has been archived because it depends upon some other
> > > > packages which have issues.
> > > >
> > > > However, such projects as Introduction to Probability and Statistics in 
> > > > R
> > > > depend upon it for learning. There are a few other resources that also 
> > > > use
> > > > it.
> > > >
> > > > Does anyone know of any workarounds?
> > > >
> > > > Someone at stack exchange mentioned using R 2.9.
> > >
> > > I'm not sure I would trust that person. They seem a bit uninformed.
> > >
> > > > However, that broke my
> > > > RStudio (WSOD) and the dependent packages still wouldn't install, 
> > > > anyway.
> > >
> > > The latest version of pkg-prob at the Archive directory of CRAN indicates 
> > > that it was last updated within this year. The DESCRIPTION file indicates 
> > > that it does not need compilation, but:
> > >
> > > Depends: combinat, fAsianOptions
> > >
> > > So there should be code in text files in its ../R directory which can be 
> > > sourced from that directory.
> > >
> > > ~myuser_name$ ls /Users/../Downloads/prob/R
> > > characteristicfunctions.r   simulation.r
> > > utils-spaces.r
> > > genData.R 

Re: [R] "prob" package alternative

2017-11-02 Thread Tiby Kantrowitz
Yes, that is exactly what I was doing two days ago.

Warning in install.packages :
  installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero exit
status

Which is what a reading of the explanation for why "prob" was retired leads
one to expect. Do you have some other suggestion about how to get it to
work? I notice you're not using Windows which might have a relationship to
why it is working for you.

Otherwise, do you know of some other package that could be used instead of
prob?

On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius 
wrote:

>
> > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz  wrote:
> >
> > Yes. That's the version I've been discussing that has non-zero exit
> status. That situation is why CRAN retired the prob package. It's possible
> you installed that library earlier in development and it's been "carried"
> along. It no longer installs, now.
> >
> > The problems with all of this seem to have started this month according
> to the conversations. However, no one has mentioned any solutions or
> workarounds except the one mentioned in passing (2.9).
>
> Not true. Not even close to being true. I explained it all on the SO
> question page that you posted 2 days ago.
>
> --
>
> David.
> >
> > Is there some other package that does something similar to prob that can
> be used instead?
> >
> > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius 
> wrote:
> >
> > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz 
> wrote:
> > >
> > > The issue is fAsianOptions. Is there a version that works with the
> latest version of R? If not, which version of it works with which version
> of R and where can it be found? I tried several at the archive already.
> >
> > sessionInfo()
> > R version 3.4.2 Patched (2017-10-04 r73465)
> > Platform: x86_64-apple-darwin15.6.0 (64-bit)
> > Running under: OS X El Capitan 10.11.6
> >
> > >
> >
> >
> > packageDescription("fAsianOptions")
> > Package: fAsianOptions
> > Version: 3010.79
> > Revision: 5522
> > Date: 2013-06-23
> > Title: EBM and Asian Option Valuation
> > Author: Diethelm Wuertz and many others, see the SOURCE file
> > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
> > Suggests: RUnit
> > Maintainer: Yohan Chalabi 
> > Description: Environment for teaching "Financial Engineering and
> Computational Finance"
> > Note: Several parts are still preliminary and may be changed in the
> future. this
> >   typically includes function and argument names, as well as
> defaults for
> >   arguments and return values.
> > LazyData: yes
> > License: GPL (>= 2)
> > URL: http://www.rmetrics.org
> > Packaged: 2013-06-23 18:22:14 UTC; yohan
> > NeedsCompilation: yes
> > Repository: CRAN
> > Date/Publication: 2013-06-24 01:53:27
> > Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix
> >
> >
> >
> > > Alternatively, is there another package that behaves similarly to prob?
> > >
> > >
> > >
> > > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius <
> dwinsem...@comcast.net> wrote:
> > >
> > > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz 
> wrote:
> > > >
> > > > The prob package has been archived because it depends upon some other
> > > > packages which have issues.
> > > >
> > > > However, such projects as Introduction to Probability and Statistics
> in R
> > > > depend upon it for learning. There are a few other resources that
> also use
> > > > it.
> > > >
> > > > Does anyone know of any workarounds?
> > > >
> > > > Someone at stack exchange mentioned using R 2.9.
> > >
> > > I'm not sure I would trust that person. They seem a bit uninformed.
> > >
> > > > However, that broke my
> > > > RStudio (WSOD) and the dependent packages still wouldn't install,
> anyway.
> > >
> > > The latest version of pkg-prob at the Archive directory of CRAN
> indicates that it was last updated within this year. The DESCRIPTION file
> indicates that it does not need compilation, but:
> > >
> > > Depends: combinat, fAsianOptions
> > >
> > > So there should be code in text files in its ../R directory which can
> be sourced from that directory.
> > >
> > > ~myuser_name$ ls /Users/../Downloads/prob/R
> > > characteristicfunctions.r   simulation.r
> utils-spaces.r
> > > genData.R   spaces-examples.r
>  utils-subsets.r
> > > misc.r  spaces-prob.r
> > > prob.r  utils-events.r
> > >
> > >
> > > Or you can install from source after downloading:
> > >
> > > install.packages("~/Downloads/prob", repo=NULL,type="source")
> > >
> > > # Success
> > >
> > >
> > > >  library(prob)   # So does require having several other packages
> > > Loading required package: combinat
> > >
> > > Attaching package: ‘combinat’
> > >
> > > The following object is masked from ‘package:utils’:
> > >
> > > combn
> > >
> > > Loading required package: fAsianOptions
> > > Loading required package: timeDate
> > >
> > > Attaching package: ‘timeDate’
> > >
> > > The following object is masked from ‘package:cairoDev

Re: [R] "prob" package alternative

2017-11-02 Thread David Winsemius

> On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz  wrote:
> 
> Yes. That's the version I've been discussing that has non-zero exit status. 
> That situation is why CRAN retired the prob package. It's possible you 
> installed that library earlier in development and it's been "carried" along. 
> It no longer installs, now.
> 
> The problems with all of this seem to have started this month according to 
> the conversations. However, no one has mentioned any solutions or workarounds 
> except the one mentioned in passing (2.9).

Not true. Not even close to being true. I explained it all on the SO question 
page that you posted 2 days ago.

-- 

David.
> 
> Is there some other package that does something similar to prob that can be 
> used instead?
> 
> On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius  
> wrote:
> 
> > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz  wrote:
> >
> > The issue is fAsianOptions. Is there a version that works with the latest 
> > version of R? If not, which version of it works with which version of R and 
> > where can it be found? I tried several at the archive already.
> 
> sessionInfo()
> R version 3.4.2 Patched (2017-10-04 r73465)
> Platform: x86_64-apple-darwin15.6.0 (64-bit)
> Running under: OS X El Capitan 10.11.6
> 
> >
> 
> 
> packageDescription("fAsianOptions")
> Package: fAsianOptions
> Version: 3010.79
> Revision: 5522
> Date: 2013-06-23
> Title: EBM and Asian Option Valuation
> Author: Diethelm Wuertz and many others, see the SOURCE file
> Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
> Suggests: RUnit
> Maintainer: Yohan Chalabi 
> Description: Environment for teaching "Financial Engineering and 
> Computational Finance"
> Note: Several parts are still preliminary and may be changed in the future. 
> this
>   typically includes function and argument names, as well as defaults 
> for
>   arguments and return values.
> LazyData: yes
> License: GPL (>= 2)
> URL: http://www.rmetrics.org
> Packaged: 2013-06-23 18:22:14 UTC; yohan
> NeedsCompilation: yes
> Repository: CRAN
> Date/Publication: 2013-06-24 01:53:27
> Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix
> 
> 
> 
> > Alternatively, is there another package that behaves similarly to prob?
> >
> >
> >
> > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius  
> > wrote:
> >
> > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz  wrote:
> > >
> > > The prob package has been archived because it depends upon some other
> > > packages which have issues.
> > >
> > > However, such projects as Introduction to Probability and Statistics in R
> > > depend upon it for learning. There are a few other resources that also use
> > > it.
> > >
> > > Does anyone know of any workarounds?
> > >
> > > Someone at stack exchange mentioned using R 2.9.
> >
> > I'm not sure I would trust that person. They seem a bit uninformed.
> >
> > > However, that broke my
> > > RStudio (WSOD) and the dependent packages still wouldn't install, anyway.
> >
> > The latest version of pkg-prob at the Archive directory of CRAN indicates 
> > that it was last updated within this year. The DESCRIPTION file indicates 
> > that it does not need compilation, but:
> >
> > Depends: combinat, fAsianOptions
> >
> > So there should be code in text files in its ../R directory which can be 
> > sourced from that directory.
> >
> > ~myuser_name$ ls /Users/../Downloads/prob/R
> > characteristicfunctions.r   simulation.r
> > utils-spaces.r
> > genData.R   spaces-examples.r   
> > utils-subsets.r
> > misc.r  spaces-prob.r
> > prob.r  utils-events.r
> >
> >
> > Or you can install from source after downloading:
> >
> > install.packages("~/Downloads/prob", repo=NULL,type="source")
> >
> > # Success
> >
> >
> > >  library(prob)   # So does require having several other packages
> > Loading required package: combinat
> >
> > Attaching package: ‘combinat’
> >
> > The following object is masked from ‘package:utils’:
> >
> > combn
> >
> > Loading required package: fAsianOptions
> > Loading required package: timeDate
> >
> > Attaching package: ‘timeDate’
> >
> > The following object is masked from ‘package:cairoDevice’:
> >
> > Cairo
> >
> > The following objects are masked from ‘package:PerformanceAnalytics’:
> >
> > kurtosis, skewness
> >
> > Loading required package: timeSeries
> >
> > Attaching package: ‘timeSeries’
> >
> > The following object is masked from ‘package:zoo’:
> >
> > time<-
> >
> > Loading required package: fBasics
> >
> >
> > Rmetrics Package fBasics
> > Analysing Markets and calculating Basic Statistics
> > Copyright (C) 2005-2014 Rmetrics Association Zurich
> > Educational Software for Financial Engineering and Computational Science
> > Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
> > https://www.rmetrics.org --- Mail to: i...@rmetrics.org
> > Loading required package: fOptions
> >

Re: [R] "prob" package alternative

2017-11-02 Thread Tiby Kantrowitz
Yes. That's the version I've been discussing that has non-zero exit status.
That situation is why CRAN retired the prob package. It's possible you
installed that library earlier in development and it's been "carried"
along. It no longer installs, now.

The problems with all of this seem to have started this month according to
the conversations. However, no one has mentioned any solutions or
workarounds except the one mentioned in passing (2.9).

Is there some other package that does something similar to prob that can be
used instead?

On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius 
wrote:

>
> > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz  wrote:
> >
> > The issue is fAsianOptions. Is there a version that works with the
> latest version of R? If not, which version of it works with which version
> of R and where can it be found? I tried several at the archive already.
>
> sessionInfo()
> R version 3.4.2 Patched (2017-10-04 r73465)
> Platform: x86_64-apple-darwin15.6.0 (64-bit)
> Running under: OS X El Capitan 10.11.6
>
> >
>
>
> packageDescription("fAsianOptions")
> Package: fAsianOptions
> Version: 3010.79
> Revision: 5522
> Date: 2013-06-23
> Title: EBM and Asian Option Valuation
> Author: Diethelm Wuertz and many others, see the SOURCE file
> Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
> Suggests: RUnit
> Maintainer: Yohan Chalabi 
> Description: Environment for teaching "Financial Engineering and
> Computational Finance"
> Note: Several parts are still preliminary and may be changed in the
> future. this
>   typically includes function and argument names, as well as
> defaults for
>   arguments and return values.
> LazyData: yes
> License: GPL (>= 2)
> URL: http://www.rmetrics.org
> Packaged: 2013-06-23 18:22:14 UTC; yohan
> NeedsCompilation: yes
> Repository: CRAN
> Date/Publication: 2013-06-24 01:53:27
> Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix
>
>
>
> > Alternatively, is there another package that behaves similarly to prob?
> >
> >
> >
> > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius 
> wrote:
> >
> > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz 
> wrote:
> > >
> > > The prob package has been archived because it depends upon some other
> > > packages which have issues.
> > >
> > > However, such projects as Introduction to Probability and Statistics
> in R
> > > depend upon it for learning. There are a few other resources that also
> use
> > > it.
> > >
> > > Does anyone know of any workarounds?
> > >
> > > Someone at stack exchange mentioned using R 2.9.
> >
> > I'm not sure I would trust that person. They seem a bit uninformed.
> >
> > > However, that broke my
> > > RStudio (WSOD) and the dependent packages still wouldn't install,
> anyway.
> >
> > The latest version of pkg-prob at the Archive directory of CRAN
> indicates that it was last updated within this year. The DESCRIPTION file
> indicates that it does not need compilation, but:
> >
> > Depends: combinat, fAsianOptions
> >
> > So there should be code in text files in its ../R directory which can be
> sourced from that directory.
> >
> > ~myuser_name$ ls /Users/../Downloads/prob/R
> > characteristicfunctions.r   simulation.r
> utils-spaces.r
> > genData.R   spaces-examples.r
>  utils-subsets.r
> > misc.r  spaces-prob.r
> > prob.r  utils-events.r
> >
> >
> > Or you can install from source after downloading:
> >
> > install.packages("~/Downloads/prob", repo=NULL,type="source")
> >
> > # Success
> >
> >
> > >  library(prob)   # So does require having several other packages
> > Loading required package: combinat
> >
> > Attaching package: ‘combinat’
> >
> > The following object is masked from ‘package:utils’:
> >
> > combn
> >
> > Loading required package: fAsianOptions
> > Loading required package: timeDate
> >
> > Attaching package: ‘timeDate’
> >
> > The following object is masked from ‘package:cairoDevice’:
> >
> > Cairo
> >
> > The following objects are masked from ‘package:PerformanceAnalytics’:
> >
> > kurtosis, skewness
> >
> > Loading required package: timeSeries
> >
> > Attaching package: ‘timeSeries’
> >
> > The following object is masked from ‘package:zoo’:
> >
> > time<-
> >
> > Loading required package: fBasics
> >
> >
> > Rmetrics Package fBasics
> > Analysing Markets and calculating Basic Statistics
> > Copyright (C) 2005-2014 Rmetrics Association Zurich
> > Educational Software for Financial Engineering and Computational Science
> > Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
> > https://www.rmetrics.org --- Mail to: i...@rmetrics.org
> > Loading required package: fOptions
> >
> >
> > Rmetrics Package fOptions
> > Pricing and Evaluating Basic Options
> > Copyright (C) 2005-2014 Rmetrics Association Zurich
> > Educational Software for Financial Engineering and Computational Science
> > Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
>

Re: [R] "prob" package alternative

2017-11-02 Thread David Winsemius

> On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz  wrote:
> 
> The issue is fAsianOptions. Is there a version that works with the latest 
> version of R? If not, which version of it works with which version of R and 
> where can it be found? I tried several at the archive already.

sessionInfo()
R version 3.4.2 Patched (2017-10-04 r73465)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

> 


packageDescription("fAsianOptions")
Package: fAsianOptions
Version: 3010.79
Revision: 5522
Date: 2013-06-23
Title: EBM and Asian Option Valuation
Author: Diethelm Wuertz and many others, see the SOURCE file
Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions
Suggests: RUnit
Maintainer: Yohan Chalabi 
Description: Environment for teaching "Financial Engineering and Computational 
Finance"
Note: Several parts are still preliminary and may be changed in the future. this
  typically includes function and argument names, as well as defaults 
for
  arguments and return values.
LazyData: yes
License: GPL (>= 2)
URL: http://www.rmetrics.org
Packaged: 2013-06-23 18:22:14 UTC; yohan
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2013-06-24 01:53:27
Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix



> Alternatively, is there another package that behaves similarly to prob?
> 
> 
> 
> On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius  
> wrote:
> 
> > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz  wrote:
> >
> > The prob package has been archived because it depends upon some other
> > packages which have issues.
> >
> > However, such projects as Introduction to Probability and Statistics in R
> > depend upon it for learning. There are a few other resources that also use
> > it.
> >
> > Does anyone know of any workarounds?
> >
> > Someone at stack exchange mentioned using R 2.9.
> 
> I'm not sure I would trust that person. They seem a bit uninformed.
> 
> > However, that broke my
> > RStudio (WSOD) and the dependent packages still wouldn't install, anyway.
> 
> The latest version of pkg-prob at the Archive directory of CRAN indicates 
> that it was last updated within this year. The DESCRIPTION file indicates 
> that it does not need compilation, but:
> 
> Depends: combinat, fAsianOptions
> 
> So there should be code in text files in its ../R directory which can be 
> sourced from that directory.
> 
> ~myuser_name$ ls /Users/../Downloads/prob/R
> characteristicfunctions.r   simulation.rutils-spaces.r
> genData.R   spaces-examples.r   
> utils-subsets.r
> misc.r  spaces-prob.r
> prob.r  utils-events.r
> 
> 
> Or you can install from source after downloading:
> 
> install.packages("~/Downloads/prob", repo=NULL,type="source")
> 
> # Success
> 
> 
> >  library(prob)   # So does require having several other packages
> Loading required package: combinat
> 
> Attaching package: ‘combinat’
> 
> The following object is masked from ‘package:utils’:
> 
> combn
> 
> Loading required package: fAsianOptions
> Loading required package: timeDate
> 
> Attaching package: ‘timeDate’
> 
> The following object is masked from ‘package:cairoDevice’:
> 
> Cairo
> 
> The following objects are masked from ‘package:PerformanceAnalytics’:
> 
> kurtosis, skewness
> 
> Loading required package: timeSeries
> 
> Attaching package: ‘timeSeries’
> 
> The following object is masked from ‘package:zoo’:
> 
> time<-
> 
> Loading required package: fBasics
> 
> 
> Rmetrics Package fBasics
> Analysing Markets and calculating Basic Statistics
> Copyright (C) 2005-2014 Rmetrics Association Zurich
> Educational Software for Financial Engineering and Computational Science
> Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
> https://www.rmetrics.org --- Mail to: i...@rmetrics.org
> Loading required package: fOptions
> 
> 
> Rmetrics Package fOptions
> Pricing and Evaluating Basic Options
> Copyright (C) 2005-2014 Rmetrics Association Zurich
> Educational Software for Financial Engineering and Computational Science
> Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
> https://www.rmetrics.org --- Mail to: i...@rmetrics.org
> 
> Attaching package: ‘prob’
> 
> The following objects are masked from ‘package:dplyr’:
> 
> intersect, setdiff, union
> 
> The following objects are masked from ‘package:base’:
> 
> intersect, setdiff, union
> 
> >
> >
> >
> > Tiby
> >
> >   [[alternative HTML version deleted]]
> 
> A specific suggestion would be that you read the listinfo and the Posting 
> Guide and learn to post in plain text.
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reprodu

Re: [R] "prob" package alternative

2017-11-02 Thread Tiby Kantrowitz
The issue is fAsianOptions. Is there a version that works with the latest
version of R? If not, which version of it works with which version of R and
where can it be found? I tried several at the archive already.

Alternatively, is there another package that behaves similarly to prob?



On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius 
wrote:

>
> > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz  wrote:
> >
> > The prob package has been archived because it depends upon some other
> > packages which have issues.
> >
> > However, such projects as Introduction to Probability and Statistics in R
> > depend upon it for learning. There are a few other resources that also
> use
> > it.
> >
> > Does anyone know of any workarounds?
> >
> > Someone at stack exchange mentioned using R 2.9.
>
> I'm not sure I would trust that person. They seem a bit uninformed.
>
> > However, that broke my
> > RStudio (WSOD) and the dependent packages still wouldn't install, anyway.
>
> The latest version of pkg-prob at the Archive directory of CRAN indicates
> that it was last updated within this year. The DESCRIPTION file indicates
> that it does not need compilation, but:
>
> Depends: combinat, fAsianOptions
>
> So there should be code in text files in its ../R directory which can be
> sourced from that directory.
>
> ~myuser_name$ ls /Users/../Downloads/prob/R
> characteristicfunctions.r   simulation.r
> utils-spaces.r
> genData.R   spaces-examples.r
>  utils-subsets.r
> misc.r  spaces-prob.r
> prob.r  utils-events.r
>
>
> Or you can install from source after downloading:
>
> install.packages("~/Downloads/prob", repo=NULL,type="source")
>
> # Success
>
>
> >  library(prob)   # So does require having several other packages
> Loading required package: combinat
>
> Attaching package: ‘combinat’
>
> The following object is masked from ‘package:utils’:
>
> combn
>
> Loading required package: fAsianOptions
> Loading required package: timeDate
>
> Attaching package: ‘timeDate’
>
> The following object is masked from ‘package:cairoDevice’:
>
> Cairo
>
> The following objects are masked from ‘package:PerformanceAnalytics’:
>
> kurtosis, skewness
>
> Loading required package: timeSeries
>
> Attaching package: ‘timeSeries’
>
> The following object is masked from ‘package:zoo’:
>
> time<-
>
> Loading required package: fBasics
>
>
> Rmetrics Package fBasics
> Analysing Markets and calculating Basic Statistics
> Copyright (C) 2005-2014 Rmetrics Association Zurich
> Educational Software for Financial Engineering and Computational Science
> Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
> https://www.rmetrics.org --- Mail to: i...@rmetrics.org
> Loading required package: fOptions
>
>
> Rmetrics Package fOptions
> Pricing and Evaluating Basic Options
> Copyright (C) 2005-2014 Rmetrics Association Zurich
> Educational Software for Financial Engineering and Computational Science
> Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
> https://www.rmetrics.org --- Mail to: i...@rmetrics.org
>
> Attaching package: ‘prob’
>
> The following objects are masked from ‘package:dplyr’:
>
> intersect, setdiff, union
>
> The following objects are masked from ‘package:base’:
>
> intersect, setdiff, union
>
> >
> >
> >
> > Tiby
> >
> >   [[alternative HTML version deleted]]
>
> A specific suggestion would be that you read the listinfo and the Posting
> Guide and learn to post in plain text.
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
> 'Any technology distinguishable from magic is insufficiently advanced.'
>  -Gehm's Corollary to Clarke's Third Law
>
>
>
>
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] ggplot inside function doesn't plot

2017-11-02 Thread David Winsemius

> On Nov 2, 2017, at 10:03 AM, Ed Siefker  wrote:
> 
> I don't really understand. I mean, I understand the solution is
> print(ggplot(...)).  But why is that required in a function and not at
> the console?

The REPL design of the interactive console is offered the user as a 
convenience, but I agree it's somewhat at odds with pure functional principles. 

> 
> Shouldn't I be able to rely on what I do at the console working in a
> script?  Is this inconsistent behavior by design?

By design? Yes. Completely by design. Functions are a method of encapsulating 
intermediate results in a manner that does not interact with the objects that 
exist outside the function. There are three plotting paradigms: base-graphics, 
lattice, and ggplot. The latter two are built with grid graphics and a both 
more functional and object oriented (loosely spoken since they return objects) 
than base graphics. Base graphics behaves the way you expect. Execution of 
`lines` or `points` will give you "pen-on-ink" output, actually pixel on device 
output.


> 
> 
> 
> On Thu, Nov 2, 2017 at 11:54 AM, David Winsemius  
> wrote:
>> 
>>> On Nov 2, 2017, at 9:27 AM, Ed Siefker  wrote:
>>> 
>>> I have a function:
>>> 
>>> myplot <- function (X) {
>>>   d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
>>>   png(paste("img/", X, ".png", sep=""))
>>>   ggplot(d, aes(x=condition, y=count, color=condition)) +
>>>   geom_point(position=position_jitter(w=0.1,h=0)) +
>>>   scale_y_log10(breaks=c(25,100,400)) +
>>>   ggtitle(X) +
>>>   theme(plot.title = element_text(hjust = 0.5))
>>> 
>>>   dev.off()
>>>   }
>>> 
>>> 'd' is a dataframe
>>> 
>>>count  condition
>>> E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
>>> E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
>>> E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
>>> E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
>>> E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
>>> E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO
>>> 
>>> If I set X="Etv5" and paste the contents of the function into R, I get
>>> 'img/Etv5.png'
>>> If I run myplot(X), I get nothing.
>>> 
>>> 
 X
>>> [1] "Etv5"
 list.files("img")
>>> character(0)
 myplot(X)
>>> null device
>>> 1
 list.files("img")
>>> character(0)
 d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
 png(paste("img/", X, ".png", sep=""))
 ggplot(d, aes(x=condition, y=count, color=condition)) +
>>> + geom_point(position=position_jitter(w=0.1,h=0)) +
>>> + scale_y_log10(breaks=c(25,100,400)) +
>>> + ggtitle(X) +
>>> + theme(plot.title = element_text(hjust = 0.5))
 dev.off()
>>> null device
>>> 1
 list.files("img")
>>> [1] "Etv5.png"
>>> 
>>> Why doesn't my function work?
>> 
>> `ggplot` creates an object. You need to print it when used inside a 
>> function. Inside a function (in a more restricted environment) there is no 
>> parse-eval-print-loop.
>> 
>> 
>>> 
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> David Winsemius
>> Alameda, CA, USA
>> 
>> 'Any technology distinguishable from magic is insufficiently advanced.'   
>> -Gehm's Corollary to Clarke's Third Law
>> 
>> 
>> 
>> 
>> 
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot inside function doesn't plot

2017-11-02 Thread Duncan Murdoch

On 02/11/2017 1:03 PM, Ed Siefker wrote:

I don't really understand. I mean, I understand the solution is
print(ggplot(...)).  But why is that required in a function and not at
the console?

Shouldn't I be able to rely on what I do at the console working in a
script?  Is this inconsistent behavior by design?


Yes, it's by design.  At top level, values are normally printed after 
being computed (but this can be turned off).  So


x <- 5
x + 1

will print 6 after the second line.  If you have the line "x + 1" in a 
function, nothing will print.  So you can have a function


addOne <- function(x) {
  x + 1
}

and you can call it lots of times from other functions without printing 
a line each time.


Duncan Murdoch





On Thu, Nov 2, 2017 at 11:54 AM, David Winsemius  wrote:



On Nov 2, 2017, at 9:27 AM, Ed Siefker  wrote:

I have a function:

myplot <- function (X) {
d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
png(paste("img/", X, ".png", sep=""))
ggplot(d, aes(x=condition, y=count, color=condition)) +
geom_point(position=position_jitter(w=0.1,h=0)) +
scale_y_log10(breaks=c(25,100,400)) +
ggtitle(X) +
theme(plot.title = element_text(hjust = 0.5))

dev.off()
}

'd' is a dataframe

 count  condition
E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO

If I set X="Etv5" and paste the contents of the function into R, I get
'img/Etv5.png'
If I run myplot(X), I get nothing.



X

[1] "Etv5"

list.files("img")

character(0)

myplot(X)

null device
  1

list.files("img")

character(0)

d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
png(paste("img/", X, ".png", sep=""))
ggplot(d, aes(x=condition, y=count, color=condition)) +

+ geom_point(position=position_jitter(w=0.1,h=0)) +
+ scale_y_log10(breaks=c(25,100,400)) +
+ ggtitle(X) +
+ theme(plot.title = element_text(hjust = 0.5))

dev.off()

null device
  1

list.files("img")

[1] "Etv5.png"

Why doesn't my function work?


`ggplot` creates an object. You need to print it when used inside a function. 
Inside a function (in a more restricted environment) there is no 
parse-eval-print-loop.




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law







__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot inside function doesn't plot

2017-11-02 Thread Richard M. Heiberger
FAQ 7.22

Open the file indicated by
system.file("../../doc/FAQ")
and scroll down to 7.22



On Thu, Nov 2, 2017 at 1:03 PM, Ed Siefker  wrote:
> I don't really understand. I mean, I understand the solution is
> print(ggplot(...)).  But why is that required in a function and not at
> the console?
>
> Shouldn't I be able to rely on what I do at the console working in a
> script?  Is this inconsistent behavior by design?
>
>
>
> On Thu, Nov 2, 2017 at 11:54 AM, David Winsemius  
> wrote:
>>
>>> On Nov 2, 2017, at 9:27 AM, Ed Siefker  wrote:
>>>
>>> I have a function:
>>>
>>> myplot <- function (X) {
>>>d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
>>>png(paste("img/", X, ".png", sep=""))
>>>ggplot(d, aes(x=condition, y=count, color=condition)) +
>>>geom_point(position=position_jitter(w=0.1,h=0)) +
>>>scale_y_log10(breaks=c(25,100,400)) +
>>>ggtitle(X) +
>>>theme(plot.title = element_text(hjust = 0.5))
>>>
>>>dev.off()
>>>}
>>>
>>> 'd' is a dataframe
>>>
>>> count  condition
>>> E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
>>> E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
>>> E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
>>> E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
>>> E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
>>> E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO
>>>
>>> If I set X="Etv5" and paste the contents of the function into R, I get
>>> 'img/Etv5.png'
>>> If I run myplot(X), I get nothing.
>>>
>>>
 X
>>> [1] "Etv5"
 list.files("img")
>>> character(0)
 myplot(X)
>>> null device
>>>  1
 list.files("img")
>>> character(0)
 d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
 png(paste("img/", X, ".png", sep=""))
 ggplot(d, aes(x=condition, y=count, color=condition)) +
>>> + geom_point(position=position_jitter(w=0.1,h=0)) +
>>> + scale_y_log10(breaks=c(25,100,400)) +
>>> + ggtitle(X) +
>>> + theme(plot.title = element_text(hjust = 0.5))
 dev.off()
>>> null device
>>>  1
 list.files("img")
>>> [1] "Etv5.png"
>>>
>>> Why doesn't my function work?
>>
>> `ggplot` creates an object. You need to print it when used inside a 
>> function. Inside a function (in a more restricted environment) there is no 
>> parse-eval-print-loop.
>>
>>
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> David Winsemius
>> Alameda, CA, USA
>>
>> 'Any technology distinguishable from magic is insufficiently advanced.'   
>> -Gehm's Corollary to Clarke's Third Law
>>
>>
>>
>>
>>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Cox Regression : Spline Coefficient Interpretation?

2017-11-02 Thread Kevin E. Thorpe

Your output is mangled beyond interpretation.

However, when it comes to interpreting splines in general, you cannot 
easily convert the individual beta coefficients into, say HR by 
exponenitating them. The collection of beta coefficients describe the 
relationship between the continuous variable and the outcome.


Consider a simple case. Suppose you fit a model with x and x^2. You 
cannot really interpret the x^2 coefficient in isolation from the x 
coefficient. It is the same with splines only worse.


Graphical displays of the spline are often more informative.

Kevin

On 11/01/2017 04:12 PM, Kosta S. wrote:

Hi,

I'm using a Cox-Regression to estimate hazard rates on prepayments.

I'm using the "pspline" function to face non-linearity, but I have no clue
how to interpret the result.
Unfortunately I did not find enough information on the "pspline" function
wether in the survival package nor using google..

I got following output:

* library(survival)*
















*> Option.test2<-coxph(Surv(START,STOP,ZEROBAL==1)~pspline(OPTION),
data=FNMA)coxph(formula = Surv(START, STOP, ZEROBAL == 1) ~
pspline(OPTION), data = FNMA)> > Option.test2> Call:> coxph(formula =
Surv(START, STOP, ZEROBAL == 1) ~ pspline(OPTION), > data = FNMA)>
  coef  se(coef)   se2 Chisq   DF
 p> pspline(OPTION), linear   -0.13340.01310.0131  104.4325
1.00 <0.0002> pspline(OPTION), nonlin
 1747.1295 3.05 <0.0002> Iterations: 8 outer, 19
Newton-Raphson>  Theta= 0.991 > Degrees of freedom for terms= 4 >
Likelihood ratio test=2136  on 4.05 df, p=0  n= 3390429 >  *



Thanks,

KS




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] repeat a function

2017-11-02 Thread Bert Gunter
Petr et al. :

I only wish to comment on Petr's remark; I have nothing useful to say about
the subject of this thread.

"AFAIK if a function is defined within another function (which is your
case) it cannot be called directly so it is necessary to define it in
global environment."

Right, a deliberate consequence of R's (lexical) scoping semantics.
However, as you are probably aware, a function can *return* a function that
is then visible and can be called in the caller's scope. e.g. , using your
example:

> fff <- function(a){
function(x) x^2 + a
 }

> fff(2)(3) ## note syntax: 3^2 + 2
[1] 11

> fff(3)(2) ## 2^2 + 3
[1] 7

## or you can assign the function to a symbol and call it directly

> myf <- fff(2)

> myf(3) ## 3^2 + 2
[1] 11


You all can decide whether or not this is useful in the current context.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Thu, Nov 2, 2017 at 8:56 AM, PIKAL Petr  wrote:

> Hi Eric
>
> I did not see any answer and frankly speaking I cannot provide you with
> canned help.
>
> AFAIK if a function is defined within another function (which is your
> case) it cannot be called directly so it is necessary to define it in
> global environment.
>
> >  fff <- function(x) {
> +  myf <- function(a) a+2
> +  myf(x)^2}
> >
> > fff(5)
> [1] 49
> > myf(5)
> Error in myf(5) : could not find function "myf"
> >
>
> Your function set is quite complicated but I wonder why would it be
> necessary to use for cycle for what seems to be simple table. Everything
> seems quite deterministic.
>
> Basically you have combination of rows (-2,-1,0,1,2) and columns -1,-,1.
> expand.grid(u=-2:2, v=-1:1)
> for each row you can than use one function with parameters u, v and a and
> dt.
> After you calculate vector of results, you can easily transform it to
> matrix by setting dim argument to it.
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> > eric.pu...@avivainvestors.com
> > Sent: Wednesday, November 1, 2017 1:31 PM
> > To: r-help@r-project.org
> > Subject: [R] repeat a function
> >
> > I want to populate the matrix prb through the function HWMProb <-
> function
> > (a,j,dt) that encapsulates different functions (please see code below),
> using j=
> > 0:2 for each j.
> >
> > It only populates prb if I specify each function independently in the
> global
> > environment and then run the loop with the iF statement, as per below.
> > for (j in 0:2) {
> >   if (j==0) {
> > prb["0","1"] <- ProbUP(a,j,dt)
> > prb["0","0"] <- ProbMID(a,j,dt)
> > prb["0","-1"] <- ProbDWN(a,j,dt)
> >   }
> >   else {
> > if (j==jmax) {
> >   prb[paste(j,sep = ""),"1"] <- TOPProbUP(a,j,dt)
> >   prb[paste(j,sep = ""),"0"] <- TOPProbMID(a,j,dt)
> >   prb[paste(j,sep = ""),"-1"] <- TOPProbDWN(a,j,dt)
> >   prb[paste(-j,sep = ""),"1"] <- BTTMProbUP(a,-j,dt)
> >   prb[paste(-j,sep = ""),"0"] <- BTTMProbMID(a,-j,dt)
> >   prb[paste(-j,sep = ""),"-1"] <- BTTMProbDWN(a,-j,dt)
> > }
> > else {
> >   prb[paste(j,sep = ""),"1"] <- ProbUP(a,j,dt)
> >   prb[paste(j,sep = ""),"0"] <- ProbMID(a,j,dt)
> >   prb[paste(j,sep = ""),"-1"] <- ProbDWN(a,j,dt)
> >   prb[paste(-j,sep = ""),"1"] <- ProbUP(a,-j,dt)
> >   prb[paste(-j,sep = ""),"0"] <- ProbMID(a,-j,dt)
> >   prb[paste(-j,sep = ""),"-1"] <- ProbDWN(a,-j,dt)
> > } # Close 2nd IF
> >   } # Close 1st IF
> > }
> >
> > Many thanks in advance.
> > Kind regards,
> >
> > Eric Pueyo
> > Investment Risk Analyst
> > Email:
> > eric.pu...@avivainvestors.com
> > D: +44 (0)20 7809 8070
> > No. 1 Undershaft, London EC3P 3DQ
> > Web:
> > www.avivainvestors.com > 3A__www.avivainvestors.com_&d=CwMFAg&c=zUO0BtkCe66yJvAZ4cAvZg&r=-
> > 34SVFvqwmZvbxD0ShuYglbuijP84lygitjFgiP1fxI&m=kRg3I7ESFxV-
> > KaNbYHN6DPupgyEmFCiThNO6oDnpAFs&s=tQa1EuXKNfzRgiR2HgG0H_tW_X-
> > BCpgebe5AL9A_GC8&e=>
> >
> > jmax<-2
> > prb <-matrix(0L,nrow=5, ncol=3)
> > rownames(prb) <- c(seq(-2,2, by = 1))
> > colnames(prb) <- c(-1,0,1)
> > a<- 0.1
> > dt<-1
> >
> > ExpX <-function(x,a,dt) {  ##Defines the
> Expectation of X
> > on t+1 | t
> > ExpX <- x*exp(-a*dt)
> > ExpX
> > }
> > Mfactor<-function(a,dt)  {   ###Factor
> multiplicative
> >   Mfactor<- exp(-a*dt)-1
> >   Mfactor
> > }
> > VarX <-function(sigma,a,dt) { ###Defubes the
> Variance of X
> > on t+1 | t
> >   VarX <- (sigma^2/(2*a))*(1-exp(-2*a*dt))
> >   VarX
> > }
> > DeltaX <-function(sigma,a,dt) {   ##Defines the
> change of X
> >   DeltaX<- sqrt(3*VarX(sigma,a,dt))
> >   DeltaX<-value(DeltaX)
> > }
> >
> > Mfactor<-function(a,dt)  {   ###Factor
> multiplica

Re: [R] ggplot inside function doesn't plot

2017-11-02 Thread Ed Siefker
I don't really understand. I mean, I understand the solution is
print(ggplot(...)).  But why is that required in a function and not at
the console?

Shouldn't I be able to rely on what I do at the console working in a
script?  Is this inconsistent behavior by design?



On Thu, Nov 2, 2017 at 11:54 AM, David Winsemius  wrote:
>
>> On Nov 2, 2017, at 9:27 AM, Ed Siefker  wrote:
>>
>> I have a function:
>>
>> myplot <- function (X) {
>>d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
>>png(paste("img/", X, ".png", sep=""))
>>ggplot(d, aes(x=condition, y=count, color=condition)) +
>>geom_point(position=position_jitter(w=0.1,h=0)) +
>>scale_y_log10(breaks=c(25,100,400)) +
>>ggtitle(X) +
>>theme(plot.title = element_text(hjust = 0.5))
>>
>>dev.off()
>>}
>>
>> 'd' is a dataframe
>>
>> count  condition
>> E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
>> E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
>> E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
>> E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
>> E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
>> E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO
>>
>> If I set X="Etv5" and paste the contents of the function into R, I get
>> 'img/Etv5.png'
>> If I run myplot(X), I get nothing.
>>
>>
>>> X
>> [1] "Etv5"
>>> list.files("img")
>> character(0)
>>> myplot(X)
>> null device
>>  1
>>> list.files("img")
>> character(0)
>>> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
>>> png(paste("img/", X, ".png", sep=""))
>>> ggplot(d, aes(x=condition, y=count, color=condition)) +
>> + geom_point(position=position_jitter(w=0.1,h=0)) +
>> + scale_y_log10(breaks=c(25,100,400)) +
>> + ggtitle(X) +
>> + theme(plot.title = element_text(hjust = 0.5))
>>> dev.off()
>> null device
>>  1
>>> list.files("img")
>> [1] "Etv5.png"
>>
>> Why doesn't my function work?
>
> `ggplot` creates an object. You need to print it when used inside a function. 
> Inside a function (in a more restricted environment) there is no 
> parse-eval-print-loop.
>
>
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
> 'Any technology distinguishable from magic is insufficiently advanced.'   
> -Gehm's Corollary to Clarke's Third Law
>
>
>
>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot inside function doesn't plot

2017-11-02 Thread David Winsemius

> On Nov 2, 2017, at 9:27 AM, Ed Siefker  wrote:
> 
> I have a function:
> 
> myplot <- function (X) {
>d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
>png(paste("img/", X, ".png", sep=""))
>ggplot(d, aes(x=condition, y=count, color=condition)) +
>geom_point(position=position_jitter(w=0.1,h=0)) +
>scale_y_log10(breaks=c(25,100,400)) +
>ggtitle(X) +
>theme(plot.title = element_text(hjust = 0.5))
> 
>dev.off()
>}
> 
> 'd' is a dataframe
> 
> count  condition
> E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
> E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
> E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
> E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
> E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
> E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO
> 
> If I set X="Etv5" and paste the contents of the function into R, I get
> 'img/Etv5.png'
> If I run myplot(X), I get nothing.
> 
> 
>> X
> [1] "Etv5"
>> list.files("img")
> character(0)
>> myplot(X)
> null device
>  1
>> list.files("img")
> character(0)
>> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
>> png(paste("img/", X, ".png", sep=""))
>> ggplot(d, aes(x=condition, y=count, color=condition)) +
> + geom_point(position=position_jitter(w=0.1,h=0)) +
> + scale_y_log10(breaks=c(25,100,400)) +
> + ggtitle(X) +
> + theme(plot.title = element_text(hjust = 0.5))
>> dev.off()
> null device
>  1
>> list.files("img")
> [1] "Etv5.png"
> 
> Why doesn't my function work?

`ggplot` creates an object. You need to print it when used inside a function. 
Inside a function (in a more restricted environment) there is no 
parse-eval-print-loop.


> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot inside function doesn't plot

2017-11-02 Thread PIKAL Petr
Hi

You have to print it.

just add

print(all ggplot stuff)

inside the function.

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ed Siefker
> Sent: Thursday, November 2, 2017 5:27 PM
> To: r-help 
> Subject: [R] ggplot inside function doesn't plot
>
> I have a function:
>
> myplot <- function (X) {
> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
> png(paste("img/", X, ".png", sep=""))
> ggplot(d, aes(x=condition, y=count, color=condition)) +
> geom_point(position=position_jitter(w=0.1,h=0)) +
> scale_y_log10(breaks=c(25,100,400)) +
> ggtitle(X) +
> theme(plot.title = element_text(hjust = 0.5))
>
> dev.off()
> }
>
> 'd' is a dataframe
>
>  count  condition
> E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
> E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
> E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
> E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
> E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
> E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO
>
> If I set X="Etv5" and paste the contents of the function into R, I get
> 'img/Etv5.png'
> If I run myplot(X), I get nothing.
>
>
> > X
> [1] "Etv5"
> > list.files("img")
> character(0)
> > myplot(X)
> null device
>   1
> > list.files("img")
> character(0)
> > d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
> > png(paste("img/", X, ".png", sep="")) ggplot(d, aes(x=condition,
> > y=count, color=condition)) +
> + geom_point(position=position_jitter(w=0.1,h=0)) +
> + scale_y_log10(breaks=c(25,100,400)) +
> + ggtitle(X) +
> + theme(plot.title = element_text(hjust = 0.5))
> > dev.off()
> null device
>   1
> > list.files("img")
> [1] "Etv5.png"
>
> Why doesn't my function work?
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person 

[R] ggplot inside function doesn't plot

2017-11-02 Thread Ed Siefker
I have a function:

myplot <- function (X) {
d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
png(paste("img/", X, ".png", sep=""))
ggplot(d, aes(x=condition, y=count, color=condition)) +
geom_point(position=position_jitter(w=0.1,h=0)) +
scale_y_log10(breaks=c(25,100,400)) +
ggtitle(X) +
theme(plot.title = element_text(hjust = 0.5))

dev.off()
}

'd' is a dataframe

 count  condition
E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO

If I set X="Etv5" and paste the contents of the function into R, I get
'img/Etv5.png'
If I run myplot(X), I get nothing.


> X
[1] "Etv5"
> list.files("img")
character(0)
> myplot(X)
null device
  1
> list.files("img")
character(0)
> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
> png(paste("img/", X, ".png", sep=""))
> ggplot(d, aes(x=condition, y=count, color=condition)) +
+ geom_point(position=position_jitter(w=0.1,h=0)) +
+ scale_y_log10(breaks=c(25,100,400)) +
+ ggtitle(X) +
+ theme(plot.title = element_text(hjust = 0.5))
> dev.off()
null device
  1
> list.files("img")
[1] "Etv5.png"

Why doesn't my function work?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] repeat a function

2017-11-02 Thread PIKAL Petr
Hi Eric

I did not see any answer and frankly speaking I cannot provide you with canned 
help.

AFAIK if a function is defined within another function (which is your case) it 
cannot be called directly so it is necessary to define it in global environment.

>  fff <- function(x) {
+  myf <- function(a) a+2
+  myf(x)^2}
>
> fff(5)
[1] 49
> myf(5)
Error in myf(5) : could not find function "myf"
>

Your function set is quite complicated but I wonder why would it be necessary 
to use for cycle for what seems to be simple table. Everything seems quite 
deterministic.

Basically you have combination of rows (-2,-1,0,1,2) and columns -1,-,1.
expand.grid(u=-2:2, v=-1:1)
for each row you can than use one function with parameters u, v and a and dt.
After you calculate vector of results, you can easily transform it to matrix by 
setting dim argument to it.

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> eric.pu...@avivainvestors.com
> Sent: Wednesday, November 1, 2017 1:31 PM
> To: r-help@r-project.org
> Subject: [R] repeat a function
>
> I want to populate the matrix prb through the function HWMProb <- function
> (a,j,dt) that encapsulates different functions (please see code below), using 
> j=
> 0:2 for each j.
>
> It only populates prb if I specify each function independently in the global
> environment and then run the loop with the iF statement, as per below.
> for (j in 0:2) {
>   if (j==0) {
> prb["0","1"] <- ProbUP(a,j,dt)
> prb["0","0"] <- ProbMID(a,j,dt)
> prb["0","-1"] <- ProbDWN(a,j,dt)
>   }
>   else {
> if (j==jmax) {
>   prb[paste(j,sep = ""),"1"] <- TOPProbUP(a,j,dt)
>   prb[paste(j,sep = ""),"0"] <- TOPProbMID(a,j,dt)
>   prb[paste(j,sep = ""),"-1"] <- TOPProbDWN(a,j,dt)
>   prb[paste(-j,sep = ""),"1"] <- BTTMProbUP(a,-j,dt)
>   prb[paste(-j,sep = ""),"0"] <- BTTMProbMID(a,-j,dt)
>   prb[paste(-j,sep = ""),"-1"] <- BTTMProbDWN(a,-j,dt)
> }
> else {
>   prb[paste(j,sep = ""),"1"] <- ProbUP(a,j,dt)
>   prb[paste(j,sep = ""),"0"] <- ProbMID(a,j,dt)
>   prb[paste(j,sep = ""),"-1"] <- ProbDWN(a,j,dt)
>   prb[paste(-j,sep = ""),"1"] <- ProbUP(a,-j,dt)
>   prb[paste(-j,sep = ""),"0"] <- ProbMID(a,-j,dt)
>   prb[paste(-j,sep = ""),"-1"] <- ProbDWN(a,-j,dt)
> } # Close 2nd IF
>   } # Close 1st IF
> }
>
> Many thanks in advance.
> Kind regards,
>
> Eric Pueyo
> Investment Risk Analyst
> Email:
> eric.pu...@avivainvestors.com
> D: +44 (0)20 7809 8070
> No. 1 Undershaft, London EC3P 3DQ
> Web:
> www.avivainvestors.com 3A__www.avivainvestors.com_&d=CwMFAg&c=zUO0BtkCe66yJvAZ4cAvZg&r=-
> 34SVFvqwmZvbxD0ShuYglbuijP84lygitjFgiP1fxI&m=kRg3I7ESFxV-
> KaNbYHN6DPupgyEmFCiThNO6oDnpAFs&s=tQa1EuXKNfzRgiR2HgG0H_tW_X-
> BCpgebe5AL9A_GC8&e=>
>
> jmax<-2
> prb <-matrix(0L,nrow=5, ncol=3)
> rownames(prb) <- c(seq(-2,2, by = 1))
> colnames(prb) <- c(-1,0,1)
> a<- 0.1
> dt<-1
>
> ExpX <-function(x,a,dt) {  ##Defines the 
> Expectation of X
> on t+1 | t
> ExpX <- x*exp(-a*dt)
> ExpX
> }
> Mfactor<-function(a,dt)  {   ###Factor 
> multiplicative
>   Mfactor<- exp(-a*dt)-1
>   Mfactor
> }
> VarX <-function(sigma,a,dt) { ###Defubes the 
> Variance of X
> on t+1 | t
>   VarX <- (sigma^2/(2*a))*(1-exp(-2*a*dt))
>   VarX
> }
> DeltaX <-function(sigma,a,dt) {   ##Defines the 
> change of X
>   DeltaX<- sqrt(3*VarX(sigma,a,dt))
>   DeltaX<-value(DeltaX)
> }
>
> Mfactor<-function(a,dt)  {   ###Factor 
> multiplicative
>   Mfactor<- exp(-a*dt)-1
>   Mfactor
> }
>
> KNode<-function(sigma,x,a,j,dt) {##Central Node
>   KNode<- round(ExpX(x,a,dt)/DeltaX(sigma,a,dt))
>   KNode
> }
>
> ### Probability Calculations taking into account different branches
> HWMProb <- function (a,j,dt) {
>   # DESCRIPTION
> #
>   ProbUP<- function( a, j, dt) 1 / 6 + ((j ^ 2 * Mfactor(a, dt) ^ 2 + j * 
> Mfactor(a,
> dt)) / 2) # Probability X going up
>   ProbMID<- function(a, j, dt) 2 / 3 - (j ^ 2 * Mfactor(a, dt) ^ 2)
>  Probability X going middle
>   ProbDWN<-function( a, j, dt) 1 / 6 + ((j ^ 2 * Mfactor(a, dt) ^ 2 - j * 
> Mfactor(a,
> dt)) / 2)  ###  Probability X going down
>   TOPProbUP<- function( a, j, dt) 7 / 6 + (j ^ 2 * Mfactor(a, dt) ^ 2 + 3 * j 
> *
> Mfactor(a, dt)) / 2 ### Top branch probability going up
>   TOPProbMID<- function(a, j, dt) -1 / 3 - j ^ 2 * Mfactor(a, dt) ^ 2 - 2 * j 
> *
> Mfactor(a, dt)  ### Top branch probability going MID
>   TOPProbDWN<- function( a, j, dt) 1 / 6 + (j ^ 2 * Mfactor(a, dt) ^ 2 + j *
> Mfactor(a, dt)) / 2   ### Top branch probability going DOWN
>   BTTMProbUP<- f

Re: [R] Cox Regression : Spline Coefficient Interpretation?

2017-11-02 Thread Bert Gunter
Always reply to the list. I do not do private consulting.
(I have cc'ed this to the list).

I still think this belongs on stackexchange, not r-help. I think you need
to read up on the mathematics of spline bases.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Thu, Nov 2, 2017 at 3:43 AM, Kosta S.  wrote:

> Hi Bert,
>
> Maybe I should make this more clear.
> I get following output when I use the pspline function inside the coxph
> statement:
>
> * library(survival)*
>
>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *> Option.test2<-coxph(Surv(START,STOP,ZEROBAL==1)~pspline(OPTION),
>> data=FNMA)coxph(formula = Surv(START, STOP, ZEROBAL == 1) ~
>> pspline(OPTION),data = FNMA)> > Option.test2> Call:> coxph(formula =
>> Surv(START, STOP, ZEROBAL == 1) ~ pspline(OPTION),> data = FNMA)>
>>coef  se(coef)   se2 Chisq   DF
>>   p> pspline(OPTION), linear   -0.13340.01310.0131  104.4325
>> 1.00 <0.0002> pspline(OPTION), nonlin
>> 1747.1295 3.05 <0.0002> Iterations: 8 outer, 19
>> Newton-Raphson>  Theta= 0.991> Degrees of freedom for terms= 4>
>> Likelihood ratio test=2136  on 4.05 df, p=0  n= 3390429*
>
>
>
> What I do not understand, and what I have not found either in the package
> documentation nor somewhere else is how to  interpret the output result:
>
>
>
>
>
>
>
> *>  coef  se(coef)   se2 Chisq   DF
> p> pspline(OPTION), linear   -0.13340.01310.0131
>  104.4325 1.00 <0.0002> pspline(OPTION), nonlin
>   1747.1295 3.05 <0.0002> Iterations: 8 outer, 19
> Newton-Raphson>  Theta= 0.991> Degrees of freedom for terms= 4>
> Likelihood ratio test=2136  on 4.05 df, p=0  n= 3390429*
>
>
> What does it actually tell me? What does the "linear" and "nonlinear"
> mean? It differs from the usual coxph output. Is this a proof of
> non-linearity?
>
> This topic was also alreday asked on the cross validated board, but
> unfortunately without any answer, see https://stats.
> stackexchange.com/questions/280168/interpretation-of-coxph-pspline-terms
>
>
> Thanks,
>
> KS
>
>
>
>
>
>
>
>
> 2017-11-01 23:11 GMT+01:00 Bert Gunter :
>
>> ??
>>
>> It is unclear to me what "How to interpret the result" means. Note that
>> the survival package is very well documented and there is a vignette
>> specifically on the topic of the use of "Spline terms in a Cox model." Have
>> you studied it?
>>
>> If you want to discuss the statistical issues, e.g. of survival modeling
>> or the technical details of penalized smoothing splines, that is mostly OT
>> here: stats.stackexchange.com would probably be a better place to post
>> for that. This list is mostly about R programming rather than statistics,
>> although they do sometimes intersect.
>>
>> If I have misunderstood your question, you might wish to clarify exactly
>> what it is that you are seeking in another post.
>>
>> Finally, as you can see from the below, post in PLAIN TEXT ONLY, as html
>> can get mangled by the server on this plain text mailing list.
>>
>> Cheers,
>> Bert
>>
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>> On Wed, Nov 1, 2017 at 1:12 PM, Kosta S.  wrote:
>>
>>> Hi,
>>>
>>> I'm using a Cox-Regression to estimate hazard rates on prepayments.
>>>
>>> I'm using the "pspline" function to face non-linearity, but I have no
>>> clue
>>> how to interpret the result.
>>> Unfortunately I did not find enough information on the "pspline" function
>>> wether in the survival package nor using google..
>>>
>>> I got following output:
>>>
>>> * library(survival)*
>>>
>>>
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > *> Option.test2<-coxph(Surv(START,STOP,ZEROBAL==1)~pspline(OPTION),
>>> > data=FNMA)coxph(formula = Surv(START, STOP, ZEROBAL == 1) ~
>>> > pspline(OPTION), data = FNMA)> > Option.test2> Call:>
>>> coxph(formula =
>>> > Surv(START, STOP, ZEROBAL == 1) ~ pspline(OPTION), > data = FNMA)>
>>> >  coef  se(coef)   se2 Chisq   DF
>>> > p> pspline(OPTION), linear   -0.13340.01310.0131
>>> 104.4325
>>> > 1.00 <0.0002> pspline(OPTION), nonlin
>>> > 1747.1295 3.05 <0.0002> Iterations: 8 outer, 19
>>> > Newton-Raphson>  Theta= 0.991 > Degrees of freedom for terms= 4 >
>>> > Likelihood ratio test=2136  on 4.05 df, p=0  n= 3390429 >  *
>>>
>>>
>>> Thanks,
>>>
>>> KS
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-he

[R] SamplingStrata R package

2017-11-02 Thread Chris S
Hi all

I am hoping to use the SamplingStrata R package for a dataset describing a
population of businesses wherein I have information on the type of
business, as well as, for designated employment number bands, number of
employees and business turnover information. So ideally the stratification
will be business type X business size. I am not 100% sure what "domains"
(in the vernacular of the package) would be referring to in this case? Also
can I employ both number of employees and business turnover information to
optimise the stratification sampling procedure?

thank you in advance

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Correct subsetting in R

2017-11-02 Thread peter dalgaard

> On 1 Nov 2017, at 18:03 , Elahe chalabi via R-help  
> wrote:
> 
> But they row.names() cannot give me the IDs
> 

Is "training" extracted from "data" using standard data frame indexing? If so, 
data[row.names(training), "ID"] should give you the relevant values. 

If not, then you are in trouble because you cannot tell the difference between 
two IDs that have identical responses in columns 2:608. You might proceed with 
something like 

signature1 <- do.call("paste", data)
any(duplicated(signature1)) # if TRUE you're not quite happy because two or 
more IDs are indistinguishable.

signature2 <- do.call("paste", data)
m <- match(signature2, signature1)

any(duplicated(m)) # ouch if TRUE... will require more thought

any(is.na(m)) # even more ouch, if TRUE...

data$ID[m]


-pd

> 
> 
> 
> 
> 
> On Wednesday, November 1, 2017 9:45 AM, David Wolfskill  
> wrote:
> 
> 
> 
> On Wed, Nov 01, 2017 at 04:13:42PM +, Elahe chalabi via R-help wrote:
> 
>> Hi all,
>> I have two data frames that one of them does not have the column ID:
>> 
>>> str(data)
>>'data.frame':499 obs. of  608 variables:
>>$ ID   : int  1 2 3 4 5 6 7 8 9 10 ...
>>$ alright  : int  1 0 0 0 0 0 0 1 2 1 ...
>>$ bad  : int  1 0 0 0 0 0 0 0 0 0 ...
>>$ boy  : int  1 2 1 1 0 2 2 4 2 1 ...
>>$ cooki: int  1 2 2 1 0 1 1 4 2 3 ...
>>$ curtain  : int  1 0 0 0 0 2 0 2 0 0 ...
>>$ dish : int  2 1 0 1 0 0 1 2 2 2 ...
>>$ doesnt   : int  1 0 0 0 0 0 0 0 1 0 ...
>>$ dont : int  2 1 4 2 0 0 2 1 2 0 ...
>>$ fall : int  3 1 0 0 1 0 1 2 3 2 ...
>>$ fell : int  1 0 0 0 0 0 0 0 0 0 ...
>> 
>> and the other one is:
>> 
>>> str(training)
>>'data.frame':375 obs. of  607 variables:
>>$ alright  : num  1 0 0 0 1 2 1 0 0 0 ...
>>$ bad  : num  1 0 0 0 0 0 0 0 0 0 ...
>>$ boy  : num  1 1 2 2 4 2 1 0 1 0 ...
>>$ cooki: num  1 1 1 1 4 2 3 1 2 2 ...
>>$ curtain  : num  1 0 2 0 2 0 0 0 0 0 ...
>>$ dish : num  2 1 0 1 2 2 2 1 4 1 ...
>>$ doesnt   : num  1 0 0 0 0 1 0 0 0 0 ...
>>$ dont : num  2 2 0 2 1 2 0 0 1 0 ...
>>$ fall : num  3 0 0 1 2 3 2 0 2 0 ...
>>$ fell : num  1 0 0 0 0 0 0 0 0 0 ...
>> Does anyone know how should I get the IDs of training from data?
>> thanks for any help!
>> Elahe
>> 
> 
> row.names() appears to be what is wanted.
> 
> Peace,
> david
> -- 
> David H. Wolfskillr...@catwhisker.org
> Unsubstantiated claims of "Fake News" are evidence that the claimant lies 
> again.
> 
> See http://www.catwhisker.org/~david/publickey.gpg for my public key.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.