#Load and assign data data.Fram<-as.matrix(read.table(file="Framinghamdata.txt")) W1 <-data.Fram[,1] W <- W1 W2 <-data.Fram[,2] Z <-data.Fram[,3] chd <-data.Fram[,4] # Compute the measurement error variance sigmasqu <- var(W1-W2) / 2 # Run the naive logistic regression naive.model <- glm(chd ~ Z + W, family = binomial(link="logit"), x=TRUE) # Run SIMEX with B = 100 replicates. Use the quadratic extrapolantRsimex simex.model <- simex(model = naive.model, SIMEXvariable = "W", measurement.error = sqrt(sigmasqu), lambda = c(0.5,1.0,1.5,2.0), B=100, fitting.method = "quad") # Plot the SIMEX trace plot plot(simex.model,mfrow = c(2,2)) # Give the SIMEX values for all lambda simex.model$SIMEX.estimates # Give the jackknife variance estimates simex.model$variance.jackknife # Give the results of the naive model simex.model$model