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

B77S bps0002 at auburn.edu
Tue Dec 6 03:28:45 CET 2011

```Why can't you figure this out?

Time to learn, or get another job I suppose.  I hope you at least speak
math-statistics if you are going to attempt to understand this.

The only way you are going to be able to figure that code out is to break it
up into pieces until you DO understand it.  If that is too much work for
you, then ????

Good luck.

Jasmine007 wrote
>
> 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
>
> ## 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 <- quantile[1]
>
> ## 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