# Spida

### From Wiki1

This page describes the 'spida' package in R. See also the p3d package.

The 'spida' package is a collection of utility functions for mixed models initially developed for SPIDA 2009 and updated since then.

The currently available version of the spida package has been compiled with R-3.0.0

## Contents |

## Installation

#### On a PC

# install some required packages and their dependencies install.packages(c('car','Hmisc','magrittr','latticeExtra')) # to install 'spida' download.file("http://blackwell.math.yorku.ca/R/spida.zip", "spida.zip") install.packages("spida.zip", repos = NULL)

The commands above only need to be used occasionally to update your version of the package or when you have installed a new version of R.

At each R session, you load the package with the R commands:

library(spida)

#### On a Mac

On a Mac, you need to install this packages using the shell (Terminal in Mac)

- First, you need to install developer tools - that is Xcode 3.1 for Mac OS X 10.5 (Leopard) or Xcode 3.2 for Mac OS X 10.6 (Snow Leopard) or Xcode 4 for Mac OS X 10.7 (Lion) Xcode is present on the OS X installation DVD or can be downloaded from http://developer.apple.com/mac/. Xcode 4 is also available for free in the App Store. (If you want Xcode 3.1 or 3.2 but don't want to join Apple Developer, it is available other places if you are a bit resourceful.)

## The following 3 lines only need to be run when you start using R and after ## installing a new version of R. ## They install the package 'spida' in your R libraries ## so they are available to be loaded with the library command. install.packages(c('car','Hmisc','magrittr','latticeExtra')) path <- .libPaths()[1] download.file("http://blackwell.math.yorku.ca/R/spida.tar.gz", paste(path,"/spida.tar.gz", sep="")) .libPaths()[1]

- This last line of code will print out the file path to the newly downloaded files. Copy the whole path from R.
- Next, go outside of R to
**Finder -> Applications -> Utilities -> Terminal**- In the terminal window type: cd <paste file path>
- In the terminal window type: R CMD INSTALL spida.tar.gz

The commands above only need to be used occasionally to update your version of the packages or when you have installed a new version of R.

At each R session, you load the package with the R commands:

library(spida) # note that a number of other packages get loaded at the same time

If you run into problems, have a look at this MacOSX help file. Please let me know if you find a solution.

#### On Linux

You can use Hadley Wickam's package 'devtools':

install.packages('devtools','Hmisc','magrittr','latticeExtra') library(devtools) install_url("http://blackwell.math.yorku.ca/R/spida.tar.gz")

## Overview

The major functions are:

- wald
- Wald test with functions to easily generate hypothesis matrices to estimate linear combinations of linear parameters of model fitted with lm, lme, lmer, etc. Methods are easily created for other fitting methods
- gsp
- general spline generator with any degree and smoothness with additional function 'sc' to contruct hypotheses, smsp - easy smoothing splines with lme and nlme
- capply, cvar, dvar, up
- easy manipulation of hierarchical data sets: create contextual variables, summarize, transform, merge, etc.

## Data sets

The following data sets and descriptions are available directly in R after installing and loading the 'spida' or 'spida.beta' packages. Access to .csv versions is provided here for anyone who would like to access them without using R.

### Descriptions of data sets

- Drugs: Longitudinal study of schizophrenia symptoms with non-randomized treatment
- Normal response with complete data at the same 6 times points. Time-varying treatment.

- hsfull, hs, hs1, hs2: Math achievement and ses in a sample of 160 U.S. schools from the 1982 study “High School and Beyond”. hs, hs1 and hs2 are subsamples
- Normal response with hierarchical model. 'ses' is a level 1 variable with potential contextual effects

- iq: Longitudinal study of IQ after traumatic brain injuries
- Normal response, collected at highly unbalanced times, illustrating a non-linear model for recovery trajectories

- Indonesia: Respiratory infections among Indonesian children. Longitudinal observational study with no treatment
- Dichotomous response, unbalanced with two time variables: date and age.

- migraines: Effectiveness of migraine treatment
- Dichotomous response, unbalanced with common onset of treatment, possible seasonal effects and non-linear response curves

- Orthodont:Growth curve data on an orthdontic measurement
- Classical repeated measures balanced data set