s-news
[Top] [All Lists]

model.matrix and ~ 1

To: s-news@wubios.wustl.edu
Subject: model.matrix and ~ 1
From: Steve Buyske <buyske@stat.rutgers.edu>
Date: Tue, 31 Jul 2001 11:00:26 -0400
I have some functions that include a call
        model.matrix(temp.formula, data)
where temp.formula is determined previously. Typically, temp.formula is something like " ~ age " and everything works dandy. Occasionally, temp.formula is simply " ~ 1 " (i.e., intercept only), and then I get the error: Error in model.matrix.default ( ~ 1, data = mmlcr..: Length of variable 1 is 1 != length of row names (750)

If I were to get the column of 1's that I expected, the rest of the function would work just fine. Any suggestions to work around this? There are lots of reasons why a user might use formula = ~ 1, so if I have to change the formula used I'll have to have some way of detecting that the user has put in formula = ~ 1

Thanks,
Steve Buyske
Rutgers University Statistics Department

<Prev in Thread] Current Thread [Next in Thread>
  • model.matrix and ~ 1, Steve Buyske <=