Description Usage Arguments Details Value References See Also
This function fits a mixed model with minimal user input.
1 2 | Mixed_Model_Spline_Fit(Y, knots, K, P = 1, spline = "Radial", r = 1,
theta = 2)
|
Y |
A tibble containing |
knots |
OPTIONAL: A vector of knots to be used to compute random effects in
mixed model. SUPPLY ONLY |
K |
OPTIONAL: A value for how many number knots the user would like: DO NOT
SUPPLY BOTH |
P |
OPTIONAL: A value for the degree of the polynomial. Default P = 1 for linear trend. |
spline |
OPTIONAL: A character indicating the type of spline basis function to use: "Radial" or "Truncated Poly". |
r |
OPTIONAL: A value for the degree of the radial basis function. Not used in the truncated polynomial basis function. |
theta |
OPTIONAL: A value for the range of the radial basis function. Not used in the truncated polynomial basis function. |
The trend function determined by P, is a polynomial: beta0 + beta1x + beta2x^2 + ... + betaPx^P. This forms the fixed effects part of the model. The bases at knots create the random effects part of the mixed model. The final model looks like:
y_i = beta0 + beta1x_i + beta2x_i^2 + ... + betaPx_i^P + sum_j=1^K (u_j B_j(x_i)) + epsilon_i.
A large list is returned containing:
Y
, a tibble containing the inputted ID
, y
, x
, and estimated fit of the data fitted
.
coeff_fixed
a tibble containing ID
, and the estimated fixed effects coefficients labeled beta0
,
beta1
, ..., betaP
.
coeff_rand
a tibble containing ID
, and the estimated random effects coefficients labeled u1
,
u2
, ..., uK
.
wand2003unequalgroupoutlier
@examples library(tidyverse) x <- rep(c(1:1000), 100) Y <- rnorm(100*1000, x, 2500) ID <- rep(1:100, 1000) ID <- ID[order(ID)]
Y <- tibble(ID = ID, y = Y, x = x) knots <- choose_knots(Y, 40)
fit <- Mixed_Model_Spline_Fit(Y, knots, theta = 10)
ggplot(fit$Y, aes(x = x, y = fitted, group = ID))+ geom_line(alpha = .5)
Mixed_Spline_Fit_Single
to fit a mixed model with splines on individual datasets.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.