Do glucose and age still have an effect in diabetes?
en lloc de have an effect potser parlaria d'association? no ho tinc clar..
Do glucose and age still have an effect in diabetes?
en lloc de have an effect potser parlaria d'association? no ho tinc clar..
For obese, OR=3.80 -> Obese individuals have higher odds of developing diabetes than non-obese individuals
ara estava pensant si a la interpretació dles models multiples que has ficat s'hauria de ficar sempre for the same age and bmi category
tbl_regression(exponentiate=T)
ficar labels perquè no surti bmi_cat?
Use mutate() and case_when() functions from the dplyr package to categorize a numerical variable.
Afegiria que no s'oblidin dels missings!
- Non-obese: BMI lower than 30 - Obese: 30 or greater
se'm fa raro que canvi la lletra
exp(5*coef(m4)[“glucose”])=1.176517.
ho ficaria en codi en un chunk a continuació
An increase of 1 mmHg in sbp i
For the same sex,
#?PimaIndiansDiabetes table(df$diabetes) neg pos 500 268 table(df$diabetes)["pos"] pos 268 df |> select(diabetes) |> tbl_summary()
jajaj t'has pasao fent-ho de tres formes diferents. Jo faria un tbl_summary i afegiria a l'enunciat que reportin en una taula el número de positiius i negatius de la diabetes
PimaIndiansDiabetes consists of several medical predictor variables and one target variable, diabetes. This dataset is originally from the National Institute of Diabetes and Digestive and Kidney Diseases of the USA and includes data on female patients at least 21 years old of Pima Indian heritage.
en un callout note
4. Perform a diagnosis of the simple linear regression model.
el plot(m1, 3) no el fas per verificar la homoscedasticity?
Fit the model and interpret its coefficients.
Ficaria un d. que digués build a table perquè sapiguen que han d'utilitzar tbl_regression.
També ficaria un punt abans que digués de visualitzar la relació no? I verificar que és lineal abans de fer el model
tbl_summary()
Afegiria labels perquè surti maco
,cv
espai
The regicor dataset consists of data from 3 different cross-sectional surveys of individuals representative of the population from a north-west Spanish province (Girona), REGICOR study.
Ficar-ho igual que en el de survival no?
Useful to investigate the effect of a set of predictor variables in a response variable
afegiria que a vegades volem estudiar l'efecte d'una variable d'interès ajustat per un set de covariables.
Comparison of linear models
aquí desapareix el R2 que també es podria fer servir per a comparar models no? Almenys l'ajustat.
Al final diria que l'AIC és el més recomanat, que al final és el que sempre utiltizem nosaltres no?
tbl_regression
ficaria a continuació el link a la vignette que parla del tbl_regression (https://www.danieldsjoberg.com/gtsummary/articles/tbl_regression.html) perquè tingui info dels arguments que pot utilitzar. Els hi diria que té la mateixa sintaxis que el tbl_summary.
Modelization
ficaria que és un linear model això! per tant tambe s'ha de verificar la linealitat però en l'escala de les odds.
linear
crec que és molt important aquest punt! s'hauria de resaltar d'alguna forma i dir que si no és lineal hi ha altres models però que no es faran en aquesta sessió
Linear regression
bueno ojo perquè si no és lineal... el mateix per la logistic regression!! afegiria un punt de chequear la linealitat de la relació! i dir que hi ha opcions no lineals.
També, ara que hi penso no s'ha parlat de colinealitat en multiple regression, val la pena?
explanatory
explanatory predictive independent? ja no sé que s'hauria d'utilitzar jaja
ylab("Predicted probability of death") + xlab("BMI") + # Add lab to x-axis
fer-ho amb labs que està en la següent línea, ho pots ficar dins
theme_bw
al final però abans del theme() que sino no t'aplicarà la legend.position
regicor3$pred <- predict(m3, type="response", data=regicor3) head(regicor3 |> select(id,smoker,bmi, death,pred))
aqui ho fas diferent, fas el select dins del head. Faria el mutate i el select i després el head. Sino es marejaran
Logistic model (qualitative and quantitative variable)
se'm fa raro que l'estructura és diferent de la de linear model, que tenies simple/multiple i ara fas continua/categorica/continua+categorica
regicor2$pred <- predict(m1, type="response", data=regicor2) regicor2 <- regicor2 |> select(id,bmi,death,pred)
idem mutate
function
falta un espai?
OR = 1.13 ⟶⟶\longrightarrow For a 1-unit increase in the bmi, the odds of dying are increased by 13%.
ho ficaria amb una altra fletxa a continuació del punt atnerior sense que fos un nou punt
increase
increases
exp(βi)=eβi
ficaria a més a més el quocient escrit en fórmula per si no se'n recorden de que és una odd
p
majúscula
ln
se'm' fa raro que sigui ln, sempre ho he vist com a log encara que sigui el logaritme neperià
computed
idem
computed
per què està en passat? potser podríem dir we can compute
the P(Y=1)=p
ho diria en paraules: we want to study the probability of the outcome (P(Y = 1) = p)
Introduction
Com que després introdueixes un exemple potser podries partir d'aquest exemple tot el rato, no? Si no se'ls farà més dificil d'imaginar
ε
ojo abans utilitzaves la lletra e
explanatory
ara aquí passen a ser explanatory variables en lloc de predictor que és el nom que s'utilitzava pel lineal model
best
better
AIC penalizes for model complexity. Smaller values indicate better fit. The AIC for a model can be computed with AIC() function.
indent
nested
ho explicaria de veu el que vol dir nested model perquè no s'entén sol
newdata$pred <- predict(m2, type="response", newdata=newdata)
pots fer-ho amb un mutate i ensenyar la sortida de l'output no cal tornar a ficar 'newdata' aleshores. Igual pel següent
regicor2$pred <- predict(m2, type="response", data=regicor2) #store prediccions
pots fer-ho amb un mutate abans de fer el select posterior
newdata <- data.frame(age=70, sex="Male") #define new data newdata$pred <- predict(m2, type="response", newdata=newdata) newdata
aquí igual que abans i així no cal ni assignar-ho a newdata. Pots ficar el mutate i que es visualitzi l'output
Goodness of fit
m'he adonat que no hi ha número de pàgina
Adjusted R2R2R^2
Afegiria un punt abans que digués que el R2 sempre augmenta quantes més variables que afegim no?
Females have 5.4 mmHg less SBP than males.
Females are expected to have
Both p-values are lower than 0.05 ⟶⟶\longrightarrow Both age and sex are associated with SBP
Ho ficaria al final. Ficaria associated significantly.
sex=Female
raro el igual aquí sembla que tota la formula dongui = Female. Ho ficaria diferent, p.ex.: SBP = 85 + 0.9[age] - 5.4[sex=Female]
~
ficaria un espai
If XiXiX_i is qualitative
per què això no ho has ficat en la simple linear regression? també ho podríem tenir, se'm fa raro que es digui només aquí
Assuming that residuals
indent
Given
el mateix que t'havia dit abans, se'm fa raro aquest given per parlar de la fórmula
predictor
No sé si es faran un lio amb explanatory/predictive modelling. Perquè a més també es podria dir explanatory variable. Pot ser tant aquí com a dalt parlaria de independent variable?
Model diagnostics
i la linearitat no la ficaries aquí? en el cas dels linear models és important
p-value for age <0.001⟶<0.001⟶<0.001 \longrightarrow Age has a statistically significant effect on SBP
al final potser? primer parlar de B1 i després de si té un efecte significatiu
age
ficar un espai
Pearson’s correlation coefficient assumes that X and Y follow a normal distribution Alternative: Spearman’s correlation coefficient (argument method in cor.test())
ho ficaria en la següent diapo. També afegiria en algun punt la correlation matrix que em sembla una funció molt útil per a reportar la correlació (https://www.sthda.com/sthda/RDoc/figure/statistics/correlation-matrix-graph-1.png)
takes values between -1 and 1
en lloc d'aquestes frases crec que s'enten millor amb un gràfic. Veure: https://i.ytimg.com/vi/TbtLww4k2Js/maxresdefault.jpg
to see how is its association.
se'm fa rara la frase. Ficaria: to see how their association is.
xlab("Age") + ylab("Systolic blood pressure") +
faria servir labs() així no has de fer xlab i ylab que ho fiques a la mateixa línea sense salt de linea
Example dataset: REGICOR study
es podria veure millor aquesta taula? no es veu massa bé. Si li fas un as.tibble(regicor)? o pots fer trampes i fer-li un gt de fons jeje
{compareGroups}
😭
increase
increases no?
YYY value when X=0X=0X=0
no es ben bé això perquè també hi ha el coeficient de l'error quan X = 0. Ficaria Y expected value
β0β0\beta_0 is the intercept
indent en aquests bullets que fan referència a la fórmula anterior
Assuming that residuals
li ficaria un indent perquè estàs fent referència a la fómrula anterior
Given the formula
Ho canviaria per una altra frase tipo formula specification o algo així
Multinomial regression models
També podria ser ordinal regression, si la variable fos ordinal
(Correlation)
per què entre parentèsis? I no hauria d'anar abans que fos lo primer? crec que s'explicaria millor després un linear model
12. Test the proportional hazards assumption for model2.
buf estan al límit algunes. Faries algun Schoenfeld plot? Se'm fa raro que no extreguis cap interpretació d'aquí.
11. Reorder the levels of variable platelet with meaningful order and fit a Cox model again.
Això ho haurien d'haver fet ja al punt 1. Ho afegiria allà junt amb el missatge que et deia abans de converteix en factor les variables amb un ordre. Per tant aquest exercici el treuria.
interpret
a la solució et falta l'interpret
hepato
sobra espai
Increasing albumin lower the odds of dying
Ficaria la interpretació completa d'un HR: for a patient who has not died by a certain point in time increasing albumin lowers his risk of dying. Diria que és risk i no odds.
odds
idem
9. Fit a Cox model
Ho ficaria potser sense apartats com en el 8. Un enunciat tot seguit ja que té la mateixa estructura que el 8
with the
in function of the?
survival
survival probability?
survival
no li faltaria un complement tipo: 3-year survival probability
60
ficaria 5*12 com abans
risk.table=T
idem
Use summary() on a survfit object to obtain survival estimates at specific time points.
Potser faria un tip general pel punt 4 que fos: use the survfit object. Valorar aleshores si treure aquest o no.
risk.table=T
Fica'ls-hi en l'enunciat que afegeixin el number at risk. Perquè també si no podrien fer un km sense això.
status
perquè s'enrecordin que ha de ser numèrica els hi pots ficar al tip algo així: remember that the response used inside 'Surv()` has to be numeric. Crec que no és baladí
status2
Fica-li un label bonic no? I perquè entenguin que han de fer la taula pots ficar report in a table how many patients...
head
header enlloc de head no? Així ho has dit al tip.
according to their type.
Afegiria que transformesin a factor les variables que tinguin ordre, o algo així. Perquè sino no se'ls hi ocurrirà.
mutate(trt=factor(trt, labels=c("D-penic", "Placebo")), hepato=factor(hepato, labels=c("No", "Yes")), status2=factor(status, labels=c("Alive", "Dead")))
fica els levels també, perquè sempre va bé no deixar-sels. Així a més entenen com funciona la sintaxis de factor
>=300=
sem fa raro de llegir potser substituiria els '=' pels ':'. Aleshores seria '>=300:'
A description of the variables is given below:
això també ho pots ficar dins un callout note i ho pots fer collapsable perquè no els hi ocupi tant d'entrada. El codi és: ::: {.callout-note collapse="true"} :::
The file PBCdata.txt contains a subset of data from a trial on primary biliary cirrhosis (PBC) of the liver conducted in the Mayo Clinic between 1974 and 19841. The patients were randomized to receive placebo or the drug D-penicillamine. The objectives in this study were to compare D-penicillamine and placebo in terms of survival and to find prognostic factors.
Fica-ho tot dins un callout note no? jeje
La file haurà d'estar a una carpeta dins de Data
Mola el 19841, estarem vius?
We can’t reject the null hypothesis about NO interaction between Time and Group.
hi ha un salt de línea massa gran
data = WeightLoss_long
salt de línea pls
interaction
no ho havia vist mai :O
=
virbulilla (~)
Normality is not so…
potser ho ficaria en el punt d'abans si no potser no s'enten
#Shapiro-Wilk WeightLoss_long |> group_by(Time, group) |> summarise(p_value = shapiro.test(Weight)$p.value)
si ho treus el gràfic et queda més gran
color = "Group"
sobra no?
an independent factor
one independent factor o poden ser més?
, color = "Supplement"
ai`xo per què?
#scale_x_continuous(breaks = c(0.5,1,2), labels = c("0.5", "1", "2")) +
fa falta?
Analysis of Variance
A la SS_AB abans li dius SS_AXB
stat_qq
no t'oblidis de canviar això per geom_qq() aquesta i totes les altres, ja que com diu el João és la que vam fer servir
rstandard
library aquí també, crec que és TSA pot ser?
DescTools
Si s'utilitza el DescTools faltaria també un library no?
TukeyHSD
llibreria stats no? S'hauria de fer un library abans. Igual per la següent
# Arrange results results_anova <- broom::tidy(model_anova) resultats_anova$term<-c("Between-groups","Within-groups") names(resultats_anova)<-c("Terms","df","SS","MSQ","F","P-value")
comentari que et diu el João més tard també (aquí no ho ha ficat)
conditions
ficaria aquí normality i a la següent homoesce com es digui al títol per distingirho millor
#Shapiro-Wilk ToothGrowth |> group_by(dose) |> summarise(p_value = shapiro.test(len)$p.value)
però els hi hem dit que no ho utilitzin, no? potser ho treuria i així es veur`amillor el qqplot
x = "Dose", y = "Length (cm)")
No es correspon al gràfic
=
virbulilla (~)
by=dose,
salt de línea
p
puntet al final
Variance
Afegiria que és el quadrat de la SD que és el que els hi he explicat avui
modify
Creo que no se entiende muy bien. A lo mejor podrías decir let's create a pre marker and a posterior marker o algo así
case_when( trt == "Drug A" ~ 1, .default = 0 )
está un poco raro los espacios, pasale un control shift A jeje
"Treatment"
Es importante decirles que no se recomienda poner estos nombres a las variables (a lo mejor como nota)
Complete this step, since the upcoming examples will rely on this dataframe.
Creo que es mas natural hacerlo al final de explicar todos los selects, y dices que te quedas con las variables que vas a usar en los siguientes ejemplos. Además, haría el select con los nombres de las variables en vez de la posición después
df[3, "fruit"]
també es podria fer df$fruit[3]
→ CSV files
incluye txt? habría que añadirlo usando read.table (que valdría también para el csv)
Non-proportional hazards
Al final si fiques el gràfic? Realment no es veu molt la crescuda, no? Potser és un tema de sensitivitat i és que no es viola l'assumpció. Considerar ficar l'explicació i treure el gràfic?
Model validation: Graphs of Schoenfeld residual
La transició entre la diapo anterior i aquesta no l'acabo d'entendre. Potser ficaria els dos bullets en la diapo anterior i aquí ja entrar amb el [1]
n
Falta un punt '.'
risk
Tècnicament pot parlar de risk o bé s'hauria de parlar de rate? Perquè no només tenim en compte l'event sino el time to event
exp=TRUE
és una tonteria però potser podries ficar exp=TRUE enlloc de exp=TRUE en el codi perquè al final tot és codi
:
afegiria que estàs comparant, to compare the risk between sex o algo així
coxph
coxph() . mirar si m'he deixat algun d'aquest estil en les demés slides
with respect to the reference category at any t.
for each category of the variable with respect to the reference category
Quantitative
indent aquí també potser?
βiβi\beta_i > 0
indent dels dos bullet points
h(t|X1,X2,…,Xp)=h0(t)⋅exp(β1X1+β2X2+⋯+βpXp)h(t|X1,X2,…,Xp)=h0(t)⋅exp(β1X1+β2X2+⋯+βpXp)h(t | X_1, X_2, \ldots, X_p)=h_0(t) \cdot \exp(\beta_1 X_1 + \beta_2 X_2 + \cdots + \beta_p X_p) X1,…,XpX1,…,XpX_1, \ldots, X_p: Variables of interest. h0(t)h0(t)h_0(t): Baseline hazard function. β1,…,βpβ1,…,βp\beta_1, \ldots, \beta_p: Regression coefficients of each variable.
li falta indent a la formulació, no? Potser si fiques $$ en lloc de $ s'arregla?
function
afegiria and add the log-rank test in the graphic
,
falta un espai :P
Kaplan-Meier method
Potser treuria aquesta diapo. No sé si és gaire relevant i potser donar massa info es lien.
library(survminer)
Que raro que no hi hagi el espaiat després del primer chunk. Podem mirar-ho, amb el css que hem ficat t'hauria d'aparèixer.
before the tilde
Ficaria left-hand of the formula i right-hand. Se'm fa molt raro 'tilde'.
Kaplan-Meier estimator
Potser ficaria la imatge d'una Kaplan-Meier amb explicacions (queda molt buida la diapo). He trobat aquesta que no està mal: https://miro.medium.com/v2/1*KFjJc77t-MGn7-bp3RyYeg.png
TRUE/FALSE, 1/0 or 2/1.
Afegiria que TRUE, 1 i 2 sempre es llegirà com l'event i l'altre com el censor.
TRUE ~ status
Utilitza millor el .default = status, enlloc del TRUE
<-
et sobra un salt de línea
Aims
No faria una secció gran (només un #) per només una diapositiva. Ho deixaria dins de la introducció. A més potser en lloc de aims ficaria types, valorar.
stroke
for time to stroke, no? Igual per les següents.
Introduction
Valorar ficar una imatge amb més etiquetes. He trobat una que no està mal: https://www.mdpi.com/make/make-01-00058/article_deploy/html/images/make-01-00058-g001.png
Introduction
No ho ficaries tot en una mateixa diapo? Per espai et cap, i crec que donaria més consistència. Potser es podria moure l'anterior definició de Survival time després del primer punt d'aquesta diapo.
If we click on the option render on save
Ojo amb aquesta opció
uses
Jo ficaria un altre verb