Hi Rob,
rms wants symmetry in the sense that the interactions need to use the
same number and location of spline knots as the main effects. So if
using the * notation omit the main effects (which are generated
automatically) and live with the equal knots. Or use the restricted
interaction operator %ia% to not use doubly nonlinear terms in forming
the interactions, which is a sensible restriction.
Frank
Frank E Harrell Jr Professor and Chairman School of Medicine
Department of Biostatistics Vanderbilt University
On Mon, 2 Aug 2010, Rob James wrote:
> I am encountering an error I do not know how to debug. The error arises
> when I try to add an interaction term involving two continuous
> variables (defined using rcs functions) to an existing (and working) model.
>
> The new model reads:
>
> model5 <- lrm( B_fainting ~ gender+ rcs(exactage, 7) +
> rcs(DW_nadler_bv, 7) + rcs(drawtimefrom8am, 7)+ DW_firsttime+
> DW_race_eth +
> rcs(DW_BPS, 5)+ rcs(DW_BPD, 5)+ rcs(pulse3, 5)+ locat2+
> (rcs(exactage, 3) * rcs(drawtimefrom8am, 3))
> )
>
> This gives rise to the following error:
>
> ----
> Error in dimnames(X)[[2]] <- atr$colnames :
> length of 'dimnames' [2] not equal to array extent
> In addition: Warning message:
> In names(nmiss)[jz] <- fname[asm != 9] :
> number of items to replace is not a multiple of replacement length
> ----
>
> The sessionInfo() output is below, but I think relatively unremarkable.
> The dataset is very large (about 550K observations, although the outcome
> (B_fainting) is relatively sparse with only 1500 events in this
> sample. I do not get this error when the interaction term is replaced
> by two categorical variables (data not shown). I can replicate this
> error when there is just one continuous variable and one categorical
> variable.
>
>
> I'd welcome suggestions. Thank you in advance.
>
>
>
>
>
> sessionInfo()
> R version 2.11.0 (2010-04-22)
> x86_64-pc-linux-gnu
>
> locale:
> [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
> LC_TIME=en_CA.UTF-8
> [4] LC_COLLATE=en_CA.UTF-8 LC_MONETARY=C
> LC_MESSAGES=en_CA.UTF-8
> [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C
> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8
> LC_IDENTIFICATION=C
>
> attached base packages:
> [1] splines stats graphics grDevices utils datasets
> methods base
>
> other attached packages:
> [1] gmodels_2.15.0 rms_3.0-0 Hmisc_3.8-2 survival_2.35-8
> odfWeave_0.7.14 XML_3.1-0
> [7] lattice_0.18-8
>
> loaded via a namespace (and not attached):
> [1] cluster_1.13.1 gdata_2.8.0 grid_2.11.0 gtools_2.6.2 MASS_7.3-7
>
> ______________________________________________
> R-help at 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.
>