[R] Nonparametric bivariate distribution estimation and sampling

David Winsemius dwinsemius at comcast.net
Fri Mar 23 19:20:50 CET 2012


On Mar 23, 2012, at 1:53 PM, heyi xiao wrote:

> Sarah,
> Thanks for the response. I actually have several years of working  
> experience with R and statistics, although may not be as good as  
> you. that’s why I am here ;) I dug deeper into R documentations and  
> previous R-help posts, and couldn’t found anything particular help.  
> Again, I want to do two things: (1) estimate the probability density  
> of this bivariate distribution using some nonparametric method  
> (kernel, spline etc);

?MASS::kde2d
?KernSmooth::bkde2D
?ade4::s.kde2d
help(package=locfit)

> (2) sample a big dataset from this bivariate distribution for a  
> simulation study.

What is wrong with `sample`?

# to get sample of size n without replacement
set.seed(42)
dfrm[ sample(1:NROW(dfrm), n) , ]

-- 
David.
> If my questions are not clear enough show my how I can improve, or  
> which part is not clear enough. If you have any particular  
> suggestions/comments, you are more than welcome. Thanks!
> Heyi
>
>
> --- On Fri, 3/23/12, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>
>> From: Sarah Goslee <sarah.goslee at gmail.com>
>> Subject: Re: [R] Nonparametric bivariate distribution estimation  
>> and sampling
>> To: "heyi xiao" <xiaoheyiyh at yahoo.com>
>> Cc: r-help at r-project.org
>> Date: Friday, March 23, 2012, 12:26 PM
>> R can do all of that and more.
>>
>> But you'll need to put some work in reading about how to use
>> R, about
>> the statistical methods involved, and about how to use them
>> to best
>> effect. You might want, for instance, generalized additive
>> models. Or
>> not. If your question isn't more fully-formed than this,
>> your best bet
>> is almost certainly to talk to a local statistician, spend
>> some time
>> working with R, and then come back to the list with
>> specific
>> questions.
>>
>> Sarah
>>
>> On Fri, Mar 23, 2012 at 12:17 PM, heyi xiao <xiaoheyiyh at yahoo.com>
>> wrote:
>>> Dear all,
>>> I have a bivariate dataset from a preliminary study. I
>> want to do two things: (1) estimate the probability density
>> of this bivariate distribution using some nonparametric
>> method (kernel, spline etc); (2) sample a big dataset from
>> this bivariate distribution for a simulation study.
>>> Is there any good method or package I can use in R for
>> my work? I don’t want parametric models like bivariate
>> normal distribution etc, as I would like to accurate model
>> my data. I don’t want to use the bootstrapping approach,
>> i.e. sampling with replacement, as this will generate lots
>> of duplicate data points. Any thoughts or input will be
>> highly appreciated!
>>> Heyi
>>>
>>>
>>
>> -- 
>> Sarah Goslee
>> http://www.functionaldiversity.org
>>
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list