#covid prevalence in California counties
tsl <- tsl_initialize(
x = covid_prevalence,
name_column = "name",
time_column = "time"
) |>
#subset to shorten example runtime
tsl_subset(
names = 1:5
)
#dissimilarity analysis
df <- distantia_ls(tsl = tsl)
#combine several predictors
#into a new one
composite_predictors <- list(
economy = c(
"poverty_percentage",
"median_income",
"domestic_product"
)
)
#generate model frame
model_frame <- distantia_model_frame(
response_df = df,
predictors_df = covid_counties,
composite_predictors = composite_predictors,
scale = TRUE
)
head(model_frame)
#names of response and predictors
#and an additive formula
#are stored as attributes
attributes(model_frame)$predictors
#if response_df is output of distantia():
attributes(model_frame)$response
attributes(model_frame)$formula
#example of linear model
# model <- lm(
# formula = attributes(model_frame)$formula,
# data = model_frame
# )
#
# summary(model)
Run the code above in your browser using DataLab