View source: R/mixed-methods.R
| get_individual_coefficients | R Documentation |
This function extracts and combines fixed and random effects to calculate individual-level predicted coefficients for all parameter-factor combinations from a beezdemand_nlme model object. It automatically detects the factor structure and calculates coefficients for each individual and factor level.
get_individual_coefficients(
fit_obj,
params = c("Q0", "alpha"),
format = c("wide", "long")
)
fit_obj |
A |
params |
Character vector specifying which parameters to calculate. Options are "Q0", "alpha", or c("Q0", "alpha"). Default is c("Q0", "alpha"). |
format |
Character, output format. "wide" returns one row per individual with separate columns for each parameter-factor combination. "long" returns one row per individual-parameter-factor combination. Default is "wide". |
Individual-level coefficients represent the predicted parameter values for each subject in the study. For models with factors, these coefficients combine:
The baseline intercept effect (fixed + random)
The factor-specific effect (fixed + random) for each factor level
This is equivalent to manually calculating:
coefficient = intercept_fixed + intercept_random + factor_fixed + factor_random
The function automatically handles:
Models with or without factors
Any number of factor levels
Missing random effects (defaults to 0)
Complex factor structures with multiple factors
For models without factors, only intercept coefficients are calculated. For models with factors, both intercept and factor-level coefficients are provided.
A data frame with individual-level predicted coefficients.
In "wide" format: rows are individuals, columns are parameter-factor combinations
In "long" format: columns are id, parameter, condition, coefficient_value
Column naming convention for wide format:
estimated_\{param\}_intercept: Baseline/reference level coefficient
estimated_\{param\}_\{factor\}\{level\}: Factor level-specific coefficient
All coefficients are on the log10 scale (same as model estimation scale).
To convert to natural scale, use 10^coefficient.
fit_demand_mixed for fitting the original model
coef.beezdemand_nlme for extracting model coefficients
get_demand_param_emms for estimated marginal means
data(ko)
fit <- fit_demand_mixed(ko, y_var = "y_ll4", x_var = "x",
id_var = "monkey", factors = "drug",
equation_form = "zben")
individual_coefs <- get_individual_coefficients(fit)
head(individual_coefs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.