Re: [S] Integration difficulties

Nicole DePriest Demers (ntd@stat.ohio-state.edu)
Wed, 11 Mar 1998 12:37:36 -0500 (EST)


Thanks for prompt responses from Bill Venables, Nick Ellis,
Henrik Aalborg Nielsen and Bob Byers. I was reminded of a similar
posting on Feb. 2 by Henrik regarding 'u' and 'upper'. At the
time I didn't fully understand the problem but now I do!
Apparently, my 'k' argument is being confused with the 'keep.xy'
argument in integrate(), a result of partial matching of arguments
prior to evaluation of the '...' argument. Using 'kk' instead of
'k' was the suggested remedy and it worked like a charm.

Since repetition is the mother of learning (at least for me it is)
I'll reiterate Henrik's advice: "Be careful when using '...' !"

Thanks again,

Nicole

On Tue, 10 Mar 1998, Nicole DePriest Demers wrote:

> I am trying to integrate a function and a few problems have arisen.
>
> #Function to be integrated is
>
> moment_function(x,theta,k=1) x^k*p.mix(x,theta)
>
> #where p.mix is a mixture of two normal distributions
>
> p.mix_function(x,theta) .5*dnorm(x,theta) + .5*dnorm(x,-theta)
>
>
> Note what happens in the following cases:
>
> 1) > ans_integrate(moment,-Inf,-1,theta=0.1,k=2)
> > ans$integral
> [1] -0.2443884
> > ans$call
> integrate(f = moment, lower = - Inf, upper = -1, keep.xy = 2,
> theta = 0.1)
>
> #The integrate function ignored my k=2 argument in the call to
> #integrate. The result is for k=1.
>
>
> 2) #I removed the default value for k
> > moment_function(x,theta,k) x^k*p.mix(x,theta)
> > ans_integrate(moment,-Inf,-1,theta=0.1,k=2)
> Error in qsub(f, bound, sgn, 0, 1, aux = optargs(l..: singularity
> encountered
> Dumped
>
>
> 3) #I switched the order of k and theta.
> > moment_function(x,k,theta=.1) x^k*p.mix(x,theta)
> > ans_integrate(moment,-Inf,-1,k=2)
> Error in qsub(f, bound, sgn, 0, 1, aux = optargs(l..: singularity
> encountered
> Dumped
>
>
> 4) #I supply defaults for k and theta and send a different value for
> #theta when I call integrate.
> > moment_function(x,k=2,theta=.1) x^k*p.mix(x,theta)
> > ans_integrate(moment,-Inf,-1,theta=0.2)
> > ans$call
> integrate(f = moment, lower = - Inf, upper = -1, theta = 0.2)
>
>
> #For some reason, I need a default value for k in my integrand function
> but not for theta. When k is supplied as an argument to integrate it is
> ignored but theta is not. I want to vary both k and theta within the
> integrate command. All suggestions/explanations will be appreciated.
>
>
> Nicole Demers
>

______________________________________________________________________________
Nicole Demers
Statistics Department
The Ohio State University
1958 Neil Ave., #404
Columbus, OH 43210, USA
ntd@stat.ohio-state.edu

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news