[R] Prevent Printing Function's Environment

2018-08-14 Thread Abs Spurdle
Hi All

When you print a function constructed within a function, R prints it's
environment.
For example:

> myfunction = function ()
+ {   f = function () NULL
+ attributes (f) = list (class="myfunction", myattribute=1)
+ f
+ }

> myfunction.f = myfunction ()

> myfunction.f
function ()
NULL

attr(,"class")
[1] "myfunction"
attr(,"myattribute")
[1] 1

One way to prevent this is to set the function's environment to the global
environment.
But I was wondering if there's a way to stop R from printing the
environment without changing the environment?


kind regards
Abs

[[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.


[R] [R-pkgs] Introducing empirical: Probability Distributions as Models of Data

2018-12-03 Thread Abs Spurdle
hi all

I would like to introduce my R package:
empirical: Probability Distributions as Models of Data

The description is:
Computes continuous (not step) empirical (and nonparametric) probability
density, cumulative distribution and quantile functions. Supports
univariate, multivariate and conditional probability distributions, some
kernel smoothing features and weighted data (possibly useful mixed with
fuzzy clustering). Can compute multivariate and conditional probabilities.
Also, can compute conditional medians, quantiles and modes.

Notes:
(1) I'm planning to support categorical variables in the future.
(2) There are some problems with univariate models (but not multivariate),
especially PDFs.
(3) Contrary to what the name empirical suggests, currently multivariate
models use kernel smoothing.
(4) I'm interested in implementing a hybrid Kernel-Quantile method, which I
suspect may be more robust to outliers. If I succeed, then I may rewrite
the univariate implementation.

The URL is:
https://cran.r-project.org/package=empirical

I've written a vignette which describes the package in more detail.
It's URL is:
https://cran.r-project.org/web/packages/empirical/vignettes/empirical.pdf


kind regards
Abs

[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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] Quantile Density Contours

2019-03-30 Thread Abs Spurdle
My R package, "probhat", provides plots of bivariate PDFs and bivariate
CDFs, using kernel smoothing.
Note that there is no bivariate quantile function, as such.

Here's the vignette:
https://cran.r-project.org/web/packages/probhat/vignettes/probhat.pdf

This contains examples.

Note that I'm not subscribed to this mailing list.
(Maybe I will subscribe).
And I had difficulty reading the email addresses from the archive page.

[[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.


[R] (no subject)

2019-04-23 Thread Abs Spurdle
Note that your post has no subject line.
I can't find it in my emails, which may explain why no one else has replied.

> fo<-h~a+b*log(dbh)+c*(log(dbh))^2+1.3

I'm assuming that you want to fit a model with three parameters, a, b and c.
This would be a linear model (linear in the parameters).
I'm going to ignore the +1.3 (because you don't need two intercepts),
but you can modify the following script if you want.

> I want to compute a nlm for each plot

So, three models?

How about this:
> r1 = lm (h ~ log (dbh) + I ( (log (dbh) ) ^ 2), data=ah 
> [ah$plot=="Sinca",])$coef
> r2 = lm (h ~ log (dbh) + I ( (log (dbh) ) ^ 2), data=ah 
> [ah$plot=="budeni",])$coef
> r3 = lm (h ~ log (dbh) + I ( (log (dbh) ) ^ 2), data=ah 
> [ah$plot=="Ceahlau",])$coef

> params = rbind (r1, r2, r3)
> rownames (params) = c ("Sinca", "budeni", "Ceahlau")
> colnames (params) = c ("a", "b", "c")

> params
 a b  c
Sinca-13.05110  5.657927   1.606357
budeni-2.11277  3.997636   1.104683
Ceahlau -135.57911 82.836952 -10.918932

__
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] Surface plots....

2019-04-25 Thread Abs Spurdle
> Does anyone have a recommendation for the best package/function for doing 
> surface plots?

> What I am looking for is one with a lot of functionality like easily rotate 
> the plot and so on.

There is persp() and the rgl package, as Duncan has already mentioned.

However (I'm probably biased here), there's also my package, barsurf.
It doesn't let you rotate the plots and has less features.
However, it does make it easy to put a contour plot next to a surface
plot, and is integrated with HCL color space.

__
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] Time series (trend over time) for irregular sampling dates and multiple sites

2019-04-30 Thread Abs Spurdle
> My data has a few problems: (1) I think I will need to fix the effects of
> seasonal variation (Monthly) and (2) of possible spatial correlation
> (probability of finding an item is higher after finding one since they can
> come from the same ship). (3) How do I handle the fact that the
> measurements were not taken at a regular interval?

Can I ask two questions:
(1) Is the data autocorrelated (or "Seasonal") over time?
If not then this problem is a lot simpler.
(2) Can you expand on the following statement?
"possible spatial correlation (probability of finding an item is higher
after finding one since they can come from the same ship"

[[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] Time series (trend over time) for irregular sampling dates and multiple sites

2019-04-30 Thread Abs Spurdle
> > My data has a few problems: (1) I think I will need to fix the effects
of
> > seasonal variation (Monthly) and (2) of possible spatial correlation
> > (probability of finding an item is higher after finding one since they
can
> > come from the same ship). (3) How do I handle the fact that the
> > measurements were not taken at a regular interval?
>
> Can I ask two questions:
> (1) Is the data autocorrelated (or "Seasonal") over time?
> If not then this problem is a lot simpler.
> (2) Can you expand on the following statement?
> "possible spatial correlation (probability of finding an item is higher
after finding one since they can come from the same ship"

I just had a closer look at your example.

You've tried to model nMonth (presumably in {1, 2, ..., 12}) but is there a
long term trend, over Year?
Also, I'm not an expert on mgcv, but I was wondering if you want bs="cp"
rather than bs="ps"?

When you say "measurements were not taken at a regular interval" are you
referring to the variable "DaysIa"?
In which case, my previous question about autocorrelation applies to this
variable.

[[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] Time series (trend over time) for irregular sampling dates and multiple sites

2019-04-30 Thread Abs Spurdle
This is possibly off topic now...
However, given that it involves mgcv, I think that it's relevant to R.

> to test if there is a change over the years on the amount of debris in
these locations and more specifically a change after the implementation of
a mitigation strategy

> My debris items per effort (Ieffort) are fishing and shipping related
items that can be due to an intentional discharge or an accidental
discharge. It is very common to find a great amount of these items together
in the beach (from where we collected these data (beach clean-ups),
possibly having origin from the same ship. I was thinking that this can be
a problem but still don't know how to overcome or if it makes sense to
include in the model.

I could be wrong on this.
If your goal is simply to determine whether the MARPOL term in significant
or not (or how strong the effect is), I don't think the above issue is
important.
However, you could do a separate spatial analysis, which could be very
interesting...

> This does not apply along the different years.

Are you sure (there's no long term effect)?
Note that you could combine Year and nMonth into one variable, say t.
However, if I understand your variables correctly, this would be correlated
with DaysIa.
So, if you try to fit a model with both Year and DaysIa, then Year is less
likely to be significant, and you probably don't need both.

Note that another approach, is to regard month as a categorical variable.

Also, note that it may be worthwhile testing for interactions, between
MARPOL and Location or Site.
If you want to be fancy, you could test for interactions between MARPOL and
your time variables.

It's possible that there are higher order interactions, however, these sort
of models are difficult for most people to interpret, so are probably a bad
idea.

[[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.