Message Boards Message Boards

Failure in reproducing plots in a post

Posted 4 years ago

I am trying to reproduce the plots in this post Finding outliers in 2D and 3D numerical data with my own data.

However, I am new to the Wolfram language (I used to use R). I don't quite understand what's going on in the code. Here're some rows of my data: *I attach the whole dataset at the end enter image description here

I want to create a 3D Quantile Regression envelopes to find the outliers as in the post, with the variables Age, Ratio.bp, and Ratio.heart. However, I can't get any the plots. Here's an example: enter image description here

Here's my code:

testData = N@data[[All, {2, 5, 8}]]; sTestData = Transpose[Standardize /@ Transpose[N@testData]];
Block[{offset = -2 (Min /@ Transpose[sTestData])},    sTestData = Map[# + offset &, sTestData]]; 
opts = {PlotRange -> All, ImageSize -> Medium,     PlotTheme -> "Detailed"}; 
Grid[{{ListPointPlot3D[sTestData, opts],     ListPointPlot3D[sTestData, opts]}}]

What did I do wrong?

I don't know how to upload the file, but I put my file in R and here's the code: https://codeshare.io/alRLNY

I uploaded the csv file: http://www.sharecsv.com/s/3676944d24cb54ae4adcd8d34e0f2435/newdata.csv

Thank you :)

POSTED BY: Solar Chan
5 Replies
Posted 4 years ago

Crossposted here.

POSTED BY: Rohit Namjoshi
Posted 4 years ago

Some problems

The data contains non-numeric values e.g. "NA". You will have to remove those rows or impute the missing values using e.g. SynthesizeMissingValues.

The header row needs to be excluded so

 testData = d[[2 ;;, {2, 5, 8}]]
POSTED BY: Rohit Namjoshi
Posted 4 years ago

Thanks! I removed all the NA rows. but when I run the testData = data[[2 ;;, {2, 5, 8}]] , I got this error -- Part::take: Cannot take positions 2 through -1 in d.

POSTED BY: Solar Chan
Posted 4 years ago

This works fine

d = Import["~/Downloads/new_heart_data.csv"];
testData = d[[2 ;;, {2, 5, 8}]] // Select[FreeQ[#, "NA"] &];
POSTED BY: Rohit Namjoshi
Posted 4 years ago

It works! Do you wanna post this as an answer in StackExchange? So that I can give you an upvote :)

POSTED BY: Solar Chan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract