Hello,
I have a logged linear regression that predicts total muscle “U” from a measurement of length “L” and adipose fat “A”.
\log(U) \sim \alpha_{lu} + \beta_{lu1} \ast \log(L) + \beta_{lu2} \ast \log(A).
Once fitted, this equation can be used to predict the mass of structural muscle (Ku) which is associated with structure (bones etc) as:
\log(Ku) \leftarrow \alpha_{lu} + \beta_{lu1} \ast \log(L)
From which I can estimate the amount of storage muscle (Ou) which is associated with adipose mass (energy stores)
Ou \leftarrow U - Ku
The proportion of storage that is muscle (PrOou) can then be found as:
PrO_{Ou} \leftarrow \frac{Ou}{Ou+A}
I would like to then use this calculated, latent variable to fit a beta regression that relates a measure of body condition (BC) (overall fatness) to the proportion of storage that is muscle (PrOou)
PrO_{Ou} \sim beta(Au, Bu)
logit(\mu) \leftarrow \alpha_{pr} + \beta_{pr} \ast BC
Au = (\mu)*phi_{U}
Bu = (1 - \mu))*phi_{U}
I have tried to make this work multiple ways but I don’t seem to be able to use the PrOou value calculated in any of the blocks to be the dependent variable in the beta regression.
The model below runs but although PrOou is calculated in the transformed parameter block it does not appear that the beta regression uses it, instead it appears to be fit to nothing or missing data as the estimated parameters for the beta regression are completely uniformed.
Any advice or discussion on how I might best fit these “sequential” regressions would be much appreciated! Even if I can figure out how to use the latent variable as a dependent in the beta regression I wonder if the likelihood could be sorted out or if I might be better to just take a Generalized likelihood uncertainty estimation approach.
//multiple linear regression code for Logged total muscle regression
data {
int<lower=0> nbears; // number of dissected bears
int<lower=0> KlU; // number of total muscle linear regression predictors
matrix[nbears, KlU] lUPreds; // total muscle linear regression predictor matrix where each row is an observation and each column a predictor
vector[nbears] lU; // Observed logged total muscle
vector[nbears] lL; // Observed logged straight line body length predictor for lKnU
vector[nbears] lKnU; // Observed logged total structure non-muscle
vector[nbears] U; //Observed mass total muscle
vector[nbears] A; //Observed mass of adipose
vector[nbears] SMI; //Scaled mass index calculated from observed total mass and length
}
parameters {
real alphalU; // total muscle linear regression intercept
vector[KlU] betalU; // total muscle linear regression coefficients
real<lower=0> sigmalU; // total muscle linear regression error scale
real alphalKnU; // total structure non-muscle intercept
real betalKnU; //total structure non-muscle slope with logged length
real<lower=0> sigmalKnU; // total structure non-muscle linear regression error scale
real alphaPrU; //Proportion of storage that is muscle intercept
real<upper=0> betaPrU; //Proportion of storage that is muscle slope with SMI
real<lower=0, upper=300> phiU; // Proportion of storage that is muscle dispersion parameter
}
transformed parameters{
vector[nbears] Ku; //estimate for the proportion of storage that is muscle
vector[nbears] PrOu;
Ku= exp(alphalU + betalU[1]*lL); //Estimate the mass of structural muscle
PrOu = (U-Ku) ./ (U-Ku+A); //Estimate the proportion of storage that is muscle
}
model {
// model calculations
//vector[nbears] Xbeta; // linear predictor
//vector[nbears] mu; // transformed linear predictor
vector[nbears] Au; // shape parameter for beta distn
vector[nbears] Bu; // shape parameter for beta distn
// priors
phiU ~ uniform(0, 300); // put upper on phi if using this
// likelihood
lU ~ normal(lUPreds* betalU + alphalU, sigmalU); // logged total muscle likelihood
lKnU ~ normal(betalKnU * lL + alphalKnU, sigmalKnU); // logged total structure non-muscle likelihood
for (i in 1:nbears){
Au[i] = (inv_logit(alphaPrU + SMI[i] * betaPrU))*phiU;
Bu[i] = (1-inv_logit(alphaPrU + SMI[i] * betaPrU))*phiU;
PrOu[i]~beta(Au[i], Bu[i]);
}
}
// track variables of interest
generated quantities {
vector[nbears] muKu;
vector[nbears] muPrOu;
muKu= exp(alphalU + betalU[1]*lL); //Estimate the mass of structural muscle
muPrOu = (U-muKu) ./ (U-muKu+A); //Estimate the proportion of storage that is muscle
}