Anteprima
Vedrai una selezione di 8 pagine su 34
Fondamenti di biostatistica - Esercitazioni tramite Matlab Pag. 1 Fondamenti di biostatistica - Esercitazioni tramite Matlab Pag. 2
Anteprima di 8 pagg. su 34.
Scarica il documento per vederlo tutto.
Fondamenti di biostatistica - Esercitazioni tramite Matlab Pag. 6
Anteprima di 8 pagg. su 34.
Scarica il documento per vederlo tutto.
Fondamenti di biostatistica - Esercitazioni tramite Matlab Pag. 11
Anteprima di 8 pagg. su 34.
Scarica il documento per vederlo tutto.
Fondamenti di biostatistica - Esercitazioni tramite Matlab Pag. 16
Anteprima di 8 pagg. su 34.
Scarica il documento per vederlo tutto.
Fondamenti di biostatistica - Esercitazioni tramite Matlab Pag. 21
Anteprima di 8 pagg. su 34.
Scarica il documento per vederlo tutto.
Fondamenti di biostatistica - Esercitazioni tramite Matlab Pag. 26
Anteprima di 8 pagg. su 34.
Scarica il documento per vederlo tutto.
Fondamenti di biostatistica - Esercitazioni tramite Matlab Pag. 31
1 su 34
D/illustrazione/soddisfatti o rimborsati
Disdici quando
vuoi
Acquista con carta
o PayPal
Scarica i documenti
tutte le volte che vuoi
Estratto del documento

ESERCITAZIONE QUATTRO: VARIABILI CASUALI CONTINUE

1) La temperatura della camera di sterilizzazione di una unifcdf(128,120,140)

sterilizzatrice

si distribuisce in modo uniforme tra 120 °C e 140°C. ans =

Calcolare la

probabilità che osservando la temperatura in un 0.4000

determinato istante,

questa non superi 128°C. pdf esegue la densità di 128

nel continuo 128 incluso o escluso non importa, > o >=

la probabilità è la stessa (127,999999)

2) Il tempo di vita di una cellula si distribuisce come una p=normcdf(7,5,1.5)-normcdf(4,5,1.5)

normale di p= 0.6563

media 5 giorni e scarto quadratico 1.5 giorni. Calcolare

la probabilità il terzo parametro chiede la deviazione standard non la

che il tempo di vita della cellula sia compreso tra 4 e 7 varianza (prendere la radice quadrata)

giorni. il tempo è continuo pur essendo espresso in giorni

quindi la cellula può vivere 4,00001 gg

non escludo né il 4 né il 7

3) Si considerino ora 5 cellule dell'esercizio precedente. p1=1-normcdf(6,5,1.5)

Calcolare la p2=1-binocdf(2,5,p1)

probabilità che almeno 3 vivano più di 6 giorni. p1 =

0.2525

p2 =

0.1062

entrano in gioco sia il continuo che il discreto

almeno 3 vivano: 3,4,5

più di 6 gg: maggiore di 6

unifcdf(30,20,50)

4) Il tempo di esecuzione di un esame universitario si

distribuisce ans =

secondo una variabile casuale uniforme compresa tra 0.3333

20 e 50 minuti. Quale

è la probabilità che lo studente finisca l'esame in meno mezz’ora: 30 min

di mezz'ora? 1/3

5) Il tempo di esecuzione di un esame universitario si t=norminv(0.98,30,5)

t = 40.27

distribuisce

secondo una Normale di media 30 minuti e varianza 25 problema inverso

minuti^2. A quanto è sigma=(varianza)^1/2=5

necessario fissare il tempo di consegna affinché solo il funzione inversa data in input una probabilità trovare

2% degli studenti una x

non finisca l'esame in tempo? il risultato è il tempo di consegna affinché solo il 2%

degli studenti consegna senza aver finito

se avessi messo 0.02 il risultato sarebbe stato molto più

basso della media

%% Tool di visualizzazione variabili casuali

disttool

a differenza del discreto la variabile casuale

continua da utilizzare deve essere fornita

uniform y = unifpdf(x,a,b) returns the pdf of the continuous

uniform distribution on the interval [a, b], evaluated

at the values in x.

p = unifcdf(x,a,b)

ESERCITAZIONE 5:

INTERVALLI DI CONFIDENZA

Supponiamo che la tabella Hospital sia una popolazione infinita

%Ciascuna colonna (carattere) del

dataset hospital è vista come

%campione estratto da una

popolazione con determinati

parametri da stimare inferenza statistica possiamo farla solo se conosciamo la

%Esercizio: stimare gli intervalli di distribuzione della popolazione (in questo caso normale)

confidenza per media e varianza del

%carattere peso (comando normfit).

Fissare alpha=5%. [mu_hat,sigma_hat,mu_ci,sigma_ci]=normfit(hospital.Weight)

i comandi MatLab assumono sempre 5% come valore di

alpha deviazione standard

estremi della media

ampiezza di un intervallo = differenza tra i due limiti

varianza di un intervallo = differenza tra i due estremi al

quadrato

normfit

Normal parameter estimates [muHat,sigmaHat] = normfit(x)

returns estimates of normal distribution parameters (the

mean muHat and standard deviation sigmaHat), given the

sample data in x. muHat is the sample mean, and sigmaHat

is the square root of the unbiased estimator of the variance.

[muHat,sigmaHat,muCI,sigmaCI] = normfit(x)

also returns 95% confidence intervals for the parameter

estimates on the mean and standard deviation in the arrays

muCI and sigmaCI, respectively.

[muHat,sigmaHat,muCI,sigmaCI] = normfit(x,alpha)

specifies the confidence level for the confidence intervals to

be 100(1–alpha)%.

[___] = normfit(x,alpha,censoring)

specifies whether each value in x is right-censored or not.

Use the logical vector censoring in which 1 indicates

observations that are right-censored and 0 indicates

observations that are fully observed. With censoring, muHat

and sigmaHat are the maximum likelihood estimates (MLEs).

[___] = normfit(x,alpha,censoring,freq)

specifies the frequency or weights of observations.

[___] = normfit(x,alpha,censoring,freq,options)

specifies optimization options for the iterative algorithm

normfit to use to compute MLEs with censoring. Create

options by using the function statset.

You can pass in [] for alpha, censoring, and freq to use their

default values.

%Esercizio: stimare l'intervallo di alpha=0.05;

confidenza del parametro pi-greco per n=sum(hospital.Smoker);

%il carattere fumatore. Fissare N=length(hospital.Smoker);

alpha=1%. [pi_hat,pi_ci]=binofit(n,N,alpha)

pi greco di una popolazioe Bernoulliana

binofit phat = binofit(x,n)

Binomial parameter estimates returns a maximum likelihood estimate of the probability of

success in a given binomial trial based on the number of

This example generates a binomial successes, x, observed in n independent trials. If x = (x(1),

sample of 100 elements, where the x(2), ... x(k)) is a vector, binofit returns a vector of the same

probability of success in a given trial size as x whose ith entry is the parameter estimate for x(i). All

is 0.6, and then estimates this k estimates are independent of each other. If n = (n(1), n(2),

probability from the outcomes in the ..., n(k)) is a vector of the same size as x, the binomial fit,

sample. binofit, returns a vector whose ith entry is the parameter

estimate based on the number of successes x(i) in n(i)

r = binornd(100,0.6); independent trials. A scalar value for x or n is expanded to

[phat,pci] = binofit(r,100) the same size as the other input.

phat =

0.5800 [phat,pci] = binofit(x,n)

pci = returns the probability estimate, phat, and the 95%

0.4771 0.6780 confidence intervals, pci. binofit uses the Clopper-Pearson

method to calculate confidence intervals.

The 95% confidence interval, pci,

contains the true value, 0.6. [phat,pci] = binofit(x,n,alpha)

returns the 100(1 - alpha)% confidence intervals. For

example, alpha = 0.01 yields 99% confidence intervals.

TEST D’IPOTESI

%Esercizio: effettuare un test [h,pv]=ttest(hospital.Weight,155,'Alpha',0.01,'tail','right')

d'ipotesi sul carattere peso

ipotizzando che

%sulla popolazione il peso medio sia

155 contro l'ipotesi alternativa che

%sia maggiore. Fissare alpha=0.01 e

valutare il p-value. output sono h e pvalue

h=0 accetta

pvalue molto più grande di alpha -> accetto h0

[h,pv]=ttest(hospital.Weight,1800,'Alpha',0.01,'tail','right')

accetta h0

ipotesi nulla 1800kg

l’ipotesi alternativa è che il peso sia > 1800

[h,pv]=ttest(hospital.Weight,180,'Alpha',0.01,'tail','left')

rifiuto h0

pvalue è un numero molto piccolo

ipotizzo che sia 180 (la media è 154 del peso medio del

campione di 100 pazienti)

ttest

One-sample and paired-sample t-test h = ttest(x)

returns a test decision for the null hypothesis that the data in x

comes from a normal distribution with mean equal to zero and

unknown variance, using the one-sample t-test. The

alternative hypothesis is that the population distribution does

not have a mean equal to zero. The result h is 1 if the test

rejects the null hypothesis at the 5% significance level, and 0

otherwise.

h = ttest(x,y)

returns a test decision for the null hypothesis that the data in x

– y comes from a normal distribution with mean equal to zero

and unknown variance, using the paired-sample t-test.

h = ttest(x,y,Name,Value)

returns a test decision for the paired-sample t-test with

additional options specified by one or more name-value pair

arguments. For example, you can change the significance

level or conduct a one-sided test.

h = ttest(x,m)

returns a test decision for the null hypothesis that the data in x

comes from a normal distribution with mean m and unknown

variance. The alternative hypothesis is that the mean is not m.

h = ttest(x,m,Name,Value)

returns a test decision for the one-sample t-test with additional

options specified by one or more name-value pair arguments.

For example, you can change the significance level or

conduct a one-sided test.

[h,p] = ttest(___)

also returns the p-value, p, of the test, using any of the input

arguments from the previous syntax groups.

[h,p,ci,stats] = ttest(___)

also returns the confidence interval ci for the mean of x, or of

x y for the paired t-test, and the structure stats containing

information about the test statistic.

%Quanto deve essere ampio il nout = sampsizepwr('z',[154 26],155,0.8)

campione affinché il test abbia una mi viene data la deviazione standard (la varianza è nota)

potenza la statistica test da utilizzare è una normale

%pari a 0.8 quando si testa l'ipotesi

155 ma la vera media è 154?

%(Supponendo come deviazione

standard della popolazione 26). per avere una potenza di 0.8 (non è elevatissima) ci serve un

campione di 5306 pazienti

serve un campione così alto perché la differenza tra le due

medie è molto piccola (155 e 154)

più la varianza è alta più una differenza sulla media non la

vedo

sampsizepwr nout = sampsizepwr(testtype,p0,p1)

Sample size and power of test returns the sample size, nout, required for a two-sided test of

the type specified by testtype to have a power (probability of

rejecting the null hypothesis when the alternative hypothesis

is true) of 0.90 when the significance level (probability of

rejecting the null hypothesis when the null hypothesis is true)

is 0.05. p0 specifies parameter values under the null

hypothesis. p1 specifies the value, or an array of values, of

the single parameter being tested under the alternative

hypothesis.

nout = sampsizepwr(testtype,p0,p1,pwr)

returns the sample size, nout, that corresponds to the

specified power, pwr, and the parameter value under the

alternative hypothesis, p1.

pwrout = sampsizepwr(testtype,p0,p1,[],n)

returns the power achieved for a sample size of n when the

true parameter value is p1.

p1out = sampsizepwr(testtype,p0,[],pwr,n)

returns the parameter value detectable with the specified

sample size, n, and the specified power, pwr.

___ = sampsizepwr(testtype,p0,p1,pwr,n,Name,Value)

returns any of the previous arguments using one or more

name-value pair arguments. For example, you can change the

significance level of the test, or specify a right- or left-tailed

test. The name-value pairs can appear in any order but must

begin in the sixt

Dettagli
Publisher
A.A. 2022-2023
34 pagine
SSD Scienze economiche e statistiche SECS-S/01 Statistica

I contenuti di questa pagina costituiscono rielaborazioni personali del Publisher silvicc di informazioni apprese con la frequenza delle lezioni di Fondamenti di biostatistica e studio autonomo di eventuali libri di riferimento in preparazione dell'esame finale o della tesi. Non devono intendersi come materiale ufficiale dell'università Università degli Studi di Bergamo o del prof Finazzi Francesco.