2
$\begingroup$

I'm trying to build a regression model for predicting mortality in users according to their lab reports, the thing is in my dataset each row is a different laboratory even for the same user, for example:

    value           start   category    unit    type                         display    record.death                    seed    report_frequency
 3  25.83   1291715668918   vital-signs kg/m2   39156-5 Body mass index (BMI) [Ratio]   1561456468918   -4803776664509238228    4
25  26.47   1318326868918   vital-signs kg/m2   39156-5 Body mass index (BMI) [Ratio]   1561456468918   -4803776664509238228    4
37  27.42   1386669268918   vital-signs kg/m2   39156-5 Body mass index (BMI) [Ratio]   1561456468918   -4803776664509238228    4
49  29.19   1481622868918   vital-signs kg/m2   39156-5 Body mass index (BMI) [Ratio]   1561456468918   -4803776664509238228    4
74  19.35   1196939625807   vital-signs kg/m2   39156-5 Body mass index (BMI) [Ratio]   1490267625807    401572787436335446     10

I'm not exactly sure what to use as my features, I'm using value, start (which is the laboratory date in timestamp) and type (which is the code for the metric type), and the goal variable is record.death, the thing is as you can see in the table I can have multiple rows per user according to how many times they visited the laboratory, I'm using linear regression but my mean squared error is too high, what could be wrong? Maybe I need to use another model for this case?

$\endgroup$
1

2 Answers 2

6
$\begingroup$

Since the response is mortality, the most appropriate method is survival analysis that explains time to death, a strictly positive value. It appears that the difference between the first start and record.death is duration to death and value is a predictor. The data structure you have is close to a "counting process," and you have a predictor that changes over time (i.e., a time-dependent covariate), both of which survival analysis can appropriately handle. Mean squared errors may or may not be a useful measure here because survival time cannot take negative values.

The package {survival} in R has most resources you may need. Check its manuals and vignettes, especially on coxph() from https://cran.r-project.org/web/packages/survival/index.html. You will need to

  • Construct both stand and end variables for each person record. You will also need to adjust the start time to be zero for each patient, such as start <- start - min(start) by patient ID (seed). Two consecutive records should have the end of the former record equal the start of the latter record. Possibly you will need end <- lag(start) - start for the first (K-1) records of a patient with K records and use end <- record.death - start for the last record. You will likely need to scale both start and end variables so their values are not huge (e.g., the duration is measured in days or months instead of in seconds), to ensure convergence.

  • Construct a death indicator for each person record to represent status if a patient is dead by the end of record k. The first (K-1) records of a patient with K records should have value 0 for alive and the last record 1 for dead. Using dplyr pipeline will streamline the process. Then Surv(start, end, death) defines the response variable that a patient has a status death by the end of the time interval (start, end].

Repeated measurements of the same patient is usually not problematic in survival analysis because the construction of partial likelihood function in coxph() incorporates multiple records per patient. Nevertheless, you can use clustered standard errors coxph(Surv(start, end, death) ~ value + I(value^2) + I(value^3) + ... + cluster(seed)) or random intercepts via frailty terms coxph(Surv(start, end, death) ~ value + I(value^2) + I(value^3) + ... + frailty(seed)) to check whether it is necessary to correct for longitudinal data, where seed represents the patient identify.

$\endgroup$
0
$\begingroup$

Longitudinal regression can handle multiple rows per subject, not linear regression. The problem is caused by within-subject correlation between repeated measurements. If you are starting out, then an easier way to approach analysis of repeated measurements is to perhaps look at RMANOVA (repeated measures ANOVA), or longitudinal regression. Many longitudinal methods assume the time between measurements is equal, which can be an issue when looking for the appropriate method/software. Personally, I typically use GEE (generalized estimating equations) regression for longitudinal analysis, since it makes no assumption about time differences between measurements.

You might look at this on linear regression with repeated measurements, and also look for mixed-effect models, where a subject ID variable can be used as an input. GLM (generalized linear models) and panel data regression analyses are other forms of regression analysis which contain families of models to handle repeated measures.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.