I'm performing a small statistical analysis for an assignment, where I'm dealing with a bivariate normal distribution for adult females and males and a simulation of 100 heights and weights for each gender. I've combined the male and female heights into a single variable named "heights". I've done the same with weight. I'd like to create a dummy variable (1 for females, 0 for males) that matches height and weight, but I'm not sure how to do this.
Here is the code I have so far:
BivNormDist = function(n,m1,m2,s1,s2,r) {
y = rnorm(n,m2,s2)
x = rnorm(n,m1+r*s1*(y-m2)/s2,s1*sqrt(1-r^2))
data.frame(x,y)
}
males = BivNormDist(100,167,60,7,9,0.60)
females = BivNormDist(100,177,76,8,11,0.55)
height = c(males$x, females$x)
weight = c(males$y, females$y)
gender =
Any ideas? Thanks in advance!
"male"
and"female"
— rather than arbitrary numbers. – Konrad Rudolph