# [R] Fw: Generating 3Dplot in lattice package

William Dunlap wdunlap at tibco.com
Tue May 3 18:05:05 CEST 2016

```See if you can use is.nan() to figure out which values of B, Bmax, ...,
cause
the result to be NaN (not a number).  One possibility is if B were always
negative so abs(B)/max(B) could be negative: (negative)^(non-integer power)
is NaN.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, May 3, 2016 at 3:54 AM, T.Riedle <tr206 at kent.ac.uk> wrote:

> Something is wrong here. The formula
>
> pmin(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))
>
>
> provides a time series. Nevertheless, the returned values are incorrect
> and it produces NANs.
>
>
>
> ________________________________
> From: William Dunlap <wdunlap at tibco.com>
> Sent: 02 May 2016 20:04
> To: T.Riedle
> Cc: r-help at r-project.org
> Subject: Re: [R] Generating 3Dplot in lattice package
>
> For starters, use 'pmin' (parallel min) instead of 'min'.
>
> substitute(MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14))),
>      list(MIN=quote(pmin), K14=quote(VaR), ABS=quote(abs),
>           EXP=quote(exp), LN=quote(log), H14=quote(Bmax),
>           omega=quote(w2)))
> # pmin(psi/VaR, exp(((abs(Bmax)/peak)^w2) * log(psi/VaR)))
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com<http://tibco.com>
>
> On Mon, May 2, 2016 at 11:31 AM, T.Riedle <tr206 at kent.ac.uk<mailto:
> tr206 at kent.ac.uk>> wrote:
> Dear R users,
>
> I am trying to generate a 3D plot using the wireframe() function in the
> lattice package.
>
> The corresponding formula in Excel looks as follows and is applied to the
> wireframe() function:
>
> MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14)))
>
> I tried to "translate" this formula in R and the code looks as follows
>
>
> min(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))
>
>
>
> In this case I get only one value which is NAN but I should get a time
> series with 13000 values. Hence, I deleted the min() function and tried the
> wireframe() function:
>
>
>
> wireframe(inflator~exp((abs(B)/Bmax)^w2)*log((psi/VaR),base=2.718182),data=data_3Dplot)
>
> However, it doesn't work as the formula for the inflator is incorrect. It
> produces NANs although it shouldn't do that and actually doesn't do that in
> Excel. Furthermore, the results are totally different to those calculated
> by Excel.
>
> Can anyone help me with the formula and translate it correctly in terms of
> R? How do I get the time series? How do I get the values I get in Excel?
>
> I have attached the data as csv file to this email.
>
> Thank you very much for your help.
>
> ______________________________________________
> R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help