Specifying a variable as a random effect in model.matrix()
0
1
Entering edit mode
23 months ago
Curious_Gene ▴ 10

I understand that it is possible to specify variables as fixed effects in R for building a model matrix, for example:

model.matrix(~age-category, data = sample_table)

Is it possible to do the same but with random effects? I want to specify a column called "subject_ID" for a paired analysis as a random effect, but it is currently a factor. The below command throws an error:

model.matrix(~(1 | subject_ID), data = sample_table)

Error in 1 | subject : 
  operations are possible only for numeric, logical or complex types

Is this the right approach? Are there functions other than model.matrix() that can be used to achieve this? For context, I'm trying to build the model matrix before I run SNM for the normalization of expression data. Appreciate any help!

SNM model.matrix R • 556 views
ADD COMMENT
0
Entering edit mode

I am facing the same error.. Have you figured it out?

ADD REPLY

Login before adding your answer.

Traffic: 3042 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6