# Methods for easily fitting multiple ellipses from repeated measures designs.

### Description

Fit a sinusoidal hysteretic process between an input and an output variable across multiple loops separated by subjects and repeated.

### Usage

1 2 3 |

### Arguments

`x` |
numeric input vector. |

`y` |
numeric output vector. |

`subjects` |
factor of the same length as x that represents experimental units. |

`repeated` |
factor of the same length as x that represents the repeated measure. |

`subjects.in` |
a vector of characters, the levels of |

`repeated.in` |
a vector of characters, the levels of |

`object` |
an |

`N` |
Number of bootstrap replicates. |

`boot` |
whether to use bootstrapping to obtain standard errors and less biased parameter estimates. |

`seed` |
for generating random numbers. See |

`...` |
extra arguments to either |

### Details

Fits multiple ellipses with one call, separated by the factors `subjects`

and `repeated`

. The arguments `subjects.in`

and `repeated.in`

are used to select subsets of the factors `subjects`

and `repeated`

.

### Value

`fel.repeated`

returns an object of class `ellipsefitlist`

.

`models` |
Separate model fits for each ellipse, see |

`Estimates` |
Parameter estimates for all ellipses in matrix form. |

`Std.Errors` |
Delta standard errors for all ellipses in matrix form. |

When `boot=TRUE`

`fel.repeated`

returns an object of class `ellipsesummarylist`

which consists of

`models` |
a vector of separate model summaries for each ellipse, see |

`values` |
Bootstrapped parameter estimates, standard errors, quantiles, and more for each ellipse. |

`Boot.Estimates` |
Bootstrapped parameter estimates with reduced bias. |

`Boot.Std.Errors` |
Standard errors provided by bootstrapping. |

### Author(s)

Spencer Maynes, Fan Yang, and Anne Parkhurst.

### References

Yang, F. and A. Parkhurst, Efficient Estimation of Elliptical Hysteresis (submitted)

### See Also

`fel`

for a more general way to fit multiple ellipses, or for fitting just one ellipse. `plot.ellipsefit`

for plotting and `summary.ellipsefit`

for summarizing and bootstrapping an `ellipsefitlist`

object. Also `residuals.ellipsefitlist`

.

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ```
## Select 2 subjects with 2 replications and fit 4 ellipses
data(EllipseData)
emodels.rep <- fel.repeated(EllipseData$X, EllipseData$Y, method = "harmonic2",
subjects = EllipseData$subjects,subjects.in=c("A","C"),
repeated=EllipseData$repeated)
emodels.rep #Gives estimates and delta standard errors
emodels.rep$Estimates #List estimates only
emodels.rep$Std.Errors #List delta standard errors
par(mfrow=c(2,2))
plot(emodels.rep, main="Repeated Ellipses",xlab="X",ylab="Y")
par(mfrow=c(1,1))
### Bootstrap estimates and standard errors (Seed is necessary if want to reproduce results)
boot.rep.ellipse<-fel.repeated(EllipseData$X,EllipseData$Y,method = "harmonic2",
subjects = EllipseData$subjects,subjects.in=c("A","C"),
repeated=EllipseData$repeated,boot=TRUE,seed=123)
boot.rep.ellipse #Gives boot estimates, boot bias, boot SE and boot quartiles
par(mfrow=c(2,2))
plot(boot.rep.ellipse, main="Repeated Ellipses",xlab="X",ylab="Y",values="ellipse")
par(mfrow=c(1,1))
##Can write results to a file. First set your directory from the file tab.
#Change file path in command below to coincide with where you want to store data files
#setwd("C:/Users................")
#write.table(boot.rep.ellipse$Boot.Estimates,"Ellipes.eg.repbootvalues.txt")
#test.fel=read.table("Ellipes.eg.repbootvalues.txt",header=TRUE)
#head(test.fel)
``` |