[R] Why can't I figure this out? :S

Carl Witthoft carl at witthoft.com
Tue Dec 6 02:12:25 CET 2011

If you 'don't speak computer,' what are you doing trying to run R in the 
first place?
Your email address suggests this is homework, but even if it isn't 
please go talk to your professor or teaching assistant.

From: Jasmine007 <magee20v_at_uregina.ca>
Date: Mon, 05 Dec 2011 16:32:00 -0800 (PST)

Hi, so I don't speak computer and I have no idea what this code is 
telling the program to do, but I apparently need to be able to find and 
isolate influencial observations. Problem, I have no idea what the error 
means and where it may be from in the code.

error I get is below the code

## OLS results

NameC<- lm(gpanew~female+female:lastinit+agenew+canadian+mom_ed+yearstudy)

## default: choose psamp = quantile

n <- length(residuals(NameC))
k <- length(coef(NameC))
if(is.null(quantile)) quantile <- c(floor((n + k + 1)/2), floor((n + k)/2))
quantile <- rep(quantile, length.out = 2) if(is.null(psamp)) psamp <- 

## LTS results with robust residuals

NameC_lts <-
quantile = quantile[1], psamp = psamp, nsamp = nsamp) rr <- 
residuals(NameC_lts)/NameC_lts$scale[2] rr_nok <- abs(rr) > critval[1]
## robust leverage via MCD (or MVE)

X <- model.matrix(NameC)[,-1]
cv <- cov.rob(X, method = method,
quantile = quantile[2], nsamp = dist_nsamp) rd <- sqrt(mahalanobis(X, 
cv$center, cv$cov)) rd_nok <- rd > critval[2]
## ROBUST results

nok <- rr_nok & rd_nok
NameC_rob <- lm(formula, data[!nok,])
rval <- list(ols = NameC, lts = NameC_lts, robust = NameC_rob, cov.rob = 
cv, robresid = rr, robdist = rd, high_residuals = rr[rr_nok], 
high_leverage = rd[rd_nok], bad_leverage = nok, psamp = psamp, method = 
method, nsamp = list(lts = nsamp, dist = dist_nsamp), quantile = 
list(lts = quantile[1], dist = quantile[2])) return(rval)

Error: object of type 'closure' is not subsettable

Any ideas, In plain non-computer language.. I have a headache from 
trying to figure out if this question had been answered before.

Thank you

Sent from my Cray XK6
"Pendeo-navem mei anguillae plena est."

More information about the R-help mailing list