[R] Simulate phi-coefficient
Spencer Graves
spencer.graves at pdf.com
Sun Sep 11 05:17:42 CEST 2005
Please pardon my ignorance, but what's a "phi coefficient" in this
context? RSiteSearch("phi coefficient") produced 36 hits that seemed to
discuss issues unrelated to your question.
If it refers to correlation, have you considered something like the
following:
VECTOR1<-rep(c(1,0),c(15,10))
n <- length(VECTOR1)
library(MASS)
Sig <- array(c(1,.5, .5, 1), dim=c(2,2))
z <- mvrnorm(n, mu=c(0,0), Sigma=Sig)
p <- mean(VECTOR1)
q. <- qnorm(p)
Z <- 0+(z<q.)
hope this helps.
spencer graves
Bliese, Paul D LTC USAMH wrote:
> Looking for help with the following problem.
>
>
>
> Given a sample of zeros and ones, for example:
>
>
>
>
>>VECTOR1<-rep(c(1,0),c(15,10))
>
>
>>VECTOR1
>
>
> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
>
>
>
> How would I create a new sample (VECTOR2) also containing zeros and
> ones, in which the phi-coefficient between the two sample vectors was
> drawn from a population with a known phi-coefficient value?
>
>
>
> Basically, I have a vector of zeros and ones and want to simulate
> another vector such that the two vectors have a known phi-coefficient.
>
>
>
> I know there are ways to do this with normally distributed numbers (for
> example the mvrnorm function in MASS), but am stumped when dealing with
> dichotomous variables.
>
>
>
> Appreciate any thoughts.
>
>
>
> Paul
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
--
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA
spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel: 408-938-4420
Fax: 408-280-7915
More information about the R-help
mailing list