Statistica clinica

SetDirectory[NotebookDirectory[]];

Visualizzazione variabili

dati={22,9,39};
legenda={"Stadio I","Stadio II","Stadio III"};

BarChart[dati,ChartLabels->legenda,ChartElementFunction->"GlassRectangle",ChartStyle->"Pastel"]

BarChart3D[dati,ChartLabels->legenda,ChartStyle->"Pastel"]

PieChart[dati,ChartLabels->legenda,ChartStyle->"Pastel"]

PieChart3D[dati,ChartLabels->legenda,ChartStyle->"Pastel"]

Quartili e Boxplot

dati=RandomInteger[{-10,10},100]//Sort

Quartiles[dati]

Median[dati[[1;;50]]]

Median[dati]

Median[dati[[51;;100]]]

InterquartileRange[dati]

SmoothHistogram[dati]

BoxWhiskerChart[dati]

Distribuzioni asimmetriche e normali

distr=RandomVariate[PoissonDistribution[10],10^4];
Print["Skewness=",Skewness[distr]//N," Curtosi=",Kurtosis[distr]//N];
Show[
Histogram[distr,Automatic,"ProbabilityDensity"],
SmoothHistogram[distr,Automatic,"PDF"]]

distr=RandomVariate[NormalDistribution[0,1],10^4];
Print["Skewness=",Skewness[distr]//N," Curtosi=",Kurtosis[distr]//N];
Show[
Histogram[distr,Automatic,"ProbabilityDensity"],
SmoothHistogram[distr,Automatic,"PDF"]]

distr=Exp[RandomVariate[NormalDistribution[Log[166],Log[104.22]],2876]];
Print["Skewness=",Skewness[distr]//N," Curtosi=",Kurtosis[distr]//N];
Show[
Histogram[distr,Automatic,"ProbabilityDensity"],
SmoothHistogram[distr,Automatic,"PDF"]]

Print["Skewness=",Skewness[Log[distr]]," Curtosi=",Kurtosis[Log[distr]]," μ=",Mean[Log[distr]]," σ=",StandardDeviation[Log[distr]]];
Show[
Histogram[Log[distr],Automatic,"ProbabilityDensity"],
SmoothHistogram[Log[distr],Automatic,"PDF"]]

Test statistici

?LocationTest

?KolmogorovSmirnovTest

?ShapiroWilkTest

Needs["ANOVA`"];(* per l'analisi della varianza *)

?ANOVA

Correlazione e regressione

?Correlation

?CorrelationTest

m1=RandomVariate[BinormalDistribution[.5],1000];
m2=RandomVariate[BinormalDistribution[-.5],850];
ListPlot[{m1,m2}]
CorrelationTest[m1,m2,{"TestDataTable",All}]