Quantcast

Resampling with replacement on a binary (0,1) variable to get CIs

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Resampling with replacement on a binary (0,1) variable to get CIs

lincoln
This post was updated on .
...is it possible to do that?

I apologize for something that must be a very trivial question for most of you but, unfortunately, it is not for me.
A binary variable is measured, say, 50 times each year during 10 year. My interest is focused on the percentage of 1s with respect to the total if each year.
There is no way to repeat those measure within each year and getting the CIs by the "normal way".
By the way, it would be important to get even a rough estimate of the CIs of these estimates (n1/n1+n0).

In case this is not a blasphemy, how might be done in R?

Thanks in advance for any help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resampling with replacement on a binary (0, 1) dataset to get Cis

David Winsemius

On Dec 1, 2011, at 6:34 AM, lincoln wrote:

> ...is it possible to do that?
>
> I apologize for something that must be a very trivial question for  
> most of
> you but, unfortunately, it is not for me.
> A binary variable is measured, say, 50 times each year during 10  
> year. My
> interest is focused on the percentage of 1s with respect to the  
> total if
> each year.
> There is no way to repeat those measure within each year and getting  
> the CIs
> by the "normal way".
> By the way, it would be important to get even a rough estimate of  
> the CIs of
> these estimates (/n/1//n/1+/n/0).
>
> In case this is not a blasphemy, how might be done in R?

?prop.test

>
> Thanks in advance for any help
>

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resampling with replacement on a binary (0, 1) dataset to get Cis

lincoln
Thanks.

So, suppose for one specific year (first year over 10) the percentage of successes deriving from 100 trials with 38 successes (and 62 failures), its value would be 38/100=0.38.
I could calculate its confidence intervals this way:
> success<-38
> total<-100
> prop.test(success,total,p=0.5,alternative="two.sided")

        1-sample proportions test with continuity
        correction

data:  success out of total, null probability 0.5
X-squared = 5.29, df = 1, p-value = 0.02145
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
 0.2863947 0.4829411
sample estimates:
   p
0.38

So it would be var$1=0.38 , CI=0.286-0.483

Is it correct?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resampling with replacement on a binary (0, 1) dataset to get Cis

David Winsemius

On Dec 1, 2011, at 10:49 AM, lincoln wrote:

> Thanks.
>
> So, suppose for one specific year (first year over 10) the  
> percentage of
> successes deriving from 100 trials with 38 successes (and 62  
> failures), its
> value would be 38/100=0.38.
> I could calculate its confidence intervals this way:
>> success<-38
>> total<-100
>> prop.test(success,total,p=0.5,alternative="two.sided")
>
> 1-sample proportions test with continuity
> correction
>
> data:  success out of total, null probability 0.5
> X-squared = 5.29, df = 1, p-value = 0.02145
> alternative hypothesis: true p is not equal to 0.5
> 95 percent confidence interval:
> 0.2863947 0.4829411
> sample estimates:
>   p
> 0.38
>
> So it would be var$1=0.38 , CI=0.286-0.483
>
> Is it correct?
>

I couldn't tell if this were homework, so I just threw out a starting  
point. If you were told to do a resampling method then this would just  
be a starting point and you would be expected to go further with the  
boot function.

> --
> View this message in context: http://r.789695.n4.nabble.com/Resampling-with-replacement-on-a-binary-0-1-variable-to-get-CIs-tp4127990p4129048.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resampling with replacement on a binary (0, 1) dataset to get Cis

lincoln
Thanks.
Anyway, it is not homework and I was not told to do that. My question has not been answered yet, I'll try to reformulate it:
Does it make (statistical) sense to resample with replacement in this situation to get an estimate of the CIs? In case it does, how could I do it in R?

Some further details on my real case study:
10 independent samples from a population in ten sessions. Each sample consists of a number (somehow variable) of random individuals that are classified as 0 or 1 depending on one specific state (presence or absence of a disease).
I can calculate, for each session, the percentage of individuals diseased but I have nothing about the CIs, any suggestion?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resampling with replacement on a binary (0, 1) dataset to get Cis

David Winsemius

On Dec 2, 2011, at 3:55 AM, lincoln wrote:

> Thanks.
> Anyway, it is not homework and I was not told to do that. My  
> question has
> not been answered yet, I'll try to reformulate it:
> Does it make (statistical) sense to resample with replacement in this
> situation to get an estimate of the CIs? In case it does, how could  
> I do it
> in R?

> Some further details on my real case study:
> 10 independent samples from a population in ten sessions. Each sample
> consists of a number (somehow variable) of random individuals that are
> classified as 0 or 1 depending on one specific state (presence or  
> absence of
> a disease).
> I can calculate, for each session, the percentage of individuals  
> diseased
> but I have nothing about the CIs, any suggestion?

I do not see much advantage to using resampling in this instance. The  
variance of a proportion is not theoretically complicated and you have  
introduced no further complicating factors that would call into  
question the validity of the estimates you would get from prop.test.

--

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.
Loading...