In R, how do I find outliers in a multivariate regression?
My dataset is called "data" and my model name is m1. It includes 3 variables, called Rating, Reviews, and Mgb. Reviews is an integer value, whereas Rating and Mgb are both float values. My data is in a .csv format excel spreadsheet.
For a homework assignment, I need to find which rows in the spreadsheet are outliers without editing them in any way. In the next two questions, I need to find high leverage points and find influential points using Cook's distance. (I've already done that last one.) How do I do the first two?
See also questions close to this topic

How to draw a response surface plot for three factorial design?
I have created a three factorial design with two levels (Low & high) using Rstudio. My factors are:
 Type of catalyst (T300 coded as 1, TG300 coded as +1) (Categorical)
 Loading of TiO2 (0.1 g/L coded as 1, 1.0 g/L coded as +1) (Numerical)
 Hydrogen peroxide dose (2.5 mL coded as 1, 10 mL coded as +1) (Numerical)
Outcome variable is "
% Degradation of Gallic acid
"My prediction model is:
water < lm(y ~ C + S + T + C*T + C*S + S*T + C*T*S)
or
C < T < S < c(1, +1) design < expand.grid(C=C, T=T, S=S) C < design$C T < design$T S < design$S y < c(50, 46, 39, 36, 75, 73, 52, 55)
My question is how to draw a response surface plot for my model?

R Shiny: slickR select event
The slickR package has a
focusOnSelect
option  when clicking on an image in the carousel, it is highlighted. How can I access the selection event to use in R Shiny to trigger other actions? Specifically, I want to click on an image and have it update a textbox with the image name.To use the example below, put 3 images (image1.jpg, image2.jpg, image3.jpg) in the same directory as the app.
library(shiny) ui < shiny::basicPage( slickROutput("my_slick",width='100%',height='200px') ) server < function(input, output) { output$my_slick < renderSlickR({ my_images < c("image1.jpg", "image2.jpg", "image3.jpg") slickR( my_images, slideId = 'slick_images', width='90%' ) }) } shinyApp(ui, server)

fix() error with XQuartz cannot be solved
I was following this extremely easy example from ISLR book,
I used fix() for the first time (I usually just used head()), and I got the first error... I followed the error and went to xquartz.macosforge.org and installed it, and then I got the second error "X11 dataentry cannot be loaded"
I thought fix() was part of base... why I am I getting two different errors? Why is XQuartz needed for an R base function?

mlr: Define own Preprocessing Wrapper for Outlier Detection
I am struggling with defining a new preprocessingWrapper for Outlier Detection based on the given example in the mlrtutorial: [https://mlr.mlrorg.com/articles/tutorial/preproc.html#preprocessingwithmakepreprocwrappercaret][1]
What I am concretely trying to do is to integrate an outlier detection based on the Median Absolute Deviation (MAD) as a robust outlier measure. I have written a DoubleMADsFromMedian()function that I use in a forloop to identify outliers in every featurecolumn and set the identifed outliercells to "NA".
I started with the following train & predictfunctions:
trainfun = function(data, target, args = crit) { for (element in data){ vec_temp < as.numeric(data$element) outlier < DoubleMADsFromMedian(vec_temp)>crit outlier < as.data.frame(outlier) df < cbind(vec_temp,outlier) df < df %>% mutate(vec_temp = replace(vec_temp, outlier==TRUE, NA)) %>% data.frame()%>% select(.data$vec_temp ) } # Store the outlier parameter in control # These are needed to preprocess the data before prediction control = args if (is.logical(control$crit) && control$crit) control$crit = attr(x, "outlier:crit") data = as.data.frame(df) return(list(data = data, control = control)) } predictfun = function(data, target, args, control) { data = crit(data, outlier = control$crit) data = as.data.frame(data) return(data) }
After that, I defined the preprocessingWrapper like that:
lrn = makePreprocWrapper(lrn, train = trainfun, predict = predictfun, par.set=makeParamSet(makeIntegerParam("crit")), par.vals =list("crit"=4))
However, I am getting the following error:
Error in .learner$train(data = getTaskData(.task, .subset, functionals.as = "matrix"), : object 'crit' not found
Since I do not want to tune the MADbased outliercriterion, I am wondering how to define the "args" and "control" arguments of the train/ predictfunction in the mlrpackage? Moreover, I think I must have made several mistakes in my train and predictfunctions?

Syntax error with tsoutliers package using Nile dataset
I'm trying to locate outliers in a time series using the tsoutliers package.
I'm using the classic Nile dataset (which you can find here: https://vincentarelbundock.github.io/Rdatasets/datasets.html) and I'm unsucessfully getting the tso() function to work.
My code is:
nile.outliers < tso(Nile,types = c("AO","LS","TC"))
However, I get this syntax error, or what I assume is a syntax error:
Error in tso0(x = y, xreg = xreg, cval = cval, delta = delta, n.start = n.start, : trying to get slot "y" from an object (class "data.frame") that is not an S4 object
If anyone can help me figure out this problem that would be amazing! Thanks!

Use the DBSCAN algorithm on data
I'm trying to apply the
DBSCAN
algorithm on a small dataframe to make outlier prediction after. All the columns have numeric values but I keep getting the same error even though I have no null values.This is my code to call the algorithm:
db = DBSCAN(eps=0.09, min_samples=10).fit(dfc) m = loop.LocalOutlierProbability(dfc).fit() scores_noclust = m.local_outlier_probabilities m_clust = loop.LocalOutlierProbability(dfc, cluster_labels=list(db.labels_)).fit() scores_clust = m_clust.local_outlier_probabilities print(list(scores_clust))
I get this error:
ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
I donĀ“t understand why, since I have no null values.