Distance Matrix
Example 1
Summary: Creates a distance matrix from an open data table in JMP.
Code:
Open("data_table.jmp");
Distance Matrix();
Code Explanation:
- Open data table;
- Create distance matrix.
Example 2
Summary: Creates a distance matrix from an open data table.
Code:
dt = Open("data_table.jmp");
dt << Distance Matrix();
Code Explanation:
- Open data table;
- Create distance matrix.
Example 3
Summary: Creates a distance matrix from a data table, allowing for interactive exploration and analysis.
Code:
Open("data_table.jmp");
Distance Matrix();
dt = Open("data_table.jmp");
dt << Distance Matrix();
dt = Open("data_table.jmp");
Code Explanation:
- Open data table;
- Create distance matrix.
- Open data table;
- Create distance matrix on dataset.
- Open data table;
Example 4
Summary: Creates a distance matrix using height and weight columns, replacing missing values with zero and applying a local data filter by weight.
Code:
Open("data_table.jmp");
Distance Matrix( Y( :height, :weight ), Missing Value Imputation( 0 ), Local Data Filter( Add Filter( columns( :weight ) ) ) );
Code Explanation:
- Open data table;
- Create distance matrix.
- Use height and weight columns.
- Replace missing values with zero.
- Add local data filter.
- Filter by weight column.
Example 5
Summary: Creates a distance matrix for height and weight, with missing values imputed to 0, and filters data by height range using Local Data Filter, ultimately generating a report.
Code:
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :height, :weight ), Missing Value Imputation( 0 ), );
ldf = obj << Local Data Filter( Add Filter( columns( :height ), Where( :height >= 56.1 & :height <= 58.2 ) ) );
rpt = obj << report;
Code Explanation:
- Open data table;
- Create distance matrix for height and weight.
- Set missing values to 0.
- Add local data filter.
- Filter height between 56.1 and 58.2.
- Generate report from distance matrix.
Example 6
Summary: Creates a distance matrix with missing value imputation and local data filtering for both height and weight columns, generating a report.
Code:
Open("data_table.jmp");
Distance Matrix( Y( :height, :weight ), Missing Value Imputation( 0 ), Local Data Filter( Add Filter( columns( :weight ) ) ) );
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :height, :weight ), Missing Value Imputation( 0 ), );
ldf = obj << Local Data Filter( Add Filter( columns( :height ), Where( :height >= 56.1 & :height <= 58.2 ) ) );
rpt = obj << report;
Code Explanation:
- Open data table;
- Create distance matrix.
- Impute missing values with 0.
- Add local data filter for weight.
- Open data table;
- Create distance matrix.
- Impute missing values with 0.
- Add local data filter for height.
- Set filter criteria for height.
- Generate report.
Example 7
Summary: Creates a distance matrix from a data table, selecting specific columns and filtering by species 'setosa'.
Code:
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Where( :species == "setosa" ) );
Code Explanation:
- Open data table;
- Create distance matrix.
- Select Sepal length.
- Select Sepal width.
- Select Petal length.
- Select Petal width.
- Filter species: setosa.
Example 8
Summary: Creates a distance matrix using Sepal length, Sepal width, Petal length, and Petal width variables from an open data table.
Code:
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Create New Tables for Results( 1 ) );
Code Explanation:
- Open data table;
- Create distance matrix.
- Use Sepal length.
- Use Sepal width.
- Use Petal length.
- Use Petal width.
- Generate new tables.
Example 9
Summary: Creates a distance matrix object using the Bray-Curtis method, selecting variables from an open data table.
Code:
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Method( "Bray-Curtis" ), );
Code Explanation:
- Open data table;
- Create distance matrix object.
- Select variables for analysis.
- Use Bray-Curtis method.
Example 10
Summary: Creates a distance matrix object from a data table, utilizing missing value imputation and incorporating Sepal length, Sepal width, Petal length, and Petal width variables.
Code:
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Missing Value Imputation( 1 ) );
Code Explanation:
- Open data table;
- Create distance matrix object.
- Use Sepal length variable.
- Use Sepal width variable.
- Use Petal length variable.
- Use Petal width variable.
- Enable missing value imputation.
Example 11
Summary: Creates a distance matrix using height and weight variables, with sex as the categorical predictor, and imputes missing values with 0, while filtering data by the weight column.
Code:
Open("data_table.jmp");
Distance Matrix( Y( :height, :weight ), X( :sex ), Missing Value Imputation( 0 ), Local Data Filter( Add Filter( columns( :weight ) ) ) );
Code Explanation:
- Open data table;
- Create Distance Matrix.
- Use height and weight for Y.
- Use sex for X.
- Impute missing values with 0.
- Add local data filter.
- Filter by weight column.
Example 12
Summary: Creates a distance matrix from a data table, filtering by height range and generating a report.
Code:
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :height, :weight ), X( :sex ), Missing Value Imputation( 0 ), Number of Permutations( 5000 ) );
ldf = obj << Local Data Filter( Add Filter( columns( :height ), Where( :height >= 56.1 & :height <= 58.2 ) ) );
rpt = obj << report;
Code Explanation:
- Open data table;
- Create distance matrix.
- Set Y variables: height, weight.
- Set X variable: sex.
- Impute missing values as 0.
- Set number of permutations to 5000.
- Add local data filter.
- Filter height between 56.1 and 58.2.
- Generate report.
Example 13
Summary: Creates a distance matrix with height and weight variables, grouped by sex, and imputes missing values using 0. It also adds a local filter for height within a specific range.
Code:
Open("data_table.jmp");
Distance Matrix( Y( :height, :weight ), X( :sex ), Missing Value Imputation( 0 ), Local Data Filter( Add Filter( columns( :weight ) ) ) );
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :height, :weight ), X( :sex ), Missing Value Imputation( 0 ), Number of Permutations( 5000 ) );
ldf = obj << Local Data Filter( Add Filter( columns( :height ), Where( :height >= 56.1 & :height <= 58.2 ) ) );
rpt = obj << report;
Code Explanation:
- Open data table;
- Create distance matrix with height, weight.
- Set sex as grouping variable.
- Impute missing values with 0.
- Add local filter for weight.
- Reopen sample data file.
- Create distance matrix with height, weight.
- Set sex as grouping variable.
- Impute missing values with 0.
- Perform 5000 permutations.
Distance Matrix using If
Example 1
Summary: Creates distance matrices for multiple methods and imputation choices in JMP Pro, utilizing a nested loop structure to iterate through combinations.
Code:
If( Contains( JMP Product Name(), "Pro" ),
MethodChoice = {"Euclidian", "Manhattan", "Gower", "Bray-Curtis", "Jaccard", "Binary", "Hamming"};
ImputChoice = {1};
nMethod = If( Contains( JMP Product Name(), "Pro" ),
N Items( MethodChoice ),
N Items( MethodChoice ) - 1
);
nChoice = N Items( ImputChoice );
For( i = 1, i <= nMethod, i++,
For( j = 1, j <= nChoice, j++,
dt = Open("data_table.jmp");
dt[[1 3 5 6], [2 3]] = dt[[2 4 7 8 9 10], [1 4]] = .;
pca = dt << Distance Matrix(
Y( :Sepal length, :Sepal width, :Petal length, :Petal width ),
Method( MethodChoice[i] ),
Missing Value Imputation( ImputChoice[j] ),
);
Close( dt, nosave );
)
);
);
Code Explanation:
- Check if JMP Pro.
- Define method choices.
- Define imputation choices.
- Set number of methods.
- Set number of imputations.
- Loop through each method.
- Loop through each imputation.
- Open data table;
- Introduce missing values.
- Create distance matrix.
- Close dataset without saving.
Example 2
Summary: Creates a distance matrix and report in JMP Pro, utilizing Local Data Filter for filtering by height range.
Code:
If( Contains( JMP Product Name(), "Pro" ),
Open("data_table.jmp");
Distance Matrix( Y( :height, :weight ), Missing Value Imputation( 0 ), Local Data Filter( Add Filter( columns( :weight ) ) ) );
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :height, :weight ), Missing Value Imputation( 0 ), );
ldf = obj << Local Data Filter( Add Filter( columns( :height ), Where( :height >= 56.1 & :height <= 58.2 ) ) );
rpt = obj << report;
Close( dt, nosave );
);
Code Explanation:
- Check if JMP is Pro.
- Open data table;
- Create Distance Matrix.
- Open data table;
- Create Distance Matrix object.
- Add Local Data Filter for weight.
- Generate report.
- Close "data_table.jmp" without saving.
Example 3
Summary: Runs data table operations to create a distance matrix and capture log output, utilizing the Log Capture function in JMP Pro.
Code:
If( Contains( JMP Product Name(), "Pro" ),
dt = Open("data_table.jmp");
dt << Lock Data Table;
LC = Log Capture( obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ) ) );
);
Code Explanation:
- Check if JMP is Pro.
- Open data table;
- Lock the data table.
- Create distance matrix.
- Capture log output.
Example 4
Summary: Creates and customizes a distance matrix in JMP, utilizing various options such as species selection, method choice, and missing value imputation.
Code:
If( Contains( JMP Product Name(), "Pro" ),
dt = Open("data_table.jmp");
test = Is Scriptable( obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ) ) );
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Where( :species == "setosa" ) );
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Create New Tables for Results( 1 ) );
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Method( "Bray-Curtis" ), );
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Missing Value Imputation( 1 ) );
);
Code Explanation:
- Check if JMP Pro is installed.
- Open data table;
- Check scriptability of Distance Matrix.
- Reopen data_table dataset
- Create Distance Matrix for setosa species.
- Reopen data_table dataset
- Create new tables for results.
- Reopen data_table dataset
- Use Bray-Curtis method.
- Handle missing values with imputation.
Example 5
Summary: Creates and filters a distance matrix in JMP Pro, utilizing local data filters to refine results.
Code:
If( Contains( JMP Product Name(), "Pro" ),
Open("data_table.jmp");
Distance Matrix(
Y( :height, :weight ),
X( :sex ),
Missing Value Imputation( 0 ),
Local Data Filter( Add Filter( columns( :weight ) ) )
);
dt = Open("data_table.jmp");
obj = dt << Distance Matrix( Y( :height, :weight ), X( :sex ), Missing Value Imputation( 0 ), Number of Permutations( 5000 ) );
ldf = obj << Local Data Filter( Add Filter( columns( :height ), Where( :height >= 56.1 & :height <= 58.2 ) ) );
rpt = obj << report;
);
Code Explanation:
- Check if JMP Pro.
- Open data_table data
- Create distance matrix.
- Set Y variables.
- Set X variable.
- Impute missing values.
- Add local filter.
- Open data_table data again.
- Create distance matrix with permutations.
- Set Y variable for filter.
- Apply height filter.
- Generate report.