Predictive
Potser podria dir alguna cosa dels residus, no? binned residuals:
https://easystats.github.io/performance/reference/binned_residuals.html
Predictive
Potser podria dir alguna cosa dels residus, no? binned residuals:
https://easystats.github.io/performance/reference/binned_residuals.html
goodness of fit of models
Also the residuals
Statistical models
Warning sobre l'ús i l'objectiu del models
-Adjust for confounders when evaluating intervention effects.
-Use DAGs when assessing causal relationships.
-Internally and externally validate predictive models.
-Exploratory analyses allow more flexibility, but model assumptions must always be checked.
Explicar ROC curve? (no sé si hi ha temps)
Ho faria breument. Definició Figura Interpretació
model
No compares els models?
dying than Never smokers.
Compte... possible survival bias... aprofita per dir-los que els efectes cal llegir-los amb esperit crític
HR
OR
We can estimate
En lloc de 2 diapos podrien ser 3. La primera fins a la formula. La segona de "We can estimate..." fins al final del codi del model". I la tercera amb l'output del mode. Què et sembla?
with
with the
the
a
death
death risk
Odds ratios
Els recordaria que no ho llegeixin com un RR malgrat la temptació
Modelization
Potser aniria directament als ODDS RATIO
logistic regression modelling
a logistic regression
we would like
it would be nicer to have
line
We can add the linear regression line, but...
it’s not what we need
Ho demostres d'aquí dos diapos amb un exemple molt xulo... potser no ho diria aquí
absent
not present... absent em fa pensar amb missings
ng some disease
Es fa estrany que els altres dos exemples siguin concrets i aquest no. Seguint amb el que deies a la diapo anterior:
Evaluating whether a patient responds to a treatment for hypertension.
Test for some infection
Potser millor... Disease diagnosis Up to you
Responding to treatment
Treatment response
Logistic
Sí... transició!!! Ole, ole
R2
Els pots comentar que NOMÉS per a la regressió linial, l'arrel quadrada de la R2 és igual al coeficient de correlació.
fits the data best than m1
Existeix un test sobre la versemblança. lmtest: lrtest et compara models niuats via el likelihood ratio test.
anova
Ai, ai... que me'ls liaràs... és broma... els pots fer veure que comparar la SS residual i si la reducció quan afegeixes sexe paga la pena.
logistic regression model.
aplica a tots els GLM
SBP independent
SBP,
equality between the models.
equal explicability
in
on
residuals
Aquí podries posar e= \hat{y} - y
Assessing outliers
Faltaria llistar les condicions del model o ho diràs de veu? Independència Normalitat del residus Homogeneïtat de les variàncies
Multiple linear regression
Fer una diapo de transició amb "Multiple linear regression model".
Simple linear regression
Aquesta diapo no la posaries després de la interpretació del model, abans de la R2
larger than 1
Compte, la interpretació també ha de considerar el context i el leverage de les dades. Aquest 3 punts podrien ser un problema en el context d'aquest estudi.
plot(m1,1)
Comentar que aquests no estan estandarditzats i per tant estaran centrats en 0, però tindran un rang de variació en funció de la desviació estàndard dels propis residus.
plot(m1,2)
Comentar que és un QQplot
plot(m1)
Posaria tot el codi, però no mostraria els gràfics
response
Aquí els hi pots dir que és com si NOMÉS poguéssim explicar Y amb la mitjana de Y.
an
a
β0=82β0=82\beta_0=82: the expected value of systolic blood pressure when age = 0 (senseless)
Els hi explicaràs com fer-ho perquè tingui sentit?
if age increases one year, SBP increases in 0.90.90.9 mmHg.
The expected SBP value for a subject with one year more would be 0.9 mmHg higher, for a subject with 5 more years 4,5 mmHg more.
compute
estimate?
Correlation
Aquí és important que diguis que no hi ha jerarquia entre les variables. X sobre Y ó Y sobre X ho llegirem igual.
I també està pensada per raons linials i que si no ho són la rho no és interpretable (feu el gràfic). Els podries mostrar el quartet de Anscombe's
Correlation is not causation
Trauria el punt o faria una entradeta dels punts de sota per deixar clar que el concepte és aquest.
Do not interpret the p-value in a correlation test.
T'has passat... ;)... si tens, com els passa als genetistes, una matriu de 1000x1000 o més per algun lloc has de començar a descartar... no ens agrada, però és realista. Trauria la frase, però comentaria de veu les greus limitacions.
Instead, use the
Whenever possible, focus on the
Small correlations
In large samples, small correlations
of
from
an example
a sample
are going to
will
and it indicates whether XXX has a statistically significant effect on YYY.
uhm... "indicates whether there is statistically significant evidence that X is associated with Y"
The ppp-value associated to β1β1\beta_1 correspond to
We can do a hypothesis test on b_1:
that the regression model is unable to explain
that is not explained by the predictor variables in the regression model
To establish a relationship between YYY and a predictor variable X
No m'acaba de convencer això d'establish:
To quantify the relationship between a dependent variable Y and a predictor variables X
Depending on the nature of the response variable YYY there are different types of models
Per lligar-ho amb el títol de la presentació aquí podries anunciar o definir els GLM i explicar-ne 4 tipus en funció de la variable dependent i la seva distribució. I dir que n'hi ha més.
Els Cox no són GLM per tant ni els mencionaria.
models
model
models
model
models
model
models
model
Find risk factors associated with high blood pressure
Millor amb un exemple concret.... What is the effect of sugary drinks (X) on diabetes risk (Y)?
Build a prognostic index to predict the values of YYY given explanatory variables XiXiX_i
Estimate a clinical prediction model to predict the risk of diabetes (Y) given a subject's demographic and clinical characteristics (X_i)
in
on
modelling
no cal dir modelling, a predictive tampoc.
distribution
Idealment una normal amb mitjana 0 i desv stand la desv stand de l'error. Estarà bé que ho diguis.
linear
No sempre són linear, no?
means of an equation
Handle with care
Afegir al bottom
...life is no so easy
Summary
Falta la diapo de comiat
1.212851
The odds of tumour response is 21% higher in the group treated with drug B than in the group treated with drug A.
1.142493
The incidence of tumour response is 14% higher in the group treated with drug B than in the group treated with drug A.
represents
is
represents
is
d value
Compte amb la direcció dels > <
The most commonly used measure of effect size for a t-test is Cohen’s d
Cohens d is a standardized effect size for measuring the difference between two group means:
same test
t_test
represents
is
Example
library(HSAUR3) data("WeightLoss")
hours of sleep
sleep hours
hours of sleep
in sleep hours
E=(Row total×Column total)Grand total
Posaria un exemple de càlcul a sota
E_1 = (33*28)/48 = 19.25
∑(O−E)2E
Falten subindex i a O i a E.
-4.999980 3.999954
Explicarà la lectura d'aquests valors? Per fer-ho més fàcil podries posar una frase a sota.
Wilcoxon rank-sum test
Delete. És molt interessant per nosaltres però diria que irrellevant per ells en un curs com aquest (falta temps per tot arreu).
The p-value is derived from the smaller UUU of the two groups: Umin=min(U1,U2)=min(16,14)=14Umin=min(U1,U2)=min(16,14)=14U_{\text{min}} = min(U_1, U_2) = min(16, 14) = 14 R calculates the p-value based on UminUminU_{\text{min}}.
Delete
Wilcoxon rank-sum test
Delete
-4.566621 3.690640
Aquí explicaria de veu que això és una manera de reportar l'efecte observat.
Formula
Caldria identificar quina és Welch. Pots posar un sub index a la t $t_{Welch}$
sp
Falta S1 i S2
Paired samples
In a dependent sample, the measures are related.
For example, if you take a sample of patients who have had a painkiller and ask them about their pain before and after taking the medicine
Independent samples
Independent samples are samples that are selected randomly so that its observations do not depend on the values other observations.
For example, if the men's group and the women's group are asked about their health status.
at the start and end of
before and after
certain
borrar
Useful resources
Falta la diapo de comiat
counting the number of observations in each bin
També és poden fer amb %'s o densitat. Potser diria:
Histograms are constructed by binning the data and counting the number of observations in each bin, or the percentage or density:
ways of representing graphically the distribution of a numerical variable is
types of graphical representation of the distribution of a numerical variable are
the distribution of the variable
a variable distribution.
Customize the table
En aquesta diapo no cal animar el codi, no?
or tibble
Hem explicat els tibble?
, and more using sensible defaults
fem-ho fàcil i breu
of all sorts
fem-ho més breu.
will depend
depends
mean
Al text podries referenciar la M de la mitjana de la figura. De totes maneres la Me es fa servir per la mediana i la mitjana es presenta amb un $\bar{x}$. És possible modificar la figura?
Percentiles
Això no pot anar aquí. Et proposo el següent ordre: Standard deviation Range Interquartile range ... i aleshores aprofites per explicar què és un percentil de veu o en una slide extra. Què et sembla?
(xi−x¯)
SUMATORI!
If there is an even number of observations take the average of the two center values.
Ho pots dir, però no crec que calgui indicar-ho.
that try to answer the question of which value is the most “typical”
statistic to know which value is the most "typical"
we can use
we should use
inform
prepare
serving as its precursor
Pots acabar amb ...any inference.
in a an informative way
in a meaningful way
Applied Biostatistics Course with R
Afegir data
outcome of the subjects
subjects study outcomes.
how many
Ho volem amb counts o amb percentatges? o ambdós?
subjects have obesity
people are obese.
values of the age that are greater than 100
Potser posaria un tip...
that
A la fòrmula posar meters
an
as an
called
file
Exercices
Exercises
Censored
No seria milor parlar de "Time to event"?
ggcoxzph(test.ph)
Si fas dos columnes, i mostres els gràfics 2 i 1, diria que es podran veure millor.
Ok. No havia vist les següents diapos... però aleshores potser no els mostraria aquí.
Trobo a faltar una variable que presenti problemes, per exemplificar l'aspecte del gràfic.
Ok. Ara he arribat a la diapo amb l'exemple amb problemes. No seria la bomba, però potser no en tens cap altre.
Pots riure.
function ggcoxzph()
ggcoxzph() function
assumption
Es podria afegir un darrer punt advertint de la sensibilitat d'aquest test. Si la n és relativament gran pot produir falsos positius (mirar gràfics)
function cox.zph()
cox.zph() function
between groups
Faltaria especificar el temps, no?
The hazard ratios between groups remain constant over time
in
on
The risk of death was 0.59 times lower for females than for males at any t.
(or almost 70% higher for men).
We can visualise the table of results (HR, 95% CI and p-values) using tbl_regression() from gtsummary package, with the exponentiate option set to TRUE to return the hazard ratio rather than the ββ\beta coefficient:
El text no respira massa. Què tal així?
We can visualise the model results in a fancy table:
It needs a regression formula and the data
Ho pots dir... no crec que calgui posar-ho
function coxph
coxph() function
Cox regression models
Uhm... no aniries directament a la interpretació dels HR? Interpretar les betes a 0 per després passar als HR a 1 potser es foten un embolic, no?
of continuous
of a continuous
function ggsurvplot()
ggsurvplot() function
outcomes
survival times o bé surivial funcions
Are there differences in survival between sexes
Are the survival functions different for sex?
Are survival functions different between sexs?
median survival time
Comentar que la funció reporta NA si no s'hi arriba.
function summary()
summary() fuction
our
the
in
from
We
Salt de diapo? Això podria anar a la diapo següent, no?
High survival rate
Depèn com es miri... vull dir que a l'any ha palmat el 60%. Crec que és més interessant que comentis la pendent. A l'esquerra moren tots i ràpid. A l'esquerra moren menys però a ritme més lent.
T
T ho explicaria com temps a seques, com t. El parèntesis el posaria amb el Survival time. Com ho veus? Es fa estrany llegir dos cops el mateix. Després quan expliques la formula pots especificar què vol dir T
Aims
No m'agraden massa aquestes caixetes... millor bullets, no?
Exact observation
La paraula "Exact" no m'acaba d'agradar, però ara no em ve una millor.
Event happens/occurs at a certain time
a sample
No seria millor parlar de "a subject"
Follow a subject until the event of interest occurs or is lost.
:
calen els ":"
Usually: time from diagnosis/study enrolment/surgery/… to the event of interest
Això no és millor que ho diguis tu de veu?
time from some fixed starting point to the occurrence of a given event.
no afegiries al final "or lost to follow up."
To analyse data representing the length of time between two events
To analyse time to event data.
Joining Datasets
Després de repassar tot el capitol de "Joining Datasets", per practicat em limitaria a ensenyar el left_join directament amb el by. Ho podem comentar
For the following examples of joining datasets, we will use these built-in datasets
For the following examples we will use these built-in datasets
Always
Always put
summary
Compute statistics
o...
Compute descriptive statistics
Retain
Filter by
Treatment Age Marker (ng/mL) stage
Calen tants fx animation!?!?
Change the name of columns
Change column names
To consult the help on the package
Consult the package help:
The following objects are masked from 'package:stats':
Això ho explicareu?
into your R session
Aquí podríeu dir allò de instal·lar i carregar a la biblioteca de paquets de la teva sessió d'R. Així entendran perquè això de library(xxx).
-
Aquí es podria posar un salt de línia, no?
Management
Així sí!!!!
A data frame is composed of vectors and all vectors must have the same length.
Faria servir exactament la mateixa definició que s'ha donat a la sessió anterior.
data.frame() function
Bravo!!!
library(readxl)
fx animation... voleu dir que calen?
my_data
Aquí no hi ha massa línies per sobre i per sota?
one of the most common formats
a common format
Per tots ells el més comú segur que és l'Excel dels collons.
Data Reading
No seria Reading Data
Manipulation
Vamos, no me jodas Rafa... Management!!!!
tidyverse
Això és una promo... se us veu el llautó... ha ha ha
Set of R packages which provide, among other things, convenient methods for managing data
A set of R packages ideal for data management. They will make your life a lot easier.
hosting R packages
for R packages
We can use logical operators to access an element of a vector:
To access a vector element, we can use logical operators:
to apply the right logical expression.
Sometimes we need to use parentheses to apply the correct logical expression.
this
these
this
these
, as before
no cal l'aclaració
These are the basic logic operators used to check any value
These are the basic logic operators:
Rest
Subtract
An operation applied in a vector will be applied elementwise to each one of its elements.
Potser és més simple així... a veure què us sembla... When you perform an operation on a vector, the operation is automatically applied to each individual element of the vector.
R comes with some basic arithmetic operations that can be used on
In R, basic arithmetic operations that can be performed on a single numeric object, a numeric vector, a numeric matrix or a dataframe with numeric columns.
Matrix
Les matrius no les explicaria. Ens falta temps i la majoria no les faran servir mai.
Naming objects
Em sembla un Useful tip
R is case sensitive so daily_cigar is considered to be different to Daily_Cigar
R is case sensitive, so daily_cigar is different to Daily_Cigar.
with is.na()
with is.na() function
to identify
to know
dataset
dataframe
column
Es podria dir...
To access a column (variable) in a dataframe we will use $
the function list()
the list() function
Ordered
An ordered
the function matrix()
the matrix() function:
Two-dimensional
A two-dimensional...
Change also the labels
Change labels too
Set the levels
Set levels
the argument level
the level argument
A factor is a special kind of vector
Entenc la idea, però potser podria ser interessant vendre-ho com una manera de construir variables categòriques. Alguna cosa com ara... "A factor is a categorical variable that stores discrete values as labeled levels, which can be ordered or not."
the function factor()
the factor() function:
Ordered
An ordered collection of single value objects of the same type
Check if the class of the object is numeric
Check whether object class is numeric
Show the class of the object
Show object class
the
a
Single value that can be numeric, character, logical, datetime, etc.
A single value that can be a numeric, a character, a logical, a datetime, etc.