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 <- quantile[1]
## LTS results with robust residuals
NameC_lts <-
lqs(gpanew~female+female:lastinit+agenew+canadian+mom_ed+yearstudy,
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
--
View this message in context: http://r.789695.n4.nabble.com/Why-can-t-I-figure-this-out-S-tp4162826p4162826.html
Sent from the R help mailing list archive at Nabble.com.
Why can't I figure this out? :S
2 messages · Jasmine007, Brad Patrick Schneid
Why can't you figure this out? I think you already know the answer: "I don't speak computer"..... 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
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 <- quantile[1]
## LTS results with robust residuals
NameC_lts <-
lqs(gpanew~female+female:lastinit+agenew+canadian+mom_ed+yearstudy,
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
-- View this message in context: http://r.789695.n4.nabble.com/Why-can-t-I-figure-this-out-S-tp4162826p4163150.html Sent from the R help mailing list archive at Nabble.com.