View source: R/residuals.fittedloop.R
residuals.fittedloop | R Documentation |
Extract input, output, geometric and algebraic residuals, studentized residuals and fitted values from fitted loops or ellipses.
##S3 methods for classes 'ellipsefit', 'ellipsesummary', 'fittedloop',
##'loopsummary','ellipsefitlist', 'ellipsesummarylist', 'fittedlooplist',
##'loopsummarylist', 'loop2r', 'fittedlooplist2r',
##'loopsummarylist2r' and 'loop2rsummary'.
## S3 method for class 'ellipsefit'
residuals(object,...)
## S3 method for class 'ellipsefit'
rstudent(model,...)
## S3 method for class 'ellipsefit'
fitted(object,...)
object |
an object created by |
model |
an object created by |
... |
other arguments. |
Geometric residuals are based on the straight line distance between predicted and true values along an x,y cartesian plane, and algebraic residuals are based on the method used to calculate the ellipsefit
object.
If method="harmonic2" (which is always the case if this is a fittedloop
object) or if bootstrapping has occurred, then, there are no algebraic residuals and residuals.ellipsefit
replaces these with the geometric residuals.
Studentization for the rstudent
function is performed as if method="harmonic2" regardless of the method used for fitting the ellipse/loop. Therefore, unless method="harmonic2" and no bootstrapping is performed, these are pseudo-studentized residuals, not true studentized residuals. This is internal scaling studentization. Studentization for bootstrapping in the functions summary.ellipsefit
/summary.fittedloop
differs from the studentization performed by rstudent
in that it only accounts for the influence matrix and does not divide by the standard deviation.
input |
a numeric vector. Observed input - fitted input for residuals. |
output |
a numeric vector. Observed output - fitted output for residuals. |
geometric |
a numeric vector. Not available with rstudent. See details. |
algebraic |
a numeric vector. Not available with rstudent or when the 'harmonic2' method is used. See details. |
Spencer Maynes, Fan Yang, and Anne Parkhurst.
Yang, F. and A. Parkhurst, Estimating Elliptical Hysteresis: A Comparison of Analytic Methods. (submitted)
fel
, floop
, summary.ellipsefit
and summary.fittedloop
.
##For multiple loops/ellipses
data(HysteresisData)
Mloopmodels.rep <- floop.repeated(HysteresisData$X, HysteresisData$Y,
n=5,m=3, subjects = HysteresisData$subjects,subjects.in=c("A","C"),
repeated=HysteresisData$repeated)
Mloopmodels.rep #Gives estimates and delta standard errors
residuals(Mloopmodels.rep) #$input $output $geometric
fitted(Mloopmodels.rep) #$input $output
scatterplotMatrix(cbind(residuals(Mloopmodels.rep)$input,
residuals(Mloopmodels.rep)$output,residuals(Mloopmodels.rep)$geometric,
fitted(Mloopmodels.rep)$input,fitted(Mloopmodels.rep)$output),
main='Residuals for Multiple Hysteresis Loops',smooth=FALSE,
var.labels=c("Input Resid","Output Resid","Geometric Resid",
"Fitted Input", "Fitted Output"),
groups=residuals(Mloopmodels.rep)$repeated)
rstudent(Mloopmodels.rep) #$input $output
scatterplotMatrix(cbind(rstudent(Mloopmodels.rep)$input,
rstudent(Mloopmodels.rep)$output,fitted(Mloopmodels.rep)$input,
fitted(Mloopmodels.rep)$output),main='Studentized Residuals
for Multiple Hysteresis Loops',smooth=FALSE,
var.labels=c("Input Resid","Output Resid", "Fitted Input",
"Fitted Output"),groups=residuals(Mloopmodels.rep)$repeated)
##For single Ellipse
ellipse1 <- mel(sd.x=0.2,sd.y=0.04)
ellipse1.fit <- fel(ellipse1$x,ellipse1$y)
residuals(ellipse1.fit)
fitted(ellipse1.fit)
scatterplotMatrix(cbind(residuals(ellipse1.fit)$input,
residuals(ellipse1.fit)$output,residuals(ellipse1.fit)$geometric,
fitted(ellipse1.fit)$input,fitted(ellipse1.fit)$output),
main='Residuals for Simulated Ellipse',smooth=FALSE,
var.labels=c("Input Resid","Output Resid","Geometric Resid",
"Fitted Input", "Fitted Output"))
rstudent(ellipse1.fit) #for input and output variables
scatterplotMatrix(cbind(rstudent(ellipse1.fit)$input,
rstudent(ellipse1.fit)$output,fitted(ellipse1.fit)$input,
fitted(ellipse1.fit)$output),main='Studentized Residuals
for Simulated Ellipse',smooth=FALSE,
var.labels=c("Input Resid","Output Resid","Fitted Input",
"Fitted Output"))
plot(ellipse1.fit$pred.y,rstudent(ellipse1.fit)$output,
xlab="Fitted Output",ylab="Output Studentized Residuals",
main="Studentized Residuals:Simulated Ellipse")
abline(h = 0, lty = 2, col = "gray")
qqnorm(rstudent(ellipse1.fit)$output,sub='Output Studentized
Residuals Simulated Ellipse')
qqline(rstudent(ellipse1.fit)$output,col="red") #q-q line
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.