getInformation | R Documentation |
Extract information relative to a parameter.
getInformation(object, ...)
## S3 method for class 'matrix'
getInformation(object, variance, ...)
## S3 method for class 'ttest'
getInformation(object, type = "estimation", variance = NULL, ...)
## S3 method for class 'gls'
getInformation(
object,
name.coef,
data = NULL,
details = FALSE,
newdata = NULL,
variance = NULL,
...
)
## S3 method for class 'lmmGSD'
getInformation(object, newdata = NULL, variance = NULL, timevar = NULL, ...)
object |
a |
... |
not used. For compatibility with the generic details. |
variance |
[NULL, list] If |
type |
[character] Should the information be estimated only for the observed data ( |
name.coef |
[character] For which coefficient the information should be computed (only relevant for gls models). |
details |
[logical] Should intermediate results be output. See details section. |
newdata, data |
[data.frame] The dataset relative to which the information should be computed. See details section. |
weighting |
[logical] Should weight be used to handle missing values in the covariates. |
Argument data: the dataset may contain missing value in the outcome but no in the covariates. Missing value in the outcome indicates that the information is not available at the interim analysis but will be come available at decision.
Argument details: when using gls models, an attribute detail is added to the output which contain a list:
decision: information at decision analysis
interim: information at the interim analysis using all available data
interim.cc: information at the interim analysis using a complete case analysis
n: sample size at decision, interim with complete observation, interim with only partial observations
library(nlme)
n <- 1e2
#### Single endpoint ####
## simulate data
set.seed(10)
X <- rnorm(n)
Y <- rnorm(n)
df <- rbind(data.frame(group=0,value=X),
data.frame(group=1,value=Y))
## t-test
getInformation(ttest(value~1, df[df$group==0,])) ## only work for R>=4.0
getInformation(ttest(x = X)) ## based on the estimate variance
getInformation(ttest(X), variance = 1) ## based on a variance of 1
getInformation(ttest(X), variance = 2) ## based on a variance of 2
getInformation(ttest(rnorm(length(X))), variance = 2) ## note: the X values do not matter here
getInformation(ttest(value~group, data = df))
getInformation(ttest(x = X, Y))
getInformation(ttest(X,Y), variance = 1:2) ## information with a variance of 1 in one group and 2 in the other group
getInformation(ttest(X,Y), variance = c(1,3)) ## information with a variance of 1 in one group and 3 in the other group
## gls
library(nlme)
e1.gls <- gls(value~1, data = df[df$group==0,])
getInformation(e1.gls, name.coef = "(Intercept)")
getInformation(e1.gls, name.coef = "(Intercept)", variance = matrix(1,1,1))
e2.gls <- gls(value~group, data = df, weights = varIdent(form=~1|group))
getInformation(e2.gls, name.coef = "group")
getInformation(e2.gls, name.coef = "group", variance = list(matrix(1,1,1),matrix(2,1,1)))
#### Two endpoints ####
## simulate data
library(mvtnorm)
set.seed(10)
X <- rmvnorm(n, sigma = 0.5 + diag(0.5,2))
Y <- rmvnorm(n, sigma = 0.5 + diag(0.5,2))
df <- rbind(data.frame(id = paste0("id",1:n),group=0,time=0,value=X[,1]),
data.frame(id = paste0("id",1:n),group=0,time=1,value=X[,2]),
data.frame(id = paste0("id",n+1:n),group=1,time=0,value=Y[,1]),
data.frame(id = paste0("id",n+1:n),group=1,time=1,value=Y[,2]))
## gls
e.gls <- gls(value~time-1, data = df[df$group==0,],
correlation = corSymm(form=~1|id),
weights = varIdent(form=~1|time))
getInformation(e.gls, name.coef = "time") ## 1/vcov(e.gls)
getInformation(e.gls, name.coef = "time", variance = list(diag(1:2)))
## with interaction
e.gls <- gls(value~time*group, data = df,
correlation = corSymm(form=~1|id),
weights = varIdent(form=~1|time*group))
getInformation(e.gls, name.coef = "time:group") ## 1/vcov(e.gls)
getInformation(e.gls, name.coef = "time", variance = list(diag(1:2),diag(1:2)))
## with random ordering
df2 <- df[sample.int(NROW(df)),,drop=FALSE]
e2.gls <- gls(value~time*group, data = df2,
correlation = corSymm(form=~1|id),
weights = varIdent(form=~1|time*group))
getInformation(e2.gls, name.coef = "time:group") ## 1/vcov(e2.gls)
getInformation(e.gls, name.coef = "time", variance = list(diag(1:2),diag(1:2)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.