Learn R Programming

lavaSearch2 (version 1.4)

iidJack: Jackknife iid Decomposition from Model Object

Description

Extract iid decomposition (i.e. influence function) from model object.

Usage

iidJack(object, ...)

# S3 method for default iidJack(object, data = NULL, grouping = NULL, cpus = 1, keep.warnings = TRUE, keep.error = TRUE, cl = NULL, trace = TRUE, ...)

Arguments

object

a object containing the model.

...

[internal] only used by the generic method.

data

[data.frame] dataset used to perform the jackknife.

grouping

[vector] variable defining cluster of observations that will be simultaneously removed by the jackknife.

cpus

[integer >0] the number of processors to use. If greater than 1, the fit of the model and the computation of the influence function for each jackknife sample is performed in parallel.

keep.warnings

[logical] keep warning messages obtained when estimating the model with the jackknife samples.

keep.error

[logical]keep error messages obtained when estimating the model with the jackknife samples.

cl

[cluster] a parallel socket cluster generated by parallel::makeCluster that has been registered using registerDoParallel.

trace

[logical] should a progress bar be used to trace the execution of the function

Value

A matrix with in row the samples and in columns the parameters.

Examples

Run this code
# NOT RUN {
n <- 20

#### glm ####
set.seed(10)
m <- lvm(y~x+z)
distribution(m, ~y+z) <- binomial.lvm("logit")
d <- lava::sim(m,n)
g <- glm(y~x+z,data=d,family="binomial")
iid1 <- iidJack(g, cpus = 1)
iid2 <- lava::iid(g)
quantile(iid1-iid2)
vcov(g)
colSums(iid2^2)
colSums(iid1^2)

#### Cox model ####
library(survival)
data(Melanoma, package = "riskRegression")
m <- coxph(Surv(time,status==1)~ici+age, data = Melanoma, x = TRUE, y = TRUE)

# }
# NOT RUN {
## require riskRegression > 1.4.3
if(utils::packageVersion("riskRegression") > "1.4.3"){
library(riskRegression)
iid1 <- iidJack(m)
iid2 <- iidCox(m)$IFbeta

apply(iid1,2,sd)

print(iid2)

apply(iid2,2,sd)
  }
# }
# NOT RUN {
#### LVM ####
set.seed(10)

mSim <- lvm(c(Y1,Y2,Y3,Y4,Y5) ~ 1*eta)
latent(mSim) <- ~eta
categorical(mSim, K=2) <- ~G
transform(mSim, Id ~ eta) <- function(x){1:NROW(x)}
dW <- lava::sim(mSim, n, latent = FALSE)
dL <- reshape2::melt(dW, id.vars = c("G","Id"),
                     variable.name = "time", value.name = "Y")
dL$time <- gsub("Y","",dL$time)

m1 <- lvm(c(Y1,Y2,Y3,Y4,Y5) ~ 1*eta)
latent(m1) <- ~eta
regression(m1) <- eta ~ G
e <- estimate(m1, data = dW)
# }
# NOT RUN {
iid1 <- iidJack(e)
iid2 <- iid(e)
attr(iid2, "bread") <- NULL

apply(iid1,2,sd)
apply(iid2,2,sd)
quantile(iid2 - iid1)
# }
# NOT RUN {
library(nlme)
e2 <- lme(Y~G+time, random = ~1|Id, weights = varIdent(form =~ 1|Id), data = dL)
e2 <- lme(Y~G, random = ~1|Id, data = dL)
# }
# NOT RUN {
iid3 <- iidJack(e2)
apply(iid3,2,sd)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab