[prev in list] [next in list] [prev in thread] [next in thread]
List: r-sig-epi
Subject: Re: [R-sig-Epi] Frequencies like Epiinfo
From: "BXC (Bendix Carstensen)" <bxc () steno ! dk>
Date: 2010-11-29 22:55:04
Message-ID: 2F73FA3AF524144C863B7C2C903DBC3302B665D265 () exdkmbx002 ! corp ! novocorp ! net
[Download RAW message or body]
Inside the function twoby2 from the Epi-package you will find a small locally defined \
function that gives you confidence intervals for proportions that are better than \
those you compute, which occasionally will give limits outside (0,1). This one is \
based on the logit approximation, and is what you get if you used a logistic \
regression to estimate the proportions:
bin.ci <-
function(x, n)
{
ef <- exp(qnorm(1 - alpha/2)/sqrt(x * (n - x)/n))
p <- x/n
c( p, p/(p + (1 - p) * ef), p/(p + (1 - p)/ef))
}
Best regards,
Bendix Carstensen
> -----Original Message-----
> From: r-sig-epi-bounces@r-project.org
> [mailto:r-sig-epi-bounces@r-project.org] On Behalf Of Diego Garcilazo
> Sent: 30. november 2010 08:36
> To: r-sig-epi@stat.math.ethz.ch; r-sig-epi@r-project.org
> Subject: [R-sig-Epi] Frequencies like Epiinfo
>
>
>
>
> I am trying to make a function that works like the command
> Frequencies of Epiinfo. I am a beginner user and I make
> something like this:
>
>
>
> freq<-function(x){
>
> Frecuencia<-table(x,exclude=NULL);
>
> Porcentaje<-as.vector(round(prop.table(table(x,exclude=NULL)),2));
>
> Porc<-as.vector(round(prop.table(table(x,exclude=NULL))*100,1));
>
> Acumulado<-cumsum(Porc);
>
> IC95.Sup<-round(as.vector(Porc+196*sqrt(Porcentaje*(1-Porcenta
je)/sum(Frecue
> ncia))),1);
>
> IC95.Inf<-round(as.vector(Porc-196*sqrt(Porcentaje*(1-Porcenta
je)/sum(Frecue
> ncia))),1);
>
> matrix(
>
> c(Frecuencia,sum(Frecuencia),Porc,round(sum(Porc),1),
>
> Acumulado,NA,IC95.Inf,NA,IC95.Sup,NA),length(Frecuencia)+1,5,
>
> dimnames=list(c(labels(Frecuencia)[[1]],"Total"),c("Frecuencia
> ","Porcentaje"
> ,"Acumulado","[IC--","--95%]"))
>
> );
>
> }
>
>
>
> There is a way more efficient to create a function like this?
>
> there is a way to make it more visually - friendly adding
> something like
> -------------- that stat.table does?
>
> How can I add an argument like missing=T that show NA's and
> missing=F that exclude Na's??
>
>
>
> Thanks in advance.
>
>
>
> Diego.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Epi@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-epi
>
_______________________________________________
R-sig-Epi@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-epi
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic