MyNixOS website logo
Description

Ordinary Least Squares Trajectory Analysis.

The 'OLStrajr' package provides comprehensive functions for ordinary least squares (OLS) trajectory analysis and case-by-case OLS regression as outlined in Carrig, Wirth, and Curran (2004) <doi:10.1207/S15328007SEM1101_9> and Rogosa and Saner (1995) <doi:10.3102/10769986020002149>. It encompasses two primary functions, OLStraj() and cbc_lm(). The OLStraj() function simplifies the estimation of individual growth curves over time via OLS regression, with options for visualizing both group-level and individual-level growth trajectories and support for linear and quadratic models. The cbc_lm() function facilitates case-by-case OLS estimates and provides unbiased mean population intercept and slope estimators by averaging OLS intercepts and slopes across cases. It further offers standard error calculations across bootstrap replicates and computation of 95% confidence intervals based on empirical distributions from the resampling processes.

OLStrajr

The Maximizing the Yield of Small Samples in Prevention Research: A Review of General Strategies and Best Practices paper by Hopkin, Hoyle, and Gottfredson (2015) suggests that when working with small sample sizes, analysts should leverage plots to explore within-group associations between predictor variables and the outcome variable. These plots are intended to provide detailed insights about the data rather than to be used for generalizing to the population.

The paper cites the work of Carrig, Wirth, and Curran (2004) who proposed an easy-to-use SAS macro for visualizing person-specific growth trajectories with repeated measures data.

The objective of the OLStrajr package is to bring the functionality of this SAS macro, OLStraj, to R. While the original link to the macro in Carrig’s paper is no longer active, it can still be accessed through the Wayback Machine.

Installation

You can install the released version of OLStrajr from CRAN with:

install.packages("OLStrajr")

You can install the development version of OLStrajr as follows:

# install.packages("devtools")
devtools::install_github("mightymetrika/OLStrajr")

Ratio of Robin Males to Females

This serves as an exemplary demonstration of using OLStrajr. It features an analysis of data representing the yearly ratio of male to female robins, as documented in Birds: incomplete counts—five-minute bird counts Version 1.0. This data, collected at Walker Creek and Knobs Flat from August 2005 to August 2009, provides a compelling case study

# Load package
library(OLStrajr)

# Get robins data
data(robins)

# Print robins data
robins
#>           site aug_05 aug_06 aug_07 aug_08 aug_09
#> 1 Walker_Creek   1.67   1.50   1.80    1.6   1.38
#> 2   Knobs_Flat   1.64   1.76   2.33    3.0   2.40

OLStraj

To obtain the OLS trajectories, use the following code:

robins_traj <- OLStraj(data = robins,
                      idvarname = "site",
                      predvarname = "Year",
                      outvarname = "Ratio",
                      varlist = c("aug_05", "aug_06", "aug_07", 
                                  "aug_08", "aug_09"),
                      timepts = c(0, 1, 2, 3, 4),
                      regtype = "lin",
                      int_bins = 3,
                      lin_bins = 3)

The OLStraj function provides several types of plots that facilitate the examination of your data:

Group Plots:

robins_traj$group_plots
#> $simple_joined
#> 
#> $ols
#> `geom_smooth()` using formula = 'y ~ x'

Group plots depict the simple-joined trajectories and the estimated trajectories for each group in your data, allowing for a quick comparison of trends across different groups.

Individual OLS Trajectories:

robins_traj$individual_plots
#> $`ols Knobs_Flat`
#> `geom_smooth()` using formula = 'y ~ x'
#> 
#> $`ols Walker_Creek`
#> `geom_smooth()` using formula = 'y ~ x'

Individual plots represent each subject’s unique trajectory over time, providing insights into individual patterns of change.

Histograms for intercepts and slopes:

robins_traj$histogram_plots
#> $intercepts
#> 
#> $slopes

These histograms reveal the distribution of intercepts and slopes across subjects. They are useful for identifying skewness or other interesting distributional properties in the data.

Box plots of intercepts and slopes:

robins_traj$box_plot

Box plots provide a summary of the distribution of intercepts and slopes across subjects. They allow you to visualize the spread and skewness of the data. Any outliers are clearly highlighted in these plots. In the OLStraj box plots, the mean value is represented by a blue dot. Additionally, each outlier is labeled with the corresponding subject identifier, providing a straightforward way to identify subjects whose data deviate significantly from the rest of the group.

Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows