Load data
data(
thirst,
package = "jeksterslabRdatarepo"
)
Model
\[\begin{equation}
Y_i
=
\delta_Y
+
\tau^{
\prime
}
X_i
+
\beta
M_i
+
\varepsilon_{
Y_{
i
}
}, \\
\enspace
\text{
where
}
\enspace
\boldsymbol{
\varepsilon_{
Y_{
i
}
}
}
\sim
\mathcal{
N
}
\left(
\mu_{\varepsilon_{Y_{i}}}
=
0,
\sigma^{
2
}_{
\varepsilon_{
Y_{
i
}
}
}
\mathrm{
I
}
\right)
\end{equation}\]
\[\begin{equation}
M_i
=
\delta_M
+
\alpha
X_i
+
\varepsilon_{
M_i
}, \\
\enspace
\text{where}
\enspace
\boldsymbol{
\varepsilon_{
M_i
}
}
\sim
\mathcal{
N
}
\left(
\mu_{
\varepsilon_{
M_{
i
}
}
}
=
0,
\sigma^2_{
\varepsilon_{
M_i
}
}
\mathrm{
I
}
\right)
\end{equation}\]
Data
Variables
temp |
Room temperature in degrees Fahrenheit. |
\(X\) |
thirst |
Self-reported thirst at the end of a 2-hour period. |
\(M\) |
water |
Water consumed during the last 2 hours in deciliters. |
\(Y\) |
Mean structure
Estimated mean of \(X\) and regression intercepts
muhatX |
Estimated mean of \(X\). |
\(\hat{\mu}_X\) |
70.18000 |
deltahatM |
Estimated intercept of \(M\). |
\(\hat{\delta}_M\) |
-20.70243 |
deltahatY |
Estimated intercept of \(Y\). |
\(\hat{\delta}_Y\) |
-12.71288 |
Covariance structure
Estimated regression slopes
alphahat |
Estimated regression slope of path from \(X\) to \(M\). |
\(\hat{\alpha}\) |
0.3385926 |
tauprimehat |
Estimated regression slope of path from \(X\) to \(Y\). |
\(\hat{\tau}^{\prime}\) |
0.2076475 |
betahat |
Estimated regression slope of path from \(M\) to \(Y\). |
\(\hat{\beta}\) |
0.4510391 |
alphahatbetahat |
Estimated indirect effect. |
\(\hat{\alpha} \hat{\beta}\) |
0.1527185 |
Estimated variance of \(X\) and error variances
sigma2hatX |
Estimated variance of \(X\). |
\(\hat{\sigma}^2_X\) |
1.2934694 |
sigma2hatepsilonhatM |
Estimated error variance of \(\hat{\varepsilon}_M\). |
\(\hat{\sigma}^2_{\hat{\varepsilon}_{M}}\) |
0.9490376 |
sigma2hatepsilonhatY |
Estimated error variance of \(\hat{\varepsilon}_Y\). |
\(\hat{\sigma}^2_{\hat{\varepsilon}_{Y}}\) |
0.9706797 |
Fitted model-implied variance-covariance matrix
\(\boldsymbol{\hat{\mu}} \left( \boldsymbol{\hat{\theta}} \right)\) (muhatthetahat
)
X |
70.18 |
M |
3.06 |
Y |
3.24 |
Fitted model-implied mean vector
\(\boldsymbol{\hat{\Sigma}} \left( \boldsymbol{\hat{\theta}} \right)\) (Sigmahatthetahat
)
X |
1.2934694 |
0.4379592 |
0.4661224 |
M |
0.4379592 |
1.0973273 |
0.5858786 |
Y |
0.4661224 |
0.5858786 |
1.3317230 |
testthat
test_that("regression_coefficients", {
expect_equivalent(
round(
c(
-20.702430,
0.338593,
-12.712884,
0.207648,
0.451039
),
digits = 2
),
round(
c(
deltahatM,
alphahat,
deltahatY,
tauprimehat,
betahat
),
digits = 2
)
)
})
#> Test passed 🥳