Consider the following two specifications of a model:

library( splines )
x <- 1:100
y <- rnorm( 100 )
w <- rep( 1, 100 )
A <- factor( sample( 1:2, 100, replace=T ) )
B <- factor( sample( letters[1:4], 100, replace=T ) )
summary( lm( y ~ ns( x, knots=c(30, 50, 70 ), intercept=T ):A - 1 + B )
)
summary( lm( y ~ ns( x, knots=c(30, 50, 70 ), intercept=T ):A - 1 + B:w
) )

The interaction with the constant variable w is how I got to have the
two spline terms as "proper" intercept terms.

Is there another way to do this, or is it a featur of the model formulae
that lower order terms appear before higher order terms regardless of
the
order they are specified in the model?

Bendix Carstensen
----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 30 75 87 38
fax: +45 44 43 07 06
[EMAIL PROTECTED]
www.biostat.ku.dk/~bxc

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to