design.matrix | R Documentation |
Builds the design matrix for the whole model when the sum-to-zero constraints are specified. The function is called inside model.cons
for Gauss-Legendre quadrature.
design.matrix(
formula,
data.spec,
t1.name,
Z.smf,
Z.tensor,
Z.tint,
list.smf,
list.tensor,
list.tint,
list.rd
)
formula |
formula object identifying the model |
data.spec |
data frame that represents the environment from which the covariate values and knots are to be calculated |
t1.name |
name of the vector of follow-up times |
Z.smf |
List of matrices that represents the sum-to-zero constraint to apply for |
Z.tensor |
List of matrices that represents the sum-to-zero constraint to apply for |
Z.tint |
List of matrices that represents the sum-to-zero constraint to apply for |
list.smf |
List of all smf.smooth.spec objects contained in the model |
list.tensor |
List of all tensor.smooth.spec objects contained in the model |
list.tint |
List of all tint.smooth.spec objects contained in the model |
list.rd |
List of all rd.smooth.spec objects contained in the model |
design matrix for the model
library(survPen)
# standard spline of time with 4 knots
data <- data.frame(time=seq(0,5,length=100),event=1,t0=0)
form <- ~ smf(time,knots=c(0,1,3,5))
t1 <- eval(substitute(time), data)
t0 <- eval(substitute(t0), data)
event <- eval(substitute(event), data)
# Setting up the model
model.c <- model.cons(form,lambda=0,data.spec=data,t1=t1,t1.name="time",
t0=rep(0,100),t0.name="t0",event=event,event.name="event",
expected=NULL,expected.name=NULL,type="overall",n.legendre=20,
cl="survPen(form,data,t1=time,event=event)",beta.ini=NULL)
# Retrieving the sum-to-zero constraint matrices and the list of knots
Z.smf <- model.c$Z.smf ; list.smf <- model.c$list.smf
# Calculating the design matrix
design.M <- design.matrix(form,data.spec=data,t1.name="time",Z.smf=Z.smf,list.smf=list.smf,
Z.tensor=NULL,Z.tint=NULL,list.tensor=NULL,list.tint=NULL,list.rd=NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.