SAS homogeneity of variance - statistics

I have different categorical data in which are CLASS and I want to test homogeneity of variance using Proc GML and it doesn't display the output of the test
Proc GLM DATA=MYLIB.musictask;
CLASS TASK Music_Type Child_number_ID;
MODEL Emotional_state = Task Music_Type Child_number_ID Task*Music_Type Task*Child_number_ID Music_Type*Child_number_ID;
Means TASK Music_Type Child_number_ID/ hovtest=levene;
run;
quit;

You need to define an ODS Output statement. The ODS table names for Proc GLM include Bartlett, which is the test underlying the HOVTEST= option. So, add these lines to your code:
ods output bartlett=hovtestoutput;
run;
proc print data=hovtestoutput;
run;
Or something like that.

Related

How to use a Weka model to print prediction in an excel column

I would like to use the classification model I've created in Weka in excel. Is that possible?
The classification model uses the SimpleLogistic function. In Weka, it prints out the prediction for each row in a beautiful way. I would like to have exactly those predictions as a column in excel without opening Weka.
Is it possible to export some sort of formula in Weka, that I can use it excel?
Weka printed out some the following formula, but apparently it is not the prediction.
Class Problem :
-7.15 +
[A] * -143.53 +
[B] * -15.74 +
[D] * 176.96 +
[E] * -1.67
Class NoProblem :
-7.15 +
[A] * -143.53 +
[B] * -15.74 +
[D] * 176.96 +
[E] * 1.67
Thanks.
No. Weka models are Java objects and need to be used from a Java context.
Apart from LinearRegression, most models cannot be easily expressed with simple formulas, hence there is no export of models to spreadsheet applications like LibreOffice Calc or MS Excel available.
If you just want the predictions, but in a format that is easier to use in a spreadsheet application, then you could output them in a CSV file:
on the Classify tab
click on the More options button
select CSV for Output predictions
specify the CSV file you want to store the predictions in
check suppressOutput if you do not want the predictions to be output in the user interface as well (they will still be output to the file)
click on the Start button

Writing floats into a csv file but floats become a string

I am writing a dataframe into a csv as follows:
appended_Dimension.to_csv("outputDimension.csv")
The dataframe is as follows:
Cameroun Rwanda Niger Zambia Mali Angola Ethiopia
ECON 0.056983 0.064422 0.047602 0.070119 0.048395 0.059233 0.085559
FOOD 0.058250 0.046348 0.048849 0.043527 0.049064 0.013157 0.081436
ENV 0.013906 0.004013 0.010519 0.001973 0.005360 0.023010 0.008469
HEA 0.041496 0.078403 0.040154 0.054466 0.029954 0.053007 0.061761
PERS 0.056687 0.021978 0.062655 0.056477 0.087056 0.089886 0.043747
The output is as follows:
I d like to write data in a float format so i can process it in csv directly. How can i do that please?
You cannot keep it as float inside the csv. The csv will treat everything as strings. You must load your data from the csv and perform the relevant operations then save it back. You cannot manipulate it while it is present inside the csv.

how to method chain describe(), value_counts(), and to_csv()

Here is my code
#import modules
import pandas as pd
#assign pd.read_csv() to infile to read in data from a datafile
infile = pd.read_csv('..\Infiles\\StarWars_Data.txt')
#get user input for selecting a Series name
Series_name = input("please enter the name of one of the series's for closer inspection")
#Select the Series
Series_Data = infile[Series_name]
#Chain the value_counts(), and describe() and to_csv() methods
Series_Data.value_counts()\
.describe()\
.to_csv('..\Outfiles\StarWars_Results.txt')
I expect it to perform value_counts() (returns the numbers of unique values in a series), describe() (gives summary statistics on a series), and to_csv(writes what is stored into a specified csv file).
For some reason to_csv() is returning describe() but it is not returning value_counts(), how do I write the data from both value_counts() and describe() to the same document?
IIUC, do you want?
pd.concat([df['words'].value_counts(),
df['words'].describe()])\
.to_csv('..\Outfiles\StarWars_Results.txt')
MCVE:
s = pd.Series([*'AABBBBCDDEEEEEEE'])
pd.concat([s.value_counts(), s.describe()]).rename_axis('key').to_csv('a.text')
!type a.txt
Output:
key,0
E,7
B,4
A,2
D,2
C,1
count,16
unique,5
top,E
freq,7

Output simple T-Test stats to SAS dataset

I am aware this is a very naive question, however I am trying to find a way to export T-Test statistics to a simple output dataset. For example, I have the following code being run now:
proc ttest plots(only) = (summary) data = work.mydf;
options orientation = landscape;
class byvar;
var var1 var2;
ods output statistics = outputdf;
by UNIT_ID;
run;
The ods output statistics = outputdf yields a dataset with upper an lower confidence intervals, mean of the two groups, upper and lower limit of STD...etc.
I need a dataset with p-values from the test of equality of variances. Any help is appreciated.
The way you answer this is typically to add
ods trace on;
before you run it once. Then the log will report all of the different tables that the proc outputs, and you can add ods output statements for them.
In this case you see, among other things in the log:
Output Added:
-------------
Name: Equality
Label: Equality of Variances
Template: Stat.TTest.Equality
Path: Ttest.MPG_Highway.Equality
This means you need to add equality (the Name: above) to your ods output statement and give it a dataset name to output to.
ods output statistics = outputdf equality=outputeq;

Using lbsvm in Matlab with Excel data

My data are in Excel, so to convert them in Libsvm format, I convert the Excel sheet to CSV format and follow the procedure on Libsvm web site:- assuming the CSV file is SPECTF.train : -
matlab> SPECTF = csvread('SPECTF.train'); % read a csv file
matlab> labels = SPECTF(:, 1); % labels from the 1st column
matlab> features = SPECTF(:, 2:end);
matlab> features_sparse = sparse(features); % features must be in a
sparse matrix
matlab> libsvmwrite('SPECTFlibsvm.train', labels, features_sparse);
Then I read it using libsvmread (name)
Is there a shorter way to format excel data in Libsvm format directly? Thanks.
I don't think there is a need to convert to csv. You can use xlsread to read the data directly from the excel file and use libsvmwrite to get that in the form compatible with libsvm.

Resources