fracpoly fits the best fitting fractional polynomial of degree 1 and 2.
Arguments
- y
outcome.
- x
exposure.
- covar
data.frame with covariates.
- family
the glm family (options: gaussian and binomial).
Value
List of best-fitting polynomials of degrees 1 and 2 as well as associated statistics.
- power_d1
power of the best-fitting fractional polynomial of degree 1
- fp1
model of the best-fitting fractional polynomial of degree 1
- power_d2
powers of the best-fitting fractional polynomial of degree 2
- fp2
model of the best-fitting fractional polynomial of degree 2
- p_d1
p-value testing the best-fitting fractional polynomial of degree 1 against the linear model
- p_d2
p-value testing the best-fitting fractional polynomial of degree 2 against the best-fitting fractional polynomial of degree 2
- xmin
miniumum value of the exposure
- xmax
maximum value of the exposure
- family
family used in the analysis
Author
James Staley jrstaley95@gmail.com
Examples
# Data
y <- rnorm(5000)
x <- rnorm(5000, 10, 1)
c1 <- rbinom(5000, 1, 0.5)
c2 <- rnorm(5000)
study <- c(rep("study1", 1000), rep("study2", 1000), rep("study3", 1000), rep("study4", 1000), rep("study5", 1000))
covar <- data.frame(c1 = c1, c2 = c2, study = study)
# Analyses
res <- fracpoly(y = y, x = x, covar = covar, family = "gaussian")