[R] cdf
Duncan Murdoch
murdoch at stats.uwo.ca
Wed Oct 14 00:37:11 CEST 2009
maram salem wrote:
> Dear all,
> I have the cdf of the following power fuction distribution:
> F(y)=(y/350)^a ,0<y<350,
> where " a " is some parameter with range a>0.
> I want to use it as the argument of the discretize function of the actuar package.
>
> So I think I need to define this function to R so that if I entered a=1, I get the following
> F(y)=(y/350)
> and if I entered a=4.5, I get the following
> F(y) =(y/350)^4.5
> ........... and so on
>
> I've tried
> a<-vector(mode="numeric",length=1)
> powercdf<-function(a,y)
> (y/350)^a
>
You want to return a function of y, so do it like this:
powercdf <- function(a) {
force(a) # crucial, so that a gets evaluated now.
return( function(y) (y/350)^a )
}
Duncan Murdoch
>
> But when I typed: powercdf(10,y)
> instead of getting : (y/350)^10 (which is what I want)
> I got : object y not found ??
>
> I want y to remain as it is, a continous variable, not for example seq(0,350).
> Thank you in advance.
> Maram
>
>
>
> [[alternative HTML version deleted]]
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
More information about the R-help
mailing list