On May 30, 2011, at 11:30 AM, 1Rnwb wrote:
I hope this modified example will work
set.seed(100)
disease<-paste(rep(c('y','n'),50))
gender<-c(paste(rep(c('m','f'),25)), paste(rep(c('f','m'),25)))
mcp<-rnorm(100, mean=1000,sd=600)
age<-rnorm(100,mean=32,sd=20)
dat<-data.frame(disease=disease,sex=gender,Dr_age=age,MCP=mcp)
matchControls in package e1701 might be appropriate. I still don't
understand the matching rules and the example doesn't really help.
My best guess:
require(e1701)
m <- matchControls(disease ~ age +gender, contlabel="y", data=dat)
m
rbind(dat[as.numeric(m$controls), ], dat[as.numeric(m$cases), ] )
the output should be very closely in age for equal number of disease
and
gender.
disease sex Dr_age MCP
99 y f 25.87435 -534.4172
93 y f 65.60017 1741.8817
47 y m 46.15360 407.0412
19 y m 26.24546 910.1833
24 n f 66.53540 1343.3980
30 n f 47.21835 888.0062
78 n m 42.75345 1605.1334
82 n m 27.05292 1671.9386
--
View this message in context:
http://r.789695.n4.nabble.com/matching-by-gender-and-age-tp3552825p3561009.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@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
______________________________________________
R-help@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.