Message Boards Message Boards

GROUPS:

Failure in reproducing plots in a post

Posted 9 months ago
765 Views
|
5 Replies
|
0 Total Likes
|

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 :)

5 Replies
Posted 9 months 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 9 months 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 9 months ago

This works fine

d = Import["~/Downloads/new_heart_data.csv"];
testData = d[[2 ;;, {2, 5, 8}]] // Select[FreeQ[#, "NA"] &];
Posted 9 months ago

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

Posted 9 months ago

Crossposted here.

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