[R] extract p-value from mixed model in kinship package

Ram H. Sharma sharma.ram.h at gmail.com
Thu Apr 14 05:38:09 CEST 2011


Dear R experts

I was using kinship package to fit mixed model with kinship matrix.
The package looks like lme4, but I could find a way to extract p-value
out of it. I need to extract is as I need to analyse large number of
variables (> 10000).

Please help me:

require(kinship)

Generating random example  data

id <- 1:100

dadid <- c(rep(0, 5), rep(1, 5), rep(3, 5), rep(5, 5), rep(7, 10),
rep(9, 10), rep(11, 10), rep(13, 10), rep(15, 10), rep(17, 10),
rep(19, 10), rep(21, 10))

momid <- c(rep(0, 5), rep(2, 5), rep(4, 5), rep(6, 5), rep(8, 10),
rep(10, 10), rep(12, 10), rep(14, 10), rep(16, 10), rep(18, 10),
rep(20, 10), rep(22, 10) )

ped <- data.frame(id, dadid, momid)

cfam <- makefamid(ped$id,ped$momid, ped$dadid)

kmat <- makekinship(cfam, ped$id, ped$momid, ped$dadid)

set.seed(3456)

SNPdata <- c(1:1000)

dat <- sample(c(-1,0,1), 10000, replace = TRUE)

snpmat<- data.frame(matrix(dat, ncol = 100))

names(snpmat) <- c(paste ("VR",1:100, sep='' ))

yvar <- rnorm(100, 30, 5)

mydata <- data.frame(trait1, covtrait, snpmat)

fmod <- lmekin(y~ mydata[,i] , data= snpdata, random = ~1|id,
varlist=list(kmat)) $coefficients[2,4] # does not work

Ultimately I want to put into the loop:

for(i in 3:length(snpdata)) {

P <- vector (mode="numeric", length = 1000)

P[i] <- lmekin(trait1~ snpdata[,i] , data= snpdata, random = ~1|id,
varlist=list(kmat)) $coefficients[2,4]

}

Error message:
incorrect number of dimensions
I can extract fixed effects as well as I do in lme4
 b <- fixef(fit1)
Error in UseMethod("fixef") :
  no applicable method for 'fixef' applied to an object of class "lmekin"


--

Ram H



More information about the R-help mailing list